Skip to content

Invalid DX resource flags cause rive renderer initialization to fail #57

@gustavo-lighttwist

Description

@gustavo-lighttwist

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions