{"action":"created","issue":{"url":"https://api.github.com/repos/KhronosGroup/glslang/issues/1525","repository_url":"https://api.github.com/repos/KhronosGroup/glslang","labels_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/1525/labels{/name}","comments_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/1525/comments","events_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/1525/events","html_url":"https://github.com/KhronosGroup/glslang/issues/1525","id":367822063,"node_id":"MDU6SXNzdWUzNjc4MjIwNjM=","number":1525,"title":"Implicit int8->float cast adds Int8 capability to the shader without asking for GL_KHX_shader_explicit_arithmetic_types","user":{"login":"zeux","id":1106629,"node_id":"MDQ6VXNlcjExMDY2Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1106629?v=4","gravatar_id":"","url":"https://api.github.com/users/zeux","html_url":"https://github.com/zeux","followers_url":"https://api.github.com/users/zeux/followers","following_url":"https://api.github.com/users/zeux/following{/other_user}","gists_url":"https://api.github.com/users/zeux/gists{/gist_id}","starred_url":"https://api.github.com/users/zeux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeux/subscriptions","organizations_url":"https://api.github.com/users/zeux/orgs","repos_url":"https://api.github.com/users/zeux/repos","events_url":"https://api.github.com/users/zeux/events{/privacy}","received_events_url":"https://api.github.com/users/zeux/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-08T14:39:25Z","updated_at":"2018-10-10T03:00:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Given this shader:\r\n\r\n```\r\n#version 450\r\n\r\n#extension GL_EXT_shader_16bit_storage: require\r\n#extension GL_EXT_shader_8bit_storage: require\r\n\r\nstruct Vertex\r\n{\r\n\tfloat vx, vy, vz;\r\n\tuint8_t nx, ny, nz, nw;\r\n\tfloat tu, tv;\r\n};\r\n\r\nlayout(binding = 0) readonly buffer Vertices\r\n{\r\n\tVertex vertices[];\r\n};\r\n\r\nlayout(location = 0) out vec4 color;\r\n\r\nvoid main()\r\n{\r\n\tvec3 position = vec3(vertices[gl_VertexIndex].vx, vertices[gl_VertexIndex].vy, vertices[gl_VertexIndex].vz);\r\n\tvec3 normal = vec3(vertices[gl_VertexIndex].nx, vertices[gl_VertexIndex].ny, vertices[gl_VertexIndex].nz) / 127.0 - 1.0;\r\n\tvec2 texcoord = vec2(vertices[gl_VertexIndex].tu, vertices[gl_VertexIndex].tv);\r\n\r\n\tgl_Position = vec4(position + vec3(0, 0, 0.5), 1.0);\r\n\r\n\tcolor = vec4(normal * 0.5 + vec3(0.5), 1.0);\r\n}\r\n```\r\n\r\nglslang compiles it without errors, but it adds Int8 capability which can't be used in Vulkan at this point in time which produces a shader that doesn't compile. Adding an explicit int8->int cast fixes the issue.\r\n\r\nWhat's odd is that if I, say, copy the struct out like this:\r\n\r\n```\r\nVertex v = vertices[gl_VertexIndex];\r\n```\r\n\r\nThen the code doesn't compile any more and glslang asks to add `GL_KHX_shader_explicit_arithmetic_types` extension - however, this doesn't happen for the implicit cast, which seems like a problem if I understand the intent of `GL_KHX_shader_explicit_arithmetic_types` - couldn't find the spec for this."},"comment":{"url":"https://api.github.com/repos/KhronosGroup/glslang/issues/comments/428421735","html_url":"https://github.com/KhronosGroup/glslang/issues/1525#issuecomment-428421735","issue_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/1525","id":428421735,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODQyMTczNQ==","user":{"login":"johnkslang","id":5607714,"node_id":"MDQ6VXNlcjU2MDc3MTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/5607714?v=4","gravatar_id":"","url":"https://api.github.com/users/johnkslang","html_url":"https://github.com/johnkslang","followers_url":"https://api.github.com/users/johnkslang/followers","following_url":"https://api.github.com/users/johnkslang/following{/other_user}","gists_url":"https://api.github.com/users/johnkslang/gists{/gist_id}","starred_url":"https://api.github.com/users/johnkslang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnkslang/subscriptions","organizations_url":"https://api.github.com/users/johnkslang/orgs","repos_url":"https://api.github.com/users/johnkslang/repos","events_url":"https://api.github.com/users/johnkslang/events{/privacy}","received_events_url":"https://api.github.com/users/johnkslang/received_events","type":"User","site_admin":false},"created_at":"2018-10-10T03:00:55Z","updated_at":"2018-10-10T03:00:55Z","author_association":"MEMBER","body":"### The big picture\r\n\r\n> Vulkan doesn't even have a way to provide Int8 capability\r\n\r\nDoesn't GL_KHX_shader_explicit_arithmetic_types need that?\r\n\r\nOne fundamental issue here is that instead of glslang doing (A), we mostly do (B):\r\n\r\n(A) get an explicit list of capabilities to stay within from the coder, and code-gen within that constraint\r\n\r\n(B) see what capabilities are apparently auto-requested by the GLSL, and request those of Vulkan\r\n\r\nIt is mostly (B), because now, for issues like this, it seems we should instead look at what extensions were and were not requested and make decisions based on that.  (Also \"mostly\", because we have a few command-line options now to describe the target, but nothing like getting to choose arbitrary subsets of capabilities.)\r\n\r\nSo, I basically agree with most of what everyone above is saying, but it is simply a complex situation, that's all I meant initially.\r\n\r\n### This specific issue\r\n\r\nI somewhat think it is a flaw that the extension doesn't allow the OpConvertUToF, but for the moment that decision is already baked into the extension, validator, drivers, etc.\r\n\r\nFor now, we can decide we are not targeting `Int8` based on the requested extensions, so glslang can use that \"extra\" information to not generate an OpConvertUToF, though I have not yet looked at how difficult that is (e.g., if a transform undoes something).\r\n"}}
{"actor":{"display_login":"johnkslang"}}