Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3D12: Unhandled exception when creating more than 64 samplers #3093

Open
falia18 opened this issue Apr 28, 2023 · 5 comments
Open

D3D12: Unhandled exception when creating more than 64 samplers #3093

falia18 opened this issue Apr 28, 2023 · 5 comments
Labels

Comments

@falia18
Copy link

falia18 commented Apr 28, 2023

Describe the bug
On D3D12, creating more than 64 samplers will throw an exception in DescriptorAllocatorD3D12::alloc() on line device->CreateSampler(&sd, cpuHandle);

To Reproduce
Steps to reproduce the behavior:

  1. Create at least 65 different texture samplers
  2. Launch with D3D12 renderer
  3. See error

I've forked and edited example 6-bump to reproduce the issue (https://github.com/falia18/bgfx/tree/d3d12-sampler-crash-example)
Clone the project and switch to branch d3d12-sampler-crash-example
Launch example 6-bump with --d3d12 and crash will occur after ~20 frames.

Expected behavior
Sampler creation proceeds without exception.

Additional context
Tested on Windows 10 with both NVIDIA and AMD GPU

@bkaradzic
Copy link
Owner

Did you test it in debug build?

@falia18
Copy link
Author

falia18 commented Apr 28, 2023

Release and debug, both crash

@bkaradzic bkaradzic added the bug label Apr 28, 2023
@falia18
Copy link
Author

falia18 commented Apr 28, 2023

I've had time to look a bit through the code and I suspect the problem comes from the fact that m_numDescriptorsPerBlock (in m_samplerAllocator.create() ) is initialized with BGFX_CONFIG_MAX_TEXTURE_SAMPLERS in RendererContextD3D12::init().
Not sure what 'm_numDescriptorsPerBlock` is supposed to do but if initialized at 1 it seems to work as intended.

@bkaradzic
Copy link
Owner

falia18@ef42e58

bkaradzic added a commit that referenced this issue May 6, 2023
@bkaradzic
Copy link
Owner

@falia18 this is partial fix... I'm still working on proper fix.

mipek pushed a commit to mipek/bgfx that referenced this issue Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants