[naga spv-out] Ensure loops generated by SPIRV backend are bounded (#7080)

If it is undefined behaviour for loops to be infinite, then, when
encountering an infinite loop, downstream compilers are able to make
certain optimizations that may be unsafe. For example, omitting bounds
checks. To prevent this, we must ensure that any loops emitted by our
backends are provably bounded. We already do this for both the MSL and
HLSL backends. This patch makes us do so for SPIRV as well.

The construct used is the same as for HLSL and MSL backends: use a
vec2<u32> to emulate a 64-bit counter, which is incremented every
iteration and breaks after 2^64 iterations.

While the implementation is fairly verbose for the SPIRV backend, the
logic is simple enough. The one point of note is that SPIRV requires
`OpVariable` instructions with a `Function` storage class to be
located at the start of the first block of the function. We therefore
remember the IDs generated for each loop counter variable in a
function whilst generating the function body's code. The instructions
to declare these variables are then emitted in `Function::to_words()`
prior to emitting the function's body.

As this may negatively impact shader performance, this workaround can
be disabled using the same mechanism as for other backends: eg calling
Device::create_shader_module_trusted() and setting the
ShaderRuntimeChecks::force_loop_bounding flag to false.
This commit is contained in:
Jamie Nicol
2025-02-25 14:23:44 +00:00
committed by GitHub
parent e0f01854a8
commit b7d1f4c6cf
20 changed files with 3052 additions and 2332 deletions

View File

@@ -117,6 +117,17 @@ pub enum PollError {
By @cwfitzgerald in [#6942](https://github.com/gfx-rs/wgpu/pull/6942).
By @cwfitzgerald in [#7030](https://github.com/gfx-rs/wgpu/pull/7030).
#### Naga
##### Ensure loops generated by SPIR-V and HLSL Naga backends are bounded
Make sure that all loops in shaders generated by these naga backends are bounded
to avoid undefined behaviour due to infinite loops. Note that this may have a
performance cost. As with the existing implementation for the MSL backend this
can be disabled by using `Device::create_shader_module_trusted()`.
By @jamienicol in [#6929](https://github.com/gfx-rs/wgpu/pull/6929) and [#7080](https://github.com/gfx-rs/wgpu/pull/7080).
### New Features
#### General

View File

@@ -261,6 +261,155 @@ impl Writer {
}
impl BlockContext<'_> {
/// Generates code to ensure that a loop is bounded. Should be called immediately
/// after adding the OpLoopMerge instruction to `block`. This function will
/// [`consume()`](crate::back::spv::Function::consume) `block` and append its
/// instructions to a new [`Block`], which will be returned to the caller for it to
/// consumed prior to writing the loop body.
///
/// Additionally this function will populate [`force_loop_bounding_vars`](crate::back::spv::Function::force_loop_bounding_vars),
/// ensuring that [`Function::to_words()`](crate::back::spv::Function::to_words) will
/// declare the required variables.
///
/// See [`crate::back::msl::Writer::gen_force_bounded_loop_statements`] for details
/// of why this is required.
fn write_force_bounded_loop_instructions(&mut self, mut block: Block, merge_id: Word) -> Block {
let uint_type_id = self.writer.get_uint_type_id();
let uint2_type_id = self.writer.get_uint2_type_id();
let uint2_ptr_type_id = self
.writer
.get_uint2_pointer_type_id(spirv::StorageClass::Function);
let bool_type_id = self.writer.get_bool_type_id();
let bool2_type_id = self.writer.get_bool2_type_id();
let zero_uint_const_id = self.writer.get_constant_scalar(crate::Literal::U32(0));
let zero_uint2_const_id = self.writer.get_constant_composite(
LookupType::Local(LocalType::Numeric(NumericType::Vector {
size: crate::VectorSize::Bi,
scalar: crate::Scalar::U32,
})),
&[zero_uint_const_id, zero_uint_const_id],
);
let one_uint_const_id = self.writer.get_constant_scalar(crate::Literal::U32(1));
let max_uint_const_id = self
.writer
.get_constant_scalar(crate::Literal::U32(u32::MAX));
let max_uint2_const_id = self.writer.get_constant_composite(
LookupType::Local(LocalType::Numeric(NumericType::Vector {
size: crate::VectorSize::Bi,
scalar: crate::Scalar::U32,
})),
&[max_uint_const_id, max_uint_const_id],
);
let loop_counter_var_id = self.gen_id();
if self.writer.flags.contains(WriterFlags::DEBUG) {
self.writer
.debugs
.push(Instruction::name(loop_counter_var_id, "loop_bound"));
}
let var = super::LocalVariable {
id: loop_counter_var_id,
instruction: Instruction::variable(
uint2_ptr_type_id,
loop_counter_var_id,
spirv::StorageClass::Function,
Some(zero_uint2_const_id),
),
};
self.function.force_loop_bounding_vars.push(var);
let break_if_block = self.gen_id();
self.function
.consume(block, Instruction::branch(break_if_block));
block = Block::new(break_if_block);
// Load the current loop counter value from its variable. We use a vec2<u32> to
// simulate a 64-bit counter.
let load_id = self.gen_id();
block.body.push(Instruction::load(
uint2_type_id,
load_id,
loop_counter_var_id,
None,
));
// If both the high and low u32s have reached u32::MAX then break. ie
// if (all(eq(loop_counter, vec2(u32::MAX)))) { break; }
let eq_id = self.gen_id();
block.body.push(Instruction::binary(
spirv::Op::IEqual,
bool2_type_id,
eq_id,
max_uint2_const_id,
load_id,
));
let all_eq_id = self.gen_id();
block.body.push(Instruction::relational(
spirv::Op::All,
bool_type_id,
all_eq_id,
eq_id,
));
let inc_counter_block_id = self.gen_id();
block.body.push(Instruction::selection_merge(
inc_counter_block_id,
spirv::SelectionControl::empty(),
));
self.function.consume(
block,
Instruction::branch_conditional(all_eq_id, merge_id, inc_counter_block_id),
);
block = Block::new(inc_counter_block_id);
// To simulate a 64-bit counter we always increment the low u32, and increment
// the high u32 when the low u32 overflows. ie
// counter += vec2(select(0u, 1u, counter.y == u32::MAX), 1u);
let low_id = self.gen_id();
block.body.push(Instruction::composite_extract(
uint_type_id,
low_id,
load_id,
&[1],
));
let low_overflow_id = self.gen_id();
block.body.push(Instruction::binary(
spirv::Op::IEqual,
bool_type_id,
low_overflow_id,
low_id,
max_uint_const_id,
));
let carry_bit_id = self.gen_id();
block.body.push(Instruction::select(
uint_type_id,
carry_bit_id,
low_overflow_id,
one_uint_const_id,
zero_uint_const_id,
));
let increment_id = self.gen_id();
block.body.push(Instruction::composite_construct(
uint2_type_id,
increment_id,
&[carry_bit_id, one_uint_const_id],
));
let result_id = self.gen_id();
block.body.push(Instruction::binary(
spirv::Op::IAdd,
uint2_type_id,
result_id,
load_id,
increment_id,
));
block
.body
.push(Instruction::store(loop_counter_var_id, result_id, None));
block
}
/// Cache an expression for a value.
pub(super) fn cache_expression_value(
&mut self,
@@ -2558,6 +2707,10 @@ impl BlockContext<'_> {
continuing_id,
spirv::SelectionControl::NONE,
));
if self.force_loop_bounding {
block = self.write_force_bounded_loop_instructions(block, merge_id);
}
self.function.consume(block, Instruction::branch(body_id));
// We can ignore the `BlockExitDisposition` returned here because,

View File

@@ -144,6 +144,8 @@ struct Function {
signature: Option<Instruction>,
parameters: Vec<FunctionArgument>,
variables: crate::FastHashMap<Handle<crate::LocalVariable>, LocalVariable>,
/// List of local variables used as a counters to ensure that all loops are bounded.
force_loop_bounding_vars: Vec<LocalVariable>,
/// A map taking an expression that yields a composite value (array, matrix)
/// to the temporary variables we have spilled it to, if any. Spilling
@@ -726,6 +728,8 @@ struct BlockContext<'w> {
/// Tracks the constness of `Expression`s residing in `self.ir_function.expressions`
expression_constness: ExpressionConstnessTracker,
force_loop_bounding: bool,
}
impl BlockContext<'_> {
@@ -779,6 +783,7 @@ pub struct Writer {
flags: WriterFlags,
bounds_check_policies: BoundsCheckPolicies,
zero_initialize_workgroup_memory: ZeroInitializeWorkgroupMemoryMode,
force_loop_bounding: bool,
void_type: Word,
//TODO: convert most of these into vectors, addressable by handle indices
lookup_type: crate::FastHashMap<LookupType, Word>,
@@ -882,6 +887,10 @@ pub struct Options<'a> {
/// Dictates the way workgroup variables should be zero initialized
pub zero_initialize_workgroup_memory: ZeroInitializeWorkgroupMemoryMode,
/// If set, loops will have code injected into them, forcing the compiler
/// to think the number of iterations is bounded.
pub force_loop_bounding: bool,
pub debug_info: Option<DebugInfo<'a>>,
}
@@ -900,6 +909,7 @@ impl Default for Options<'_> {
capabilities: None,
bounds_check_policies: BoundsCheckPolicies::default(),
zero_initialize_workgroup_memory: ZeroInitializeWorkgroupMemoryMode::Polyfill,
force_loop_bounding: true,
debug_info: None,
}
}

View File

@@ -32,6 +32,9 @@ impl Function {
for local_var in self.variables.values() {
local_var.instruction.to_words(sink);
}
for local_var in self.force_loop_bounding_vars.iter() {
local_var.instruction.to_words(sink);
}
for internal_var in self.spilled_composites.values() {
internal_var.instruction.to_words(sink);
}
@@ -71,6 +74,7 @@ impl Writer {
flags: options.flags,
bounds_check_policies: options.bounds_check_policies,
zero_initialize_workgroup_memory: options.zero_initialize_workgroup_memory,
force_loop_bounding: options.force_loop_bounding,
void_type,
lookup_type: crate::FastHashMap::default(),
lookup_function: crate::FastHashMap::default(),
@@ -111,6 +115,7 @@ impl Writer {
flags: self.flags,
bounds_check_policies: self.bounds_check_policies,
zero_initialize_workgroup_memory: self.zero_initialize_workgroup_memory,
force_loop_bounding: self.force_loop_bounding,
capabilities_available: take(&mut self.capabilities_available),
binding_map: take(&mut self.binding_map),
@@ -267,6 +272,14 @@ impl Writer {
self.get_type_id(local_type.into())
}
pub(super) fn get_uint2_type_id(&mut self) -> Word {
let local_type = LocalType::Numeric(NumericType::Vector {
size: crate::VectorSize::Bi,
scalar: crate::Scalar::U32,
});
self.get_type_id(local_type.into())
}
pub(super) fn get_uint3_type_id(&mut self) -> Word {
let local_type = LocalType::Numeric(NumericType::Vector {
size: crate::VectorSize::Tri,
@@ -283,6 +296,17 @@ impl Writer {
self.get_type_id(local_type.into())
}
pub(super) fn get_uint2_pointer_type_id(&mut self, class: spirv::StorageClass) -> Word {
let local_type = LocalType::LocalPointer {
base: NumericType::Vector {
size: crate::VectorSize::Bi,
scalar: crate::Scalar::U32,
},
class,
};
self.get_type_id(local_type.into())
}
pub(super) fn get_uint3_pointer_type_id(&mut self, class: spirv::StorageClass) -> Word {
let local_type = LocalType::LocalPointer {
base: NumericType::Vector {
@@ -299,6 +323,14 @@ impl Writer {
self.get_type_id(local_type.into())
}
pub(super) fn get_bool2_type_id(&mut self) -> Word {
let local_type = LocalType::Numeric(NumericType::Vector {
size: crate::VectorSize::Bi,
scalar: crate::Scalar::BOOL,
});
self.get_type_id(local_type.into())
}
pub(super) fn get_bool3_type_id(&mut self) -> Word {
let local_type = LocalType::Numeric(NumericType::Vector {
size: crate::VectorSize::Tri,
@@ -839,6 +871,7 @@ impl Writer {
// Steal the Writer's temp list for a bit.
temp_list: std::mem::take(&mut self.temp_list),
force_loop_bounding: self.force_loop_bounding,
writer: self,
expression_constness: super::ExpressionConstnessTracker::from_arena(
&ir_function.expressions,

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 26
; Bound: 46
OpCapability Shader
OpCapability Linkage
%1 = OpExtInstImport "GLSL.std.450"
@@ -13,31 +13,55 @@ OpMemoryModel Logical GLSL450
%8 = OpConstant %3 4
%9 = OpConstant %3 1
%11 = OpTypePointer Function %3
%18 = OpTypeBool
%17 = OpTypeInt 32 0
%18 = OpTypeVector %17 2
%19 = OpTypePointer Function %18
%20 = OpTypeBool
%21 = OpTypeVector %20 2
%22 = OpConstant %17 0
%23 = OpConstantComposite %18 %22 %22
%24 = OpConstant %17 1
%25 = OpConstant %17 4294967295
%26 = OpConstantComposite %18 %25 %25
%5 = OpFunction %2 None %6
%4 = OpLabel
%10 = OpVariable %11 Function %7
%27 = OpVariable %19 Function %23
OpBranch %12
%12 = OpLabel
OpBranch %13
%13 = OpLabel
OpLoopMerge %14 %16 None
OpBranch %28
%28 = OpLabel
%29 = OpLoad %18 %27
%30 = OpIEqual %21 %26 %29
%31 = OpAll %20 %30
OpSelectionMerge %32 None
OpBranchConditional %31 %14 %32
%32 = OpLabel
%33 = OpCompositeExtract %17 %29 1
%34 = OpIEqual %20 %33 %25
%35 = OpSelect %17 %34 %24 %22
%36 = OpCompositeConstruct %18 %35 %24
%37 = OpIAdd %18 %29 %36
OpStore %27 %37
OpBranch %15
%15 = OpLabel
%17 = OpLoad %3 %10
%19 = OpSLessThan %18 %17 %8
OpSelectionMerge %20 None
OpBranchConditional %19 %20 %21
%21 = OpLabel
%38 = OpLoad %3 %10
%39 = OpSLessThan %20 %38 %8
OpSelectionMerge %40 None
OpBranchConditional %39 %40 %41
%41 = OpLabel
OpBranch %14
%20 = OpLabel
OpBranch %22
%22 = OpLabel
%40 = OpLabel
OpBranch %42
%42 = OpLabel
OpBranch %14
%16 = OpLabel
%24 = OpLoad %3 %10
%25 = OpIAdd %3 %24 %9
OpStore %10 %25
%44 = OpLoad %3 %10
%45 = OpIAdd %3 %44 %9
OpStore %10 %45
OpBranch %13
%14 = OpLabel
OpReturn

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.0
; Generator: rspirv
; Bound: 125
; Bound: 175
OpCapability Shader
OpCapability Int64Atomics
OpCapability Int64
@@ -9,9 +9,9 @@ OpExtension "SPV_KHR_storage_buffer_storage_class"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %19 "test_atomic_compare_exchange_i64"
OpEntryPoint GLCompute %77 "test_atomic_compare_exchange_u64"
OpEntryPoint GLCompute %105 "test_atomic_compare_exchange_u64"
OpExecutionMode %19 LocalSize 1 1 1
OpExecutionMode %77 LocalSize 1 1 1
OpExecutionMode %105 LocalSize 1 1 1
OpDecorate %5 ArrayStride 8
OpDecorate %8 ArrayStride 8
OpMemberDecorate %10 0 Offset 0
@@ -53,153 +53,219 @@ OpMemberDecorate %16 0 Offset 0
%31 = OpConstantNull %4
%33 = OpTypePointer Function %9
%34 = OpConstantNull %9
%47 = OpTypePointer StorageBuffer %4
%51 = OpTypeInt 32 1
%50 = OpConstant %51 1
%52 = OpConstant %3 64
%78 = OpTypePointer StorageBuffer %8
%80 = OpConstant %7 10
%83 = OpTypePointer Function %7
%84 = OpConstantNull %7
%86 = OpConstantNull %9
%99 = OpTypePointer StorageBuffer %7
%40 = OpTypeVector %3 2
%41 = OpTypePointer Function %40
%42 = OpTypeVector %9 2
%43 = OpConstantComposite %40 %22 %22
%44 = OpConstant %3 4294967295
%45 = OpConstantComposite %40 %44 %44
%64 = OpTypePointer StorageBuffer %4
%68 = OpTypeInt 32 1
%67 = OpConstant %68 1
%69 = OpConstant %3 64
%106 = OpTypePointer StorageBuffer %8
%108 = OpConstant %7 10
%111 = OpTypePointer Function %7
%112 = OpConstantNull %7
%114 = OpConstantNull %9
%138 = OpTypePointer StorageBuffer %7
%19 = OpFunction %2 None %20
%18 = OpLabel
%27 = OpVariable %28 Function %22
%29 = OpVariable %30 Function %31
%32 = OpVariable %33 Function %34
%46 = OpVariable %41 Function %43
%74 = OpVariable %41 Function %43
%23 = OpAccessChain %21 %12 %22
OpBranch %35
%35 = OpLabel
OpBranch %36
%36 = OpLabel
OpLoopMerge %37 %39 None
OpBranch %47
%47 = OpLabel
%48 = OpLoad %40 %46
%49 = OpIEqual %42 %45 %48
%50 = OpAll %9 %49
OpSelectionMerge %51 None
OpBranchConditional %50 %37 %51
%51 = OpLabel
%52 = OpCompositeExtract %3 %48 1
%53 = OpIEqual %9 %52 %44
%54 = OpSelect %3 %53 %26 %22
%55 = OpCompositeConstruct %40 %54 %26
%56 = OpIAdd %40 %48 %55
OpStore %46 %56
OpBranch %38
%38 = OpLabel
%40 = OpLoad %3 %27
%41 = OpULessThan %9 %40 %6
OpSelectionMerge %42 None
OpBranchConditional %41 %42 %43
%43 = OpLabel
OpBranch %37
%42 = OpLabel
OpBranch %44
%44 = OpLabel
%46 = OpLoad %3 %27
%48 = OpAccessChain %47 %23 %46
%49 = OpAtomicLoad %4 %48 %50 %52
OpStore %29 %49
OpStore %32 %24
OpBranch %53
%53 = OpLabel
OpLoopMerge %54 %56 None
OpBranch %55
%55 = OpLabel
%57 = OpLoad %9 %32
%58 = OpLogicalNot %9 %57
%57 = OpLoad %3 %27
%58 = OpULessThan %9 %57 %6
OpSelectionMerge %59 None
OpBranchConditional %58 %59 %60
%60 = OpLabel
OpBranch %54
OpBranch %37
%59 = OpLabel
OpBranch %61
%61 = OpLabel
%63 = OpLoad %4 %29
%64 = OpIAdd %4 %63 %25
%66 = OpLoad %3 %27
%67 = OpLoad %4 %29
%69 = OpAccessChain %47 %23 %66
%70 = OpAtomicCompareExchange %4 %69 %50 %52 %52 %64 %67
%71 = OpIEqual %9 %70 %67
%68 = OpCompositeConstruct %10 %70 %71
%72 = OpCompositeExtract %4 %68 0
OpStore %29 %72
%73 = OpCompositeExtract %9 %68 1
OpStore %32 %73
%63 = OpLoad %3 %27
%65 = OpAccessChain %64 %23 %63
%66 = OpAtomicLoad %4 %65 %67 %69
OpStore %29 %66
OpStore %32 %24
OpBranch %70
%70 = OpLabel
OpLoopMerge %71 %73 None
OpBranch %75
%75 = OpLabel
%76 = OpLoad %40 %74
%77 = OpIEqual %42 %45 %76
%78 = OpAll %9 %77
OpSelectionMerge %79 None
OpBranchConditional %78 %71 %79
%79 = OpLabel
%80 = OpCompositeExtract %3 %76 1
%81 = OpIEqual %9 %80 %44
%82 = OpSelect %3 %81 %26 %22
%83 = OpCompositeConstruct %40 %82 %26
%84 = OpIAdd %40 %76 %83
OpStore %74 %84
OpBranch %72
%72 = OpLabel
%85 = OpLoad %9 %32
%86 = OpLogicalNot %9 %85
OpSelectionMerge %87 None
OpBranchConditional %86 %87 %88
%88 = OpLabel
OpBranch %71
%87 = OpLabel
OpBranch %89
%89 = OpLabel
%91 = OpLoad %4 %29
%92 = OpIAdd %4 %91 %25
%94 = OpLoad %3 %27
%95 = OpLoad %4 %29
%97 = OpAccessChain %64 %23 %94
%98 = OpAtomicCompareExchange %4 %97 %67 %69 %69 %92 %95
%99 = OpIEqual %9 %98 %95
%96 = OpCompositeConstruct %10 %98 %99
%100 = OpCompositeExtract %4 %96 0
OpStore %29 %100
%101 = OpCompositeExtract %9 %96 1
OpStore %32 %101
OpBranch %90
%90 = OpLabel
OpBranch %73
%73 = OpLabel
OpBranch %70
%71 = OpLabel
OpBranch %62
%62 = OpLabel
OpBranch %56
%56 = OpLabel
OpBranch %53
%54 = OpLabel
OpBranch %45
%45 = OpLabel
OpBranch %39
%39 = OpLabel
%74 = OpLoad %3 %27
%75 = OpIAdd %3 %74 %26
OpStore %27 %75
%102 = OpLoad %3 %27
%103 = OpIAdd %3 %102 %26
OpStore %27 %103
OpBranch %36
%37 = OpLabel
OpReturn
OpFunctionEnd
%77 = OpFunction %2 None %20
%76 = OpLabel
%81 = OpVariable %28 Function %22
%82 = OpVariable %83 Function %84
%85 = OpVariable %33 Function %86
%79 = OpAccessChain %78 %15 %22
OpBranch %87
%87 = OpLabel
OpBranch %88
%88 = OpLabel
OpLoopMerge %89 %91 None
OpBranch %90
%90 = OpLabel
%92 = OpLoad %3 %81
%93 = OpULessThan %9 %92 %6
OpSelectionMerge %94 None
OpBranchConditional %93 %94 %95
%95 = OpLabel
OpBranch %89
%94 = OpLabel
OpBranch %96
%96 = OpLabel
%98 = OpLoad %3 %81
%100 = OpAccessChain %99 %79 %98
%101 = OpAtomicLoad %7 %100 %50 %52
OpStore %82 %101
OpStore %85 %24
OpBranch %102
%102 = OpLabel
OpLoopMerge %103 %105 None
OpBranch %104
%105 = OpFunction %2 None %20
%104 = OpLabel
%106 = OpLoad %9 %85
%107 = OpLogicalNot %9 %106
OpSelectionMerge %108 None
OpBranchConditional %107 %108 %109
%109 = OpLabel
OpBranch %103
%108 = OpLabel
OpBranch %110
%110 = OpLabel
%112 = OpLoad %7 %82
%113 = OpIAdd %7 %112 %80
%115 = OpLoad %3 %81
%116 = OpLoad %7 %82
%118 = OpAccessChain %99 %79 %115
%119 = OpAtomicCompareExchange %7 %118 %50 %52 %52 %113 %116
%120 = OpIEqual %9 %119 %116
%117 = OpCompositeConstruct %11 %119 %120
%121 = OpCompositeExtract %7 %117 0
OpStore %82 %121
%122 = OpCompositeExtract %9 %117 1
OpStore %85 %122
OpBranch %111
%111 = OpLabel
OpBranch %105
%105 = OpLabel
OpBranch %102
%103 = OpLabel
OpBranch %97
%97 = OpLabel
OpBranch %91
%91 = OpLabel
%123 = OpLoad %3 %81
%124 = OpIAdd %3 %123 %26
OpStore %81 %124
OpBranch %88
%89 = OpLabel
%109 = OpVariable %28 Function %22
%110 = OpVariable %111 Function %112
%113 = OpVariable %33 Function %114
%120 = OpVariable %41 Function %43
%145 = OpVariable %41 Function %43
%107 = OpAccessChain %106 %15 %22
OpBranch %115
%115 = OpLabel
OpBranch %116
%116 = OpLabel
OpLoopMerge %117 %119 None
OpBranch %121
%121 = OpLabel
%122 = OpLoad %40 %120
%123 = OpIEqual %42 %45 %122
%124 = OpAll %9 %123
OpSelectionMerge %125 None
OpBranchConditional %124 %117 %125
%125 = OpLabel
%126 = OpCompositeExtract %3 %122 1
%127 = OpIEqual %9 %126 %44
%128 = OpSelect %3 %127 %26 %22
%129 = OpCompositeConstruct %40 %128 %26
%130 = OpIAdd %40 %122 %129
OpStore %120 %130
OpBranch %118
%118 = OpLabel
%131 = OpLoad %3 %109
%132 = OpULessThan %9 %131 %6
OpSelectionMerge %133 None
OpBranchConditional %132 %133 %134
%134 = OpLabel
OpBranch %117
%133 = OpLabel
OpBranch %135
%135 = OpLabel
%137 = OpLoad %3 %109
%139 = OpAccessChain %138 %107 %137
%140 = OpAtomicLoad %7 %139 %67 %69
OpStore %110 %140
OpStore %113 %24
OpBranch %141
%141 = OpLabel
OpLoopMerge %142 %144 None
OpBranch %146
%146 = OpLabel
%147 = OpLoad %40 %145
%148 = OpIEqual %42 %45 %147
%149 = OpAll %9 %148
OpSelectionMerge %150 None
OpBranchConditional %149 %142 %150
%150 = OpLabel
%151 = OpCompositeExtract %3 %147 1
%152 = OpIEqual %9 %151 %44
%153 = OpSelect %3 %152 %26 %22
%154 = OpCompositeConstruct %40 %153 %26
%155 = OpIAdd %40 %147 %154
OpStore %145 %155
OpBranch %143
%143 = OpLabel
%156 = OpLoad %9 %113
%157 = OpLogicalNot %9 %156
OpSelectionMerge %158 None
OpBranchConditional %157 %158 %159
%159 = OpLabel
OpBranch %142
%158 = OpLabel
OpBranch %160
%160 = OpLabel
%162 = OpLoad %7 %110
%163 = OpIAdd %7 %162 %108
%165 = OpLoad %3 %109
%166 = OpLoad %7 %110
%168 = OpAccessChain %138 %107 %165
%169 = OpAtomicCompareExchange %7 %168 %67 %69 %69 %163 %166
%170 = OpIEqual %9 %169 %166
%167 = OpCompositeConstruct %11 %169 %170
%171 = OpCompositeExtract %7 %167 0
OpStore %110 %171
%172 = OpCompositeExtract %9 %167 1
OpStore %113 %172
OpBranch %161
%161 = OpLabel
OpBranch %144
%144 = OpLabel
OpBranch %141
%142 = OpLabel
OpBranch %136
%136 = OpLabel
OpBranch %119
%119 = OpLabel
%173 = OpLoad %3 %109
%174 = OpIAdd %3 %173 %26
OpStore %109 %174
OpBranch %116
%117 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -1,15 +1,15 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 124
; Bound: 174
OpCapability Shader
OpExtension "SPV_KHR_storage_buffer_storage_class"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %18 "test_atomic_compare_exchange_i32"
OpEntryPoint GLCompute %77 "test_atomic_compare_exchange_u32"
OpEntryPoint GLCompute %105 "test_atomic_compare_exchange_u32"
OpExecutionMode %18 LocalSize 1 1 1
OpExecutionMode %77 LocalSize 1 1 1
OpExecutionMode %105 LocalSize 1 1 1
OpDecorate %5 ArrayStride 4
OpDecorate %7 ArrayStride 4
OpMemberDecorate %9 0 Offset 0
@@ -51,154 +51,220 @@ OpMemberDecorate %15 0 Offset 0
%31 = OpConstantNull %4
%33 = OpTypePointer Function %8
%34 = OpConstantNull %8
%47 = OpTypePointer StorageBuffer %4
%50 = OpConstant %4 1
%51 = OpConstant %3 64
%78 = OpTypePointer StorageBuffer %7
%82 = OpConstantNull %3
%84 = OpConstantNull %8
%97 = OpTypePointer StorageBuffer %3
%40 = OpTypeVector %3 2
%41 = OpTypePointer Function %40
%42 = OpTypeVector %8 2
%43 = OpConstantComposite %40 %21 %21
%44 = OpConstant %3 4294967295
%45 = OpConstantComposite %40 %44 %44
%64 = OpTypePointer StorageBuffer %4
%67 = OpConstant %4 1
%68 = OpConstant %3 64
%106 = OpTypePointer StorageBuffer %7
%110 = OpConstantNull %3
%112 = OpConstantNull %8
%136 = OpTypePointer StorageBuffer %3
%18 = OpFunction %2 None %19
%17 = OpLabel
%27 = OpVariable %28 Function %21
%29 = OpVariable %30 Function %31
%32 = OpVariable %33 Function %34
%46 = OpVariable %41 Function %43
%73 = OpVariable %41 Function %43
%22 = OpAccessChain %20 %11 %21
OpBranch %35
%35 = OpLabel
OpBranch %36
%36 = OpLabel
OpLoopMerge %37 %39 None
OpBranch %47
%47 = OpLabel
%48 = OpLoad %40 %46
%49 = OpIEqual %42 %45 %48
%50 = OpAll %8 %49
OpSelectionMerge %51 None
OpBranchConditional %50 %37 %51
%51 = OpLabel
%52 = OpCompositeExtract %3 %48 1
%53 = OpIEqual %8 %52 %44
%54 = OpSelect %3 %53 %26 %21
%55 = OpCompositeConstruct %40 %54 %26
%56 = OpIAdd %40 %48 %55
OpStore %46 %56
OpBranch %38
%38 = OpLabel
%40 = OpLoad %3 %27
%41 = OpULessThan %8 %40 %6
OpSelectionMerge %42 None
OpBranchConditional %41 %42 %43
%43 = OpLabel
OpBranch %37
%42 = OpLabel
OpBranch %44
%44 = OpLabel
%46 = OpLoad %3 %27
%48 = OpAccessChain %47 %22 %46
%49 = OpAtomicLoad %4 %48 %50 %51
OpStore %29 %49
OpStore %32 %23
OpBranch %52
%52 = OpLabel
OpLoopMerge %53 %55 None
OpBranch %54
%54 = OpLabel
%56 = OpLoad %8 %32
%57 = OpLogicalNot %8 %56
OpSelectionMerge %58 None
OpBranchConditional %57 %58 %59
%59 = OpLabel
OpBranch %53
%58 = OpLabel
OpBranch %60
%57 = OpLoad %3 %27
%58 = OpULessThan %8 %57 %6
OpSelectionMerge %59 None
OpBranchConditional %58 %59 %60
%60 = OpLabel
%62 = OpLoad %4 %29
%63 = OpBitcast %24 %62
%64 = OpFAdd %24 %63 %25
%65 = OpBitcast %4 %64
%66 = OpLoad %3 %27
%67 = OpLoad %4 %29
%69 = OpAccessChain %47 %22 %66
%70 = OpAtomicCompareExchange %4 %69 %50 %51 %51 %65 %67
%71 = OpIEqual %8 %70 %67
%68 = OpCompositeConstruct %9 %70 %71
%72 = OpCompositeExtract %4 %68 0
OpStore %29 %72
%73 = OpCompositeExtract %8 %68 1
OpStore %32 %73
OpBranch %37
%59 = OpLabel
OpBranch %61
%61 = OpLabel
OpBranch %55
%55 = OpLabel
OpBranch %52
%53 = OpLabel
OpBranch %45
%45 = OpLabel
%63 = OpLoad %3 %27
%65 = OpAccessChain %64 %22 %63
%66 = OpAtomicLoad %4 %65 %67 %68
OpStore %29 %66
OpStore %32 %23
OpBranch %69
%69 = OpLabel
OpLoopMerge %70 %72 None
OpBranch %74
%74 = OpLabel
%75 = OpLoad %40 %73
%76 = OpIEqual %42 %45 %75
%77 = OpAll %8 %76
OpSelectionMerge %78 None
OpBranchConditional %77 %70 %78
%78 = OpLabel
%79 = OpCompositeExtract %3 %75 1
%80 = OpIEqual %8 %79 %44
%81 = OpSelect %3 %80 %26 %21
%82 = OpCompositeConstruct %40 %81 %26
%83 = OpIAdd %40 %75 %82
OpStore %73 %83
OpBranch %71
%71 = OpLabel
%84 = OpLoad %8 %32
%85 = OpLogicalNot %8 %84
OpSelectionMerge %86 None
OpBranchConditional %85 %86 %87
%87 = OpLabel
OpBranch %70
%86 = OpLabel
OpBranch %88
%88 = OpLabel
%90 = OpLoad %4 %29
%91 = OpBitcast %24 %90
%92 = OpFAdd %24 %91 %25
%93 = OpBitcast %4 %92
%94 = OpLoad %3 %27
%95 = OpLoad %4 %29
%97 = OpAccessChain %64 %22 %94
%98 = OpAtomicCompareExchange %4 %97 %67 %68 %68 %93 %95
%99 = OpIEqual %8 %98 %95
%96 = OpCompositeConstruct %9 %98 %99
%100 = OpCompositeExtract %4 %96 0
OpStore %29 %100
%101 = OpCompositeExtract %8 %96 1
OpStore %32 %101
OpBranch %89
%89 = OpLabel
OpBranch %72
%72 = OpLabel
OpBranch %69
%70 = OpLabel
OpBranch %62
%62 = OpLabel
OpBranch %39
%39 = OpLabel
%74 = OpLoad %3 %27
%75 = OpIAdd %3 %74 %26
OpStore %27 %75
%102 = OpLoad %3 %27
%103 = OpIAdd %3 %102 %26
OpStore %27 %103
OpBranch %36
%37 = OpLabel
OpReturn
OpFunctionEnd
%77 = OpFunction %2 None %19
%76 = OpLabel
%80 = OpVariable %28 Function %21
%81 = OpVariable %28 Function %82
%83 = OpVariable %33 Function %84
%79 = OpAccessChain %78 %14 %21
OpBranch %85
%85 = OpLabel
OpBranch %86
%86 = OpLabel
OpLoopMerge %87 %89 None
OpBranch %88
%88 = OpLabel
%90 = OpLoad %3 %80
%91 = OpULessThan %8 %90 %6
OpSelectionMerge %92 None
OpBranchConditional %91 %92 %93
%93 = OpLabel
OpBranch %87
%92 = OpLabel
OpBranch %94
%94 = OpLabel
%96 = OpLoad %3 %80
%98 = OpAccessChain %97 %79 %96
%99 = OpAtomicLoad %3 %98 %50 %51
OpStore %81 %99
OpStore %83 %23
OpBranch %100
%100 = OpLabel
OpLoopMerge %101 %103 None
OpBranch %102
%102 = OpLabel
%104 = OpLoad %8 %83
%105 = OpLogicalNot %8 %104
OpSelectionMerge %106 None
OpBranchConditional %105 %106 %107
%107 = OpLabel
OpBranch %101
%106 = OpLabel
OpBranch %108
%108 = OpLabel
%110 = OpLoad %3 %81
%111 = OpBitcast %24 %110
%112 = OpFAdd %24 %111 %25
%113 = OpBitcast %3 %112
%114 = OpLoad %3 %80
%115 = OpLoad %3 %81
%117 = OpAccessChain %97 %79 %114
%118 = OpAtomicCompareExchange %3 %117 %50 %51 %51 %113 %115
%119 = OpIEqual %8 %118 %115
%116 = OpCompositeConstruct %10 %118 %119
%120 = OpCompositeExtract %3 %116 0
OpStore %81 %120
%121 = OpCompositeExtract %8 %116 1
OpStore %83 %121
OpBranch %109
%109 = OpLabel
OpBranch %103
%103 = OpLabel
OpBranch %100
%101 = OpLabel
OpBranch %95
%95 = OpLabel
OpBranch %89
%89 = OpLabel
%122 = OpLoad %3 %80
%123 = OpIAdd %3 %122 %26
OpStore %80 %123
OpBranch %86
%87 = OpLabel
%105 = OpFunction %2 None %19
%104 = OpLabel
%108 = OpVariable %28 Function %21
%109 = OpVariable %28 Function %110
%111 = OpVariable %33 Function %112
%118 = OpVariable %41 Function %43
%143 = OpVariable %41 Function %43
%107 = OpAccessChain %106 %14 %21
OpBranch %113
%113 = OpLabel
OpBranch %114
%114 = OpLabel
OpLoopMerge %115 %117 None
OpBranch %119
%119 = OpLabel
%120 = OpLoad %40 %118
%121 = OpIEqual %42 %45 %120
%122 = OpAll %8 %121
OpSelectionMerge %123 None
OpBranchConditional %122 %115 %123
%123 = OpLabel
%124 = OpCompositeExtract %3 %120 1
%125 = OpIEqual %8 %124 %44
%126 = OpSelect %3 %125 %26 %21
%127 = OpCompositeConstruct %40 %126 %26
%128 = OpIAdd %40 %120 %127
OpStore %118 %128
OpBranch %116
%116 = OpLabel
%129 = OpLoad %3 %108
%130 = OpULessThan %8 %129 %6
OpSelectionMerge %131 None
OpBranchConditional %130 %131 %132
%132 = OpLabel
OpBranch %115
%131 = OpLabel
OpBranch %133
%133 = OpLabel
%135 = OpLoad %3 %108
%137 = OpAccessChain %136 %107 %135
%138 = OpAtomicLoad %3 %137 %67 %68
OpStore %109 %138
OpStore %111 %23
OpBranch %139
%139 = OpLabel
OpLoopMerge %140 %142 None
OpBranch %144
%144 = OpLabel
%145 = OpLoad %40 %143
%146 = OpIEqual %42 %45 %145
%147 = OpAll %8 %146
OpSelectionMerge %148 None
OpBranchConditional %147 %140 %148
%148 = OpLabel
%149 = OpCompositeExtract %3 %145 1
%150 = OpIEqual %8 %149 %44
%151 = OpSelect %3 %150 %26 %21
%152 = OpCompositeConstruct %40 %151 %26
%153 = OpIAdd %40 %145 %152
OpStore %143 %153
OpBranch %141
%141 = OpLabel
%154 = OpLoad %8 %111
%155 = OpLogicalNot %8 %154
OpSelectionMerge %156 None
OpBranchConditional %155 %156 %157
%157 = OpLabel
OpBranch %140
%156 = OpLabel
OpBranch %158
%158 = OpLabel
%160 = OpLoad %3 %109
%161 = OpBitcast %24 %160
%162 = OpFAdd %24 %161 %25
%163 = OpBitcast %3 %162
%164 = OpLoad %3 %108
%165 = OpLoad %3 %109
%167 = OpAccessChain %136 %107 %164
%168 = OpAtomicCompareExchange %3 %167 %67 %68 %68 %163 %165
%169 = OpIEqual %8 %168 %165
%166 = OpCompositeConstruct %10 %168 %169
%170 = OpCompositeExtract %3 %166 0
OpStore %109 %170
%171 = OpCompositeExtract %8 %166 1
OpStore %111 %171
OpBranch %159
%159 = OpLabel
OpBranch %142
%142 = OpLabel
OpBranch %139
%140 = OpLabel
OpBranch %134
%134 = OpLabel
OpBranch %117
%117 = OpLabel
%172 = OpLoad %3 %108
%173 = OpIAdd %3 %172 %26
OpStore %108 %173
OpBranch %114
%115 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.0
; Generator: rspirv
; Bound: 209
; Bound: 226
OpCapability Shader
OpExtension "SPV_KHR_storage_buffer_storage_class"
%1 = OpExtInstImport "GLSL.std.450"
@@ -146,6 +146,7 @@ OpName %47 "cVelCount"
OpName %48 "pos"
OpName %50 "vel"
OpName %52 "i"
OpName %77 "loop_bound"
OpMemberDecorate %7 0 Offset 0
OpMemberDecorate %7 1 Offset 8
OpMemberDecorate %8 0 Offset 0
@@ -209,13 +210,19 @@ OpDecorate %21 BuiltIn GlobalInvocationId
%60 = OpTypePointer StorageBuffer %9
%61 = OpTypePointer StorageBuffer %7
%62 = OpTypePointer StorageBuffer %6
%88 = OpTypePointer Uniform %5
%102 = OpConstant %4 2
%116 = OpConstant %4 3
%151 = OpConstant %4 4
%157 = OpConstant %4 5
%163 = OpConstant %4 6
%180 = OpTypePointer Function %5
%71 = OpTypeVector %4 2
%72 = OpTypePointer Function %71
%73 = OpTypeVector %56 2
%74 = OpConstantComposite %71 %27 %27
%75 = OpConstant %4 4294967295
%76 = OpConstantComposite %71 %75 %75
%105 = OpTypePointer Uniform %5
%119 = OpConstant %4 2
%133 = OpConstant %4 3
%168 = OpConstant %4 4
%174 = OpConstant %4 5
%180 = OpConstant %4 6
%197 = OpTypePointer Function %5
%24 = OpFunction %2 None %25
%20 = OpLabel
%52 = OpVariable %53 Function %27
@@ -228,6 +235,7 @@ OpDecorate %21 BuiltIn GlobalInvocationId
%50 = OpVariable %38 Function %51
%45 = OpVariable %46 Function %31
%42 = OpVariable %38 Function %30
%77 = OpVariable %72 Function %74
%23 = OpLoad %11 %21
%28 = OpAccessChain %26 %14 %27
OpBranch %54
@@ -259,272 +267,286 @@ OpBranch %67
%67 = OpLabel
OpLine %3 46 3
OpLoopMerge %68 %70 None
OpBranch %78
%78 = OpLabel
%79 = OpLoad %71 %77
%80 = OpIEqual %73 %76 %79
%81 = OpAll %56 %80
OpSelectionMerge %82 None
OpBranchConditional %81 %68 %82
%82 = OpLabel
%83 = OpCompositeExtract %4 %79 1
%84 = OpIEqual %56 %83 %75
%85 = OpSelect %4 %84 %33 %27
%86 = OpCompositeConstruct %71 %85 %33
%87 = OpIAdd %71 %79 %86
OpStore %77 %87
OpBranch %69
%69 = OpLabel
OpLine %3 1 1
%71 = OpLoad %4 %52
%88 = OpLoad %4 %52
OpLine %3 47 8
%72 = OpUGreaterThanEqual %56 %71 %13
%89 = OpUGreaterThanEqual %56 %88 %13
OpLine %3 47 5
OpSelectionMerge %73 None
OpBranchConditional %72 %74 %73
%74 = OpLabel
OpSelectionMerge %90 None
OpBranchConditional %89 %91 %90
%91 = OpLabel
OpBranch %68
%73 = OpLabel
%90 = OpLabel
OpLine %3 50 8
%75 = OpLoad %4 %52
%76 = OpIEqual %56 %75 %55
%92 = OpLoad %4 %52
%93 = OpIEqual %56 %92 %55
OpLine %3 50 5
OpSelectionMerge %77 None
OpBranchConditional %76 %78 %77
%78 = OpLabel
OpSelectionMerge %94 None
OpBranchConditional %93 %95 %94
%95 = OpLabel
OpBranch %70
%77 = OpLabel
%94 = OpLabel
OpLine %3 54 11
%79 = OpLoad %4 %52
%80 = OpAccessChain %62 %17 %27 %79 %27
%81 = OpLoad %6 %80
%96 = OpLoad %4 %52
%97 = OpAccessChain %62 %17 %27 %96 %27
%98 = OpLoad %6 %97
OpLine %3 54 5
OpStore %48 %81
OpStore %48 %98
OpLine %3 55 11
%82 = OpLoad %4 %52
%83 = OpAccessChain %62 %17 %27 %82 %33
%84 = OpLoad %6 %83
%99 = OpLoad %4 %52
%100 = OpAccessChain %62 %17 %27 %99 %33
%101 = OpLoad %6 %100
OpLine %3 55 5
OpStore %50 %84
OpStore %50 %101
OpLine %3 57 8
%85 = OpLoad %6 %48
%86 = OpLoad %6 %37
%87 = OpExtInst %5 %1 Distance %85 %86
%102 = OpLoad %6 %48
%103 = OpLoad %6 %37
%104 = OpExtInst %5 %1 Distance %102 %103
OpLine %3 57 8
%89 = OpAccessChain %88 %28 %33
%90 = OpLoad %5 %89
%91 = OpFOrdLessThan %56 %87 %90
%106 = OpAccessChain %105 %28 %33
%107 = OpLoad %5 %106
%108 = OpFOrdLessThan %56 %104 %107
OpLine %3 57 5
OpSelectionMerge %92 None
OpBranchConditional %91 %93 %92
%93 = OpLabel
OpSelectionMerge %109 None
OpBranchConditional %108 %110 %109
%110 = OpLabel
OpLine %3 58 15
%94 = OpLoad %6 %42
%95 = OpLoad %6 %48
%96 = OpFAdd %6 %94 %95
%111 = OpLoad %6 %42
%112 = OpLoad %6 %48
%113 = OpFAdd %6 %111 %112
OpLine %3 58 7
OpStore %42 %96
OpStore %42 %113
OpLine %3 1 1
%97 = OpLoad %12 %45
%114 = OpLoad %12 %45
OpLine %3 59 20
%98 = OpIAdd %12 %97 %32
%115 = OpIAdd %12 %114 %32
OpLine %3 59 7
OpStore %45 %98
OpBranch %92
%92 = OpLabel
OpStore %45 %115
OpBranch %109
%109 = OpLabel
OpLine %3 61 8
%99 = OpLoad %6 %48
%100 = OpLoad %6 %37
%101 = OpExtInst %5 %1 Distance %99 %100
%116 = OpLoad %6 %48
%117 = OpLoad %6 %37
%118 = OpExtInst %5 %1 Distance %116 %117
OpLine %3 61 8
%103 = OpAccessChain %88 %28 %102
%104 = OpLoad %5 %103
%105 = OpFOrdLessThan %56 %101 %104
%120 = OpAccessChain %105 %28 %119
%121 = OpLoad %5 %120
%122 = OpFOrdLessThan %56 %118 %121
OpLine %3 61 5
OpSelectionMerge %106 None
OpBranchConditional %105 %107 %106
%107 = OpLabel
OpSelectionMerge %123 None
OpBranchConditional %122 %124 %123
%124 = OpLabel
OpLine %3 62 16
%108 = OpLoad %6 %44
%109 = OpLoad %6 %48
%110 = OpLoad %6 %37
%111 = OpFSub %6 %109 %110
%112 = OpFSub %6 %108 %111
%125 = OpLoad %6 %44
%126 = OpLoad %6 %48
%127 = OpLoad %6 %37
%128 = OpFSub %6 %126 %127
%129 = OpFSub %6 %125 %128
OpLine %3 62 7
OpStore %44 %112
OpBranch %106
%106 = OpLabel
OpStore %44 %129
OpBranch %123
%123 = OpLabel
OpLine %3 64 8
%113 = OpLoad %6 %48
%114 = OpLoad %6 %37
%115 = OpExtInst %5 %1 Distance %113 %114
%130 = OpLoad %6 %48
%131 = OpLoad %6 %37
%132 = OpExtInst %5 %1 Distance %130 %131
OpLine %3 64 8
%117 = OpAccessChain %88 %28 %116
%118 = OpLoad %5 %117
%119 = OpFOrdLessThan %56 %115 %118
%134 = OpAccessChain %105 %28 %133
%135 = OpLoad %5 %134
%136 = OpFOrdLessThan %56 %132 %135
OpLine %3 64 5
OpSelectionMerge %120 None
OpBranchConditional %119 %121 %120
%121 = OpLabel
OpSelectionMerge %137 None
OpBranchConditional %136 %138 %137
%138 = OpLabel
OpLine %3 65 14
%122 = OpLoad %6 %43
%123 = OpLoad %6 %50
%124 = OpFAdd %6 %122 %123
%139 = OpLoad %6 %43
%140 = OpLoad %6 %50
%141 = OpFAdd %6 %139 %140
OpLine %3 65 7
OpStore %43 %124
OpStore %43 %141
OpLine %3 1 1
%125 = OpLoad %12 %47
%142 = OpLoad %12 %47
OpLine %3 66 19
%126 = OpIAdd %12 %125 %32
%143 = OpIAdd %12 %142 %32
OpLine %3 66 7
OpStore %47 %126
OpBranch %120
%120 = OpLabel
OpStore %47 %143
OpBranch %137
%137 = OpLabel
OpBranch %70
%70 = OpLabel
OpLine %3 1 1
%127 = OpLoad %4 %52
%144 = OpLoad %4 %52
OpLine %3 70 11
%128 = OpIAdd %4 %127 %33
%145 = OpIAdd %4 %144 %33
OpLine %3 70 7
OpStore %52 %128
OpStore %52 %145
OpBranch %67
%68 = OpLabel
OpLine %3 1 1
%129 = OpLoad %12 %45
%146 = OpLoad %12 %45
OpLine %3 73 6
%130 = OpSGreaterThan %56 %129 %31
%147 = OpSGreaterThan %56 %146 %31
OpLine %3 73 3
OpSelectionMerge %131 None
OpBranchConditional %130 %132 %131
%132 = OpLabel
OpSelectionMerge %148 None
OpBranchConditional %147 %149 %148
%149 = OpLabel
OpLine %3 74 13
%133 = OpLoad %6 %42
%134 = OpLoad %12 %45
%135 = OpConvertSToF %5 %134
%136 = OpCompositeConstruct %6 %135 %135
%137 = OpFDiv %6 %133 %136
%138 = OpLoad %6 %37
%139 = OpFSub %6 %137 %138
OpLine %3 74 5
OpStore %42 %139
OpBranch %131
%131 = OpLabel
OpLine %3 1 1
%140 = OpLoad %12 %47
OpLine %3 76 6
%141 = OpSGreaterThan %56 %140 %31
OpLine %3 76 3
OpSelectionMerge %142 None
OpBranchConditional %141 %143 %142
%143 = OpLabel
OpLine %3 77 12
%144 = OpLoad %6 %43
%145 = OpLoad %12 %47
%146 = OpConvertSToF %5 %145
%147 = OpCompositeConstruct %6 %146 %146
%148 = OpFDiv %6 %144 %147
OpLine %3 77 5
OpStore %43 %148
OpBranch %142
%142 = OpLabel
OpLine %3 1 1
%149 = OpLoad %6 %40
%150 = OpLoad %6 %42
OpLine %3 80 10
%152 = OpAccessChain %88 %28 %151
%153 = OpLoad %5 %152
%154 = OpVectorTimesScalar %6 %150 %153
%155 = OpFAdd %6 %149 %154
%156 = OpLoad %6 %44
OpLine %3 80 10
%158 = OpAccessChain %88 %28 %157
%159 = OpLoad %5 %158
%160 = OpVectorTimesScalar %6 %156 %159
%161 = OpFAdd %6 %155 %160
%162 = OpLoad %6 %43
OpLine %3 80 10
%164 = OpAccessChain %88 %28 %163
%165 = OpLoad %5 %164
%166 = OpVectorTimesScalar %6 %162 %165
%167 = OpFAdd %6 %161 %166
OpLine %3 80 3
OpStore %40 %167
OpLine %3 85 10
%168 = OpLoad %6 %40
%169 = OpExtInst %6 %1 Normalize %168
%170 = OpLoad %6 %40
%171 = OpExtInst %5 %1 Length %170
OpLine %3 85 10
%172 = OpExtInst %5 %1 FClamp %171 %29 %34
%173 = OpVectorTimesScalar %6 %169 %172
OpLine %3 85 3
OpStore %40 %173
%151 = OpLoad %12 %45
%152 = OpConvertSToF %5 %151
%153 = OpCompositeConstruct %6 %152 %152
%154 = OpFDiv %6 %150 %153
%155 = OpLoad %6 %37
%156 = OpFSub %6 %154 %155
OpLine %3 74 5
OpStore %42 %156
OpBranch %148
%148 = OpLabel
OpLine %3 1 1
%174 = OpLoad %6 %37
%175 = OpLoad %6 %40
OpLine %3 88 10
%176 = OpAccessChain %88 %28 %27
%177 = OpLoad %5 %176
%178 = OpVectorTimesScalar %6 %175 %177
%179 = OpFAdd %6 %174 %178
OpLine %3 88 3
OpStore %37 %179
OpLine %3 91 6
%181 = OpAccessChain %180 %37 %27
%157 = OpLoad %12 %47
OpLine %3 76 6
%158 = OpSGreaterThan %56 %157 %31
OpLine %3 76 3
OpSelectionMerge %159 None
OpBranchConditional %158 %160 %159
%160 = OpLabel
OpLine %3 77 12
%161 = OpLoad %6 %43
%162 = OpLoad %12 %47
%163 = OpConvertSToF %5 %162
%164 = OpCompositeConstruct %6 %163 %163
%165 = OpFDiv %6 %161 %164
OpLine %3 77 5
OpStore %43 %165
OpBranch %159
%159 = OpLabel
OpLine %3 1 1
%166 = OpLoad %6 %40
%167 = OpLoad %6 %42
OpLine %3 80 10
%169 = OpAccessChain %105 %28 %168
%170 = OpLoad %5 %169
%171 = OpVectorTimesScalar %6 %167 %170
%172 = OpFAdd %6 %166 %171
%173 = OpLoad %6 %44
OpLine %3 80 10
%175 = OpAccessChain %105 %28 %174
%176 = OpLoad %5 %175
%177 = OpVectorTimesScalar %6 %173 %176
%178 = OpFAdd %6 %172 %177
%179 = OpLoad %6 %43
OpLine %3 80 10
%181 = OpAccessChain %105 %28 %180
%182 = OpLoad %5 %181
OpLine %3 91 6
%183 = OpFOrdLessThan %56 %182 %35
OpLine %3 91 3
OpSelectionMerge %184 None
OpBranchConditional %183 %185 %184
%185 = OpLabel
OpLine %3 92 5
OpLine %3 92 5
%186 = OpAccessChain %180 %37 %27
OpStore %186 %36
OpBranch %184
%184 = OpLabel
OpLine %3 94 6
%187 = OpAccessChain %180 %37 %27
%188 = OpLoad %5 %187
OpLine %3 94 6
%189 = OpFOrdGreaterThan %56 %188 %36
OpLine %3 94 3
OpSelectionMerge %190 None
OpBranchConditional %189 %191 %190
%191 = OpLabel
OpLine %3 95 5
OpLine %3 95 5
%192 = OpAccessChain %180 %37 %27
OpStore %192 %35
OpBranch %190
%190 = OpLabel
OpLine %3 97 6
%193 = OpAccessChain %180 %37 %33
%183 = OpVectorTimesScalar %6 %179 %182
%184 = OpFAdd %6 %178 %183
OpLine %3 80 3
OpStore %40 %184
OpLine %3 85 10
%185 = OpLoad %6 %40
%186 = OpExtInst %6 %1 Normalize %185
%187 = OpLoad %6 %40
%188 = OpExtInst %5 %1 Length %187
OpLine %3 85 10
%189 = OpExtInst %5 %1 FClamp %188 %29 %34
%190 = OpVectorTimesScalar %6 %186 %189
OpLine %3 85 3
OpStore %40 %190
OpLine %3 1 1
%191 = OpLoad %6 %37
%192 = OpLoad %6 %40
OpLine %3 88 10
%193 = OpAccessChain %105 %28 %27
%194 = OpLoad %5 %193
OpLine %3 97 6
%195 = OpFOrdLessThan %56 %194 %35
OpLine %3 97 3
OpSelectionMerge %196 None
OpBranchConditional %195 %197 %196
%197 = OpLabel
OpLine %3 98 5
OpLine %3 98 5
%198 = OpAccessChain %180 %37 %33
OpStore %198 %36
OpBranch %196
%196 = OpLabel
OpLine %3 100 6
%199 = OpAccessChain %180 %37 %33
%200 = OpLoad %5 %199
OpLine %3 100 6
%201 = OpFOrdGreaterThan %56 %200 %36
OpLine %3 100 3
OpSelectionMerge %202 None
OpBranchConditional %201 %203 %202
%203 = OpLabel
OpLine %3 101 5
OpLine %3 101 5
%204 = OpAccessChain %180 %37 %33
OpStore %204 %35
OpBranch %202
%195 = OpVectorTimesScalar %6 %192 %194
%196 = OpFAdd %6 %191 %195
OpLine %3 88 3
OpStore %37 %196
OpLine %3 91 6
%198 = OpAccessChain %197 %37 %27
%199 = OpLoad %5 %198
OpLine %3 91 6
%200 = OpFOrdLessThan %56 %199 %35
OpLine %3 91 3
OpSelectionMerge %201 None
OpBranchConditional %200 %202 %201
%202 = OpLabel
OpLine %3 92 5
OpLine %3 92 5
%203 = OpAccessChain %197 %37 %27
OpStore %203 %36
OpBranch %201
%201 = OpLabel
OpLine %3 94 6
%204 = OpAccessChain %197 %37 %27
%205 = OpLoad %5 %204
OpLine %3 94 6
%206 = OpFOrdGreaterThan %56 %205 %36
OpLine %3 94 3
OpSelectionMerge %207 None
OpBranchConditional %206 %208 %207
%208 = OpLabel
OpLine %3 95 5
OpLine %3 95 5
%209 = OpAccessChain %197 %37 %27
OpStore %209 %35
OpBranch %207
%207 = OpLabel
OpLine %3 97 6
%210 = OpAccessChain %197 %37 %33
%211 = OpLoad %5 %210
OpLine %3 97 6
%212 = OpFOrdLessThan %56 %211 %35
OpLine %3 97 3
OpSelectionMerge %213 None
OpBranchConditional %212 %214 %213
%214 = OpLabel
OpLine %3 98 5
OpLine %3 98 5
%215 = OpAccessChain %197 %37 %33
OpStore %215 %36
OpBranch %213
%213 = OpLabel
OpLine %3 100 6
%216 = OpAccessChain %197 %37 %33
%217 = OpLoad %5 %216
OpLine %3 100 6
%218 = OpFOrdGreaterThan %56 %217 %36
OpLine %3 100 3
OpSelectionMerge %219 None
OpBranchConditional %218 %220 %219
%220 = OpLabel
OpLine %3 101 5
OpLine %3 101 5
%221 = OpAccessChain %197 %37 %33
OpStore %221 %35
OpBranch %219
%219 = OpLabel
OpLine %3 105 3
%205 = OpLoad %6 %37
%222 = OpLoad %6 %37
OpLine %3 105 3
%206 = OpAccessChain %62 %19 %27 %55 %27
OpStore %206 %205
%223 = OpAccessChain %62 %19 %27 %55 %27
OpStore %223 %222
OpLine %3 106 3
%207 = OpLoad %6 %40
%224 = OpLoad %6 %40
OpLine %3 106 3
%208 = OpAccessChain %62 %19 %27 %55 %33
OpStore %208 %207
%225 = OpAccessChain %62 %19 %27 %55 %33
OpStore %225 %224
OpReturn
OpFunctionEnd

View File

@@ -1,34 +1,55 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 67
; Bound: 117
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %65 "main"
OpExecutionMode %65 LocalSize 1 1 1
OpEntryPoint GLCompute %115 "main"
OpExecutionMode %115 LocalSize 1 1 1
%2 = OpTypeVoid
%3 = OpTypeBool
%4 = OpTypeInt 32 0
%7 = OpTypeFunction %2
%8 = OpConstantTrue %3
%17 = OpTypeFunction %2 %3
%19 = OpTypePointer Function %3
%20 = OpConstantNull %3
%22 = OpConstantNull %3
%36 = OpConstantNull %3
%38 = OpConstantNull %3
%50 = OpConstant %4 0
%51 = OpConstant %4 1
%52 = OpConstant %4 5
%54 = OpTypePointer Function %4
%14 = OpTypeVector %4 2
%15 = OpTypePointer Function %14
%16 = OpTypeVector %3 2
%17 = OpConstant %4 0
%18 = OpConstantComposite %14 %17 %17
%19 = OpConstant %4 1
%20 = OpConstant %4 4294967295
%21 = OpConstantComposite %14 %20 %20
%36 = OpTypeFunction %2 %3
%38 = OpTypePointer Function %3
%39 = OpConstantNull %3
%41 = OpConstantNull %3
%66 = OpConstantNull %3
%68 = OpConstantNull %3
%91 = OpConstant %4 5
%93 = OpTypePointer Function %4
%6 = OpFunction %2 None %7
%5 = OpLabel
%22 = OpVariable %15 Function %18
OpBranch %9
%9 = OpLabel
OpBranch %10
%10 = OpLabel
OpLoopMerge %11 %13 None
OpBranch %23
%23 = OpLabel
%24 = OpLoad %14 %22
%25 = OpIEqual %16 %21 %24
%26 = OpAll %3 %25
OpSelectionMerge %27 None
OpBranchConditional %26 %11 %27
%27 = OpLabel
%28 = OpCompositeExtract %4 %24 1
%29 = OpIEqual %3 %28 %20
%30 = OpSelect %4 %29 %19 %17
%31 = OpCompositeConstruct %14 %30 %19
%32 = OpIAdd %14 %24 %31
OpStore %22 %32
OpBranch %12
%12 = OpLabel
OpBranch %13
@@ -37,78 +58,123 @@ OpBranchConditional %8 %11 %10
%11 = OpLabel
OpReturn
OpFunctionEnd
%16 = OpFunction %2 None %17
%15 = OpFunctionParameter %3
%14 = OpLabel
%18 = OpVariable %19 Function %20
%21 = OpVariable %19 Function %22
OpBranch %23
%23 = OpLabel
OpBranch %24
%24 = OpLabel
OpLoopMerge %25 %27 None
OpBranch %26
%26 = OpLabel
OpBranch %27
%27 = OpLabel
OpStore %18 %15
%28 = OpLoad %3 %18
%29 = OpLogicalNotEqual %3 %15 %28
OpStore %21 %29
%30 = OpLoad %3 %21
%31 = OpLogicalEqual %3 %15 %30
OpBranchConditional %31 %25 %24
%25 = OpLabel
OpReturn
OpFunctionEnd
%34 = OpFunction %2 None %17
%33 = OpFunctionParameter %3
%32 = OpLabel
%35 = OpVariable %19 Function %36
%37 = OpVariable %19 Function %38
OpBranch %39
%39 = OpLabel
OpBranch %40
%40 = OpLabel
OpLoopMerge %41 %43 None
%35 = OpFunction %2 None %36
%34 = OpFunctionParameter %3
%33 = OpLabel
%37 = OpVariable %38 Function %39
%40 = OpVariable %38 Function %41
%47 = OpVariable %15 Function %18
OpBranch %42
%42 = OpLabel
OpStore %35 %33
%44 = OpLoad %3 %35
%45 = OpLogicalNotEqual %3 %33 %44
OpStore %37 %45
OpBranch %43
%43 = OpLabel
%46 = OpLoad %3 %37
%47 = OpLogicalEqual %3 %33 %46
OpBranchConditional %47 %41 %40
%41 = OpLabel
OpReturn
OpFunctionEnd
%49 = OpFunction %2 None %7
OpLoopMerge %44 %46 None
OpBranch %48
%48 = OpLabel
%53 = OpVariable %54 Function %50
OpBranch %55
%55 = OpLabel
OpBranch %56
%56 = OpLabel
OpLoopMerge %57 %59 None
OpBranch %58
%58 = OpLabel
%60 = OpLoad %4 %53
%61 = OpIAdd %4 %60 %51
OpStore %53 %61
OpBranch %59
%59 = OpLabel
%62 = OpLoad %4 %53
%63 = OpIEqual %3 %62 %52
OpBranchConditional %63 %57 %56
%57 = OpLabel
%49 = OpLoad %14 %47
%50 = OpIEqual %16 %21 %49
%51 = OpAll %3 %50
OpSelectionMerge %52 None
OpBranchConditional %51 %44 %52
%52 = OpLabel
%53 = OpCompositeExtract %4 %49 1
%54 = OpIEqual %3 %53 %20
%55 = OpSelect %4 %54 %19 %17
%56 = OpCompositeConstruct %14 %55 %19
%57 = OpIAdd %14 %49 %56
OpStore %47 %57
OpBranch %45
%45 = OpLabel
OpBranch %46
%46 = OpLabel
OpStore %37 %34
%58 = OpLoad %3 %37
%59 = OpLogicalNotEqual %3 %34 %58
OpStore %40 %59
%60 = OpLoad %3 %40
%61 = OpLogicalEqual %3 %34 %60
OpBranchConditional %61 %44 %43
%44 = OpLabel
OpReturn
OpFunctionEnd
%65 = OpFunction %2 None %7
%64 = OpLabel
OpBranch %66
%66 = OpLabel
%64 = OpFunction %2 None %36
%63 = OpFunctionParameter %3
%62 = OpLabel
%65 = OpVariable %38 Function %66
%67 = OpVariable %38 Function %68
%74 = OpVariable %15 Function %18
OpBranch %69
%69 = OpLabel
OpBranch %70
%70 = OpLabel
OpLoopMerge %71 %73 None
OpBranch %75
%75 = OpLabel
%76 = OpLoad %14 %74
%77 = OpIEqual %16 %21 %76
%78 = OpAll %3 %77
OpSelectionMerge %79 None
OpBranchConditional %78 %71 %79
%79 = OpLabel
%80 = OpCompositeExtract %4 %76 1
%81 = OpIEqual %3 %80 %20
%82 = OpSelect %4 %81 %19 %17
%83 = OpCompositeConstruct %14 %82 %19
%84 = OpIAdd %14 %76 %83
OpStore %74 %84
OpBranch %72
%72 = OpLabel
OpStore %65 %63
%85 = OpLoad %3 %65
%86 = OpLogicalNotEqual %3 %63 %85
OpStore %67 %86
OpBranch %73
%73 = OpLabel
%87 = OpLoad %3 %67
%88 = OpLogicalEqual %3 %63 %87
OpBranchConditional %88 %71 %70
%71 = OpLabel
OpReturn
OpFunctionEnd
%90 = OpFunction %2 None %7
%89 = OpLabel
%92 = OpVariable %93 Function %17
%99 = OpVariable %15 Function %18
OpBranch %94
%94 = OpLabel
OpBranch %95
%95 = OpLabel
OpLoopMerge %96 %98 None
OpBranch %100
%100 = OpLabel
%101 = OpLoad %14 %99
%102 = OpIEqual %16 %21 %101
%103 = OpAll %3 %102
OpSelectionMerge %104 None
OpBranchConditional %103 %96 %104
%104 = OpLabel
%105 = OpCompositeExtract %4 %101 1
%106 = OpIEqual %3 %105 %20
%107 = OpSelect %4 %106 %19 %17
%108 = OpCompositeConstruct %14 %107 %19
%109 = OpIAdd %14 %101 %108
OpStore %99 %109
OpBranch %97
%97 = OpLabel
%110 = OpLoad %4 %92
%111 = OpIAdd %4 %110 %19
OpStore %92 %111
OpBranch %98
%98 = OpLabel
%112 = OpLoad %4 %92
%113 = OpIEqual %3 %112 %91
OpBranchConditional %113 %96 %95
%96 = OpLabel
OpReturn
OpFunctionEnd
%115 = OpFunction %2 None %7
%114 = OpLabel
OpBranch %116
%116 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -1,13 +1,13 @@
; SPIR-V
; Version: 1.0
; Generator: rspirv
; Bound: 78
; Bound: 95
OpCapability Shader
OpExtension "SPV_KHR_storage_buffer_storage_class"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %67 "main" %64
OpExecutionMode %67 LocalSize 1 1 1
OpEntryPoint GLCompute %84 "main" %81
OpExecutionMode %84 LocalSize 1 1 1
%3 = OpString "collatz.wgsl"
OpSource Unknown 0 %3 "struct PrimeIndices {
data: array<u32>
@@ -55,14 +55,15 @@ OpName %29 "n_base"
OpName %30 "collatz_iterations"
OpName %34 "n"
OpName %37 "i"
OpName %64 "global_id"
OpName %67 "main"
OpName %49 "loop_bound"
OpName %81 "global_id"
OpName %84 "main"
OpDecorate %5 ArrayStride 4
OpMemberDecorate %6 0 Offset 0
OpDecorate %6 Block
OpDecorate %8 DescriptorSet 0
OpDecorate %8 Binding 0
OpDecorate %64 BuiltIn GlobalInvocationId
OpDecorate %81 BuiltIn GlobalInvocationId
%2 = OpTypeVoid
%4 = OpTypeInt 32 0
%5 = OpTypeRuntimeArray %4
@@ -79,11 +80,17 @@ OpDecorate %64 BuiltIn GlobalInvocationId
%33 = OpConstant %4 3
%35 = OpTypePointer Function %4
%36 = OpConstantNull %4
%65 = OpTypePointer Input %7
%64 = OpVariable %65 Input
%68 = OpTypeFunction %2
%70 = OpTypePointer StorageBuffer %5
%72 = OpTypePointer StorageBuffer %4
%43 = OpTypeVector %4 2
%44 = OpTypePointer Function %43
%45 = OpTypeVector %15 2
%46 = OpConstantComposite %43 %16 %16
%47 = OpConstant %4 4294967295
%48 = OpConstantComposite %43 %47 %47
%82 = OpTypePointer Input %7
%81 = OpVariable %82 Input
%85 = OpTypeFunction %2
%87 = OpTypePointer StorageBuffer %5
%89 = OpTypePointer StorageBuffer %4
%10 = OpFunction %4 None %11
%12 = OpFunctionParameter %4
%13 = OpFunctionParameter %4
@@ -107,6 +114,7 @@ OpFunctionEnd
%28 = OpLabel
%34 = OpVariable %35 Function %36
%37 = OpVariable %35 Function %16
%49 = OpVariable %44 Function %46
OpBranch %38
%38 = OpLabel
OpLine %3 15 5
@@ -115,78 +123,92 @@ OpBranch %39
%39 = OpLabel
OpLine %3 17 5
OpLoopMerge %40 %42 None
OpBranch %50
%50 = OpLabel
%51 = OpLoad %43 %49
%52 = OpIEqual %45 %48 %51
%53 = OpAll %15 %52
OpSelectionMerge %54 None
OpBranchConditional %53 %40 %54
%54 = OpLabel
%55 = OpCompositeExtract %4 %51 1
%56 = OpIEqual %15 %55 %47
%57 = OpSelect %4 %56 %18 %16
%58 = OpCompositeConstruct %43 %57 %18
%59 = OpIAdd %43 %51 %58
OpStore %49 %59
OpBranch %41
%41 = OpLabel
OpLine %3 1 1
%43 = OpLoad %4 %34
%60 = OpLoad %4 %34
OpLine %3 17 11
%44 = OpUGreaterThan %15 %43 %18
%61 = OpUGreaterThan %15 %60 %18
OpLine %3 17 10
OpSelectionMerge %45 None
OpBranchConditional %44 %45 %46
%46 = OpLabel
OpSelectionMerge %62 None
OpBranchConditional %61 %62 %63
%63 = OpLabel
OpBranch %40
%45 = OpLabel
OpBranch %47
%47 = OpLabel
%62 = OpLabel
OpBranch %64
%64 = OpLabel
OpLine %3 1 1
%49 = OpLoad %4 %34
%66 = OpLoad %4 %34
OpLine %3 18 12
%50 = OpFunctionCall %4 %10 %49 %32
%67 = OpFunctionCall %4 %10 %66 %32
OpLine %3 18 12
%51 = OpIEqual %15 %50 %16
%68 = OpIEqual %15 %67 %16
OpLine %3 18 9
OpSelectionMerge %52 None
OpBranchConditional %51 %53 %54
%53 = OpLabel
OpSelectionMerge %69 None
OpBranchConditional %68 %70 %71
%70 = OpLabel
OpLine %3 1 1
%55 = OpLoad %4 %34
%72 = OpLoad %4 %34
OpLine %3 19 17
%56 = OpFunctionCall %4 %21 %55 %32
%73 = OpFunctionCall %4 %21 %72 %32
OpLine %3 19 13
OpStore %34 %56
OpBranch %52
%54 = OpLabel
OpStore %34 %73
OpBranch %69
%71 = OpLabel
OpLine %3 22 17
%57 = OpLoad %4 %34
%58 = OpIMul %4 %33 %57
%74 = OpLoad %4 %34
%75 = OpIMul %4 %33 %74
OpLine %3 22 17
%59 = OpIAdd %4 %58 %18
%76 = OpIAdd %4 %75 %18
OpLine %3 22 13
OpStore %34 %59
OpBranch %52
%52 = OpLabel
OpStore %34 %76
OpBranch %69
%69 = OpLabel
OpLine %3 1 1
%60 = OpLoad %4 %37
%77 = OpLoad %4 %37
OpLine %3 24 13
%61 = OpIAdd %4 %60 %18
%78 = OpIAdd %4 %77 %18
OpLine %3 24 9
OpStore %37 %61
OpBranch %48
%48 = OpLabel
OpStore %37 %78
OpBranch %65
%65 = OpLabel
OpBranch %42
%42 = OpLabel
OpBranch %39
%40 = OpLabel
OpLine %3 1 1
%62 = OpLoad %4 %37
OpReturnValue %62
%79 = OpLoad %4 %37
OpReturnValue %79
OpFunctionEnd
%67 = OpFunction %2 None %68
%63 = OpLabel
%66 = OpLoad %7 %64
OpBranch %69
%69 = OpLabel
%84 = OpFunction %2 None %85
%80 = OpLabel
%83 = OpLoad %7 %81
OpBranch %86
%86 = OpLabel
OpLine %3 31 5
%71 = OpCompositeExtract %4 %66 0
%88 = OpCompositeExtract %4 %83 0
OpLine %3 31 54
%73 = OpCompositeExtract %4 %66 0
%74 = OpAccessChain %72 %8 %16 %73
%75 = OpLoad %4 %74
%90 = OpCompositeExtract %4 %83 0
%91 = OpAccessChain %89 %8 %16 %90
%92 = OpLoad %4 %91
OpLine %3 31 35
%76 = OpFunctionCall %4 %30 %75
%93 = OpFunctionCall %4 %30 %92
OpLine %3 31 5
%77 = OpAccessChain %72 %8 %16 %71
OpStore %77 %76
%94 = OpAccessChain %89 %8 %16 %88
OpStore %94 %93
OpReturn
OpFunctionEnd

View File

@@ -1,13 +1,13 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 134
; Bound: 207
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %104 "main" %101
OpExecutionMode %104 LocalSize 1 1 1
OpDecorate %101 BuiltIn GlobalInvocationId
OpEntryPoint GLCompute %179 "main" %176
OpExecutionMode %179 LocalSize 1 1 1
OpDecorate %176 BuiltIn GlobalInvocationId
%2 = OpTypeVoid
%4 = OpTypeInt 32 0
%3 = OpTypeVector %4 3
@@ -15,21 +15,28 @@ OpDecorate %101 BuiltIn GlobalInvocationId
%9 = OpTypeFunction %2 %5
%15 = OpTypeFunction %2
%16 = OpConstant %5 0
%37 = OpTypeFunction %2 %5 %5 %5
%73 = OpTypeFunction %2 %5 %5 %5 %5
%74 = OpConstant %5 1
%75 = OpConstant %5 2
%77 = OpTypePointer Function %5
%102 = OpTypePointer Input %3
%101 = OpVariable %102 Input
%105 = OpConstant %5 3
%106 = OpConstant %5 4
%107 = OpConstant %4 0
%109 = OpConstantNull %5
%111 = OpConstant %4 2
%112 = OpConstant %4 1
%113 = OpConstant %4 72
%114 = OpConstant %4 264
%29 = OpTypeVector %4 2
%30 = OpTypePointer Function %29
%31 = OpTypeBool
%32 = OpTypeVector %31 2
%33 = OpConstant %4 0
%34 = OpConstantComposite %29 %33 %33
%35 = OpConstant %4 1
%36 = OpConstant %4 4294967295
%37 = OpConstantComposite %29 %36 %36
%57 = OpTypeFunction %2 %5 %5 %5
%126 = OpTypeFunction %2 %5 %5 %5 %5
%127 = OpConstant %5 1
%128 = OpConstant %5 2
%130 = OpTypePointer Function %5
%177 = OpTypePointer Input %3
%176 = OpVariable %177 Input
%180 = OpConstant %5 3
%181 = OpConstant %5 4
%183 = OpConstantNull %5
%185 = OpConstant %4 2
%186 = OpConstant %4 72
%187 = OpConstant %4 264
%8 = OpFunction %2 None %9
%7 = OpFunctionParameter %5
%6 = OpLabel
@@ -58,218 +65,308 @@ OpFunctionEnd
%23 = OpFunction %2 None %9
%22 = OpFunctionParameter %5
%21 = OpLabel
%38 = OpVariable %30 Function %34
OpBranch %24
%24 = OpLabel
OpBranch %25
%25 = OpLabel
OpLoopMerge %26 %28 None
OpBranch %39
%39 = OpLabel
%40 = OpLoad %29 %38
%41 = OpIEqual %32 %37 %40
%42 = OpAll %31 %41
OpSelectionMerge %43 None
OpBranchConditional %42 %26 %43
%43 = OpLabel
%44 = OpCompositeExtract %4 %40 1
%45 = OpIEqual %31 %44 %36
%46 = OpSelect %4 %45 %35 %33
%47 = OpCompositeConstruct %29 %46 %35
%48 = OpIAdd %29 %40 %47
OpStore %38 %48
OpBranch %27
%27 = OpLabel
OpSelectionMerge %29 None
OpSwitch %22 %31 1 %30
%30 = OpLabel
OpSelectionMerge %49 None
OpSwitch %22 %51 1 %50
%50 = OpLabel
OpBranch %28
%31 = OpLabel
OpBranch %29
%29 = OpLabel
%51 = OpLabel
OpBranch %49
%49 = OpLabel
OpBranch %28
%28 = OpLabel
OpBranch %25
%26 = OpLabel
OpReturn
OpFunctionEnd
%36 = OpFunction %2 None %37
%33 = OpFunctionParameter %5
%34 = OpFunctionParameter %5
%35 = OpFunctionParameter %5
%32 = OpLabel
OpBranch %38
%38 = OpLabel
OpBranch %39
%39 = OpLabel
OpLoopMerge %40 %42 None
OpBranch %41
%41 = OpLabel
OpSelectionMerge %43 None
OpSwitch %33 %46 1 %44 2 %45
%44 = OpLabel
OpBranch %42
%45 = OpLabel
OpSelectionMerge %47 None
OpSwitch %34 %49 1 %48
%48 = OpLabel
OpBranch %42
%49 = OpLabel
OpBranch %50
%50 = OpLabel
OpLoopMerge %51 %53 None
OpBranch %52
%56 = OpFunction %2 None %57
%53 = OpFunctionParameter %5
%54 = OpFunctionParameter %5
%55 = OpFunctionParameter %5
%52 = OpLabel
OpSelectionMerge %54 None
OpSwitch %35 %56 1 %55
%55 = OpLabel
OpBranch %53
%56 = OpLabel
OpBranch %54
%54 = OpLabel
OpBranch %53
%53 = OpLabel
OpBranch %50
%51 = OpLabel
OpBranch %47
%47 = OpLabel
OpBranch %43
%46 = OpLabel
OpBranch %43
%43 = OpLabel
OpSelectionMerge %57 None
OpSwitch %34 %58
%63 = OpVariable %30 Function %34
%85 = OpVariable %30 Function %34
%105 = OpVariable %30 Function %34
OpBranch %58
%58 = OpLabel
OpBranch %42
%57 = OpLabel
OpBranch %42
%42 = OpLabel
OpBranch %39
%40 = OpLabel
OpBranch %59
%59 = OpLabel
OpLoopMerge %60 %62 None
OpBranch %64
%64 = OpLabel
%65 = OpLoad %29 %63
%66 = OpIEqual %32 %37 %65
%67 = OpAll %31 %66
OpSelectionMerge %68 None
OpBranchConditional %67 %60 %68
%68 = OpLabel
%69 = OpCompositeExtract %4 %65 1
%70 = OpIEqual %31 %69 %36
%71 = OpSelect %4 %70 %35 %33
%72 = OpCompositeConstruct %29 %71 %35
%73 = OpIAdd %29 %65 %72
OpStore %63 %73
OpBranch %61
%61 = OpLabel
OpSelectionMerge %63 None
OpSwitch %34 %64 1 %64
%64 = OpLabel
OpSelectionMerge %65 None
OpSwitch %35 %66
%66 = OpLabel
OpSelectionMerge %74 None
OpSwitch %53 %77 1 %75 2 %76
%75 = OpLabel
OpBranch %62
%65 = OpLabel
OpBranch %63
%63 = OpLabel
%76 = OpLabel
OpSelectionMerge %78 None
OpSwitch %54 %80 1 %79
%79 = OpLabel
OpBranch %62
%80 = OpLabel
OpBranch %81
%81 = OpLabel
OpLoopMerge %82 %84 None
OpBranch %86
%86 = OpLabel
%87 = OpLoad %29 %85
%88 = OpIEqual %32 %37 %87
%89 = OpAll %31 %88
OpSelectionMerge %90 None
OpBranchConditional %89 %82 %90
%90 = OpLabel
%91 = OpCompositeExtract %4 %87 1
%92 = OpIEqual %31 %91 %36
%93 = OpSelect %4 %92 %35 %33
%94 = OpCompositeConstruct %29 %93 %35
%95 = OpIAdd %29 %87 %94
OpStore %85 %95
OpBranch %83
%83 = OpLabel
OpSelectionMerge %96 None
OpSwitch %55 %98 1 %97
%97 = OpLabel
OpBranch %84
%98 = OpLabel
OpBranch %96
%96 = OpLabel
OpBranch %84
%84 = OpLabel
OpBranch %81
%82 = OpLabel
OpBranch %78
%78 = OpLabel
OpBranch %74
%77 = OpLabel
OpBranch %74
%74 = OpLabel
OpSelectionMerge %99 None
OpSwitch %54 %100
%100 = OpLabel
OpBranch %62
%99 = OpLabel
OpBranch %62
%62 = OpLabel
OpBranch %59
%60 = OpLabel
OpReturn
OpFunctionEnd
%72 = OpFunction %2 None %73
%68 = OpFunctionParameter %5
%69 = OpFunctionParameter %5
%70 = OpFunctionParameter %5
%71 = OpFunctionParameter %5
%67 = OpLabel
%76 = OpVariable %77 Function %16
OpBranch %78
%78 = OpLabel
OpBranch %79
%79 = OpLabel
OpLoopMerge %80 %82 None
OpBranch %81
%81 = OpLabel
OpSelectionMerge %83 None
OpSwitch %68 %85 1 %84
%84 = OpLabel
OpStore %76 %74
OpBranch %83
%85 = OpLabel
OpBranch %83
%83 = OpLabel
OpBranch %82
%82 = OpLabel
OpBranch %79
%80 = OpLabel
OpBranch %86
%86 = OpLabel
OpLoopMerge %87 %89 None
OpBranch %88
%88 = OpLabel
OpSelectionMerge %90 None
OpSwitch %68 %93 1 %91 2 %92
%91 = OpLabel
OpBranch %90
%92 = OpLabel
OpSelectionMerge %94 None
OpSwitch %69 %96 1 %95
%95 = OpLabel
OpBranch %89
%96 = OpLabel
OpSelectionMerge %97 None
OpSwitch %70 %99 1 %98
%98 = OpLabel
OpStore %76 %75
OpBranch %97
%99 = OpLabel
OpBranch %97
%97 = OpLabel
OpBranch %94
%94 = OpLabel
OpBranch %90
%93 = OpLabel
OpBranch %90
%90 = OpLabel
OpBranch %89
%89 = OpLabel
OpBranch %86
%87 = OpLabel
OpReturn
OpFunctionEnd
%104 = OpFunction %2 None %15
%100 = OpLabel
%108 = OpVariable %77 Function %109
%103 = OpLoad %3 %101
OpBranch %110
OpBranch %101
%101 = OpLabel
OpLoopMerge %102 %104 None
OpBranch %106
%106 = OpLabel
%107 = OpLoad %29 %105
%108 = OpIEqual %32 %37 %107
%109 = OpAll %31 %108
OpSelectionMerge %110 None
OpBranchConditional %109 %102 %110
%110 = OpLabel
OpControlBarrier %111 %112 %113
OpControlBarrier %111 %111 %114
OpSelectionMerge %115 None
OpSwitch %74 %116
%116 = OpLabel
OpStore %108 %74
OpBranch %115
%115 = OpLabel
%117 = OpLoad %5 %108
%111 = OpCompositeExtract %4 %107 1
%112 = OpIEqual %31 %111 %36
%113 = OpSelect %4 %112 %35 %33
%114 = OpCompositeConstruct %29 %113 %35
%115 = OpIAdd %29 %107 %114
OpStore %105 %115
OpBranch %103
%103 = OpLabel
OpSelectionMerge %116 None
OpSwitch %54 %117 1 %117
%117 = OpLabel
OpSelectionMerge %118 None
OpSwitch %117 %123 1 %119 2 %120 3 %121 4 %121 5 %122 6 %123
OpSwitch %55 %119
%119 = OpLabel
OpStore %108 %16
OpBranch %118
%120 = OpLabel
OpStore %108 %74
OpBranch %118
%121 = OpLabel
OpStore %108 %75
OpBranch %118
%122 = OpLabel
OpStore %108 %105
OpBranch %118
%123 = OpLabel
OpStore %108 %106
OpBranch %118
OpBranch %104
%118 = OpLabel
OpSelectionMerge %124 None
OpSwitch %107 %126 0 %125
%125 = OpLabel
OpBranch %124
%126 = OpLabel
OpBranch %124
%124 = OpLabel
%127 = OpLoad %5 %108
OpSelectionMerge %128 None
OpSwitch %127 %133 1 %129 2 %130 3 %131 4 %132
%129 = OpLabel
OpStore %108 %16
OpBranch %128
%130 = OpLabel
OpStore %108 %74
OpBranch %116
%116 = OpLabel
OpBranch %104
%104 = OpLabel
OpBranch %101
%102 = OpLabel
OpReturn
OpFunctionEnd
%125 = OpFunction %2 None %126
%121 = OpFunctionParameter %5
%122 = OpFunctionParameter %5
%123 = OpFunctionParameter %5
%124 = OpFunctionParameter %5
%120 = OpLabel
%129 = OpVariable %130 Function %16
%136 = OpVariable %30 Function %34
%154 = OpVariable %30 Function %34
OpBranch %131
%131 = OpLabel
OpStore %108 %75
OpReturn
OpBranch %132
%132 = OpLabel
OpReturn
OpLoopMerge %133 %135 None
OpBranch %137
%137 = OpLabel
%138 = OpLoad %29 %136
%139 = OpIEqual %32 %37 %138
%140 = OpAll %31 %139
OpSelectionMerge %141 None
OpBranchConditional %140 %133 %141
%141 = OpLabel
%142 = OpCompositeExtract %4 %138 1
%143 = OpIEqual %31 %142 %36
%144 = OpSelect %4 %143 %35 %33
%145 = OpCompositeConstruct %29 %144 %35
%146 = OpIAdd %29 %138 %145
OpStore %136 %146
OpBranch %134
%134 = OpLabel
OpSelectionMerge %147 None
OpSwitch %121 %149 1 %148
%148 = OpLabel
OpStore %129 %127
OpBranch %147
%149 = OpLabel
OpBranch %147
%147 = OpLabel
OpBranch %135
%135 = OpLabel
OpBranch %132
%133 = OpLabel
OpStore %108 %105
OpBranch %150
%150 = OpLabel
OpLoopMerge %151 %153 None
OpBranch %155
%155 = OpLabel
%156 = OpLoad %29 %154
%157 = OpIEqual %32 %37 %156
%158 = OpAll %31 %157
OpSelectionMerge %159 None
OpBranchConditional %158 %151 %159
%159 = OpLabel
%160 = OpCompositeExtract %4 %156 1
%161 = OpIEqual %31 %160 %36
%162 = OpSelect %4 %161 %35 %33
%163 = OpCompositeConstruct %29 %162 %35
%164 = OpIAdd %29 %156 %163
OpStore %154 %164
OpBranch %152
%152 = OpLabel
OpSelectionMerge %165 None
OpSwitch %121 %168 1 %166 2 %167
%166 = OpLabel
OpBranch %165
%167 = OpLabel
OpSelectionMerge %169 None
OpSwitch %122 %171 1 %170
%170 = OpLabel
OpBranch %153
%171 = OpLabel
OpSelectionMerge %172 None
OpSwitch %123 %174 1 %173
%173 = OpLabel
OpStore %129 %128
OpBranch %172
%174 = OpLabel
OpBranch %172
%172 = OpLabel
OpBranch %169
%169 = OpLabel
OpBranch %165
%168 = OpLabel
OpBranch %165
%165 = OpLabel
OpBranch %153
%153 = OpLabel
OpBranch %150
%151 = OpLabel
OpReturn
%128 = OpLabel
OpFunctionEnd
%179 = OpFunction %2 None %15
%175 = OpLabel
%182 = OpVariable %130 Function %183
%178 = OpLoad %3 %176
OpBranch %184
%184 = OpLabel
OpControlBarrier %185 %35 %186
OpControlBarrier %185 %185 %187
OpSelectionMerge %188 None
OpSwitch %127 %189
%189 = OpLabel
OpStore %182 %127
OpBranch %188
%188 = OpLabel
%190 = OpLoad %5 %182
OpSelectionMerge %191 None
OpSwitch %190 %196 1 %192 2 %193 3 %194 4 %194 5 %195 6 %196
%192 = OpLabel
OpStore %182 %16
OpBranch %191
%193 = OpLabel
OpStore %182 %127
OpBranch %191
%194 = OpLabel
OpStore %182 %128
OpBranch %191
%195 = OpLabel
OpStore %182 %180
OpBranch %191
%196 = OpLabel
OpStore %182 %181
OpBranch %191
%191 = OpLabel
OpSelectionMerge %197 None
OpSwitch %33 %199 0 %198
%198 = OpLabel
OpBranch %197
%199 = OpLabel
OpBranch %197
%197 = OpLabel
%200 = OpLoad %5 %182
OpSelectionMerge %201 None
OpSwitch %200 %206 1 %202 2 %203 3 %204 4 %205
%202 = OpLabel
OpStore %182 %16
OpBranch %201
%203 = OpLabel
OpStore %182 %127
OpReturn
%204 = OpLabel
OpStore %182 %128
OpReturn
%205 = OpLabel
OpReturn
%206 = OpLabel
OpStore %182 %180
OpReturn
%201 = OpLabel
OpReturn
OpFunctionEnd

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 94
; Bound: 111
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@@ -60,6 +60,7 @@ OpName %49 "fs_main"
OpName %55 "color"
OpName %57 "i"
OpName %59 "ii"
OpName %75 "loop_bound"
OpMemberDecorate %6 0 Offset 0
OpMemberDecorate %6 1 Offset 16
OpMemberDecorate %8 0 Offset 0
@@ -107,8 +108,14 @@ OpDecorate %48 Location 0
%58 = OpTypePointer Function %9
%60 = OpTypePointer Function %4
%61 = OpConstantNull %4
%69 = OpTypeBool
%77 = OpTypePointer Function %4
%68 = OpTypeVector %31 2
%69 = OpTypePointer Function %68
%70 = OpTypeBool
%71 = OpTypeVector %70 2
%72 = OpConstantComposite %68 %36 %36
%73 = OpConstant %31 4294967295
%74 = OpConstantComposite %68 %73 %73
%94 = OpTypePointer Function %4
%21 = OpFunction %2 None %22
%10 = OpLabel
%24 = OpVariable %25 Function %26
@@ -142,6 +149,7 @@ OpFunctionEnd
%55 = OpVariable %28 Function %56
%57 = OpVariable %58 Function %50
%59 = OpVariable %60 Function %61
%75 = OpVariable %69 Function %72
%45 = OpLoad %7 %43
%47 = OpLoad %5 %46
%42 = OpCompositeConstruct %8 %45 %47
@@ -155,60 +163,74 @@ OpBranch %64
%64 = OpLabel
OpLine %3 26 5
OpLoopMerge %65 %67 None
OpBranch %76
%76 = OpLabel
%77 = OpLoad %68 %75
%78 = OpIEqual %71 %74 %77
%79 = OpAll %70 %78
OpSelectionMerge %80 None
OpBranchConditional %79 %65 %80
%80 = OpLabel
%81 = OpCompositeExtract %31 %77 1
%82 = OpIEqual %70 %81 %73
%83 = OpSelect %31 %82 %30 %36
%84 = OpCompositeConstruct %68 %83 %30
%85 = OpIAdd %68 %77 %84
OpStore %75 %85
OpBranch %66
%66 = OpLabel
OpLine %3 1 1
%68 = OpLoad %9 %57
%86 = OpLoad %9 %57
OpLine %3 26 21
%70 = OpSLessThan %69 %68 %51
%87 = OpSLessThan %70 %86 %51
OpLine %3 26 20
OpSelectionMerge %71 None
OpBranchConditional %70 %71 %72
%72 = OpLabel
OpSelectionMerge %88 None
OpBranchConditional %87 %88 %89
%89 = OpLabel
OpBranch %65
%71 = OpLabel
OpBranch %73
%73 = OpLabel
%88 = OpLabel
OpBranch %90
%90 = OpLabel
OpLine %3 27 18
%75 = OpLoad %9 %57
%76 = OpConvertSToF %4 %75
%92 = OpLoad %9 %57
%93 = OpConvertSToF %4 %92
OpLine %3 27 9
OpStore %59 %76
OpStore %59 %93
OpLine %3 28 9
%78 = OpLoad %4 %59
%95 = OpLoad %4 %59
OpLine %3 28 9
%79 = OpFMul %4 %78 %52
%80 = OpAccessChain %77 %55 %36
%81 = OpLoad %4 %80
%82 = OpFAdd %4 %81 %79
%96 = OpFMul %4 %95 %52
%97 = OpAccessChain %94 %55 %36
%98 = OpLoad %4 %97
%99 = OpFAdd %4 %98 %96
OpLine %3 28 9
%83 = OpAccessChain %77 %55 %36
OpStore %83 %82
%100 = OpAccessChain %94 %55 %36
OpStore %100 %99
OpLine %3 29 9
%84 = OpLoad %4 %59
%101 = OpLoad %4 %59
OpLine %3 29 9
%85 = OpFMul %4 %84 %53
%86 = OpAccessChain %77 %55 %30
%87 = OpLoad %4 %86
%88 = OpFAdd %4 %87 %85
%102 = OpFMul %4 %101 %53
%103 = OpAccessChain %94 %55 %30
%104 = OpLoad %4 %103
%105 = OpFAdd %4 %104 %102
OpLine %3 29 9
%89 = OpAccessChain %77 %55 %30
OpStore %89 %88
OpBranch %74
%74 = OpLabel
%106 = OpAccessChain %94 %55 %30
OpStore %106 %105
OpBranch %91
%91 = OpLabel
OpBranch %67
%67 = OpLabel
OpLine %3 26 29
%90 = OpLoad %9 %57
%91 = OpIAdd %9 %90 %54
%107 = OpLoad %9 %57
%108 = OpIAdd %9 %107 %54
OpLine %3 26 29
OpStore %57 %91
OpStore %57 %108
OpBranch %64
%65 = OpLabel
OpLine %3 1 1
%92 = OpLoad %5 %55
%109 = OpLoad %5 %55
OpLine %3 32 12
%93 = OpCompositeConstruct %7 %92 %23
OpStore %48 %93
%110 = OpCompositeConstruct %7 %109 %23
OpStore %48 %110
OpReturn
OpFunctionEnd

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.4
; Generator: rspirv
; Bound: 46
; Bound: 65
OpCapability Shader
OpCapability RayQueryKHR
OpExtension "SPV_KHR_ray_query"
@@ -40,10 +40,19 @@ OpDecorate %10 Binding 0
%25 = OpConstantComposite %7 %22 %23 %24
%26 = OpConstantComposite %8 %16 %17 %18 %19 %21 %25
%28 = OpTypePointer Function %5
%41 = OpTypeBool
%40 = OpTypeVector %6 2
%41 = OpTypePointer Function %40
%42 = OpTypeBool
%43 = OpTypeVector %42 2
%44 = OpConstant %6 0
%45 = OpConstantComposite %40 %44 %44
%46 = OpConstant %6 1
%47 = OpConstant %6 4294967295
%48 = OpConstantComposite %40 %47 %47
%13 = OpFunction %2 None %14
%12 = OpLabel
%27 = OpVariable %28 Function
%49 = OpVariable %41 Function %45
%15 = OpLoad %4 %10
OpBranch %29
%29 = OpLabel
@@ -57,18 +66,32 @@ OpRayQueryInitializeKHR %27 %15 %30 %31 %34 %32 %35 %33
OpBranch %36
%36 = OpLabel
OpLoopMerge %37 %39 None
OpBranch %50
%50 = OpLabel
%51 = OpLoad %40 %49
%52 = OpIEqual %43 %48 %51
%53 = OpAll %42 %52
OpSelectionMerge %54 None
OpBranchConditional %53 %37 %54
%54 = OpLabel
%55 = OpCompositeExtract %6 %51 1
%56 = OpIEqual %42 %55 %47
%57 = OpSelect %6 %56 %46 %44
%58 = OpCompositeConstruct %40 %57 %46
%59 = OpIAdd %40 %51 %58
OpStore %49 %59
OpBranch %38
%38 = OpLabel
%40 = OpRayQueryProceedKHR %41 %27
OpSelectionMerge %42 None
OpBranchConditional %40 %42 %43
%43 = OpLabel
%60 = OpRayQueryProceedKHR %42 %27
OpSelectionMerge %61 None
OpBranchConditional %60 %61 %62
%62 = OpLabel
OpBranch %37
%42 = OpLabel
OpBranch %44
%44 = OpLabel
OpBranch %45
%45 = OpLabel
%61 = OpLabel
OpBranch %63
%63 = OpLabel
OpBranch %64
%64 = OpLabel
OpBranch %39
%39 = OpLabel
OpBranch %36

View File

@@ -1,16 +1,16 @@
; SPIR-V
; Version: 1.4
; Generator: rspirv
; Bound: 166
; Bound: 183
OpCapability Shader
OpCapability RayQueryKHR
OpExtension "SPV_KHR_ray_query"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %123 "main" %15 %17
OpEntryPoint GLCompute %143 "main_candidate" %15
OpExecutionMode %123 LocalSize 1 1 1
OpExecutionMode %143 LocalSize 1 1 1
OpEntryPoint GLCompute %140 "main" %15 %17
OpEntryPoint GLCompute %160 "main_candidate" %15
OpExecutionMode %140 LocalSize 1 1 1
OpExecutionMode %160 LocalSize 1 1 1
OpMemberDecorate %10 0 Offset 0
OpMemberDecorate %10 1 Offset 4
OpMemberDecorate %10 2 Offset 8
@@ -64,87 +64,93 @@ OpMemberDecorate %18 0 Offset 0
%29 = OpConstant %3 0.1
%30 = OpConstant %3 100.0
%32 = OpTypePointer Function %11
%50 = OpTypePointer Function %10
%51 = OpTypePointer Function %6
%52 = OpTypePointer Function %9
%53 = OpTypePointer Function %7
%54 = OpTypePointer Function %8
%55 = OpTypePointer Function %3
%56 = OpTypeFunction %10 %32
%58 = OpConstantNull %10
%62 = OpConstant %6 1
%64 = OpConstant %6 0
%76 = OpConstant %6 2
%78 = OpConstant %6 3
%81 = OpConstant %6 5
%83 = OpConstant %6 6
%85 = OpConstant %6 9
%87 = OpConstant %6 10
%96 = OpConstant %6 7
%98 = OpConstant %6 8
%106 = OpTypeFunction %4 %4 %10
%107 = OpConstant %3 1.0
%108 = OpConstant %3 2.4
%109 = OpConstant %3 0.0
%124 = OpTypeFunction %2
%126 = OpTypePointer StorageBuffer %13
%128 = OpConstantComposite %4 %109 %109 %109
%129 = OpConstantComposite %4 %109 %107 %109
%132 = OpTypePointer StorageBuffer %6
%137 = OpTypePointer StorageBuffer %4
%145 = OpConstantComposite %12 %27 %28 %29 %30 %128 %129
%146 = OpConstant %3 10.0
%57 = OpFunction %10 None %56
%59 = OpFunctionParameter %32
%60 = OpLabel
%61 = OpVariable %50 Function %58
%63 = OpRayQueryGetIntersectionTypeKHR %6 %59 %62
%65 = OpAccessChain %51 %61 %64
OpStore %65 %63
%66 = OpINotEqual %8 %63 %64
OpSelectionMerge %68 None
OpBranchConditional %66 %67 %68
%67 = OpLabel
%69 = OpRayQueryGetIntersectionInstanceCustomIndexKHR %6 %59 %62
%70 = OpRayQueryGetIntersectionInstanceIdKHR %6 %59 %62
%71 = OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR %6 %59 %62
%72 = OpRayQueryGetIntersectionGeometryIndexKHR %6 %59 %62
%73 = OpRayQueryGetIntersectionPrimitiveIndexKHR %6 %59 %62
%74 = OpRayQueryGetIntersectionObjectToWorldKHR %9 %59 %62
%75 = OpRayQueryGetIntersectionWorldToObjectKHR %9 %59 %62
%77 = OpAccessChain %51 %61 %76
OpStore %77 %69
%79 = OpAccessChain %51 %61 %78
OpStore %79 %70
%80 = OpAccessChain %51 %61 %27
OpStore %80 %71
%82 = OpAccessChain %51 %61 %81
OpStore %82 %72
%84 = OpAccessChain %51 %61 %83
OpStore %84 %73
%86 = OpAccessChain %52 %61 %85
OpStore %86 %74
%88 = OpAccessChain %52 %61 %87
OpStore %88 %75
%89 = OpIEqual %8 %63 %62
%92 = OpRayQueryGetIntersectionTKHR %3 %59 %62
%93 = OpAccessChain %55 %61 %62
OpStore %93 %92
OpSelectionMerge %91 None
OpBranchConditional %66 %90 %91
%90 = OpLabel
%94 = OpRayQueryGetIntersectionBarycentricsKHR %7 %59 %62
%95 = OpRayQueryGetIntersectionFrontFaceKHR %8 %59 %62
%97 = OpAccessChain %53 %61 %96
OpStore %97 %94
%99 = OpAccessChain %54 %61 %98
OpStore %99 %95
OpBranch %91
%91 = OpLabel
OpBranch %68
%68 = OpLabel
%100 = OpLoad %10 %61
OpReturnValue %100
%45 = OpTypeVector %6 2
%46 = OpTypePointer Function %45
%47 = OpTypeVector %8 2
%48 = OpConstant %6 0
%49 = OpConstantComposite %45 %48 %48
%50 = OpConstant %6 1
%51 = OpConstant %6 4294967295
%52 = OpConstantComposite %45 %51 %51
%69 = OpTypePointer Function %10
%70 = OpTypePointer Function %6
%71 = OpTypePointer Function %9
%72 = OpTypePointer Function %7
%73 = OpTypePointer Function %8
%74 = OpTypePointer Function %3
%75 = OpTypeFunction %10 %32
%77 = OpConstantNull %10
%93 = OpConstant %6 2
%95 = OpConstant %6 3
%98 = OpConstant %6 5
%100 = OpConstant %6 6
%102 = OpConstant %6 9
%104 = OpConstant %6 10
%113 = OpConstant %6 7
%115 = OpConstant %6 8
%123 = OpTypeFunction %4 %4 %10
%124 = OpConstant %3 1.0
%125 = OpConstant %3 2.4
%126 = OpConstant %3 0.0
%141 = OpTypeFunction %2
%143 = OpTypePointer StorageBuffer %13
%145 = OpConstantComposite %4 %126 %126 %126
%146 = OpConstantComposite %4 %126 %124 %126
%149 = OpTypePointer StorageBuffer %6
%154 = OpTypePointer StorageBuffer %4
%162 = OpConstantComposite %12 %27 %28 %29 %30 %145 %146
%163 = OpConstant %3 10.0
%76 = OpFunction %10 None %75
%78 = OpFunctionParameter %32
%79 = OpLabel
%80 = OpVariable %69 Function %77
%81 = OpRayQueryGetIntersectionTypeKHR %6 %78 %50
%82 = OpAccessChain %70 %80 %48
OpStore %82 %81
%83 = OpINotEqual %8 %81 %48
OpSelectionMerge %85 None
OpBranchConditional %83 %84 %85
%84 = OpLabel
%86 = OpRayQueryGetIntersectionInstanceCustomIndexKHR %6 %78 %50
%87 = OpRayQueryGetIntersectionInstanceIdKHR %6 %78 %50
%88 = OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR %6 %78 %50
%89 = OpRayQueryGetIntersectionGeometryIndexKHR %6 %78 %50
%90 = OpRayQueryGetIntersectionPrimitiveIndexKHR %6 %78 %50
%91 = OpRayQueryGetIntersectionObjectToWorldKHR %9 %78 %50
%92 = OpRayQueryGetIntersectionWorldToObjectKHR %9 %78 %50
%94 = OpAccessChain %70 %80 %93
OpStore %94 %86
%96 = OpAccessChain %70 %80 %95
OpStore %96 %87
%97 = OpAccessChain %70 %80 %27
OpStore %97 %88
%99 = OpAccessChain %70 %80 %98
OpStore %99 %89
%101 = OpAccessChain %70 %80 %100
OpStore %101 %90
%103 = OpAccessChain %71 %80 %102
OpStore %103 %91
%105 = OpAccessChain %71 %80 %104
OpStore %105 %92
%106 = OpIEqual %8 %81 %50
%109 = OpRayQueryGetIntersectionTKHR %3 %78 %50
%110 = OpAccessChain %74 %80 %50
OpStore %110 %109
OpSelectionMerge %108 None
OpBranchConditional %83 %107 %108
%107 = OpLabel
%111 = OpRayQueryGetIntersectionBarycentricsKHR %7 %78 %50
%112 = OpRayQueryGetIntersectionFrontFaceKHR %8 %78 %50
%114 = OpAccessChain %72 %80 %113
OpStore %114 %111
%116 = OpAccessChain %73 %80 %115
OpStore %116 %112
OpBranch %108
%108 = OpLabel
OpBranch %85
%85 = OpLabel
%117 = OpLoad %10 %80
OpReturnValue %117
OpFunctionEnd
%25 = OpFunction %10 None %26
%21 = OpFunctionParameter %4
@@ -152,6 +158,7 @@ OpFunctionEnd
%23 = OpFunctionParameter %16
%20 = OpLabel
%31 = OpVariable %32 Function
%53 = OpVariable %46 Function %49
%24 = OpLoad %5 %23
OpBranch %33
%33 = OpLabel
@@ -166,96 +173,110 @@ OpRayQueryInitializeKHR %31 %24 %35 %36 %39 %37 %40 %38
OpBranch %41
%41 = OpLabel
OpLoopMerge %42 %44 None
OpBranch %54
%54 = OpLabel
%55 = OpLoad %45 %53
%56 = OpIEqual %47 %52 %55
%57 = OpAll %8 %56
OpSelectionMerge %58 None
OpBranchConditional %57 %42 %58
%58 = OpLabel
%59 = OpCompositeExtract %6 %55 1
%60 = OpIEqual %8 %59 %51
%61 = OpSelect %6 %60 %50 %48
%62 = OpCompositeConstruct %45 %61 %50
%63 = OpIAdd %45 %55 %62
OpStore %53 %63
OpBranch %43
%43 = OpLabel
%45 = OpRayQueryProceedKHR %8 %31
OpSelectionMerge %46 None
OpBranchConditional %45 %46 %47
%47 = OpLabel
%64 = OpRayQueryProceedKHR %8 %31
OpSelectionMerge %65 None
OpBranchConditional %64 %65 %66
%66 = OpLabel
OpBranch %42
%46 = OpLabel
OpBranch %48
%48 = OpLabel
OpBranch %49
%49 = OpLabel
%65 = OpLabel
OpBranch %67
%67 = OpLabel
OpBranch %68
%68 = OpLabel
OpBranch %44
%44 = OpLabel
OpBranch %41
%42 = OpLabel
%101 = OpFunctionCall %10 %57 %31
OpReturnValue %101
%118 = OpFunctionCall %10 %76 %31
OpReturnValue %118
OpFunctionEnd
%105 = OpFunction %4 None %106
%103 = OpFunctionParameter %4
%104 = OpFunctionParameter %10
%102 = OpLabel
OpBranch %110
%110 = OpLabel
%111 = OpCompositeExtract %9 %104 10
%112 = OpCompositeConstruct %14 %103 %107
%113 = OpMatrixTimesVector %4 %111 %112
%114 = OpVectorShuffle %7 %113 %113 0 1
%115 = OpExtInst %7 %1 Normalize %114
%116 = OpVectorTimesScalar %7 %115 %108
%117 = OpCompositeExtract %9 %104 9
%118 = OpCompositeConstruct %14 %116 %109 %107
%119 = OpMatrixTimesVector %4 %117 %118
%120 = OpFSub %4 %103 %119
%121 = OpExtInst %4 %1 Normalize %120
OpReturnValue %121
%122 = OpFunction %4 None %123
%120 = OpFunctionParameter %4
%121 = OpFunctionParameter %10
%119 = OpLabel
OpBranch %127
%127 = OpLabel
%128 = OpCompositeExtract %9 %121 10
%129 = OpCompositeConstruct %14 %120 %124
%130 = OpMatrixTimesVector %4 %128 %129
%131 = OpVectorShuffle %7 %130 %130 0 1
%132 = OpExtInst %7 %1 Normalize %131
%133 = OpVectorTimesScalar %7 %132 %125
%134 = OpCompositeExtract %9 %121 9
%135 = OpCompositeConstruct %14 %133 %126 %124
%136 = OpMatrixTimesVector %4 %134 %135
%137 = OpFSub %4 %120 %136
%138 = OpExtInst %4 %1 Normalize %137
OpReturnValue %138
OpFunctionEnd
%123 = OpFunction %2 None %124
%122 = OpLabel
%125 = OpLoad %5 %15
%127 = OpAccessChain %126 %17 %64
OpBranch %130
%130 = OpLabel
%131 = OpFunctionCall %10 %25 %128 %129 %15
%133 = OpCompositeExtract %6 %131 0
%134 = OpIEqual %8 %133 %64
%135 = OpSelect %6 %134 %62 %64
%136 = OpAccessChain %132 %127 %64
OpStore %136 %135
%138 = OpCompositeExtract %3 %131 1
%139 = OpVectorTimesScalar %4 %129 %138
%140 = OpFunctionCall %4 %105 %139 %131
%141 = OpAccessChain %137 %127 %62
OpStore %141 %140
%140 = OpFunction %2 None %141
%139 = OpLabel
%142 = OpLoad %5 %15
%144 = OpAccessChain %143 %17 %48
OpBranch %147
%147 = OpLabel
%148 = OpFunctionCall %10 %25 %145 %146 %15
%150 = OpCompositeExtract %6 %148 0
%151 = OpIEqual %8 %150 %48
%152 = OpSelect %6 %151 %50 %48
%153 = OpAccessChain %149 %144 %48
OpStore %153 %152
%155 = OpCompositeExtract %3 %148 1
%156 = OpVectorTimesScalar %4 %146 %155
%157 = OpFunctionCall %4 %122 %156 %148
%158 = OpAccessChain %154 %144 %50
OpStore %158 %157
OpReturn
OpFunctionEnd
%143 = OpFunction %2 None %124
%142 = OpLabel
%147 = OpVariable %32 Function
%144 = OpLoad %5 %15
OpBranch %148
%148 = OpLabel
%149 = OpCompositeExtract %6 %145 0
%150 = OpCompositeExtract %6 %145 1
%151 = OpCompositeExtract %3 %145 2
%152 = OpCompositeExtract %3 %145 3
%153 = OpCompositeExtract %4 %145 4
%154 = OpCompositeExtract %4 %145 5
OpRayQueryInitializeKHR %147 %144 %149 %150 %153 %151 %154 %152
%155 = OpFunctionCall %10 %57 %147
%156 = OpCompositeExtract %6 %155 0
%157 = OpIEqual %8 %156 %78
OpSelectionMerge %158 None
OpBranchConditional %157 %159 %160
%160 = OpFunction %2 None %141
%159 = OpLabel
OpRayQueryGenerateIntersectionKHR %147 %146
OpReturn
%160 = OpLabel
%161 = OpCompositeExtract %6 %155 0
%162 = OpIEqual %8 %161 %62
OpSelectionMerge %163 None
OpBranchConditional %162 %164 %165
%164 = OpLabel
OpRayQueryConfirmIntersectionKHR %147
OpReturn
%164 = OpVariable %32 Function
%161 = OpLoad %5 %15
OpBranch %165
%165 = OpLabel
%166 = OpCompositeExtract %6 %162 0
%167 = OpCompositeExtract %6 %162 1
%168 = OpCompositeExtract %3 %162 2
%169 = OpCompositeExtract %3 %162 3
%170 = OpCompositeExtract %4 %162 4
%171 = OpCompositeExtract %4 %162 5
OpRayQueryInitializeKHR %164 %161 %166 %167 %170 %168 %171 %169
%172 = OpFunctionCall %10 %76 %164
%173 = OpCompositeExtract %6 %172 0
%174 = OpIEqual %8 %173 %95
OpSelectionMerge %175 None
OpBranchConditional %174 %176 %177
%176 = OpLabel
OpRayQueryGenerateIntersectionKHR %164 %163
OpReturn
%163 = OpLabel
OpBranch %158
%158 = OpLabel
%177 = OpLabel
%178 = OpCompositeExtract %6 %172 0
%179 = OpIEqual %8 %178 %50
OpSelectionMerge %180 None
OpBranchConditional %179 %181 %182
%181 = OpLabel
OpRayQueryConfirmIntersectionKHR %164
OpReturn
%182 = OpLabel
OpReturn
%180 = OpLabel
OpBranch %175
%175 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -1,16 +1,16 @@
; SPIR-V
; Version: 1.2
; Generator: rspirv
; Bound: 266
; Bound: 294
OpCapability Shader
OpExtension "SPV_KHR_storage_buffer_storage_class"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %85 "vs_main" %75 %78 %80 %82 %84
OpEntryPoint Fragment %143 "fs_main" %134 %137 %140 %142
OpEntryPoint Fragment %211 "fs_main_without_storage" %204 %206 %208 %210
OpEntryPoint Fragment %228 "fs_main_without_storage" %221 %223 %225 %227
OpExecutionMode %143 OriginUpperLeft
OpExecutionMode %211 OriginUpperLeft
OpExecutionMode %228 OriginUpperLeft
%3 = OpString "shadow.wgsl"
OpSource Unknown 0 %3 "struct Globals {
view_proj: mat4x4<f32>,
@@ -168,12 +168,14 @@ OpName %140 "world_position"
OpName %143 "fs_main"
OpName %150 "color"
OpName %151 "i"
OpName %204 "proj_position"
OpName %206 "world_normal"
OpName %208 "world_position"
OpName %211 "fs_main_without_storage"
OpName %218 "color"
OpName %219 "i"
OpName %166 "loop_bound"
OpName %221 "proj_position"
OpName %223 "world_normal"
OpName %225 "world_position"
OpName %228 "fs_main_without_storage"
OpName %235 "color"
OpName %236 "i"
OpName %244 "loop_bound"
OpMemberDecorate %9 0 Offset 0
OpMemberDecorate %9 0 ColMajor
OpMemberDecorate %9 0 MatrixStride 16
@@ -222,10 +224,10 @@ OpDecorate %134 BuiltIn FragCoord
OpDecorate %137 Location 0
OpDecorate %140 Location 1
OpDecorate %142 Location 0
OpDecorate %204 BuiltIn FragCoord
OpDecorate %206 Location 0
OpDecorate %208 Location 1
OpDecorate %210 Location 0
OpDecorate %221 BuiltIn FragCoord
OpDecorate %223 Location 0
OpDecorate %225 Location 1
OpDecorate %227 Location 0
%2 = OpTypeVoid
%4 = OpTypeFloat 32
%6 = OpTypeVector %4 4
@@ -302,16 +304,22 @@ OpDecorate %210 Location 0
%142 = OpVariable %81 Output
%146 = OpTypePointer StorageBuffer %17
%152 = OpTypePointer Function %7
%161 = OpTypePointer Uniform %8
%162 = OpTypePointer Uniform %7
%172 = OpTypePointer StorageBuffer %16
%198 = OpTypePointer Uniform %6
%204 = OpVariable %135 Input
%206 = OpVariable %138 Input
%208 = OpVariable %135 Input
%210 = OpVariable %81 Output
%214 = OpTypePointer Uniform %18
%237 = OpTypePointer Uniform %16
%160 = OpTypeVector %7 2
%161 = OpTypePointer Function %160
%162 = OpTypeVector %56 2
%163 = OpConstantComposite %160 %88 %88
%164 = OpConstant %7 4294967295
%165 = OpConstantComposite %160 %164 %164
%178 = OpTypePointer Uniform %8
%179 = OpTypePointer Uniform %7
%189 = OpTypePointer StorageBuffer %16
%215 = OpTypePointer Uniform %6
%221 = OpVariable %135 Input
%223 = OpVariable %138 Input
%225 = OpVariable %135 Input
%227 = OpVariable %81 Output
%231 = OpTypePointer Uniform %18
%265 = OpTypePointer Uniform %16
%44 = OpFunction %4 None %45
%42 = OpFunctionParameter %7
%43 = OpFunctionParameter %6
@@ -415,6 +423,7 @@ OpFunctionEnd
%132 = OpLabel
%150 = OpVariable %103 Function %24
%151 = OpVariable %152 Function %88
%166 = OpVariable %161 Function %163
%136 = OpLoad %6 %134
%139 = OpLoad %11 %137
%141 = OpLoad %6 %140
@@ -433,165 +442,194 @@ OpBranch %156
%156 = OpLabel
OpLine %3 88 5
OpLoopMerge %157 %159 None
OpBranch %167
%167 = OpLabel
%168 = OpLoad %160 %166
%169 = OpIEqual %162 %165 %168
%170 = OpAll %56 %169
OpSelectionMerge %171 None
OpBranchConditional %170 %157 %171
%171 = OpLabel
%172 = OpCompositeExtract %7 %168 1
%173 = OpIEqual %56 %172 %164
%174 = OpSelect %7 %173 %115 %88
%175 = OpCompositeConstruct %160 %174 %115
%176 = OpIAdd %160 %168 %175
OpStore %166 %176
OpBranch %158
%158 = OpLabel
OpLine %3 1 1
%160 = OpLoad %7 %151
%177 = OpLoad %7 %151
OpLine %3 88 29
%163 = OpAccessChain %162 %144 %115 %88
%164 = OpLoad %7 %163
%180 = OpAccessChain %179 %144 %115 %88
%181 = OpLoad %7 %180
OpLine %3 88 21
%165 = OpExtInst %7 %1 UMin %164 %19
%166 = OpULessThan %56 %160 %165
%182 = OpExtInst %7 %1 UMin %181 %19
%183 = OpULessThan %56 %177 %182
OpLine %3 88 20
OpSelectionMerge %167 None
OpBranchConditional %166 %167 %168
%168 = OpLabel
OpSelectionMerge %184 None
OpBranchConditional %183 %184 %185
%185 = OpLabel
OpBranch %157
%167 = OpLabel
OpBranch %169
%169 = OpLabel
%184 = OpLabel
OpBranch %186
%186 = OpLabel
OpLine %3 89 21
%171 = OpLoad %7 %151
%173 = OpAccessChain %172 %147 %171
%174 = OpLoad %16 %173
%188 = OpLoad %7 %151
%190 = OpAccessChain %189 %147 %188
%191 = OpLoad %16 %190
OpLine %3 91 38
%175 = OpLoad %7 %151
%176 = OpCompositeExtract %5 %174 0
%177 = OpCompositeExtract %6 %133 2
%178 = OpMatrixTimesVector %6 %176 %177
%192 = OpLoad %7 %151
%193 = OpCompositeExtract %5 %191 0
%194 = OpCompositeExtract %6 %133 2
%195 = OpMatrixTimesVector %6 %193 %194
OpLine %3 91 22
%179 = OpFunctionCall %4 %44 %175 %178
%196 = OpFunctionCall %4 %44 %192 %195
OpLine %3 93 25
%180 = OpCompositeExtract %6 %174 1
%181 = OpVectorShuffle %11 %180 %180 0 1 2
%182 = OpCompositeExtract %6 %133 2
%183 = OpVectorShuffle %11 %182 %182 0 1 2
%184 = OpFSub %11 %181 %183
%185 = OpExtInst %11 %1 Normalize %184
%197 = OpCompositeExtract %6 %191 1
%198 = OpVectorShuffle %11 %197 %197 0 1 2
%199 = OpCompositeExtract %6 %133 2
%200 = OpVectorShuffle %11 %199 %199 0 1 2
%201 = OpFSub %11 %198 %200
%202 = OpExtInst %11 %1 Normalize %201
OpLine %3 94 23
%186 = OpDot %4 %155 %185
%187 = OpExtInst %4 %1 FMax %48 %186
%203 = OpDot %4 %155 %202
%204 = OpExtInst %4 %1 FMax %48 %203
OpLine %3 96 9
%188 = OpFMul %4 %179 %187
%189 = OpCompositeExtract %6 %174 2
%190 = OpVectorShuffle %11 %189 %189 0 1 2
%191 = OpVectorTimesScalar %11 %190 %188
%192 = OpLoad %11 %150
%193 = OpFAdd %11 %192 %191
%205 = OpFMul %4 %196 %204
%206 = OpCompositeExtract %6 %191 2
%207 = OpVectorShuffle %11 %206 %206 0 1 2
%208 = OpVectorTimesScalar %11 %207 %205
%209 = OpLoad %11 %150
%210 = OpFAdd %11 %209 %208
OpLine %3 96 9
OpStore %150 %193
OpBranch %170
%170 = OpLabel
OpStore %150 %210
OpBranch %187
%187 = OpLabel
OpBranch %159
%159 = OpLabel
OpLine %3 88 68
%194 = OpLoad %7 %151
%195 = OpIAdd %7 %194 %115
%211 = OpLoad %7 %151
%212 = OpIAdd %7 %211 %115
OpLine %3 88 68
OpStore %151 %195
OpStore %151 %212
OpBranch %156
%157 = OpLabel
OpLine %3 1 1
%196 = OpLoad %11 %150
%213 = OpLoad %11 %150
OpLine %3 99 12
%197 = OpCompositeConstruct %6 %196 %49
%214 = OpCompositeConstruct %6 %213 %49
OpLine %3 99 12
%199 = OpAccessChain %198 %145 %115
%200 = OpLoad %6 %199
%201 = OpFMul %6 %197 %200
OpStore %142 %201
%216 = OpAccessChain %215 %145 %115
%217 = OpLoad %6 %216
%218 = OpFMul %6 %214 %217
OpStore %142 %218
OpReturn
OpFunctionEnd
%211 = OpFunction %2 None %86
%202 = OpLabel
%218 = OpVariable %103 Function %24
%219 = OpVariable %152 Function %88
%205 = OpLoad %6 %204
%207 = OpLoad %11 %206
%209 = OpLoad %6 %208
%203 = OpCompositeConstruct %12 %205 %207 %209
%212 = OpAccessChain %87 %25 %88
%213 = OpAccessChain %90 %28 %88
%215 = OpAccessChain %214 %34 %88
%216 = OpLoad %20 %37
%217 = OpLoad %21 %39
OpBranch %220
%220 = OpLabel
%228 = OpFunction %2 None %86
%219 = OpLabel
%235 = OpVariable %103 Function %24
%236 = OpVariable %152 Function %88
%244 = OpVariable %161 Function %163
%222 = OpLoad %6 %221
%224 = OpLoad %11 %223
%226 = OpLoad %6 %225
%220 = OpCompositeConstruct %12 %222 %224 %226
%229 = OpAccessChain %87 %25 %88
%230 = OpAccessChain %90 %28 %88
%232 = OpAccessChain %231 %34 %88
%233 = OpLoad %20 %37
%234 = OpLoad %21 %39
OpBranch %237
%237 = OpLabel
OpLine %3 105 18
%221 = OpCompositeExtract %11 %203 1
%222 = OpExtInst %11 %1 Normalize %221
OpBranch %223
%223 = OpLabel
%238 = OpCompositeExtract %11 %220 1
%239 = OpExtInst %11 %1 Normalize %238
OpBranch %240
%240 = OpLabel
OpLine %3 107 5
OpLoopMerge %224 %226 None
OpBranch %225
%225 = OpLabel
OpLoopMerge %241 %243 None
OpBranch %245
%245 = OpLabel
%246 = OpLoad %160 %244
%247 = OpIEqual %162 %165 %246
%248 = OpAll %56 %247
OpSelectionMerge %249 None
OpBranchConditional %248 %241 %249
%249 = OpLabel
%250 = OpCompositeExtract %7 %246 1
%251 = OpIEqual %56 %250 %164
%252 = OpSelect %7 %251 %115 %88
%253 = OpCompositeConstruct %160 %252 %115
%254 = OpIAdd %160 %246 %253
OpStore %244 %254
OpBranch %242
%242 = OpLabel
OpLine %3 1 1
%227 = OpLoad %7 %219
%255 = OpLoad %7 %236
OpLine %3 107 29
%228 = OpAccessChain %162 %212 %115 %88
%229 = OpLoad %7 %228
%256 = OpAccessChain %179 %229 %115 %88
%257 = OpLoad %7 %256
OpLine %3 107 21
%230 = OpExtInst %7 %1 UMin %229 %19
%231 = OpULessThan %56 %227 %230
%258 = OpExtInst %7 %1 UMin %257 %19
%259 = OpULessThan %56 %255 %258
OpLine %3 107 20
OpSelectionMerge %232 None
OpBranchConditional %231 %232 %233
%233 = OpLabel
OpBranch %224
%232 = OpLabel
OpBranch %234
%234 = OpLabel
OpSelectionMerge %260 None
OpBranchConditional %259 %260 %261
%261 = OpLabel
OpBranch %241
%260 = OpLabel
OpBranch %262
%262 = OpLabel
OpLine %3 110 21
%236 = OpLoad %7 %219
%238 = OpAccessChain %237 %215 %236
%239 = OpLoad %16 %238
%264 = OpLoad %7 %236
%266 = OpAccessChain %265 %232 %264
%267 = OpLoad %16 %266
OpLine %3 111 38
%240 = OpLoad %7 %219
%241 = OpCompositeExtract %5 %239 0
%242 = OpCompositeExtract %6 %203 2
%243 = OpMatrixTimesVector %6 %241 %242
%268 = OpLoad %7 %236
%269 = OpCompositeExtract %5 %267 0
%270 = OpCompositeExtract %6 %220 2
%271 = OpMatrixTimesVector %6 %269 %270
OpLine %3 111 22
%244 = OpFunctionCall %4 %44 %240 %243
%272 = OpFunctionCall %4 %44 %268 %271
OpLine %3 112 25
%245 = OpCompositeExtract %6 %239 1
%246 = OpVectorShuffle %11 %245 %245 0 1 2
%247 = OpCompositeExtract %6 %203 2
%248 = OpVectorShuffle %11 %247 %247 0 1 2
%249 = OpFSub %11 %246 %248
%250 = OpExtInst %11 %1 Normalize %249
%273 = OpCompositeExtract %6 %267 1
%274 = OpVectorShuffle %11 %273 %273 0 1 2
%275 = OpCompositeExtract %6 %220 2
%276 = OpVectorShuffle %11 %275 %275 0 1 2
%277 = OpFSub %11 %274 %276
%278 = OpExtInst %11 %1 Normalize %277
OpLine %3 113 23
%251 = OpDot %4 %222 %250
%252 = OpExtInst %4 %1 FMax %48 %251
%279 = OpDot %4 %239 %278
%280 = OpExtInst %4 %1 FMax %48 %279
OpLine %3 114 9
%253 = OpFMul %4 %244 %252
%254 = OpCompositeExtract %6 %239 2
%255 = OpVectorShuffle %11 %254 %254 0 1 2
%256 = OpVectorTimesScalar %11 %255 %253
%257 = OpLoad %11 %218
%258 = OpFAdd %11 %257 %256
%281 = OpFMul %4 %272 %280
%282 = OpCompositeExtract %6 %267 2
%283 = OpVectorShuffle %11 %282 %282 0 1 2
%284 = OpVectorTimesScalar %11 %283 %281
%285 = OpLoad %11 %235
%286 = OpFAdd %11 %285 %284
OpLine %3 114 9
OpStore %218 %258
OpBranch %235
%235 = OpLabel
OpBranch %226
%226 = OpLabel
OpStore %235 %286
OpBranch %263
%263 = OpLabel
OpBranch %243
%243 = OpLabel
OpLine %3 107 68
%259 = OpLoad %7 %219
%260 = OpIAdd %7 %259 %115
%287 = OpLoad %7 %236
%288 = OpIAdd %7 %287 %115
OpLine %3 107 68
OpStore %219 %260
OpBranch %223
%224 = OpLabel
OpStore %236 %288
OpBranch %240
%241 = OpLabel
OpLine %3 1 1
%261 = OpLoad %11 %218
%289 = OpLoad %11 %235
OpLine %3 116 12
%262 = OpCompositeConstruct %6 %261 %49
%290 = OpCompositeConstruct %6 %289 %49
OpLine %3 116 12
%263 = OpAccessChain %198 %213 %115
%264 = OpLoad %6 %263
%265 = OpFMul %6 %262 %264
OpStore %210 %265
%291 = OpAccessChain %215 %230 %115
%292 = OpLoad %6 %291
%293 = OpFMul %6 %290 %292
OpStore %227 %293
OpReturn
OpFunctionEnd

View File

@@ -565,6 +565,7 @@ fn write_output_spv(
bounds_check_policies,
binding_map: params.binding_map.clone(),
zero_initialize_workgroup_memory: spv::ZeroInitializeWorkgroupMemoryMode::Polyfill,
force_loop_bounding: true,
debug_info,
};

View File

@@ -1914,6 +1914,7 @@ impl super::Adapter {
} else {
spv::ZeroInitializeWorkgroupMemoryMode::Polyfill
},
force_loop_bounding: true,
// We need to build this separately for each invocation, so just default it out here
binding_map: BTreeMap::default(),
debug_info: None,

View File

@@ -908,6 +908,7 @@ impl super::Device {
shader_stage: naga_stage,
};
let needs_temp_options = !runtime_checks.bounds_checks
|| !runtime_checks.force_loop_bounding
|| !binding_map.is_empty()
|| naga_shader.debug_source.is_some()
|| !stage.zero_initialize_workgroup_memory;
@@ -922,6 +923,9 @@ impl super::Device {
binding_array: naga::proc::BoundsCheckPolicy::Unchecked,
};
}
if !runtime_checks.force_loop_bounding {
temp_options.force_loop_bounding = false;
}
if !binding_map.is_empty() {
temp_options.binding_map = binding_map.clone();
}