NVIDIA-RTX / NVIDIA-RTX/Streamline

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

Open
#27 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
1.2k
Forks
159
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in source/platforms/sl.chi/generic.cpp at ResourcePool::allocate() and source/platforms/sl.chi/d3d12.cpp around the resource-cloning path. Reproduce the case with Alignment 4096 and DXGI_FORMAT_R16G16_FLOAT under D3D12 debug validation, then trace cloneResource's result and the resource state access. Done means the invalid alignment and null-resource exception are handled for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.