{"action":"created","comment":{"url":"https://api.github.com/repos/KhronosGroup/glslang/pulls/comments/58087045","id":58087045,"diff_hunk":"@@ -1208,6 +1229,102 @@ Id Builder::createOp(Op opCode, Id typeId, const std::vector<Id>& operands)\n     return op->getResultId();\n }\n \n+Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& operands, const std::vector<unsigned>& literals) {\n+    switch(opCode) {\n+        // OpCodes that do not need any capababilities.\n+        case OpSConvert:\n+        case OpFConvert:\n+        case OpSNegate:\n+        case OpNot:\n+        case OpIAdd:\n+        case OpISub:\n+        case OpIMul:\n+        case OpUDiv:\n+        case OpSDiv:\n+        case OpUMod:\n+        case OpSRem:\n+        case OpSMod:\n+        case OpShiftRightLogical:\n+        case OpShiftRightArithmetic:\n+        case OpShiftLeftLogical:\n+        case OpBitwiseOr:\n+        case OpBitwiseXor:\n+        case OpBitwiseAnd:\n+        case OpVectorShuffle:\n+        case OpCompositeExtract:\n+        case OpCompositeInsert:\n+        case OpLogicalOr:\n+        case OpLogicalAnd:\n+        case OpLogicalNot:\n+        case OpLogicalEqual:\n+        case OpLogicalNotEqual:\n+        case OpSelect:\n+        case OpIEqual:\n+        case OpULessThan:\n+        case OpSLessThan:\n+        case OpUGreaterThan:\n+        case OpSGreaterThan:\n+        case OpULessThanEqual:\n+        case OpSLessThanEqual:\n+        case OpUGreaterThanEqual:\n+        case OpSGreaterThanEqual:\n+        // Added temporarily to enable compsite type spec constants comparison.\n+        // Remove this comment after Spec being updated.\n+        case OpAll:\n+        case OpAny:\n+        case OpFOrdEqual:\n+        case OpFUnordEqual:\n+        case OpFOrdNotEqual:\n+        case OpFUnordNotEqual:\n+            break;\n+\n+        // OpCodes that need Shader capability.\n+        case OpQuantizeToF16:\n+            addCapability(CapabilityShader);\n+            break;\n+\n+        // OpCodes that need Kernel capability.\n+        case OpConvertFToS:\n+        case OpConvertSToF:\n+        case OpConvertFToU:\n+        case OpConvertUToF:\n+        case OpUConvert:\n+        case OpConvertPtrToU:\n+        case OpConvertUToPtr:\n+        case OpGenericCastToPtr:\n+        case OpPtrCastToGeneric:\n+        case OpBitcast:\n+        case OpFNegate:\n+        case OpFAdd:\n+        case OpFSub:\n+        case OpFMul:\n+        case OpFDiv:\n+        case OpFRem:\n+        case OpFMod:\n+        case OpAccessChain:\n+        case OpInBoundsAccessChain:\n+        case OpPtrAccessChain:\n+        case OpInBoundsPtrAccessChain:\n+            addCapability(CapabilityKernel);","path":"SPIRV/SpvBuilder.cpp","position":138,"original_position":138,"commit_id":"135452061aca1346936aa7a28ebb138341052229","original_commit_id":"135452061aca1346936aa7a28ebb138341052229","user":{"login":"johnkslang","id":5607714,"avatar_url":"https://avatars.githubusercontent.com/u/5607714?v=3","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},"body":"Maybe we're lost in talking at the same time, so I'll make this a separate comment:\r\n\r\nSummary summary: I don't think we need this list of opcodes. It creates an unnecessary thing to maintain.  Instead, use the validator to find places the front-end made bad requests in the AST.","created_at":"2016-03-31T16:44:19Z","updated_at":"2016-03-31T16:44:19Z","html_url":"https://github.com/KhronosGroup/glslang/pull/215#discussion_r58087045","pull_request_url":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215","_links":{"self":{"href":"https://api.github.com/repos/KhronosGroup/glslang/pulls/comments/58087045"},"html":{"href":"https://github.com/KhronosGroup/glslang/pull/215#discussion_r58087045"},"pull_request":{"href":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215"}}},"pull_request":{"url":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215","id":64510693,"html_url":"https://github.com/KhronosGroup/glslang/pull/215","diff_url":"https://github.com/KhronosGroup/glslang/pull/215.diff","patch_url":"https://github.com/KhronosGroup/glslang/pull/215.patch","issue_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/215","number":215,"state":"open","locked":false,"title":"Spec Constant Operations","user":{"login":"Qining","id":2983685,"avatar_url":"https://avatars.githubusercontent.com/u/2983685?v=3","gravatar_id":"","url":"https://api.github.com/users/Qining","html_url":"https://github.com/Qining","followers_url":"https://api.github.com/users/Qining/followers","following_url":"https://api.github.com/users/Qining/following{/other_user}","gists_url":"https://api.github.com/users/Qining/gists{/gist_id}","starred_url":"https://api.github.com/users/Qining/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qining/subscriptions","organizations_url":"https://api.github.com/users/Qining/orgs","repos_url":"https://api.github.com/users/Qining/repos","events_url":"https://api.github.com/users/Qining/events{/privacy}","received_events_url":"https://api.github.com/users/Qining/received_events","type":"User","site_admin":false},"body":"Approach:\r\nAdd a flag in `Builder` to indicate 'spec constant mode' and 'normal\r\nmode'. When the builder is in 'normal mode', nothing changed. When the\r\nbuilder is in 'spec constant mode', binary, unary and other instruction\r\ncreation rountines will be redirected to `createSpecConstantOp()` to\r\ncreate instrution at module level with `OpSpecConstantOp <original\r\nopcode> <operands>`.\r\n\r\n'spec constant mode' should be enabled if and only if we are creating\r\nspec constants. So a flager setter/recover guard is added when handling\r\nbinary/unary nodes in `createSpvConstantsFromConstSubTree()`.\r\n\r\nNote when handling spec constants which are represented as ConstantUnion\r\nNode, we should not use `OpSpecConstantOp` to initialize the composite\r\nconstant, so builder is set to 'normal mode'.\r\n\r\nTests:\r\nTests are added in Test/spv.specConstantOperations.vert, including:\r\n\r\n1) Arithmetic, shift opeations for both scalar and composite type spec constants.\r\n2) Size conversion from/to float and double for both scalar and vector.\r\n3) Bitwise and/or/xor for both scalar and vector.\r\n4) Unary negate/not for both scalar and vector.\r\n5) Vector swizzles.\r\n6) Comparisons for scalars.\r\n7) == and != for composite type spec constants\r\n\r\nIssues:\r\n1) To implement == and != for composite type spec constants, the Spec needs\r\nto allow OpAll, OpAny, OpFOrdEqual, OpFUnordEqual, OpOrdNotEqual,\r\nOpFUnordNotEqual. Currently none of them are allowed in the Spec.\r\n\r\n2) Other comparison opcode for float scalar type spec constants are not added, so that cases like\r\n```\r\nconst bool c = spec_float_a < spec_float_b;\r\nconst bool d = spec_float_a <= spec_float_b;\r\nconst bool e = spec_float_a > spec_float_b;\r\nconst bool f = spec_float_a >= spec_float_b;\r\n```\r\nare not supported.\r\nSimilar to supporting vector type == and !=, supporting such these cases needs add extra float comparison opcodes to the set of allowed opcodes of OpSpecConstantOp.","created_at":"2016-03-29T18:24:22Z","updated_at":"2016-03-31T16:44:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4ceb721232070002f9018fe18efc5b195681c03","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215/commits","review_comments_url":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215/comments","review_comment_url":"https://api.github.com/repos/KhronosGroup/glslang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/215/comments","statuses_url":"https://api.github.com/repos/KhronosGroup/glslang/statuses/135452061aca1346936aa7a28ebb138341052229","head":{"label":"Qining:spec-constants-operations","ref":"spec-constants-operations","sha":"135452061aca1346936aa7a28ebb138341052229","user":{"login":"Qining","id":2983685,"avatar_url":"https://avatars.githubusercontent.com/u/2983685?v=3","gravatar_id":"","url":"https://api.github.com/users/Qining","html_url":"https://github.com/Qining","followers_url":"https://api.github.com/users/Qining/followers","following_url":"https://api.github.com/users/Qining/following{/other_user}","gists_url":"https://api.github.com/users/Qining/gists{/gist_id}","starred_url":"https://api.github.com/users/Qining/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qining/subscriptions","organizations_url":"https://api.github.com/users/Qining/orgs","repos_url":"https://api.github.com/users/Qining/repos","events_url":"https://api.github.com/users/Qining/events{/privacy}","received_events_url":"https://api.github.com/users/Qining/received_events","type":"User","site_admin":false},"repo":{"id":53376214,"name":"glslang","full_name":"Qining/glslang","owner":{"login":"Qining","id":2983685,"avatar_url":"https://avatars.githubusercontent.com/u/2983685?v=3","gravatar_id":"","url":"https://api.github.com/users/Qining","html_url":"https://github.com/Qining","followers_url":"https://api.github.com/users/Qining/followers","following_url":"https://api.github.com/users/Qining/following{/other_user}","gists_url":"https://api.github.com/users/Qining/gists{/gist_id}","starred_url":"https://api.github.com/users/Qining/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qining/subscriptions","organizations_url":"https://api.github.com/users/Qining/orgs","repos_url":"https://api.github.com/users/Qining/repos","events_url":"https://api.github.com/users/Qining/events{/privacy}","received_events_url":"https://api.github.com/users/Qining/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Qining/glslang","description":"Khronos reference front-end for GLSL and ESSL","fork":true,"url":"https://api.github.com/repos/Qining/glslang","forks_url":"https://api.github.com/repos/Qining/glslang/forks","keys_url":"https://api.github.com/repos/Qining/glslang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Qining/glslang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Qining/glslang/teams","hooks_url":"https://api.github.com/repos/Qining/glslang/hooks","issue_events_url":"https://api.github.com/repos/Qining/glslang/issues/events{/number}","events_url":"https://api.github.com/repos/Qining/glslang/events","assignees_url":"https://api.github.com/repos/Qining/glslang/assignees{/user}","branches_url":"https://api.github.com/repos/Qining/glslang/branches{/branch}","tags_url":"https://api.github.com/repos/Qining/glslang/tags","blobs_url":"https://api.github.com/repos/Qining/glslang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Qining/glslang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Qining/glslang/git/refs{/sha}","trees_url":"https://api.github.com/repos/Qining/glslang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Qining/glslang/statuses/{sha}","languages_url":"https://api.github.com/repos/Qining/glslang/languages","stargazers_url":"https://api.github.com/repos/Qining/glslang/stargazers","contributors_url":"https://api.github.com/repos/Qining/glslang/contributors","subscribers_url":"https://api.github.com/repos/Qining/glslang/subscribers","subscription_url":"https://api.github.com/repos/Qining/glslang/subscription","commits_url":"https://api.github.com/repos/Qining/glslang/commits{/sha}","git_commits_url":"https://api.github.com/repos/Qining/glslang/git/commits{/sha}","comments_url":"https://api.github.com/repos/Qining/glslang/comments{/number}","issue_comment_url":"https://api.github.com/repos/Qining/glslang/issues/comments{/number}","contents_url":"https://api.github.com/repos/Qining/glslang/contents/{+path}","compare_url":"https://api.github.com/repos/Qining/glslang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Qining/glslang/merges","archive_url":"https://api.github.com/repos/Qining/glslang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Qining/glslang/downloads","issues_url":"https://api.github.com/repos/Qining/glslang/issues{/number}","pulls_url":"https://api.github.com/repos/Qining/glslang/pulls{/number}","milestones_url":"https://api.github.com/repos/Qining/glslang/milestones{/number}","notifications_url":"https://api.github.com/repos/Qining/glslang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Qining/glslang/labels{/name}","releases_url":"https://api.github.com/repos/Qining/glslang/releases{/id}","deployments_url":"https://api.github.com/repos/Qining/glslang/deployments","created_at":"2016-03-08T02:35:58Z","updated_at":"2016-03-08T02:36:02Z","pushed_at":"2016-03-30T20:25:56Z","git_url":"git://github.com/Qining/glslang.git","ssh_url":"git@github.com:Qining/glslang.git","clone_url":"https://github.com/Qining/glslang.git","svn_url":"https://github.com/Qining/glslang","homepage":null,"size":24786,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"KhronosGroup:master","ref":"master","sha":"c3869fee412a90c4eadea0bf936ab2530d2dff51","user":{"login":"KhronosGroup","id":1608701,"avatar_url":"https://avatars.githubusercontent.com/u/1608701?v=3","gravatar_id":"","url":"https://api.github.com/users/KhronosGroup","html_url":"https://github.com/KhronosGroup","followers_url":"https://api.github.com/users/KhronosGroup/followers","following_url":"https://api.github.com/users/KhronosGroup/following{/other_user}","gists_url":"https://api.github.com/users/KhronosGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/KhronosGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KhronosGroup/subscriptions","organizations_url":"https://api.github.com/users/KhronosGroup/orgs","repos_url":"https://api.github.com/users/KhronosGroup/repos","events_url":"https://api.github.com/users/KhronosGroup/events{/privacy}","received_events_url":"https://api.github.com/users/KhronosGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":38064932,"name":"glslang","full_name":"KhronosGroup/glslang","owner":{"login":"KhronosGroup","id":1608701,"avatar_url":"https://avatars.githubusercontent.com/u/1608701?v=3","gravatar_id":"","url":"https://api.github.com/users/KhronosGroup","html_url":"https://github.com/KhronosGroup","followers_url":"https://api.github.com/users/KhronosGroup/followers","following_url":"https://api.github.com/users/KhronosGroup/following{/other_user}","gists_url":"https://api.github.com/users/KhronosGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/KhronosGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KhronosGroup/subscriptions","organizations_url":"https://api.github.com/users/KhronosGroup/orgs","repos_url":"https://api.github.com/users/KhronosGroup/repos","events_url":"https://api.github.com/users/KhronosGroup/events{/privacy}","received_events_url":"https://api.github.com/users/KhronosGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/KhronosGroup/glslang","description":"Khronos reference front-end for GLSL and ESSL","fork":false,"url":"https://api.github.com/repos/KhronosGroup/glslang","forks_url":"https://api.github.com/repos/KhronosGroup/glslang/forks","keys_url":"https://api.github.com/repos/KhronosGroup/glslang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KhronosGroup/glslang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KhronosGroup/glslang/teams","hooks_url":"https://api.github.com/repos/KhronosGroup/glslang/hooks","issue_events_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/events{/number}","events_url":"https://api.github.com/repos/KhronosGroup/glslang/events","assignees_url":"https://api.github.com/repos/KhronosGroup/glslang/assignees{/user}","branches_url":"https://api.github.com/repos/KhronosGroup/glslang/branches{/branch}","tags_url":"https://api.github.com/repos/KhronosGroup/glslang/tags","blobs_url":"https://api.github.com/repos/KhronosGroup/glslang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KhronosGroup/glslang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KhronosGroup/glslang/git/refs{/sha}","trees_url":"https://api.github.com/repos/KhronosGroup/glslang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KhronosGroup/glslang/statuses/{sha}","languages_url":"https://api.github.com/repos/KhronosGroup/glslang/languages","stargazers_url":"https://api.github.com/repos/KhronosGroup/glslang/stargazers","contributors_url":"https://api.github.com/repos/KhronosGroup/glslang/contributors","subscribers_url":"https://api.github.com/repos/KhronosGroup/glslang/subscribers","subscription_url":"https://api.github.com/repos/KhronosGroup/glslang/subscription","commits_url":"https://api.github.com/repos/KhronosGroup/glslang/commits{/sha}","git_commits_url":"https://api.github.com/repos/KhronosGroup/glslang/git/commits{/sha}","comments_url":"https://api.github.com/repos/KhronosGroup/glslang/comments{/number}","issue_comment_url":"https://api.github.com/repos/KhronosGroup/glslang/issues/comments{/number}","contents_url":"https://api.github.com/repos/KhronosGroup/glslang/contents/{+path}","compare_url":"https://api.github.com/repos/KhronosGroup/glslang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KhronosGroup/glslang/merges","archive_url":"https://api.github.com/repos/KhronosGroup/glslang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KhronosGroup/glslang/downloads","issues_url":"https://api.github.com/repos/KhronosGroup/glslang/issues{/number}","pulls_url":"https://api.github.com/repos/KhronosGroup/glslang/pulls{/number}","milestones_url":"https://api.github.com/repos/KhronosGroup/glslang/milestones{/number}","notifications_url":"https://api.github.com/repos/KhronosGroup/glslang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KhronosGroup/glslang/labels{/name}","releases_url":"https://api.github.com/repos/KhronosGroup/glslang/releases{/id}","deployments_url":"https://api.github.com/repos/KhronosGroup/glslang/deployments","created_at":"2015-06-25T17:54:39Z","updated_at":"2016-03-31T16:02:18Z","pushed_at":"2016-03-31T14:32:00Z","git_url":"git://github.com/KhronosGroup/glslang.git","ssh_url":"git@github.com:KhronosGroup/glslang.git","clone_url":"https://github.com/KhronosGroup/glslang.git","svn_url":"https://github.com/KhronosGroup/glslang","homepage":null,"size":25742,"stargazers_count":239,"watchers_count":239,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":49,"forks":75,"open_issues":49,"watchers":239,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215"},"html":{"href":"https://github.com/KhronosGroup/glslang/pull/215"},"issue":{"href":"https://api.github.com/repos/KhronosGroup/glslang/issues/215"},"comments":{"href":"https://api.github.com/repos/KhronosGroup/glslang/issues/215/comments"},"review_comments":{"href":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215/comments"},"review_comment":{"href":"https://api.github.com/repos/KhronosGroup/glslang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/KhronosGroup/glslang/pulls/215/commits"},"statuses":{"href":"https://api.github.com/repos/KhronosGroup/glslang/statuses/135452061aca1346936aa7a28ebb138341052229"}}}}