-
Notifications
You must be signed in to change notification settings - Fork 212
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
Unnecissary VariablePointers Capability Added #5322
Comments
I was gonna file this issue so thanks for doing it ;) FWIW It also breaks SPIRV-Cross both decompiling to GLSL and HLSL, so it's a pretty big issue. I get this problem both when using direct pointers, but also when using ConstBufferPointer<> as a replacement for vk::RawBufferLoad.
|
After reviewing the spirv spec, I think VariablePointer capability is not required, but we do need |
Looking at the context of the pr, it has a check right before to see if the addressing mode of the memory model is PhysicalStorageBuffer64 and skipping the variable pointer caps if it is. The output spirv does have that addressing mode enabled, which should be able to cover most normal usages of BDA. |
Well, that if is just to prevent redundantly emitting the decoration. The behavior is that as long as you have pointers, we need to declare VariablePointerStorageBuffer. |
There maybe more we can do, but without it we cannot meaningfully use pointers in any way, including using the access chain instruction. The right solve IMO is to make the debugging tools support pointers. |
FWIW that won't solve the SPIRV-Cross issue as GLSL and HLSL inherently don't support pointers (and decompiling to those languages is quite useful). Given that here we're doing things in slang that ARE supported in GLSL and HLSL (basic buffer_device_address usage), it'd be a shame to drop compatibility with them when the shader doesn't make use of that capability. |
OK, so you are saying all you did with the shader is directly loading a value from the pointer, and you want variable pointers to not be defined in that case. We can certainly do that, yeah. |
and just to be clear, if the shader does things like |
Reading through the spec for physical storage buffer, VariablePointers shouldn't be needed for doing those things with BDA pointers. As VariablePointers works on only logical pointers, but the spec defines all pointers into the physical storage buffer memory type as physical (not logical), so you should just be able to access them fine. Spirv-val seems to agree with this. OpPtrAccessChain should be supported when accessing a physical buffer pointer without variable pointers. |
Hmm, perhaps I misread the spec document. I am going to try completely removing the declaration and see if things work just fine. |
@cwfitzgerald You are right that this capability is not required. I have removed it in the PR. |
Nice, thanks! |
I'm not sure exactly whose issue this is, so I'm cross-filing it here and on spirv tools. When I use make any program with a pointer in it, the
VariablePointers
capability is enabled, even if it is not required. This isn't a big deal with shipping, as we're shipping on vk 1.2, but Renderdoc refuses to debug shaders with the VariablePointer capability, even if unused.I filed KhronosGroup/SPIRV-Tools#5854 against spirv-tools because their "trim-capabilities" pass wasn't removing it either.
My interim solution has been to disassemble, remove the cap, then re-assemble and re-validate, which has been working for all of my uses of BDA.
For example:
Generates:
If I take this spirv and remove the
OpCapability VariablePointers
andOpExtension "SPV_KHR_variable_pointers"
from the spirv and re-assemble and validate, it passes.The text was updated successfully, but these errors were encountered: