Bitcast loads from builtin compute variables.
This commit is contained in:
parent
c04d9e5c0e
commit
32a0d05e05
@ -0,0 +1,13 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout(binding = 0, std430) buffer BUF
|
||||
{
|
||||
int values[];
|
||||
} _6;
|
||||
|
||||
void main()
|
||||
{
|
||||
_6.values[int(gl_WorkGroupID.y)] = int(gl_GlobalInvocationID.z);
|
||||
}
|
||||
|
13
reference/shaders/asm/comp/builtin-compute-bitcast.asm.comp
Normal file
13
reference/shaders/asm/comp/builtin-compute-bitcast.asm.comp
Normal file
@ -0,0 +1,13 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout(binding = 0, std430) buffer BUF
|
||||
{
|
||||
int values[];
|
||||
} _6;
|
||||
|
||||
void main()
|
||||
{
|
||||
_6.values[int(gl_WorkGroupID.y)] = int(gl_GlobalInvocationID.z);
|
||||
}
|
||||
|
50
shaders/asm/comp/builtin-compute-bitcast.asm.comp
Normal file
50
shaders/asm/comp/builtin-compute-bitcast.asm.comp
Normal file
@ -0,0 +1,50 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 6
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main" %gl_WorkGroupID %gl_GlobalInvocationID
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %BUF "BUF"
|
||||
OpMemberName %BUF 0 "values"
|
||||
OpName %_ ""
|
||||
OpName %gl_WorkGroupID "gl_WorkGroupID"
|
||||
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
|
||||
OpDecorate %_runtimearr_int ArrayStride 4
|
||||
OpMemberDecorate %BUF 0 Offset 0
|
||||
OpDecorate %BUF BufferBlock
|
||||
OpDecorate %_ DescriptorSet 0
|
||||
OpDecorate %_ Binding 0
|
||||
OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId
|
||||
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
|
||||
%void = OpTypeVoid
|
||||
%int = OpTypeInt 32 1
|
||||
%_runtimearr_int = OpTypeRuntimeArray %int
|
||||
%3 = OpTypeFunction %void
|
||||
%BUF = OpTypeStruct %_runtimearr_int
|
||||
%_ptr_Uniform_BUF = OpTypePointer Uniform %BUF
|
||||
%_ = OpVariable %_ptr_Uniform_BUF Uniform
|
||||
%int_0 = OpConstant %int 0
|
||||
%v3int = OpTypeVector %int 3
|
||||
%_ptr_Input_v3int = OpTypePointer Input %v3int
|
||||
%gl_WorkGroupID = OpVariable %_ptr_Input_v3int Input
|
||||
%int_1 = OpConstant %int 1
|
||||
%_ptr_Input_int = OpTypePointer Input %int
|
||||
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3int Input
|
||||
%int_2 = OpConstant %int 2
|
||||
%_ptr_Uniform_int = OpTypePointer Uniform %int
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%18 = OpAccessChain %_ptr_Input_int %gl_WorkGroupID %int_1
|
||||
%19 = OpLoad %int %18
|
||||
%22 = OpAccessChain %_ptr_Input_int %gl_GlobalInvocationID %int_2
|
||||
%23 = OpLoad %int %22
|
||||
%25 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %19
|
||||
OpStore %25 %23
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -10070,6 +10070,10 @@ void CompilerGLSL::emit_array_copy(const string &lhs, uint32_t rhs_id)
|
||||
void CompilerGLSL::bitcast_from_builtin_load(uint32_t source_id, std::string &expr,
|
||||
const spirv_cross::SPIRType &expr_type)
|
||||
{
|
||||
auto *var = maybe_get_backing_variable(source_id);
|
||||
if (var)
|
||||
source_id = var->self;
|
||||
|
||||
// Only interested in standalone builtin variables.
|
||||
if (!has_decoration(source_id, DecorationBuiltIn))
|
||||
return;
|
||||
@ -10094,6 +10098,15 @@ void CompilerGLSL::bitcast_from_builtin_load(uint32_t source_id, std::string &ex
|
||||
expected_type = SPIRType::Int;
|
||||
break;
|
||||
|
||||
case BuiltInGlobalInvocationId:
|
||||
case BuiltInLocalInvocationId:
|
||||
case BuiltInWorkgroupId:
|
||||
case BuiltInLocalInvocationIndex:
|
||||
case BuiltInWorkgroupSize:
|
||||
case BuiltInNumWorkgroups:
|
||||
expected_type = SPIRType::UInt;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user