From c7d3656ddeb415e24e4b763ee55bc4ba6d445b21 Mon Sep 17 00:00:00 2001 From: Rex Xu Date: Wed, 27 Apr 2016 08:15:37 +0800 Subject: [PATCH] SPV: Use OpLogicalEqual/OpLogicalNotEqual for boolean type comparison. --- SPIRV/GlslangToSpv.cpp | 5 +++++ Test/baseResults/spv.Operations.frag.out | 4 ++-- Test/baseResults/spv.bool.vert.out | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 9d4dc590..07ed51cf 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -2633,6 +2633,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv { bool isUnsigned = typeProxy == glslang::EbtUint; bool isFloat = typeProxy == glslang::EbtFloat || typeProxy == glslang::EbtDouble; + bool isBool = typeProxy == glslang::EbtBool; spv::Op binOp = spv::OpNop; bool needMatchingVectors = true; // for non-matrix ops, would a scalar need to smear to match a vector? @@ -2820,6 +2821,8 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv case glslang::EOpVectorEqual: if (isFloat) binOp = spv::OpFOrdEqual; + else if (isBool) + binOp = spv::OpLogicalEqual; else binOp = spv::OpIEqual; break; @@ -2827,6 +2830,8 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, spv case glslang::EOpVectorNotEqual: if (isFloat) binOp = spv::OpFOrdNotEqual; + else if (isBool) + binOp = spv::OpLogicalNotEqual; else binOp = spv::OpINotEqual; break; diff --git a/Test/baseResults/spv.Operations.frag.out b/Test/baseResults/spv.Operations.frag.out index a5863729..f8b666d5 100755 --- a/Test/baseResults/spv.Operations.frag.out +++ b/Test/baseResults/spv.Operations.frag.out @@ -470,7 +470,7 @@ Linked fragment stage: 339: Label 341: 179(bvec4) Load 181(ub41) 343: 179(bvec4) Load 342(ub42) - 344: 179(bvec4) IEqual 341 343 + 344: 179(bvec4) LogicalEqual 341 343 345: 178(bool) Any 344 Branch 340 340: Label @@ -482,7 +482,7 @@ Linked fragment stage: 348: Label 350: 179(bvec4) Load 181(ub41) 351: 179(bvec4) Load 342(ub42) - 352: 179(bvec4) INotEqual 350 351 + 352: 179(bvec4) LogicalNotEqual 350 351 353: 178(bool) Any 352 Branch 349 349: Label diff --git a/Test/baseResults/spv.bool.vert.out b/Test/baseResults/spv.bool.vert.out index f11fe398..b6960f94 100644 --- a/Test/baseResults/spv.bool.vert.out +++ b/Test/baseResults/spv.bool.vert.out @@ -91,6 +91,6 @@ Linked vertex stage: 9(b): 7(ptr) FunctionParameter 11: Label 12: 6(bool) Load 9(b) - 14: 6(bool) INotEqual 12 13 + 14: 6(bool) LogicalNotEqual 12 13 ReturnValue 14 FunctionEnd