screen-13 icon indicating copy to clipboard operation
screen-13 copied to clipboard

Bindless not detected when using HLSL

Open DGriffin91 opened this issue 1 year ago • 3 comments

I think this is maybe not sufficient for detecting bindless: https://github.com/attackgoat/screen-13/blob/71c1c05f74c17d0ca891ae784d3e701c8fdcbc12/src/driver/graphic.rs#L457-L459 In HLSL using Texture2D Texture2DTable[] : register(t0, space0); the binding count ends up being 1 instead of 0.

I don't think it's really a solution, but as a test, before here: https://github.com/attackgoat/screen-13/blob/71c1c05f74c17d0ca891ae784d3e701c8fdcbc12/src/driver/shader.rs#L871-L873 I tried setting the binding count to 0 with:

if "Texture2DTable" == name.as_deref().unwrap_or_default() {
    binding_count = 0;
}

And it actually made a HLSL version of the bindless example work (though I still haven't gotten samplers working correctly so this was just with Texture2DTable[input.instance_index].Load(int3(0, 0, 0)))

DGriffin91 avatar Apr 14 '24 08:04 DGriffin91

I modified examples/bindless.rs to use hassle-rs (DXC) and had some success:

RUST_LOG=info cargo run --example bindless -- --hlsl --hassle-rs

When I don't pass the --hassle-rs flag it uses Shaderc and fails:

binding #0 with #63 descriptors being updated but this update oversteps the bounds
`main` entrypoint not found for stage VK_SHADER_STAGE_FRAGMENT_BIT
create_graphics_pipelines: An unknown error has occurred, due to an implementation or application bug

Could you provide a larger HLSL example?

attackgoat avatar Jul 17 '24 04:07 attackgoat

Oh! I hadn't thought of that. It looks like bindless does work with dxc in my renderer! I've been using shaderc mostly as I haven't tried setting up hassle-rs with hot reloading yet, so I've been using my workaround from the first post. But I have a cargo feature to switch to dxc so it's easy to test both. (It's also handy to be able to pass -Od to dxc to disable opt so it doesn't strip out things (like bindings) that screen-13 needs if you aren't using them in the shader yet.)

Yep! I can figure out a larger example. Are you looking for something that can be added to the repo as an official hlsl example, or just a larger code base in general that's using hlsl with screen-13?

DGriffin91 avatar Jul 17 '24 05:07 DGriffin91

I'm interested in finding the minimal HLSL that you think should work, but does not. Hopefully that would help figure out if there is anything this crate could change which would fix things, and probably make examples along the way.

I used HLSL professionally for years before switching to Vulkan and GLSL; personally at least for what I do I don't mind the clunkiness of the language because I avoid all of these random bugs. Unfortunately this has rotted my HLSL skills to basically zero - so my ask for an example is because I want to make sure I'm fixing the correct random bugs. 😊

attackgoat avatar Jul 17 '24 12:07 attackgoat