rive-app / rive-app/rive-runtime
Invalid DX resource flags cause rive renderer initialization to fail
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
I got a weird issue when using the rive-renderer in a machine that has an nvidia L40S w/ enterprise drivers. The rive renderer initialization fails when calling rive::gpu::RenderContextD3d12Impl::MakeContext.
The same exact build works in my local machine (non-enterprise drivers).
Good old "works on my machine" issue.
The error:
..\..\src\d3d12\d3d12_utils.cpp:297: D3D error The parameter is incorrect.: device->CreateCommittedResource(&m_heapPropeties, heapFlags, &m_desc, m_lastState, clearValue, IID_PPV_ARGS(&m_resource))
If I enable the debug layer and run DebugView I get this:
[6596] D3D12 ERROR: ID3D12Device::CreateCommittedResource: Certain resources are restricted to certain D3D12_RESOURCE_STATES states, and cannot be changed. Resources on D3D12_HEAP_TYPE_UPLOAD heaps requires D3D12_RESOURCE_STATE_GENERIC_READ or D3D12_RESOURCE_STATE_RESOLVE_SOURCE. Reserved buffers used exclusively for texture placement requires D3D12_RESOURCE_STATE_COMMON. [ RESOURCE_MANIPULATION ERROR #741: RESOURCE_BARRIER_INVALID_HEAP]
Huh. So I went to the docs and indeed that's what's up with D3D12_HEAP_TYPE_UPLOAD:
https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_heap_type
(...) Resources in this heap must be created with D3D12_RESOURCE_STATE_GENERIC_READ and cannot be changed away from this. The CPU address for such heaps is commonly not efficient for CPU reads. (...)
So I changed the calls that were using D3D12_RESOURCE_STATE_COPY_SOURCE (which is not valid when the heap is of type D3D12_HEAP_TYPE_UPLOAD) to D3D12_RESOURCE_STATE_GENERIC_READ.
This has fixed my issue.
I'm creating a PR with the changes.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/d3d12/d3d12_utils.cpp around line 297 and review the CreateCommittedResource calls using D3D12_HEAP_TYPE_UPLOAD. Check the D3D12 heap and resource-state documentation, then verify that renderer initialization succeeds on the affected NVIDIA driver setup; done means the invalid-resource-state error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100