-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2346 from KhronosGroup/fix-2336
MSL: Handle OpPtrAccessChain with ArrayStride
- Loading branch information
Showing
6 changed files
with
205 additions
and
9 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
reference/shaders-msl-no-opt/asm/comp/ptr-access-chain-custom-array-stride.asm.msl23.comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
|
||
using namespace metal; | ||
|
||
struct Registers | ||
{ | ||
device float3* a; | ||
device float3* b; | ||
uint2 c; | ||
uint2 d; | ||
}; | ||
|
||
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); | ||
|
||
kernel void main0(constant Registers& _7 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) | ||
{ | ||
device float3* _41 = reinterpret_cast<device float3*>(as_type<ulong>(_7.c)); | ||
*reinterpret_cast<device packed_float3 *>(reinterpret_cast<ulong>(_7.a) + gl_GlobalInvocationID.x * 12) = float3(*reinterpret_cast<device packed_float3 *>(reinterpret_cast<ulong>(_7.a) + gl_GlobalInvocationID.x * 12)) + _7.b[gl_GlobalInvocationID.x]; | ||
*reinterpret_cast<device packed_float3 *>(reinterpret_cast<ulong>(_41) + gl_GlobalInvocationID.x * 12) = float3(*reinterpret_cast<device packed_float3 *>(reinterpret_cast<ulong>(_41) + gl_GlobalInvocationID.x * 12)) + (reinterpret_cast<device float3*>(as_type<ulong>(_7.d)))[gl_GlobalInvocationID.x]; | ||
} | ||
|
98 changes: 98 additions & 0 deletions
98
shaders-msl-no-opt/asm/comp/ptr-access-chain-custom-array-stride.asm.msl23.comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
; SPIR-V | ||
; Version: 1.0 | ||
; Generator: Khronos Glslang Reference Front End; 11 | ||
; Bound: 66 | ||
; Schema: 0 | ||
OpCapability Shader | ||
OpCapability PhysicalStorageBufferAddresses | ||
OpExtension "SPV_KHR_physical_storage_buffer" | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel PhysicalStorageBuffer64 GLSL450 | ||
OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID | ||
OpExecutionMode %main LocalSize 64 1 1 | ||
OpSource GLSL 450 | ||
OpSourceExtension "GL_EXT_buffer_reference" | ||
OpSourceExtension "GL_EXT_buffer_reference_uvec2" | ||
OpSourceExtension "GL_EXT_scalar_block_layout" | ||
OpName %main "main" | ||
OpName %Registers "Registers" | ||
OpMemberName %Registers 0 "a" | ||
OpMemberName %Registers 1 "b" | ||
OpMemberName %Registers 2 "c" | ||
OpMemberName %Registers 3 "d" | ||
OpName %_ "" | ||
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID" | ||
OpMemberDecorate %Registers 0 Offset 0 | ||
OpMemberDecorate %Registers 1 Offset 8 | ||
OpMemberDecorate %Registers 2 Offset 16 | ||
OpMemberDecorate %Registers 3 Offset 24 | ||
OpDecorate %Registers Block | ||
OpDecorate %v3float_stride12_ptr ArrayStride 12 | ||
OpDecorate %v3float_stride16_ptr ArrayStride 16 | ||
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId | ||
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize | ||
%void = OpTypeVoid | ||
%3 = OpTypeFunction %void | ||
%uint = OpTypeInt 32 0 | ||
%v2uint = OpTypeVector %uint 2 | ||
%float = OpTypeFloat 32 | ||
%v3float = OpTypeVector %float 3 | ||
%_ptr_PhysicalStorageBuffer_v3float = OpTypePointer PhysicalStorageBuffer %v3float | ||
%v3float_stride12_ptr = OpTypePointer PhysicalStorageBuffer %v3float | ||
%v3float_stride16_ptr = OpTypePointer PhysicalStorageBuffer %v3float | ||
%v3float_stride12_ptr_push = OpTypePointer PushConstant %v3float_stride12_ptr | ||
%v3float_stride16_ptr_push = OpTypePointer PushConstant %v3float_stride16_ptr | ||
%v2uint_ptr = OpTypePointer PushConstant %v2uint | ||
%Registers = OpTypeStruct %v3float_stride12_ptr %v3float_stride16_ptr %v2uint %v2uint | ||
%_ptr_PushConstant_Registers = OpTypePointer PushConstant %Registers | ||
%_ = OpVariable %_ptr_PushConstant_Registers PushConstant | ||
%int = OpTypeInt 32 1 | ||
%int_0 = OpConstant %int 0 | ||
%v3uint = OpTypeVector %uint 3 | ||
%_ptr_Input_v3uint = OpTypePointer Input %v3uint | ||
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input | ||
%uint_0 = OpConstant %uint 0 | ||
%_ptr_Input_uint = OpTypePointer Input %uint | ||
%int_1 = OpConstant %int 1 | ||
%int_2 = OpConstant %int 2 | ||
%_ptr_PushConstant_v2uint = OpTypePointer PushConstant %v2uint | ||
%int_3 = OpConstant %int 3 | ||
%uint_64 = OpConstant %uint 64 | ||
%uint_1 = OpConstant %uint 1 | ||
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 | ||
%main = OpFunction %void None %3 | ||
%5 = OpLabel | ||
%29 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 | ||
%index = OpLoad %uint %29 | ||
|
||
%ptr_member_0 = OpAccessChain %v3float_stride12_ptr_push %_ %int_0 | ||
%ptr0 = OpLoad %v3float_stride12_ptr %ptr_member_0 | ||
|
||
%ptr_member_1 = OpAccessChain %v3float_stride16_ptr_push %_ %int_1 | ||
%ptr1 = OpLoad %v3float_stride16_ptr %ptr_member_1 | ||
|
||
%ptr_member_2 = OpAccessChain %v2uint_ptr %_ %int_2 | ||
%ptr2v = OpLoad %v2uint %ptr_member_2 | ||
%ptr2 = OpBitcast %v3float_stride12_ptr %ptr2v | ||
|
||
%ptr_member_3 = OpAccessChain %v2uint_ptr %_ %int_3 | ||
%ptr3v = OpLoad %v2uint %ptr_member_3 | ||
%ptr3 = OpBitcast %v3float_stride16_ptr %ptr3v | ||
|
||
%ptr0_chain = OpPtrAccessChain %v3float_stride12_ptr %ptr0 %index | ||
%ptr1_chain = OpPtrAccessChain %v3float_stride16_ptr %ptr1 %index | ||
%ptr2_chain = OpPtrAccessChain %v3float_stride12_ptr %ptr2 %index | ||
%ptr3_chain = OpPtrAccessChain %v3float_stride16_ptr %ptr3 %index | ||
|
||
%loaded0 = OpLoad %v3float %ptr0_chain Aligned 4 | ||
%loaded1 = OpLoad %v3float %ptr1_chain Aligned 16 | ||
%loaded2 = OpLoad %v3float %ptr2_chain Aligned 4 | ||
%loaded3 = OpLoad %v3float %ptr3_chain Aligned 16 | ||
|
||
%added0 = OpFAdd %v3float %loaded0 %loaded1 | ||
%added1 = OpFAdd %v3float %loaded2 %loaded3 | ||
OpStore %ptr0_chain %added0 Aligned 4 | ||
OpStore %ptr2_chain %added1 Aligned 4 | ||
|
||
OpReturn | ||
OpFunctionEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters