shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

`Load(in int Location, out uint Status)` missing from `Buffer/RWBuffer`? #4445

Closed chaoticbob closed 4 hours ago

chaoticbob commented 1 week ago

It looks like the status of the Load for Buffer and RWBuffer might be missing:

hlsl.meta.slang(15024): error 29000: unable to parse target intrinsic snippet: .Load
hlsl.meta.slang(15024): error 29000: unable to parse target intrinsic snippet: .Load
hlsl.meta.slang(15024): error 29000: unable to parse target intrinsic snippet: .Load

I couldn't find anything that looked like int hlsl.meta.slang.

Shader

Buffer<float>    floatbuf;
RWBuffer<float2> float2buf;

void main() {
    int address;
    uint status;
    float  r1 = floatbuf.Load(address, status); 
    float2 r2 = float2buf.Load(address, status); 
}
csyonghe commented 1 week ago

None of our users are using this function and there is no way we can convert this into spirv.

We can add the overload but it will only be implemented for HLSL and is not meaningful for other targets. I am not sure how important this is though.

chaoticbob commented 1 week ago

Hard to gauge the current importance of it currently. At least one person used it to justify a test for it. Probably should just back burner until someone comes asking for it.

jkwak-work commented 1 day ago

We now have an umbrella issue for this. https://github.com/shader-slang/slang/issues/4495

jkwak-work commented 1 day ago

HLSL spec for Load with status can be found in the following link. https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/t2d-load-float-int-uint-

jkwak-work commented 1 day ago

It appears that all of Load with status overloading is already in place. Only one case for Buffer is somehow missing its implementation.

    $(isReadOnly?"[__readNone] ":"")
    $(requireToSet)
    T Load(int location, out uint status);

This can be easily implemented in a same way the other Load functions are implemented for status.