rive-app / rive-app/rive-runtime
Title: D3D11 Access Violation / E_INVALIDARG when calling makeImageTexture (GENERATE_MIPS violation)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
Description:
There is a bug in the D3D11 renderer implementation (render_context_d3d_impl.cpp) inside makeImageTexture that causes a hard crash or E_INVALIDARG failure from the GPU driver when attempting to dynamically inject image textures.
The function attempts to initialize a texture using the D3D11_RESOURCE_MISC_GENERATE_MIPS flag while simultaneously passing a single D3D11_SUBRESOURCE_DATA struct to CreateTexture2D.
D3D11_TEXTURE2D_DESC desc = {};
desc.MipLevels = 0;
desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
D3D11_SUBRESOURCE_DATA initialData = {};
initialData.pSysMem = pixels;
m_device->CreateTexture2D(&desc, &initialData, &texture);
The Issue:
According to Microsoft's D3D11 specifications, you cannot supply initial data to CreateTexture2D when using GENERATE_MIPS unless you provide an array of SUBRESOURCE_DATA covering every single mip level. Because the current implementation only supplies the base image at Mip Level 0, the driver reads out of bounds and crashes.
Proposed Fix:
The correct DirectX 11 staging pattern for mipmap generation is to:
- Call
CreateTexture2Dwithnullptrfor the initial data. - Use
UpdateSubresourceon the device context to push the base image pixels specifically into Mip Level 0. - Call
GenerateMipson the resultingID3D11ShaderResourceView.
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 render_context_d3d_impl.cpp at makeImageTexture and inspect how CreateTexture2D receives the texture description and initial data. Follow the D3D11 device-context path for updating the base image and generating mipmaps. Done means dynamically injected image textures no longer produce the GENERATE_MIPS E_INVALIDARG failure or access violation.
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
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100