NVIDIAGameWorks / Streamline

Streamline Integration Framework
Other
377 stars 79 forks source link

Exception on slSetTag(), when cloning resource when 'D3D12_RESOURCE_DESC::Alignment == 4096' and 'D3D12_RESOURCE_DESC::Format == DXGI_FORMAT_R16G16_FLOAT' #27

Open QDanteQ opened 8 months ago

QDanteQ commented 8 months ago

Hello, I got exception on slSetTag(). After looking into source code, I see that it happens in ResourcePool::allocate(), when you call m_compute->getResourceState(res->state, initialState);
https://github.com/NVIDIAGameWorks/Streamline/blob/7ac42e47c7dd55b5b6dd6176c0228048636541b2/source/platforms/sl.chi/generic.cpp#L172C21-L172C21 The possible problem is that you don't test the return value of m_compute->cloneResource(source, res, debugName, initialState); which might not initialize sl::chi::Resource res variable, which is pointer to sl::Resource, therefore in res->state you access with nullptr. Also I enabled d3d12 debug layer validation to investigate why m_compute->cloneResource(source, res, debugName, initialState); don't initialize res and got this d3d12 error

D3D12 ERROR: ID3D12Device::CreateCommittedResource: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 4096. Resources with D3D12_RESOURCE_DESC::Flags with either D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET or D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL must set Alignment equal to 65536 (aka. D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT), or 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT] D3D12: BREAK enabled for the previous message, which was: [ ERROR STATE_CREATION #721: CREATERESOURCE_INVALIDALIGNMENT ]

Looks like you add D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET flag, without changing D3D12_RESOURCE_DESC::Alignment. I guess you did not expected the alignment to be 4096.

https://github.com/NVIDIAGameWorks/Streamline/blob/7ac42e47c7dd55b5b6dd6176c0228048636541b2/source/platforms/sl.chi/d3d12.cpp#L2159C39-L2159C39

Thanks for your work and hope these issues will be fixed soon.