-
Notifications
You must be signed in to change notification settings - Fork 718
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
[SPIR-V] static variable in template structures cannot pass to other functions with library profile #7049
Comments
Having a function with the In general, the way we handle initialization of private variable is to initialize them at the start of the entry point. This is working see https://godbolt.org/z/reGonbsG1. So I consider this working as far as the HLSL spec is concerned. Since development of DXC is winding down, we will not support a new work flow in DXC. If you want to follow up on this, you can open an issue in https://github.com/microsoft/hlsl-specs/ to define how HLSL compilation unit should be linked, and it could be implemented in clang. |
Yes, you're right. OpCapability Shader
OpCapability Linkage
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex %_
OpExecutionMode %main LocalSize 1 1 1
OpSource GLSL 450
OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
OpDecorate %_runtimearr_float ArrayStride 4
OpDecorate %Buffer Block
OpMemberDecorate %Buffer 0 Offset 0
OpDecorate %_ Binding 0
OpDecorate %_ DescriptorSet 0
OpDecorate %testcase_i1_ LinkageAttributes "testcase" Import
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%float = OpTypeFloat 32
%9 = OpTypeFunction %float %_ptr_Function_int
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%_ptr_Input_uint = OpTypePointer Input %uint
%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
%_runtimearr_float = OpTypeRuntimeArray %float
%Buffer = OpTypeStruct %_runtimearr_float
%_ptr_StorageBuffer_Buffer = OpTypePointer StorageBuffer %Buffer
%_ = OpVariable %_ptr_StorageBuffer_Buffer StorageBuffer
%int_0 = OpConstant %int 0
%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float
%testcase_i1_ = OpFunction %float None %9
%x = OpFunctionParameter %_ptr_Function_int
OpFunctionEnd
%main = OpFunction %void None %3
%5 = OpLabel
%id = OpVariable %_ptr_Function_uint Function
%param = OpVariable %_ptr_Function_int Function
%22 = OpLoad %uint %gl_LocalInvocationIndex
OpStore %id %22
%28 = OpLoad %uint %id
%29 = OpLoad %uint %id
%30 = OpBitcast %int %29
OpStore %param %30
%32 = OpFunctionCall %float %testcase_i1_ %param
%34 = OpAccessChain %_ptr_StorageBuffer_float %_ %int_0 %28
OpStore %34 %32
OpReturn
OpFunctionEnd And spirv-link --target-env vulkan1.3 -o linked.spv test.spv lib.spv OTOH, the result is correct if compile to dxil. Please see https://godbolt.org/z/hzsMejhET. I think this is a bug on the spir-v part. Could we reopen it now? |
I disagree that this is a bug because we do not support that work flow. You are asking us to support link of different HLSL modules, which is not an HLSL feature.
I will reopen it, but place it in the dormant milestone. If you want to find someone to fix it, we can review the change. As I mentioned earlier, DXC development is winding down, and we are focusing more on clang. The maintainers of the SPIR-V backend will not be fixing this issue. It is not a priority for us. |
Thanks to reply.
Oh, sorry, I see. I like this. (Sorry, I didn't notice your comments migrated to clang, please forgive me.)
I guess this is not a issue when I use clang, and should fix it in clang if issue exists. I think it should be closed.... |
Description
Hi, I want to use a series template structures as trait.
When I pass the static constant variables to function or return it in function.
I get the undef value.
Of course, if profile is normal stage (e.g. fragment) it looks good, but it failed if profile is library.
Steps to Reproduce
HLL
compilation
Actual Behavior
%size
is not initialized.Environment
The text was updated successfully, but these errors were encountered: