Check entry point variables in is_hidden_variables.
Need to be careful not to emit globals we're not supposed to.
This commit is contained in:
parent
4bedad3860
commit
ea02a0c03a
@ -0,0 +1,11 @@
|
||||
static const uint3 gl_WorkGroupSize = uint3(64u, 1u, 1u);
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
}
|
||||
|
||||
[numthreads(64, 1, 1)]
|
||||
void main()
|
||||
{
|
||||
comp_main();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u);
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float v;
|
||||
};
|
||||
|
||||
struct SSBO
|
||||
{
|
||||
float v;
|
||||
};
|
||||
|
||||
kernel void main0()
|
||||
{
|
||||
threadgroup float w;
|
||||
float v;
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
#version 450
|
||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
; SPIR-V
|
||||
; Version: 1.5
|
||||
; Generator: Khronos Glslang Reference Front End; 10
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
;OpEntryPoint GLCompute %main "main" %Samp %ubo %ssbo %v %w
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 64 1 1
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %Samp "Samp"
|
||||
OpName %UBO "UBO"
|
||||
OpMemberName %UBO 0 "v"
|
||||
OpName %ubo "ubo"
|
||||
OpName %SSBO "SSBO"
|
||||
OpMemberName %SSBO 0 "v"
|
||||
OpName %ssbo "ssbo"
|
||||
OpName %v "v"
|
||||
OpName %w "w"
|
||||
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
|
||||
OpDecorate %Samp DescriptorSet 0
|
||||
OpDecorate %Samp Binding 0
|
||||
OpMemberDecorate %UBO 0 Offset 0
|
||||
OpDecorate %UBO Block
|
||||
OpDecorate %ubo DescriptorSet 0
|
||||
OpDecorate %ubo Binding 1
|
||||
OpMemberDecorate %SSBO 0 Offset 0
|
||||
OpDecorate %SSBO Block
|
||||
OpDecorate %ssbo DescriptorSet 0
|
||||
OpDecorate %ssbo Binding 2
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%uint_64 = OpConstant %uint 64
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1
|
||||
%float = OpTypeFloat 32
|
||||
%12 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
%13 = OpTypeSampledImage %12
|
||||
%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13
|
||||
%Samp = OpVariable %_ptr_UniformConstant_13 UniformConstant
|
||||
%UBO = OpTypeStruct %float
|
||||
%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO
|
||||
%ubo = OpVariable %_ptr_Uniform_UBO Uniform
|
||||
%SSBO = OpTypeStruct %float
|
||||
%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO
|
||||
%ssbo = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer
|
||||
%_ptr_Private_float = OpTypePointer Private %float
|
||||
%v = OpVariable %_ptr_Private_float Private
|
||||
%_ptr_Workgroup_float = OpTypePointer Workgroup %float
|
||||
%w = OpVariable %_ptr_Workgroup_float Workgroup
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -0,0 +1,59 @@
|
||||
; SPIR-V
|
||||
; Version: 1.5
|
||||
; Generator: Khronos Glslang Reference Front End; 10
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
;OpEntryPoint GLCompute %main "main" %Samp %ubo %ssbo %v %w
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 64 1 1
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %Samp "Samp"
|
||||
OpName %UBO "UBO"
|
||||
OpMemberName %UBO 0 "v"
|
||||
OpName %ubo "ubo"
|
||||
OpName %SSBO "SSBO"
|
||||
OpMemberName %SSBO 0 "v"
|
||||
OpName %ssbo "ssbo"
|
||||
OpName %v "v"
|
||||
OpName %w "w"
|
||||
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
|
||||
OpDecorate %Samp DescriptorSet 0
|
||||
OpDecorate %Samp Binding 0
|
||||
OpMemberDecorate %UBO 0 Offset 0
|
||||
OpDecorate %UBO Block
|
||||
OpDecorate %ubo DescriptorSet 0
|
||||
OpDecorate %ubo Binding 1
|
||||
OpMemberDecorate %SSBO 0 Offset 0
|
||||
OpDecorate %SSBO Block
|
||||
OpDecorate %ssbo DescriptorSet 0
|
||||
OpDecorate %ssbo Binding 2
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%uint_64 = OpConstant %uint 64
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1
|
||||
%float = OpTypeFloat 32
|
||||
%12 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
%13 = OpTypeSampledImage %12
|
||||
%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13
|
||||
%Samp = OpVariable %_ptr_UniformConstant_13 UniformConstant
|
||||
%UBO = OpTypeStruct %float
|
||||
%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO
|
||||
%ubo = OpVariable %_ptr_Uniform_UBO Uniform
|
||||
%SSBO = OpTypeStruct %float
|
||||
%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO
|
||||
%ssbo = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer
|
||||
%_ptr_Private_float = OpTypePointer Private %float
|
||||
%v = OpVariable %_ptr_Private_float Private
|
||||
%_ptr_Workgroup_float = OpTypePointer Workgroup %float
|
||||
%w = OpVariable %_ptr_Workgroup_float Workgroup
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -0,0 +1,59 @@
|
||||
; SPIR-V
|
||||
; Version: 1.5
|
||||
; Generator: Khronos Glslang Reference Front End; 10
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
;OpEntryPoint GLCompute %main "main" %Samp %ubo %ssbo %v %w
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 64 1 1
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %Samp "Samp"
|
||||
OpName %UBO "UBO"
|
||||
OpMemberName %UBO 0 "v"
|
||||
OpName %ubo "ubo"
|
||||
OpName %SSBO "SSBO"
|
||||
OpMemberName %SSBO 0 "v"
|
||||
OpName %ssbo "ssbo"
|
||||
OpName %v "v"
|
||||
OpName %w "w"
|
||||
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
|
||||
OpDecorate %Samp DescriptorSet 0
|
||||
OpDecorate %Samp Binding 0
|
||||
OpMemberDecorate %UBO 0 Offset 0
|
||||
OpDecorate %UBO Block
|
||||
OpDecorate %ubo DescriptorSet 0
|
||||
OpDecorate %ubo Binding 1
|
||||
OpMemberDecorate %SSBO 0 Offset 0
|
||||
OpDecorate %SSBO Block
|
||||
OpDecorate %ssbo DescriptorSet 0
|
||||
OpDecorate %ssbo Binding 2
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%uint_64 = OpConstant %uint 64
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1
|
||||
%float = OpTypeFloat 32
|
||||
%12 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
%13 = OpTypeSampledImage %12
|
||||
%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13
|
||||
%Samp = OpVariable %_ptr_UniformConstant_13 UniformConstant
|
||||
%UBO = OpTypeStruct %float
|
||||
%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO
|
||||
%ubo = OpVariable %_ptr_Uniform_UBO Uniform
|
||||
%SSBO = OpTypeStruct %float
|
||||
%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO
|
||||
%ssbo = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer
|
||||
%_ptr_Private_float = OpTypePointer Private %float
|
||||
%v = OpVariable %_ptr_Private_float Private
|
||||
%_ptr_Workgroup_float = OpTypePointer Workgroup %float
|
||||
%w = OpVariable %_ptr_Workgroup_float Workgroup
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -546,10 +546,16 @@ bool Compiler::is_hidden_variable(const SPIRVariable &var, bool include_builtins
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hidden = false;
|
||||
if (check_active_interface_variables && storage_class_is_interface(var.storage))
|
||||
hidden = active_interface_variables.find(var.self) == end(active_interface_variables);
|
||||
return hidden;
|
||||
// In SPIR-V 1.4 and up we must also use the active variable interface to disable global variables
|
||||
// which are not part of the entry point.
|
||||
if (ir.get_spirv_version() >= 0x10400 && var.storage != spv::StorageClassGeneric &&
|
||||
var.storage != spv::StorageClassFunction && !interface_variable_exists_in_entry_point(var.self))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return check_active_interface_variables && storage_class_is_interface(var.storage) &&
|
||||
active_interface_variables.find(var.self) == end(active_interface_variables);
|
||||
}
|
||||
|
||||
bool Compiler::is_builtin_type(const SPIRType &type) const
|
||||
|
@ -542,7 +542,7 @@ void CompilerGLSL::ray_tracing_khr_fixup_locations()
|
||||
if (var.storage != StorageClassRayPayloadKHR && var.storage != StorageClassCallableDataKHR &&
|
||||
var.storage != StorageClassIncomingRayPayloadKHR && var.storage != StorageClassIncomingCallableDataKHR)
|
||||
return;
|
||||
if (!interface_variable_exists_in_entry_point(var.self))
|
||||
if (is_hidden_variable(var))
|
||||
return;
|
||||
set_decoration(var.self, DecorationLocation, location++);
|
||||
});
|
||||
@ -3453,6 +3453,9 @@ void CompilerGLSL::emit_resources()
|
||||
for (auto global : global_variables)
|
||||
{
|
||||
auto &var = get<SPIRVariable>(global);
|
||||
if (is_hidden_variable(var, true))
|
||||
continue;
|
||||
|
||||
if (var.storage != StorageClassOutput)
|
||||
{
|
||||
if (!variable_is_lut(var))
|
||||
|
@ -1362,7 +1362,8 @@ void CompilerHLSL::emit_resources()
|
||||
}
|
||||
|
||||
if (var.storage != StorageClassFunction && !is_builtin_variable(var) && !var.remapped_variable &&
|
||||
type.pointer && (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter))
|
||||
type.pointer && (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter) &&
|
||||
!is_hidden_variable(var))
|
||||
{
|
||||
emit_uniform(var);
|
||||
emitted = true;
|
||||
@ -1516,6 +1517,9 @@ void CompilerHLSL::emit_resources()
|
||||
for (auto global : global_variables)
|
||||
{
|
||||
auto &var = get<SPIRVariable>(global);
|
||||
if (is_hidden_variable(var, true))
|
||||
continue;
|
||||
|
||||
if (var.storage != StorageClassOutput)
|
||||
{
|
||||
if (!variable_is_lut(var))
|
||||
|
@ -413,7 +413,8 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati
|
||||
spirv_path = create_temporary()
|
||||
hlsl_path = create_temporary(os.path.basename(shader))
|
||||
|
||||
spirv_cmd = [paths.spirv_as, '--target-env', 'vulkan1.1', '-o', spirv_path, shader]
|
||||
spirv_env = 'vulkan1.1spv1.4' if '.spv14.' in shader else 'vulkan1.1'
|
||||
spirv_cmd = [paths.spirv_as, '--target-env', spirv_env, '-o', spirv_path, shader]
|
||||
if '.preserve.' in shader:
|
||||
spirv_cmd.append('--preserve-numeric-ids')
|
||||
|
||||
@ -446,7 +447,7 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati
|
||||
subprocess.check_call(hlsl_args)
|
||||
|
||||
if not shader_is_invalid_spirv(hlsl_path):
|
||||
subprocess.check_call([paths.spirv_val, '--scalar-block-layout', '--target-env', 'vulkan1.1', spirv_path])
|
||||
subprocess.check_call([paths.spirv_val, '--scalar-block-layout', '--target-env', spirv_env, spirv_path])
|
||||
|
||||
validate_shader_hlsl(hlsl_path, force_no_external_validation, paths)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user