Firemonkey 中的 DirectX10 支持(非 10.1) (DirectX10 support in Firemonkey (not 10.1))


問題描述

Firemonkey 中的 DirectX10 支持(非 10.1) (DirectX10 support in Firemonkey (not 10.1))

Is it possible to drop down to DX10 instead of DX10.1 support. I have a client whose computer supports DX10 only, so they can't take advantage of Direct2D as it seems that FM only supports 10.1

I have tried modifying the sources to use DX10 (FMX.Canvas.D2D and FMX.Context.DX10) and made another switch to drop down to DX10, but one call seems to fail.

I have modified the way the shareddevice is created

if not Assigned(FSharedDevice) then 
begin
SaveClearFPUState;
try
Flags := {$ifdef DXDEBUG}D3D10_CREATE_DEVICE_DEBUG{$else}0{$endif};
Flags := Flags or D3D10_CREATE_DEVICE_BGRA_SUPPORT;
HR := D3D10CreateDevice(nil, FDriverType, 0, Flags, D3D10_SDK_VERSION, FSharedDevice);
if Succeeded(HR) then
begin
HR := FSharedDevice.CreateBuffer(TD3D10_BufferDesc.Create(VBSize, D3D10_BIND_VERTEX_BUFFER, D3D10_USAGE_DYNAMIC, D3D10_CPU_ACCESS_WRITE), nil, @FVB);
HR := FSharedDevice.CreateBuffer(TD3D10_BufferDesc.Create(IBSize, D3D10_BIND_INDEX_BUFFER, D3D10_USAGE_DYNAMIC, D3D10_CPU_ACCESS_WRITE), nil, @FIB);
// Acquire device DXGI factory
HR := FSharedDevice.QueryInterface(IDXGIDevice, DXGIDevice);
if Succeeded(HR) and (DXGIDevice <> nil) then
begin
HR := DXGIDevice.GetParent(IDXGIAdapter, DXGIAdapter);
if Succeeded(HR) and (DXGIAdapter <> nil) then
HR := DXGIAdapter.GetParent(IDXGIFactory, FDXGIFactory);
end;
if not Assigned(FDXGIFactory) then
HR := CreateDXGIFactory(IDXGIFactory, FDXGIFactory);
end;
finally
RestoreFPUState;
end;
end;

and when I am using the device I use code like this below..

SharedDevice: ID3D10Device

if Assigned(TCustomDX10Context.SharedDevice) then
begin
FillChar(Desc, SizeOf(D3D10_TEXTURE2D_DESC), 0);
Desc.Format := DXGI_FORMAT_B8G8R8A8_UNORM;
Desc.Width := 1;
Desc.Height := 1;
Desc.MipLevels := 1;
Desc.ArraySize := 1;
Desc.SampleDesc.Count := 1;
Desc.SampleDesc.Quality := 0;
Desc.Usage := D3D10_USAGE_DEFAULT;
Desc.BindFlags := D3D10_BIND_RENDER_TARGET or D3D10_BIND_SHADER_RESOURCE;
Res := TCustomDX10Context.SharedDevice.CreateTexture2D(Desc, nil, FSharedTexture);
Prop := D2D1RenderTargetProperties(TargetMode, D2D1PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED));
Res := FFactory.CreateDxgiSurfaceRenderTarget(FSharedTexture as IDXGISurface, Prop, FSharedRenderTarget);
end;

I have created a switch in the source that allows me to switch between the 10.1 and 10 device and have modified all code in FMX.Canvas.D2D and FMX.Context.DX10 to use the alternative device.

BUT...

CreateDxgiSurfaceRenderTarget fails with an error code ‑2147024809. 

So the app loads, but the forms are all blank, because of not being able to create the Target.

Any guru's out there that could help with this?

‑‑‑‑‑

參考解法

方法 1:

Direct2D 1.0 supports interop with Direct3D 10.1 but it can still support Direct3D 10.0 hardware via feature level selection. I don’t know anything about Delphi, but instead of calling D3D10CreateDevice to create the Direct3D device, you need to call the D3D10CreateDevice1 function. You can then simply request the feature level you desire, such as D3D10_FEATURE_LEVEL_10_0. 

(by Jason ColeyKenny Kerr)

參考文件

  1. DirectX10 support in Firemonkey (not 10.1) (CC BY‑SA 3.0/4.0)

#directx-10 #delphi-xe3 #delphi #direct2d






相關問題

D3D10 (DirectX10) 全屏性能問題 (D3D10 (DirectX10) fullscreen performance issue)

directx10 中的精靈和紋理過濾 (Sprites in directx10 and texture filtering)

Firemonkey 中的 DirectX10 支持(非 10.1) (DirectX10 support in Firemonkey (not 10.1))

錯誤 LNK2019 Directx10 VC++2010 (Error LNK2019 Directx10 VC++2010)

管理 HLSL 效果 (Managing HLSL effects)

D3DX10CreateTextureFromFile 返回未知錯誤 (D3DX10CreateTextureFromFile returns unknown error)

使用 HLSL 變量分配 struct C++ (Assign struct C++ with HLSL variable)

ID3DX10Mesh::CloneMesh (ID3DX10Mesh::CloneMesh)

在 DirectX 10 中清除單個視口 (Clear single viewport in DirectX 10)

Visual c++ DirectX 編譯錯誤 (Visual c++ DirectX compilation error)

將 ID3D11Texture2D 轉換為內存緩衝區 (Convert ID3D11Texture2D into a memory buffer)

DirectX 10.1 / C++:如何通過 ID3D10Resource* 紋理在精靈上渲染文本? (DirectX 10.1 / C++: How to render text on sprite over ID3D10Resource* textures?)







留言討論