You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is not currently an HLSL equivalent to g_NumWorkGroups. I'm inferring from the information provided that you'd like this to target SPIRV. As such, I'll leave it to the SPIRV folks Jaebaek Seo (@jaebaek) and Natalie Chouinard (@sudonatalie) if they plan to do something here.
In the meantime, you might consider passing the information through a constant buffer (UBO in GL speak) good luck!
Yes, precisely for HLSL to SPIRV. I did try the vk::ext_decorate(24) as that's the NumWorkgroups ID. But it would not produce any "OpDecorate Builtin NumWorkgroups".
Sorry for being late. We will take a look. Definitely, we have to consider adding some new intrinsics. We currently experience intense workloads. It can be delayed. Sorry about that in advance.
[[vk::ext_decorate(/* BuiltIn */ 11, /* NumWorkGroups */ 24)]] does correctly generate the desired OpDecorate %var BuiltIn NumWorkgroups, but the problem is getting %var to be the correct type with our current implementation. If you decorate a global, then it gets wrapped in the Globals struct, and the decoration is incorrectly applied to the wrapper. If an entry point input variable is decorated, then it needs a semantic string. I think this issue should be handled along with #4195, but I'll leave it to Jaebaek Seo (@jaebaek) to determine if it's a duplicate before closing.
fatal error: generated SPIR-V is invalid: Interface variable id <2> is used by entry point 'main' id <1>, but is not listed as an interface
%numWorkgroups = OpVariable %_ptr_Input_v3uint Input
We have to check the variable storage class in this line and add it as an operand of the entry point if it is an Input storage class. Let me keep this issue open.
Do you have any update on this issue? I'm keen to take advantage of the code snipped you posted above but I'm running into the same is not listed as an interface issue.
This is going to be a bigger issues to fix. I don't want to just do another hack with the existing inline spir-v. I'm going to look into revamping the whole feature.
Also looking for a similar fix regarding access to Compute Shader globals (gl_GlobalInvocationID, gl_LocalInvocationIndex etc). Please note that these need to be globally accessible from a shader file that is #included and has no access to any entry point!
#include "utils.hlsl"
// Contains the following
void initializeArr() {
[[vk::ext_storage_class(1)]]
[[vk::ext_decorate(11, 28)]]
uint3 gl_GlobalInvocationID;
arr[gl_GlobalInvocationID.x] = 0;
}
// end of utils.hlsl
void main() {
initializeArr();
}
In complex shader implementations it's really cumbersome to pass around the gl_ globals, it'd be best to have access to them as we do in GLSL.
It seems possible to override an existing input as a workaround. Eg: im currently (ab)using SV_GroupIndex to get the SubgroupID: [[vk::ext_decorate(11/*BuiltIn*/, 40/*SubgroupId*/)]] int waveIndex : SV_GroupIndex
Activity
pow2clk commentedon Feb 7, 2022
Hi Eichenherz!
There is not currently an HLSL equivalent to
g_NumWorkGroups. I'm inferring from the information provided that you'd like this to target SPIRV. As such, I'll leave it to the SPIRV folks Jaebaek Seo (@jaebaek) and Natalie Chouinard (@sudonatalie) if they plan to do something here.In the meantime, you might consider passing the information through a constant buffer (UBO in GL speak) good luck!
[-]Missing gl_NumWorkGroups[/-][+][SPIRV] Missing gl_NumWorkGroups[/+]Eichenherz commentedon Feb 8, 2022
Yes, precisely for HLSL to SPIRV. I did try the vk::ext_decorate(24) as that's the NumWorkgroups ID. But it would not produce any "OpDecorate Builtin NumWorkgroups".
jaebaek commentedon Feb 8, 2022
Sorry for being late. We will take a look. Definitely, we have to consider adding some new intrinsics. We currently experience intense workloads. It can be delayed. Sorry about that in advance.
sudonatalie commentedon Apr 29, 2022
[[vk::ext_decorate(/* BuiltIn */ 11, /* NumWorkGroups */ 24)]]does correctly generate the desiredOpDecorate %var BuiltIn NumWorkgroups, but the problem is getting%varto be the correct type with our current implementation. If you decorate a global, then it gets wrapped in theGlobalsstruct, and the decoration is incorrectly applied to the wrapper. If an entry point input variable is decorated, then it needs a semantic string. I think this issue should be handled along with #4195, but I'll leave it to Jaebaek Seo (@jaebaek) to determine if it's a duplicate before closing.jaebaek commentedon May 3, 2022
I think we can define a variable like the following example:
However, the validation layer report an error
We have to check the variable storage class in this line and add it as an operand of the entry point if it is an
Inputstorage class. Let me keep this issue open.forbiddencactus commentedon Mar 17, 2023
Jaebaek Seo (@jaebaek)
Do you have any update on this issue? I'm keen to take advantage of the code snipped you posted above but I'm running into the same
is not listed as an interfaceissue.s-perron commentedon Jun 2, 2023
This is going to be a bigger issues to fix. I don't want to just do another hack with the existing inline spir-v. I'm going to look into revamping the whole feature.
s-perron commentedon Jun 13, 2023
I opened microsoft/hlsl-specs#59. This should add a new attribute that can be used to properly define builtin input and output.
kpentaris commentedon Jun 30, 2023
Also looking for a similar fix regarding access to Compute Shader globals (gl_GlobalInvocationID, gl_LocalInvocationIndex etc). Please note that these need to be globally accessible from a shader file that is
#included and has no access to any entry point!In complex shader implementations it's really cumbersome to pass around the
gl_globals, it'd be best to have access to them as we do in GLSL.Thanks in advance!
s-perron commentedon Jun 30, 2023
pentakon (@kpentaris) That is the current plan in microsoft/hlsl-specs#59.
devshgraphicsprogramming commentedon Jul 31, 2023
and when will it land in DXC?
s-perron commentedon Aug 8, 2023
No idea when it will land.
OlesenJonas commentedon Dec 18, 2023
It seems possible to override an existing input as a workaround. Eg: im currently (ab)using SV_GroupIndex to get the SubgroupID:
[[vk::ext_decorate(11/*BuiltIn*/, 40/*SubgroupId*/)]] int waveIndex : SV_GroupIndex[SPIR-V] Implement vk::ext_builtin_input and vk::ext_builtin_output (#…
devshgraphicsprogramming commentedon Jan 2, 2024
@kptentaris