{"action":"created","issue":{"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross/issues/662","repository_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross","labels_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross/issues/662/labels{/name}","comments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross/issues/662/comments","events_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross/issues/662/events","html_url":"https://github.com/KhronosGroup/SPIRV-Cross/issues/662","id":352962329,"node_id":"MDU6SXNzdWUzNTI5NjIzMjk=","number":662,"title":"Compile error using array of textures","user":{"login":"redorav","id":700032,"node_id":"MDQ6VXNlcjcwMDAzMg==","avatar_url":"https://avatars0.githubusercontent.com/u/700032?v=4","gravatar_id":"","url":"https://api.github.com/users/redorav","html_url":"https://github.com/redorav","followers_url":"https://api.github.com/users/redorav/followers","following_url":"https://api.github.com/users/redorav/following{/other_user}","gists_url":"https://api.github.com/users/redorav/gists{/gist_id}","starred_url":"https://api.github.com/users/redorav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redorav/subscriptions","organizations_url":"https://api.github.com/users/redorav/orgs","repos_url":"https://api.github.com/users/redorav/repos","events_url":"https://api.github.com/users/redorav/events{/privacy}","received_events_url":"https://api.github.com/users/redorav/received_events","type":"User","site_admin":false},"labels":[{"id":352397994,"node_id":"MDU6TGFiZWwzNTIzOTc5OTQ=","url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross/labels/invalid","name":"invalid","color":"5319e7","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-22T13:49:46Z","updated_at":"2018-08-23T12:41:28Z","closed_at":"2018-08-23T11:34:08Z","author_association":"NONE","body":"I have a simplified shader that illustrates a problem I'm having.\r\n\r\n```hlsl\r\nTextureCube t0; SamplerState s0;\r\nTextureCube t1; SamplerState s1;\r\n\r\nfloat4 fragmentProgram(float4 input : INPUT0) : SV_Target0\r\n{\r\n\tfloat4 result = 0;\r\n\r\n\tTextureCube texCubeArray[2];\r\n\ttexCubeArray[0] = t0;\r\n\ttexCubeArray[1] = t1;\r\n\r\n\t[unroll]\r\n\tfor (int i = 0; i < 2; ++i)\r\n\t{\r\n\t\tresult += texCubeArray[i].Sample(s0, input.xyz);\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n```\r\n\r\nIf I compile this to SPIR-V and then into glsl, the result I get is the following:\r\n\r\n```glsl\r\nuniform samplerCube _105[2];\r\n\r\nlayout(location = 0) in vec4 _input;\r\nlayout(location = 0) out vec4 _69;\r\n\r\nvoid main()\r\n{\r\n    _0[0] = t0;\r\n    _0[1] = t1;\r\n    vec4 _103;\r\n    _103 = vec4(0.0);\r\n    for (int _102 = 0; _102 < 2; )\r\n    {\r\n        _103 += texture(_105[_102], _input.xyz);\r\n        _102++;\r\n        continue;\r\n    }\r\n    _69 = _103;\r\n}\r\n```\r\n\r\nFor some reason it has created a _0 variable that it's trying to assign into, and also hasn't declared t0 or t1 anywhere and it's failing to compile. The glsl I'm showing comes from optimized SPIR-V, but unoptimized SPIR-V presents the same problem. Fxc is ok with this setup if indices are known at compile time.\r\n\r\n[fragmentProgram_optimized.spv.txt](https://github.com/KhronosGroup/SPIRV-Cross/files/2310564/fragmentProgram_optimized.spv.txt)\r\n"},"comment":{"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross/issues/comments/415400161","html_url":"https://github.com/KhronosGroup/SPIRV-Cross/issues/662#issuecomment-415400161","issue_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Cross/issues/662","id":415400161,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTQwMDE2MQ==","user":{"login":"redorav","id":700032,"node_id":"MDQ6VXNlcjcwMDAzMg==","avatar_url":"https://avatars0.githubusercontent.com/u/700032?v=4","gravatar_id":"","url":"https://api.github.com/users/redorav","html_url":"https://github.com/redorav","followers_url":"https://api.github.com/users/redorav/followers","following_url":"https://api.github.com/users/redorav/following{/other_user}","gists_url":"https://api.github.com/users/redorav/gists{/gist_id}","starred_url":"https://api.github.com/users/redorav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redorav/subscriptions","organizations_url":"https://api.github.com/users/redorav/orgs","repos_url":"https://api.github.com/users/redorav/repos","events_url":"https://api.github.com/users/redorav/events{/privacy}","received_events_url":"https://api.github.com/users/redorav/received_events","type":"User","site_admin":false},"created_at":"2018-08-23T12:41:28Z","updated_at":"2018-08-23T12:41:28Z","author_association":"NONE","body":"Understood, I'll send it over to glslang and continute the conversation there. Thanks for taking the time to look into it."}}
{"actor":{"display_login":"redorav"}}