Open Jasper-Bekkers opened 3 years ago
Trying to re-create the needed SPIR-V in inline assembly also fails because of OpVariable
needing to be Uniform
and thus in global scope instead of inside the function.
#[allow(unused_attributes)]
#[spirv(gl_compute)]
pub fn main_cs(
) {
unsafe {
asm!(
"%int = OpTypeInt 32 0",
"%uint = OpTypeInt 32 1",
"%int_0 = OpConstant %int 0",
"%uint_0 = OpConstant %uint 0",
"%int_array = OpTypeRuntimeArray %int",
"%ptr_int_array = OpTypePointer Uniform %int_array",
"%array = OpVariable %ptr_int_array Uniform",
"%stuff = OpAccessChain %ptr_int_array %array %uint_0 %uint_0 %uint_0"
);
}
}
From internal discussions it would seem that this is depending on https://github.com/EmbarkStudios/rust-gpu/issues/300
Really would like to have bindless support as believe it can simplify a lot in how we build our renderer with this. So approve of the idea :) But this is not that clear/concrete (to me) of how it would be implemented and what the options are, so maybe a lighter RFC is needed and/or some prototypes to map It out?
@repi This is just an issue to get over the initial hurdle so we can get rust-gpu to emit the correct SPIR-V incantation to even begin prototyping this.
Let's start off with the simplest hlsl shader I can more or less come up with to do bindless support, which I would like to port to rust-gpu.
Notice that instead of ByteArrayBuffer here, for the full feature one should be able to have (RW)Texture2D and other types as well.
Emitted SPIR-V from DXC:
First attempt:
This seems to emit a OpRuntimeArray but then proceed to do some things wrong. I had even more trouble making the slice mutable (for storing data) since that leads to a bunch of compiler errors down the line around
.load
not being available etc.Ideally we would also like to declare the bindless arrays as globals, so it's nicer to create our own wrapper types around Image2d and other (so they can do the indirection through the bindless array).