我通过 KeyedMutex 使用 Direct2D 和 DirectX11。如果我使用的是硬件设备,一切都很好。当我默认使用 Warp 设备时,我在创建 Texture2D 对象时遇到问题,我收到错误消息“Direct3D11Exception:E_OUTOFMEMORY:内存不足”
这些是负责的行:
SlimDX.Direct3D11.Texture2DDescription tds = SlimDX.Direct3D11.Texture2D.FromSwapChain(swapChain, 0).Description;
tds.BindFlags |= BindFlags.ShaderResource;
tds.SampleDescription = new SampleDescription(1, 0);
tds.OptionFlags |= ResourceOptionFlags.KeyedMutex;
textureD3D11 = new SlimDX.Direct3D11.Texture2D(device, tds);
同样,使用硬件设备一切都很好,而不是 Warp。当我对 PIX 运行它时,我看到了这个:
<0x09033390> ID3D11Device:CreateTexture2D(0x0FD1E330, NULL, 0x0FD1E32C --> NULL)
那是使用 Warp 驱动程序,但是当我使用最后一个 NULL 不是 NULL 的硬件时,它是一个指向 D3D11 Texture2D 对象的实际指针。
有什么想法吗?我知道我在这里没有包含太多代码,但我希望有人知道这是什么而不必发布整个 DX 例程。如果需要,我会的。
我确实使用调试和 10.1 DX。调试输出如下:
DXX32: Warn: Registry value too long: MainVideo_SET in SYSTEM\ControlSet001\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\0000\UMD
DXX32: Warn: Registry value too long: MainVideo_SET in SYSTEM\ControlSet001\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\0000\UMD
D3D11: WARNING: ID3D11Device::SetPrivateData: Possible re-use of existing private data GUID for different data (size has changed). [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ]
D3D11: WARNING: ID3D11Texture2D::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ]
Unable to load D2D debug layer
First-chance exception at 0x7558d36f in nART.exe: Microsoft C++ exception: _com_error at memory location 0x068ec964..
First-chance exception at 0x7558d36f in nART.exe: Microsoft C++ exception: _com_error at memory location 0x068eccf8..
First-chance exception at 0x7558d36f in nART.exe: Microsoft C++ exception: _com_error at memory location 0x068ece3c..
First-chance exception at 0x7558d36f in nART.exe: Microsoft C++ exception: _com_error at memory location 0x068edfb4..
D3D11: ERROR: ID3D11Device::CreateTexture2D: Returning E_OUTOFMEMORY, meaning memory was exhausted. [ STATE_CREATION ERROR #105: CREATETEXTURE2D_OUTOFMEMORY_RETURN ]
D3D11: WARNING: Live Device: Name="device", Addr=0x00097D58, ExtRef=4 [ STATE_CREATION WARNING #2097297: LIVE_DEVICE ]
D3D11: WARNING: Live Device Child Summary: Device Addr=0x00097D58
Using ID3D11Debug::ReportLiveDeviceObjects with D3D11_RLDO_DETAIL will help drill into object lifetimes. Objects with ExtRef=0 and IntRef=0 will be eventually destroyed through typical Immediate Context usage. However, if the application requires these objects to be destroyed sooner, ClearState followed by Flush on the Immediate Context will realize their destruction.
Live Context: 1
Live Buffer: 0
Live Texture1D: 0
Live Texture2D: 1
Live Texture3D: 0
Live ShaderResourceView: 0
Live RenderTargetView: 1
Live DepthStencilView: 0
Live VertexShader: 0
Live GeometryShader: 0
Live PixelShader: 0
Live InputLayout: 0
Live Sampler: 1
Live BlendState: 1
Live DepthStencilState: 1
Live RasterizerState: 1
Live Query: 1
Live Predicate: 0
Live Counter: 0
Live CommandList: 0
Live HullShader: 0
Live DomainShader: 0
Live ClassInstance: 0
Live ClassLinkage: 0
Live ComputeShader: 0
Live UnorderedAccessView: 0
[ STATE_CREATION WARNING #2097298: LIVE_OBJECT_SUMMARY ]
A first chance exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll
An unhandled exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll
Additional information: E_OUTOFMEMORY: Ran out of memory (-2147024882)