payload: {"action":"closed","issue":{"url":"https://api.github.com/repos/Microsoft/DirectXShaderCompiler/issues/1850","repository_url":"https://api.github.com/repos/Microsoft/DirectXShaderCompiler","labels_url":"https://api.github.com/repos/Microsoft/DirectXShaderCompiler/issues/1850/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/DirectXShaderCompiler/issues/1850/comments","events_url":"https://api.github.com/repos/Microsoft/DirectXShaderCompiler/issues/1850/events","html_url":"https://github.com/Microsoft/DirectXShaderCompiler/issues/1850","id":399347924,"node_id":"MDU6SXNzdWUzOTkzNDc5MjQ=","number":1850,"title":"[spirv] StructuredBuffer<floatMxN> does not produce a MatrixStride decoration","user":{"login":"pmichniewski","id":1138999,"node_id":"MDQ6VXNlcjExMzg5OTk=","avatar_url":"https://avatars3.githubusercontent.com/u/1138999?v=4","gravatar_id":"","url":"https://api.github.com/users/pmichniewski","html_url":"https://github.com/pmichniewski","followers_url":"https://api.github.com/users/pmichniewski/followers","following_url":"https://api.github.com/users/pmichniewski/following{/other_user}","gists_url":"https://api.github.com/users/pmichniewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pmichniewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmichniewski/subscriptions","organizations_url":"https://api.github.com/users/pmichniewski/orgs","repos_url":"https://api.github.com/users/pmichniewski/repos","events_url":"https://api.github.com/users/pmichniewski/events{/privacy}","received_events_url":"https://api.github.com/users/pmichniewski/received_events","type":"User","site_admin":false},"labels":[{"id":870577151,"node_id":"MDU6TGFiZWw4NzA1NzcxNTE=","url":"https://api.github.com/repos/Microsoft/DirectXShaderCompiler/labels/spirv","name":"spirv","color":"1d76db","default":false}],"state":"closed","locked":false,"assignee":{"login":"ehsannas","id":3828215,"node_id":"MDQ6VXNlcjM4MjgyMTU=","avatar_url":"https://avatars1.githubusercontent.com/u/3828215?v=4","gravatar_id":"","url":"https://api.github.com/users/ehsannas","html_url":"https://github.com/ehsannas","followers_url":"https://api.github.com/users/ehsannas/followers","following_url":"https://api.github.com/users/ehsannas/following{/other_user}","gists_url":"https://api.github.com/users/ehsannas/gists{/gist_id}","starred_url":"https://api.github.com/users/ehsannas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehsannas/subscriptions","organizations_url":"https://api.github.com/users/ehsannas/orgs","repos_url":"https://api.github.com/users/ehsannas/repos","events_url":"https://api.github.com/users/ehsannas/events{/privacy}","received_events_url":"https://api.github.com/users/ehsannas/received_events","type":"User","site_admin":false},"assignees":[{"login":"ehsannas","id":3828215,"node_id":"MDQ6VXNlcjM4MjgyMTU=","avatar_url":"https://avatars1.githubusercontent.com/u/3828215?v=4","gravatar_id":"","url":"https://api.github.com/users/ehsannas","html_url":"https://github.com/ehsannas","followers_url":"https://api.github.com/users/ehsannas/followers","following_url":"https://api.github.com/users/ehsannas/following{/other_user}","gists_url":"https://api.github.com/users/ehsannas/gists{/gist_id}","starred_url":"https://api.github.com/users/ehsannas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehsannas/subscriptions","organizations_url":"https://api.github.com/users/ehsannas/orgs","repos_url":"https://api.github.com/users/ehsannas/repos","events_url":"https://api.github.com/users/ehsannas/events{/privacy}","received_events_url":"https://api.github.com/users/ehsannas/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2019-01-15T13:36:42Z","updated_at":"2019-03-05T21:20:34Z","closed_at":"2019-03-05T21:20:34Z","author_association":"NONE","body":"StructuredBuffers of type floatMxN produce incorrect shaders - an OpMemberDecorate MatrixStride is missing.\r\n\r\nTestcase:\r\n```\r\nStructuredBuffer<float4x3> test;\r\nRWStructuredBuffer<float3> outp;\r\n\r\n[numthreads(1,1,1)]\r\nvoid main() {\r\n\tfloat3 v = mul(float4(1, 1, 1, 1), test[0]);\r\n\toutp[0] = v;\r\n}\r\n```\r\n\r\nResult:\r\n```\r\n; SPIR-V\r\n; Version: 1.0\r\n; Generator: Google spiregg; 0\r\n; Bound: 29\r\n; Schema: 0\r\n               OpCapability Shader\r\n               OpMemoryModel Logical GLSL450\r\n               OpEntryPoint GLCompute %main \"main\"\r\n               OpExecutionMode %main LocalSize 1 1 1\r\n               OpSource HLSL 600\r\n               OpName %type_StructuredBuffer_mat4v3float \"type.StructuredBuffer.mat4v3float\"\r\n               OpName %test \"test\"\r\n               OpName %type_RWStructuredBuffer_v3float \"type.RWStructuredBuffer.v3float\"\r\n               OpName %outp \"outp\"\r\n               OpName %main \"main\"\r\n               OpDecorate %_runtimearr_mat4v3float ArrayStride 48\r\n               OpMemberDecorate %type_StructuredBuffer_mat4v3float 0 RowMajor\r\n               OpMemberDecorate %type_StructuredBuffer_mat4v3float 0 Offset 0\r\n               OpMemberDecorate %type_StructuredBuffer_mat4v3float 0 NonWritable ; <- no MatrixStride decoration here\r\n               OpDecorate %type_StructuredBuffer_mat4v3float BufferBlock\r\n               OpDecorate %_runtimearr_v3float ArrayStride 12\r\n               OpMemberDecorate %type_RWStructuredBuffer_v3float 0 Offset 0\r\n               OpDecorate %type_RWStructuredBuffer_v3float BufferBlock\r\n               OpDecorate %test DescriptorSet 0\r\n               OpDecorate %test Binding 0\r\n               OpDecorate %outp DescriptorSet 0\r\n               OpDecorate %outp Binding 1\r\n      %float = OpTypeFloat 32\r\n    %v3float = OpTypeVector %float 3\r\n%mat4v3float = OpTypeMatrix %v3float 4\r\n%_runtimearr_mat4v3float = OpTypeRuntimeArray %mat4v3float\r\n%type_StructuredBuffer_mat4v3float = OpTypeStruct %_runtimearr_mat4v3float\r\n%_ptr_Uniform_type_StructuredBuffer_mat4v3float = OpTypePointer Uniform %type_StructuredBuffer_mat4v3float\r\n%_runtimearr_v3float = OpTypeRuntimeArray %v3float\r\n%type_RWStructuredBuffer_v3float = OpTypeStruct %_runtimearr_v3float\r\n%_ptr_Uniform_type_RWStructuredBuffer_v3float = OpTypePointer Uniform %type_RWStructuredBuffer_v3float\r\n        %int = OpTypeInt 32 1\r\n       %void = OpTypeVoid\r\n         %15 = OpTypeFunction %void\r\n    %v4float = OpTypeVector %float 4\r\n    %float_1 = OpConstant %float 1\r\n         %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1\r\n      %int_0 = OpConstant %int 0\r\n       %uint = OpTypeInt 32 0\r\n     %uint_0 = OpConstant %uint 0\r\n%_ptr_Uniform_mat4v3float = OpTypePointer Uniform %mat4v3float\r\n%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float\r\n       %test = OpVariable %_ptr_Uniform_type_StructuredBuffer_mat4v3float Uniform\r\n       %outp = OpVariable %_ptr_Uniform_type_RWStructuredBuffer_v3float Uniform\r\n       %main = OpFunction %void None %15\r\n         %24 = OpLabel\r\n         %25 = OpAccessChain %_ptr_Uniform_mat4v3float %test %int_0 %uint_0\r\n         %26 = OpLoad %mat4v3float %25\r\n         %27 = OpMatrixTimesVector %v3float %26 %18\r\n         %28 = OpAccessChain %_ptr_Uniform_v3float %outp %int_0 %uint_0\r\n               OpStore %28 %27\r\n               OpReturn\r\n               OpFunctionEnd\r\n```\r\n\r\nThis works fine if a floatMxN is wrapped in a struct, e.g.:\r\n\r\n```\r\nstruct smat\r\n{\r\n\tfloat4x3 m;\r\n};\r\n\r\nStructuredBuffer<smat> test;\r\nRWStructuredBuffer<float3> outp;\r\n\r\n[numthreads(1,1,1)]\r\nvoid main() {\r\n\tfloat3 v = mul(float4(1, 1, 1, 1), test[0].m);\r\n\toutp[0] = v;\r\n}\r\n```\r\n\r\nI traced it back to translateResourceType(QualType type, SpirvLayoutRule rule):\r\n```\r\n    if (isMxNMatrix(s))\r\n      decorations.push_back(isRowMajor ? Decoration::getColMajor(context, 0)\r\n                                       : Decoration::getRowMajor(context, 0));\r\n```\r\n\r\nThere should be a MatrixStride decoration placed inside this if block."}}
other: {"actor":{"display_login":"ehsannas"}}