admin管理员组文章数量:1390939
I try to write D2D/DWrite content into a texture that is to be used as shader resource in D3D12. For that, I create an ID3D11On12Device
as in , but I do not want to map the D3D12 back buffers, but create my own textures. The properties of the resources are:
D3D12_RESOURCE_DESC desc;
::ZeroMemory(&desc, sizeof(desc));
desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
desc.MipLevels = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.DepthOrArraySize = 1;
desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS;
desc.SampleDesc.Count = 1;
D3D12_HEAP_PROPERTIES heapProps;
::ZeroMemory(&heapProps, sizeof(heapProps));
heapProps.Type = D3D12_HEAP_TYPE_DEFAULT;
And I create the textures as follows:
THROW_IF_FAILED(d3d12Device->CreateCommittedResource(
&heapProps,
D3D12_HEAP_FLAG_SHARED,
&desc,
D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE,
&clear,
::IID_ID3D12Resource,
this->d3d12Targets[i].put_void()));
I have D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS
and D3D12_HEAP_FLAG_SHARED
set as described in Sharing ID3D11Buffer and ID3D12Resource.
However, when I subsequently create the wrapped resource
D3D11_RESOURCE_FLAGS flags = { D3D11_BIND_RENDER_TARGET };
THROW_IF_FAILED(this->d3d11On12Device->CreateWrappedResource(
this->d3d12Targets[i].get(),
&flags,
D3D12_RESOURCE_STATE_RENDER_TARGET,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
::IID_ID3D11Resource,
this->d3d11Targets[i].put_void()));
I get the validation error
D3D12 ERROR: ID3D12CompatibilityDevice::ReflectSharedProperties: Resource provided was not shared by D3D11, or with a D3D11 desc. [ MISCELLANEOUS ERROR #916: REFLECTSHAREDPROPERTIES_INVALIDOBJECT]
What am I missing here?
本文标签: cUse D3D12 texture as D2D render target causes validation errorStack Overflow
版权声明:本文标题:c++ - Use D3D12 texture as D2D render target causes validation error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744641581a2617154.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论