Add test for CompositeExtract from row-major loaded vector.

This commit is contained in:
Hans-Kristian Arntzen 2019-07-22 16:32:22 +02:00
parent d7a5303cf2
commit 82c819ee6c
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBORow
{
float v;
float4x4 row_major0;
};
kernel void main0(device SSBORow& _4 [[buffer(0)]])
{
_4.v = float4(_4.row_major0[0][1], _4.row_major0[1][1], _4.row_major0[2][1], _4.row_major0[3][1])[2];
}

View File

@ -0,0 +1,48 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 21
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpSource GLSL 450
OpName %main "main"
OpName %SSBORow "SSBORow"
OpMemberName %SSBORow 0 "v"
OpMemberName %SSBORow 1 "row_major0"
OpName %_ ""
OpMemberDecorate %SSBORow 0 Offset 0
OpMemberDecorate %SSBORow 1 RowMajor
OpMemberDecorate %SSBORow 1 Offset 16
OpMemberDecorate %SSBORow 1 MatrixStride 16
OpDecorate %SSBORow BufferBlock
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%mat4v4float = OpTypeMatrix %v4float 4
%SSBORow = OpTypeStruct %float %mat4v4float
%_ptr_Uniform_SSBORow = OpTypePointer Uniform %SSBORow
%_ = OpVariable %_ptr_Uniform_SSBORow Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%int_1 = OpConstant %int 1
%uint = OpTypeInt 32 0
%uint_2 = OpConstant %uint 2
%_ptr_Uniform_float = OpTypePointer Uniform %float
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%main = OpFunction %void None %3
%5 = OpLabel
%row_ptr = OpAccessChain %_ptr_Uniform_v4float %_ %int_1 %int_1
%vec = OpLoad %v4float %row_ptr
%float_val = OpCompositeExtract %float %vec 2
%20 = OpAccessChain %_ptr_Uniform_float %_ %int_0
OpStore %20 %float_val
OpReturn
OpFunctionEnd