DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
[SPIR-V] Support arrays of RWStructuredBuffers
I'm not confident this generates the correct code in all cases, so I'd appreciate it if there are any suggestions.
Fixes #3281
:white_check_mark: Build DirectXShaderCompiler 1.0.2019 completed (commit https://github.com/microsoft/DirectXShaderCompiler/commit/f4e46832db by @cassiebeckley)
Id love to have this merged. This would make my hlsl api much nicer.
Is there a reason this was not merged?
There are still outstanding comments. @cassiebeckley PTAL when you have a chance.
I'm ok with the -fspv-flatten-resource-arrays
behavior being fixed in a follow-up PR , but the problem with the non-existent counter variable should be fixed before this is merged.
Sorry for the slow response on this, things have been busy. I'll try to get to this by the end of the week
Thank you!
Quick update: I did make some progress on this, but I'm still working on making sure the correct error messages show up in the correct situations
This would be amazing to have for bindless workflows!
Added a new commit that prevents counters from being created from an array subscript expression, which should fix issue 2. There are some tricky situations which should probably also result in errors that I don't know how to fix - for example, a counter is always created for any buffer returned from a function call. This seems difficult to detect statically - the return value of the function is effectively the buffer + the counter, and the function could have a branch where it either returns a buffer from an array, or a buffer that is not from an array.
As for issue 1, I'll create a tracking issue to follow up.
:white_check_mark: Build DirectXShaderCompiler 1.0.2817 completed (commit https://github.com/microsoft/DirectXShaderCompiler/commit/57103c1342 by @cassiebeckley)
RWStructuredBuffer<float4> localSBuffer = MyRWSBuffer[index];
localSBuffer.IncrementCounter();
For cases like this, we should be able to issue an error during validation after legalization. We could add something to the validator or do a specific search in DXC for a load with an undef address.
As for issue 2, I'll create a tracking issue to follow up.
We should discuss this. We should not give a partially working feature until we have a design to make it fully functional. Something like issue 2 is a clear bug that would be nearly impossible to debug. Is there a design doc for this?
(I mixed up issue 1 and 2 in my comment, fixed it)
(I mixed up issue 1 and 2 in my comment, fixed it)
Cool, what is the error message?
At the moment,
arr.hlsl:5:12: fatal error: cannot find the associated counter variable
return localSBuffer.IncrementCounter();
^