Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e95eeb1

Browse files
committed
SpirvShader: Add relational ops for integers
Bug: b/127282157 Change-Id: Icaec924ef011b42069d157bec2d76ae5df3eea46 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26048 Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Ben Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
1 parent d69cdab commit e95eeb1

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/Pipeline/SpirvShader.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ namespace sw
231231
case spv::OpFSub:
232232
case spv::OpFDiv:
233233
case spv::OpUMod:
234+
case spv::OpIEqual:
235+
case spv::OpINotEqual:
236+
case spv::OpUGreaterThan:
237+
case spv::OpSGreaterThan:
238+
case spv::OpUGreaterThanEqual:
239+
case spv::OpSGreaterThanEqual:
240+
case spv::OpULessThan:
241+
case spv::OpSLessThan:
242+
case spv::OpULessThanEqual:
243+
case spv::OpSLessThanEqual:
234244
case spv::OpShiftRightLogical:
235245
case spv::OpShiftRightArithmetic:
236246
case spv::OpShiftLeftLogical:
@@ -918,6 +928,16 @@ namespace sw
918928
case spv::OpFSub:
919929
case spv::OpFDiv:
920930
case spv::OpUMod:
931+
case spv::OpIEqual:
932+
case spv::OpINotEqual:
933+
case spv::OpUGreaterThan:
934+
case spv::OpSGreaterThan:
935+
case spv::OpUGreaterThanEqual:
936+
case spv::OpSGreaterThanEqual:
937+
case spv::OpULessThan:
938+
case spv::OpSLessThan:
939+
case spv::OpULessThanEqual:
940+
case spv::OpSLessThanEqual:
921941
case spv::OpShiftRightLogical:
922942
case spv::OpShiftRightArithmetic:
923943
case spv::OpShiftLeftLogical:
@@ -1269,6 +1289,36 @@ namespace sw
12691289
case spv::OpUMod:
12701290
dst.emplace(i, As<SIMD::Float>(As<SIMD::UInt>(lhs) % As<SIMD::UInt>(rhs)));
12711291
break;
1292+
case spv::OpIEqual:
1293+
dst.emplace(i, As<SIMD::Float>(CmpEQ(As<SIMD::Int>(lhs), As<SIMD::Int>(rhs))));
1294+
break;
1295+
case spv::OpINotEqual:
1296+
dst.emplace(i, As<SIMD::Float>(CmpNEQ(As<SIMD::Int>(lhs), As<SIMD::Int>(rhs))));
1297+
break;
1298+
case spv::OpUGreaterThan:
1299+
dst.emplace(i, As<SIMD::Float>(CmpGT(As<SIMD::UInt>(lhs), As<SIMD::UInt>(rhs))));
1300+
break;
1301+
case spv::OpSGreaterThan:
1302+
dst.emplace(i, As<SIMD::Float>(CmpGT(As<SIMD::Int>(lhs), As<SIMD::Int>(rhs))));
1303+
break;
1304+
case spv::OpUGreaterThanEqual:
1305+
dst.emplace(i, As<SIMD::Float>(CmpGE(As<SIMD::UInt>(lhs), As<SIMD::UInt>(rhs))));
1306+
break;
1307+
case spv::OpSGreaterThanEqual:
1308+
dst.emplace(i, As<SIMD::Float>(CmpGE(As<SIMD::Int>(lhs), As<SIMD::Int>(rhs))));
1309+
break;
1310+
case spv::OpULessThan:
1311+
dst.emplace(i, As<SIMD::Float>(CmpLT(As<SIMD::UInt>(lhs), As<SIMD::UInt>(rhs))));
1312+
break;
1313+
case spv::OpSLessThan:
1314+
dst.emplace(i, As<SIMD::Float>(CmpLT(As<SIMD::Int>(lhs), As<SIMD::Int>(rhs))));
1315+
break;
1316+
case spv::OpULessThanEqual:
1317+
dst.emplace(i, As<SIMD::Float>(CmpLE(As<SIMD::UInt>(lhs), As<SIMD::UInt>(rhs))));
1318+
break;
1319+
case spv::OpSLessThanEqual:
1320+
dst.emplace(i, As<SIMD::Float>(CmpLE(As<SIMD::Int>(lhs), As<SIMD::Int>(rhs))));
1321+
break;
12721322
case spv::OpFAdd:
12731323
dst.emplace(i, lhs + rhs);
12741324
break;

src/Reactor/Reactor.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,8 @@ namespace rr
18471847
RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y);
18481848
RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y);
18491849
RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y);
1850+
inline RValue<Int4> CmpGT(RValue<Int4> x, RValue<Int4> y) { return CmpNLE(x, y); }
1851+
inline RValue<Int4> CmpGE(RValue<Int4> x, RValue<Int4> y) { return CmpNLT(x, y); }
18501852
RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y);
18511853
RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y);
18521854
RValue<Int4> RoundInt(RValue<Float4> cast);
@@ -1929,6 +1931,8 @@ namespace rr
19291931
RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y);
19301932
RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y);
19311933
RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y);
1934+
inline RValue<UInt4> CmpGT(RValue<UInt4> x, RValue<UInt4> y) { return CmpNLE(x, y); }
1935+
inline RValue<UInt4> CmpGE(RValue<UInt4> x, RValue<UInt4> y) { return CmpNLT(x, y); }
19321936
RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y);
19331937
RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y);
19341938
RValue<UInt4> MulHigh(RValue<UInt4> x, RValue<UInt4> y);

0 commit comments

Comments
 (0)