external/swiftshader
Revision | e6f65d9265e764034c1c078bd67db893cd565cac (tree) |
---|---|
Time | 2020-04-10 02:52:05 |
Author | Nicolas Capens <capn@goog...> |
Commiter | Nicolas Capens |
Rename GenericValue to Operand
Bug: b/129000021
Change-Id: I0000fc5e65bde87e9037400002db37cb6d50960d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43688
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
@@ -2009,7 +2009,7 @@ SpirvShader::EmitResult SpirvShader::EmitCompositeConstruct(InsnIterator insn, E | ||
2009 | 2009 | Object::ID srcObjectId = insn.word(3u + i); |
2010 | 2010 | auto &srcObject = getObject(srcObjectId); |
2011 | 2011 | auto &srcObjectTy = getType(srcObject.type); |
2012 | - GenericValue srcObjectAccess(this, state, srcObjectId); | |
2012 | + Operand srcObjectAccess(this, state, srcObjectId); | |
2013 | 2013 | |
2014 | 2014 | for(auto j = 0u; j < srcObjectTy.sizeInComponents; j++) |
2015 | 2015 | { |
@@ -2029,8 +2029,8 @@ SpirvShader::EmitResult SpirvShader::EmitCompositeInsert(InsnIterator insn, Emit | ||
2029 | 2029 | auto &newPartObjectTy = getType(newPartObject.type); |
2030 | 2030 | auto firstNewComponent = WalkLiteralAccessChain(resultTypeId, insn.wordCount() - 5, insn.wordPointer(5)); |
2031 | 2031 | |
2032 | - GenericValue srcObjectAccess(this, state, insn.word(4)); | |
2033 | - GenericValue newPartObjectAccess(this, state, insn.word(3)); | |
2032 | + Operand srcObjectAccess(this, state, insn.word(4)); | |
2033 | + Operand newPartObjectAccess(this, state, insn.word(3)); | |
2034 | 2034 | |
2035 | 2035 | // old components before |
2036 | 2036 | for(auto i = 0u; i < firstNewComponent; i++) |
@@ -2059,7 +2059,7 @@ SpirvShader::EmitResult SpirvShader::EmitCompositeExtract(InsnIterator insn, Emi | ||
2059 | 2059 | Type::ID compositeTypeId = compositeObject.definition.word(1); |
2060 | 2060 | auto firstComponent = WalkLiteralAccessChain(compositeTypeId, insn.wordCount() - 4, insn.wordPointer(4)); |
2061 | 2061 | |
2062 | - GenericValue compositeObjectAccess(this, state, insn.word(3)); | |
2062 | + Operand compositeObjectAccess(this, state, insn.word(3)); | |
2063 | 2063 | for(auto i = 0u; i < type.sizeInComponents; i++) |
2064 | 2064 | { |
2065 | 2065 | dst.move(i, compositeObjectAccess.Float(firstComponent + i)); |
@@ -2077,8 +2077,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorShuffle(InsnIterator insn, EmitSt | ||
2077 | 2077 | // half type are all independent. |
2078 | 2078 | auto &firstHalfType = getType(getObject(insn.word(3)).type); |
2079 | 2079 | |
2080 | - GenericValue firstHalfAccess(this, state, insn.word(3)); | |
2081 | - GenericValue secondHalfAccess(this, state, insn.word(4)); | |
2080 | + Operand firstHalfAccess(this, state, insn.word(3)); | |
2081 | + Operand secondHalfAccess(this, state, insn.word(4)); | |
2082 | 2082 | |
2083 | 2083 | for(auto i = 0u; i < type.sizeInComponents; i++) |
2084 | 2084 | { |
@@ -2108,8 +2108,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorExtractDynamic(InsnIterator insn, | ||
2108 | 2108 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
2109 | 2109 | auto &srcType = getType(getObject(insn.word(3)).type); |
2110 | 2110 | |
2111 | - GenericValue src(this, state, insn.word(3)); | |
2112 | - GenericValue index(this, state, insn.word(4)); | |
2111 | + Operand src(this, state, insn.word(3)); | |
2112 | + Operand index(this, state, insn.word(4)); | |
2113 | 2113 | |
2114 | 2114 | SIMD::UInt v = SIMD::UInt(0); |
2115 | 2115 |
@@ -2127,9 +2127,9 @@ SpirvShader::EmitResult SpirvShader::EmitVectorInsertDynamic(InsnIterator insn, | ||
2127 | 2127 | auto &type = getType(insn.word(1)); |
2128 | 2128 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
2129 | 2129 | |
2130 | - GenericValue src(this, state, insn.word(3)); | |
2131 | - GenericValue component(this, state, insn.word(4)); | |
2132 | - GenericValue index(this, state, insn.word(5)); | |
2130 | + Operand src(this, state, insn.word(3)); | |
2131 | + Operand component(this, state, insn.word(4)); | |
2132 | + Operand index(this, state, insn.word(5)); | |
2133 | 2133 | |
2134 | 2134 | for(auto i = 0u; i < type.sizeInComponents; i++) |
2135 | 2135 | { |
@@ -2143,10 +2143,10 @@ SpirvShader::EmitResult SpirvShader::EmitSelect(InsnIterator insn, EmitState *st | ||
2143 | 2143 | { |
2144 | 2144 | auto &type = getType(insn.word(1)); |
2145 | 2145 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
2146 | - auto cond = GenericValue(this, state, insn.word(3)); | |
2146 | + auto cond = Operand(this, state, insn.word(3)); | |
2147 | 2147 | auto condIsScalar = (getType(cond.type).sizeInComponents == 1); |
2148 | - auto lhs = GenericValue(this, state, insn.word(4)); | |
2149 | - auto rhs = GenericValue(this, state, insn.word(5)); | |
2148 | + auto lhs = Operand(this, state, insn.word(4)); | |
2149 | + auto rhs = Operand(this, state, insn.word(5)); | |
2150 | 2150 | |
2151 | 2151 | for(auto i = 0u; i < type.sizeInComponents; i++) |
2152 | 2152 | { |
@@ -2163,7 +2163,7 @@ SpirvShader::EmitResult SpirvShader::EmitAny(InsnIterator insn, EmitState *state | ||
2163 | 2163 | ASSERT(type.sizeInComponents == 1); |
2164 | 2164 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
2165 | 2165 | auto &srcType = getType(getObject(insn.word(3)).type); |
2166 | - auto src = GenericValue(this, state, insn.word(3)); | |
2166 | + auto src = Operand(this, state, insn.word(3)); | |
2167 | 2167 | |
2168 | 2168 | SIMD::UInt result = src.UInt(0); |
2169 | 2169 |
@@ -2182,7 +2182,7 @@ SpirvShader::EmitResult SpirvShader::EmitAll(InsnIterator insn, EmitState *state | ||
2182 | 2182 | ASSERT(type.sizeInComponents == 1); |
2183 | 2183 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
2184 | 2184 | auto &srcType = getType(getObject(insn.word(3)).type); |
2185 | - auto src = GenericValue(this, state, insn.word(3)); | |
2185 | + auto src = Operand(this, state, insn.word(3)); | |
2186 | 2186 | |
2187 | 2187 | SIMD::UInt result = src.UInt(0); |
2188 | 2188 |
@@ -2203,7 +2203,7 @@ SpirvShader::EmitResult SpirvShader::EmitAtomicOp(InsnIterator insn, EmitState * | ||
2203 | 2203 | auto memorySemantics = static_cast<spv::MemorySemanticsMask>(getObject(semanticsId).constantValue[0]); |
2204 | 2204 | auto memoryOrder = MemoryOrder(memorySemantics); |
2205 | 2205 | // Where no value is provided (increment/decrement) use an implicit value of 1. |
2206 | - auto value = (insn.wordCount() == 7) ? GenericValue(this, state, insn.word(6)).UInt(0) : RValue<SIMD::UInt>(1); | |
2206 | + auto value = (insn.wordCount() == 7) ? Operand(this, state, insn.word(6)).UInt(0) : RValue<SIMD::UInt>(1); | |
2207 | 2207 | auto &dst = state->createIntermediate(resultId, resultType.sizeInComponents); |
2208 | 2208 | auto ptr = state->getPointer(insn.word(3)); |
2209 | 2209 | auto ptrOffsets = ptr.offsets(); |
@@ -2274,8 +2274,8 @@ SpirvShader::EmitResult SpirvShader::EmitAtomicCompareExchange(InsnIterator insn | ||
2274 | 2274 | auto memorySemanticsUnequal = static_cast<spv::MemorySemanticsMask>(getObject(insn.word(6)).constantValue[0]); |
2275 | 2275 | auto memoryOrderUnequal = MemoryOrder(memorySemanticsUnequal); |
2276 | 2276 | |
2277 | - auto value = GenericValue(this, state, insn.word(7)); | |
2278 | - auto comparator = GenericValue(this, state, insn.word(8)); | |
2277 | + auto value = Operand(this, state, insn.word(7)); | |
2278 | + auto comparator = Operand(this, state, insn.word(8)); | |
2279 | 2279 | auto &dst = state->createIntermediate(resultId, resultType.sizeInComponents); |
2280 | 2280 | auto ptr = state->getPointer(insn.word(3)); |
2281 | 2281 | auto ptrOffsets = ptr.offsets(); |
@@ -2302,7 +2302,7 @@ SpirvShader::EmitResult SpirvShader::EmitCopyObject(InsnIterator insn, EmitState | ||
2302 | 2302 | { |
2303 | 2303 | auto ty = getType(insn.word(1)); |
2304 | 2304 | auto &dst = state->createIntermediate(insn.word(2), ty.sizeInComponents); |
2305 | - auto src = GenericValue(this, state, insn.word(3)); | |
2305 | + auto src = Operand(this, state, insn.word(3)); | |
2306 | 2306 | for(uint32_t i = 0; i < ty.sizeInComponents; i++) |
2307 | 2307 | { |
2308 | 2308 | dst.move(i, src.Int(i)); |
@@ -2428,7 +2428,7 @@ VkShaderStageFlagBits SpirvShader::executionModelToStage(spv::ExecutionModel mod | ||
2428 | 2428 | } |
2429 | 2429 | } |
2430 | 2430 | |
2431 | -SpirvShader::GenericValue::GenericValue(SpirvShader const *shader, EmitState const *state, SpirvShader::Object::ID objId) | |
2431 | +SpirvShader::Operand::Operand(SpirvShader const *shader, EmitState const *state, SpirvShader::Object::ID objId) | |
2432 | 2432 | : obj(shader->getObject(objId)) |
2433 | 2433 | , intermediate(obj.kind == SpirvShader::Object::Kind::Intermediate ? &state->getIntermediate(objId) : nullptr) |
2434 | 2434 | , type(obj.type) |
@@ -961,13 +961,13 @@ private: | ||
961 | 961 | // Constants are transparently widened to per-lane values in operator[]. |
962 | 962 | // This is appropriate in most cases -- if we're not going to do something |
963 | 963 | // significantly different based on whether the value is uniform across lanes. |
964 | - class GenericValue | |
964 | + class Operand | |
965 | 965 | { |
966 | 966 | SpirvShader::Object const &obj; |
967 | 967 | Intermediate const *intermediate; |
968 | 968 | |
969 | 969 | public: |
970 | - GenericValue(SpirvShader const *shader, EmitState const *state, SpirvShader::Object::ID objId); | |
970 | + Operand(SpirvShader const *shader, EmitState const *state, SpirvShader::Object::ID objId); | |
971 | 971 | |
972 | 972 | RValue<SIMD::Float> Float(uint32_t i) const |
973 | 973 | { |
@@ -1136,7 +1136,7 @@ private: | ||
1136 | 1136 | EmitResult EmitArrayLength(InsnIterator insn, EmitState *state) const; |
1137 | 1137 | |
1138 | 1138 | void GetImageDimensions(EmitState const *state, Type const &resultTy, Object::ID imageId, Object::ID lodId, Intermediate &dst) const; |
1139 | - SIMD::Pointer GetTexelAddress(EmitState const *state, SIMD::Pointer base, GenericValue const &coordinate, Type const &imageType, Pointer<Byte> descriptor, int texelSize, Object::ID sampleId, bool useStencilAspect) const; | |
1139 | + SIMD::Pointer GetTexelAddress(EmitState const *state, SIMD::Pointer base, Operand const &coordinate, Type const &imageType, Pointer<Byte> descriptor, int texelSize, Object::ID sampleId, bool useStencilAspect) const; | |
1140 | 1140 | uint32_t GetConstScalarInt(Object::ID id) const; |
1141 | 1141 | void EvalSpecConstantOp(InsnIterator insn); |
1142 | 1142 | void EvalSpecConstantUnaryOp(InsnIterator insn); |
@@ -1168,7 +1168,7 @@ private: | ||
1168 | 1168 | static bool IsStatement(spv::Op op); |
1169 | 1169 | |
1170 | 1170 | // Helper as we often need to take dot products as part of doing other things. |
1171 | - SIMD::Float Dot(unsigned numComponents, GenericValue const &x, GenericValue const &y) const; | |
1171 | + SIMD::Float Dot(unsigned numComponents, Operand const &x, Operand const &y) const; | |
1172 | 1172 | |
1173 | 1173 | // Splits x into a floating-point significand in the range [0.5, 1.0) |
1174 | 1174 | // and an integral exponent of two, such that: |
@@ -24,8 +24,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorTimesScalar(InsnIterator insn, Em | ||
24 | 24 | { |
25 | 25 | auto &type = getType(insn.word(1)); |
26 | 26 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
27 | - auto lhs = GenericValue(this, state, insn.word(3)); | |
28 | - auto rhs = GenericValue(this, state, insn.word(4)); | |
27 | + auto lhs = Operand(this, state, insn.word(3)); | |
28 | + auto rhs = Operand(this, state, insn.word(4)); | |
29 | 29 | |
30 | 30 | for(auto i = 0u; i < type.sizeInComponents; i++) |
31 | 31 | { |
@@ -39,8 +39,8 @@ SpirvShader::EmitResult SpirvShader::EmitMatrixTimesVector(InsnIterator insn, Em | ||
39 | 39 | { |
40 | 40 | auto &type = getType(insn.word(1)); |
41 | 41 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
42 | - auto lhs = GenericValue(this, state, insn.word(3)); | |
43 | - auto rhs = GenericValue(this, state, insn.word(4)); | |
42 | + auto lhs = Operand(this, state, insn.word(3)); | |
43 | + auto rhs = Operand(this, state, insn.word(4)); | |
44 | 44 | auto rhsType = getType(rhs.type); |
45 | 45 | |
46 | 46 | for(auto i = 0u; i < type.sizeInComponents; i++) |
@@ -60,8 +60,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorTimesMatrix(InsnIterator insn, Em | ||
60 | 60 | { |
61 | 61 | auto &type = getType(insn.word(1)); |
62 | 62 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
63 | - auto lhs = GenericValue(this, state, insn.word(3)); | |
64 | - auto rhs = GenericValue(this, state, insn.word(4)); | |
63 | + auto lhs = Operand(this, state, insn.word(3)); | |
64 | + auto rhs = Operand(this, state, insn.word(4)); | |
65 | 65 | auto lhsType = getType(lhs.type); |
66 | 66 | |
67 | 67 | for(auto i = 0u; i < type.sizeInComponents; i++) |
@@ -81,8 +81,8 @@ SpirvShader::EmitResult SpirvShader::EmitMatrixTimesMatrix(InsnIterator insn, Em | ||
81 | 81 | { |
82 | 82 | auto &type = getType(insn.word(1)); |
83 | 83 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
84 | - auto lhs = GenericValue(this, state, insn.word(3)); | |
85 | - auto rhs = GenericValue(this, state, insn.word(4)); | |
84 | + auto lhs = Operand(this, state, insn.word(3)); | |
85 | + auto rhs = Operand(this, state, insn.word(4)); | |
86 | 86 | |
87 | 87 | auto numColumns = type.definition.word(3); |
88 | 88 | auto numRows = getType(type.definition.word(2)).definition.word(3); |
@@ -108,8 +108,8 @@ SpirvShader::EmitResult SpirvShader::EmitOuterProduct(InsnIterator insn, EmitSta | ||
108 | 108 | { |
109 | 109 | auto &type = getType(insn.word(1)); |
110 | 110 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
111 | - auto lhs = GenericValue(this, state, insn.word(3)); | |
112 | - auto rhs = GenericValue(this, state, insn.word(4)); | |
111 | + auto lhs = Operand(this, state, insn.word(3)); | |
112 | + auto rhs = Operand(this, state, insn.word(4)); | |
113 | 113 | auto &lhsType = getType(lhs.type); |
114 | 114 | auto &rhsType = getType(rhs.type); |
115 | 115 |
@@ -137,7 +137,7 @@ SpirvShader::EmitResult SpirvShader::EmitTranspose(InsnIterator insn, EmitState | ||
137 | 137 | { |
138 | 138 | auto &type = getType(insn.word(1)); |
139 | 139 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
140 | - auto mat = GenericValue(this, state, insn.word(3)); | |
140 | + auto mat = Operand(this, state, insn.word(3)); | |
141 | 141 | |
142 | 142 | auto numCols = type.definition.word(3); |
143 | 143 | auto numRows = getType(type.definition.word(2)).sizeInComponents; |
@@ -157,7 +157,7 @@ SpirvShader::EmitResult SpirvShader::EmitUnaryOp(InsnIterator insn, EmitState *s | ||
157 | 157 | { |
158 | 158 | auto &type = getType(insn.word(1)); |
159 | 159 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
160 | - auto src = GenericValue(this, state, insn.word(3)); | |
160 | + auto src = Operand(this, state, insn.word(3)); | |
161 | 161 | |
162 | 162 | for(auto i = 0u; i < type.sizeInComponents; i++) |
163 | 163 | { |
@@ -169,9 +169,9 @@ SpirvShader::EmitResult SpirvShader::EmitUnaryOp(InsnIterator insn, EmitState *s | ||
169 | 169 | break; |
170 | 170 | case spv::OpBitFieldInsert: |
171 | 171 | { |
172 | - auto insert = GenericValue(this, state, insn.word(4)).UInt(i); | |
173 | - auto offset = GenericValue(this, state, insn.word(5)).UInt(0); | |
174 | - auto count = GenericValue(this, state, insn.word(6)).UInt(0); | |
172 | + auto insert = Operand(this, state, insn.word(4)).UInt(i); | |
173 | + auto offset = Operand(this, state, insn.word(5)).UInt(0); | |
174 | + auto count = Operand(this, state, insn.word(6)).UInt(0); | |
175 | 175 | auto one = SIMD::UInt(1); |
176 | 176 | auto v = src.UInt(i); |
177 | 177 | auto mask = Bitmask32(offset + count) ^ Bitmask32(offset); |
@@ -181,8 +181,8 @@ SpirvShader::EmitResult SpirvShader::EmitUnaryOp(InsnIterator insn, EmitState *s | ||
181 | 181 | case spv::OpBitFieldSExtract: |
182 | 182 | case spv::OpBitFieldUExtract: |
183 | 183 | { |
184 | - auto offset = GenericValue(this, state, insn.word(4)).UInt(0); | |
185 | - auto count = GenericValue(this, state, insn.word(5)).UInt(0); | |
184 | + auto offset = Operand(this, state, insn.word(4)).UInt(0); | |
185 | + auto count = Operand(this, state, insn.word(5)).UInt(0); | |
186 | 186 | auto one = SIMD::UInt(1); |
187 | 187 | auto v = src.UInt(i); |
188 | 188 | SIMD::UInt out = (v >> offset) & Bitmask32(count); |
@@ -320,8 +320,8 @@ SpirvShader::EmitResult SpirvShader::EmitBinaryOp(InsnIterator insn, EmitState * | ||
320 | 320 | auto &type = getType(insn.word(1)); |
321 | 321 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
322 | 322 | auto &lhsType = getType(getObject(insn.word(3)).type); |
323 | - auto lhs = GenericValue(this, state, insn.word(3)); | |
324 | - auto rhs = GenericValue(this, state, insn.word(4)); | |
323 | + auto lhs = Operand(this, state, insn.word(3)); | |
324 | + auto rhs = Operand(this, state, insn.word(4)); | |
325 | 325 | |
326 | 326 | for(auto i = 0u; i < lhsType.sizeInComponents; i++) |
327 | 327 | { |
@@ -524,14 +524,14 @@ SpirvShader::EmitResult SpirvShader::EmitDot(InsnIterator insn, EmitState *state | ||
524 | 524 | ASSERT(type.sizeInComponents == 1); |
525 | 525 | auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents); |
526 | 526 | auto &lhsType = getType(getObject(insn.word(3)).type); |
527 | - auto lhs = GenericValue(this, state, insn.word(3)); | |
528 | - auto rhs = GenericValue(this, state, insn.word(4)); | |
527 | + auto lhs = Operand(this, state, insn.word(3)); | |
528 | + auto rhs = Operand(this, state, insn.word(4)); | |
529 | 529 | |
530 | 530 | dst.move(0, Dot(lhsType.sizeInComponents, lhs, rhs)); |
531 | 531 | return EmitResult::Continue; |
532 | 532 | } |
533 | 533 | |
534 | -SIMD::Float SpirvShader::Dot(unsigned numComponents, GenericValue const &x, GenericValue const &y) const | |
534 | +SIMD::Float SpirvShader::Dot(unsigned numComponents, Operand const &x, Operand const &y) const | |
535 | 535 | { |
536 | 536 | SIMD::Float d = x.Float(0) * y.Float(0); |
537 | 537 |
@@ -495,7 +495,7 @@ SpirvShader::EmitResult SpirvShader::EmitBranchConditional(InsnIterator insn, Em | ||
495 | 495 | auto trueBlockId = Block::ID(block.branchInstruction.word(2)); |
496 | 496 | auto falseBlockId = Block::ID(block.branchInstruction.word(3)); |
497 | 497 | |
498 | - auto cond = GenericValue(this, state, condId); | |
498 | + auto cond = Operand(this, state, condId); | |
499 | 499 | ASSERT_MSG(getType(cond.type).sizeInComponents == 1, "Condition must be a Boolean type scalar"); |
500 | 500 | |
501 | 501 | // TODO: Optimize for case where all lanes take same path. |
@@ -514,7 +514,7 @@ SpirvShader::EmitResult SpirvShader::EmitSwitch(InsnIterator insn, EmitState *st | ||
514 | 514 | |
515 | 515 | auto selId = Object::ID(block.branchInstruction.word(1)); |
516 | 516 | |
517 | - auto sel = GenericValue(this, state, selId); | |
517 | + auto sel = Operand(this, state, selId); | |
518 | 518 | ASSERT_MSG(getType(sel.type).sizeInComponents == 1, "Selector must be a scalar"); |
519 | 519 | |
520 | 520 | auto numCases = (block.branchInstruction.wordCount() - 3) / 2; |
@@ -678,7 +678,7 @@ void SpirvShader::StorePhi(Block::ID currentBlock, InsnIterator insn, EmitState | ||
678 | 678 | } |
679 | 679 | |
680 | 680 | auto mask = GetActiveLaneMaskEdge(state, blockId, currentBlock); |
681 | - auto in = GenericValue(this, state, varId); | |
681 | + auto in = Operand(this, state, varId); | |
682 | 682 | |
683 | 683 | for(uint32_t i = 0; i < type.sizeInComponents; i++) |
684 | 684 | { |
@@ -1203,7 +1203,7 @@ void SpirvShader::Impl::Debugger::exposeVariable( | ||
1203 | 1203 | case Object::Kind::Constant: |
1204 | 1204 | case Object::Kind::Intermediate: |
1205 | 1205 | { |
1206 | - auto val = GenericValue(shader, state, id).Int(wordOffset); | |
1206 | + auto val = Operand(shader, state, id).Int(wordOffset); | |
1207 | 1207 | |
1208 | 1208 | switch(ty->encoding) |
1209 | 1209 | { |
@@ -1287,7 +1287,7 @@ void SpirvShader::Impl::Debugger::exposeVariable( | ||
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | // No debug type information. Derive from SPIR-V. |
1290 | - GenericValue val(shader, state, id); | |
1290 | + Operand val(shader, state, id); | |
1291 | 1291 | switch(shader->getType(val.type).opcode()) |
1292 | 1292 | { |
1293 | 1293 | case spv::OpTypeInt: |
@@ -35,7 +35,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
35 | 35 | { |
36 | 36 | case GLSLstd450FAbs: |
37 | 37 | { |
38 | - auto src = GenericValue(this, state, insn.word(5)); | |
38 | + auto src = Operand(this, state, insn.word(5)); | |
39 | 39 | for(auto i = 0u; i < type.sizeInComponents; i++) |
40 | 40 | { |
41 | 41 | dst.move(i, Abs(src.Float(i))); |
@@ -44,7 +44,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
44 | 44 | } |
45 | 45 | case GLSLstd450SAbs: |
46 | 46 | { |
47 | - auto src = GenericValue(this, state, insn.word(5)); | |
47 | + auto src = Operand(this, state, insn.word(5)); | |
48 | 48 | for(auto i = 0u; i < type.sizeInComponents; i++) |
49 | 49 | { |
50 | 50 | dst.move(i, Abs(src.Int(i))); |
@@ -53,8 +53,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
53 | 53 | } |
54 | 54 | case GLSLstd450Cross: |
55 | 55 | { |
56 | - auto lhs = GenericValue(this, state, insn.word(5)); | |
57 | - auto rhs = GenericValue(this, state, insn.word(6)); | |
56 | + auto lhs = Operand(this, state, insn.word(5)); | |
57 | + auto rhs = Operand(this, state, insn.word(6)); | |
58 | 58 | dst.move(0, lhs.Float(1) * rhs.Float(2) - rhs.Float(1) * lhs.Float(2)); |
59 | 59 | dst.move(1, lhs.Float(2) * rhs.Float(0) - rhs.Float(2) * lhs.Float(0)); |
60 | 60 | dst.move(2, lhs.Float(0) * rhs.Float(1) - rhs.Float(0) * lhs.Float(1)); |
@@ -62,7 +62,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
62 | 62 | } |
63 | 63 | case GLSLstd450Floor: |
64 | 64 | { |
65 | - auto src = GenericValue(this, state, insn.word(5)); | |
65 | + auto src = Operand(this, state, insn.word(5)); | |
66 | 66 | for(auto i = 0u; i < type.sizeInComponents; i++) |
67 | 67 | { |
68 | 68 | dst.move(i, Floor(src.Float(i))); |
@@ -71,7 +71,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
71 | 71 | } |
72 | 72 | case GLSLstd450Trunc: |
73 | 73 | { |
74 | - auto src = GenericValue(this, state, insn.word(5)); | |
74 | + auto src = Operand(this, state, insn.word(5)); | |
75 | 75 | for(auto i = 0u; i < type.sizeInComponents; i++) |
76 | 76 | { |
77 | 77 | dst.move(i, Trunc(src.Float(i))); |
@@ -80,7 +80,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
80 | 80 | } |
81 | 81 | case GLSLstd450Ceil: |
82 | 82 | { |
83 | - auto src = GenericValue(this, state, insn.word(5)); | |
83 | + auto src = Operand(this, state, insn.word(5)); | |
84 | 84 | for(auto i = 0u; i < type.sizeInComponents; i++) |
85 | 85 | { |
86 | 86 | dst.move(i, Ceil(src.Float(i))); |
@@ -89,7 +89,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
89 | 89 | } |
90 | 90 | case GLSLstd450Fract: |
91 | 91 | { |
92 | - auto src = GenericValue(this, state, insn.word(5)); | |
92 | + auto src = Operand(this, state, insn.word(5)); | |
93 | 93 | for(auto i = 0u; i < type.sizeInComponents; i++) |
94 | 94 | { |
95 | 95 | dst.move(i, Frac(src.Float(i))); |
@@ -98,7 +98,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
98 | 98 | } |
99 | 99 | case GLSLstd450Round: |
100 | 100 | { |
101 | - auto src = GenericValue(this, state, insn.word(5)); | |
101 | + auto src = Operand(this, state, insn.word(5)); | |
102 | 102 | for(auto i = 0u; i < type.sizeInComponents; i++) |
103 | 103 | { |
104 | 104 | dst.move(i, Round(src.Float(i))); |
@@ -107,7 +107,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
107 | 107 | } |
108 | 108 | case GLSLstd450RoundEven: |
109 | 109 | { |
110 | - auto src = GenericValue(this, state, insn.word(5)); | |
110 | + auto src = Operand(this, state, insn.word(5)); | |
111 | 111 | for(auto i = 0u; i < type.sizeInComponents; i++) |
112 | 112 | { |
113 | 113 | auto x = Round(src.Float(i)); |
@@ -119,8 +119,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
119 | 119 | } |
120 | 120 | case GLSLstd450FMin: |
121 | 121 | { |
122 | - auto lhs = GenericValue(this, state, insn.word(5)); | |
123 | - auto rhs = GenericValue(this, state, insn.word(6)); | |
122 | + auto lhs = Operand(this, state, insn.word(5)); | |
123 | + auto rhs = Operand(this, state, insn.word(6)); | |
124 | 124 | for(auto i = 0u; i < type.sizeInComponents; i++) |
125 | 125 | { |
126 | 126 | dst.move(i, Min(lhs.Float(i), rhs.Float(i))); |
@@ -129,8 +129,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
129 | 129 | } |
130 | 130 | case GLSLstd450FMax: |
131 | 131 | { |
132 | - auto lhs = GenericValue(this, state, insn.word(5)); | |
133 | - auto rhs = GenericValue(this, state, insn.word(6)); | |
132 | + auto lhs = Operand(this, state, insn.word(5)); | |
133 | + auto rhs = Operand(this, state, insn.word(6)); | |
134 | 134 | for(auto i = 0u; i < type.sizeInComponents; i++) |
135 | 135 | { |
136 | 136 | dst.move(i, Max(lhs.Float(i), rhs.Float(i))); |
@@ -139,8 +139,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
139 | 139 | } |
140 | 140 | case GLSLstd450SMin: |
141 | 141 | { |
142 | - auto lhs = GenericValue(this, state, insn.word(5)); | |
143 | - auto rhs = GenericValue(this, state, insn.word(6)); | |
142 | + auto lhs = Operand(this, state, insn.word(5)); | |
143 | + auto rhs = Operand(this, state, insn.word(6)); | |
144 | 144 | for(auto i = 0u; i < type.sizeInComponents; i++) |
145 | 145 | { |
146 | 146 | dst.move(i, Min(lhs.Int(i), rhs.Int(i))); |
@@ -149,8 +149,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
149 | 149 | } |
150 | 150 | case GLSLstd450SMax: |
151 | 151 | { |
152 | - auto lhs = GenericValue(this, state, insn.word(5)); | |
153 | - auto rhs = GenericValue(this, state, insn.word(6)); | |
152 | + auto lhs = Operand(this, state, insn.word(5)); | |
153 | + auto rhs = Operand(this, state, insn.word(6)); | |
154 | 154 | for(auto i = 0u; i < type.sizeInComponents; i++) |
155 | 155 | { |
156 | 156 | dst.move(i, Max(lhs.Int(i), rhs.Int(i))); |
@@ -159,8 +159,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
159 | 159 | } |
160 | 160 | case GLSLstd450UMin: |
161 | 161 | { |
162 | - auto lhs = GenericValue(this, state, insn.word(5)); | |
163 | - auto rhs = GenericValue(this, state, insn.word(6)); | |
162 | + auto lhs = Operand(this, state, insn.word(5)); | |
163 | + auto rhs = Operand(this, state, insn.word(6)); | |
164 | 164 | for(auto i = 0u; i < type.sizeInComponents; i++) |
165 | 165 | { |
166 | 166 | dst.move(i, Min(lhs.UInt(i), rhs.UInt(i))); |
@@ -169,8 +169,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
169 | 169 | } |
170 | 170 | case GLSLstd450UMax: |
171 | 171 | { |
172 | - auto lhs = GenericValue(this, state, insn.word(5)); | |
173 | - auto rhs = GenericValue(this, state, insn.word(6)); | |
172 | + auto lhs = Operand(this, state, insn.word(5)); | |
173 | + auto rhs = Operand(this, state, insn.word(6)); | |
174 | 174 | for(auto i = 0u; i < type.sizeInComponents; i++) |
175 | 175 | { |
176 | 176 | dst.move(i, Max(lhs.UInt(i), rhs.UInt(i))); |
@@ -179,8 +179,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
179 | 179 | } |
180 | 180 | case GLSLstd450Step: |
181 | 181 | { |
182 | - auto edge = GenericValue(this, state, insn.word(5)); | |
183 | - auto x = GenericValue(this, state, insn.word(6)); | |
182 | + auto edge = Operand(this, state, insn.word(5)); | |
183 | + auto x = Operand(this, state, insn.word(6)); | |
184 | 184 | for(auto i = 0u; i < type.sizeInComponents; i++) |
185 | 185 | { |
186 | 186 | dst.move(i, CmpNLT(x.Float(i), edge.Float(i)) & As<SIMD::Int>(SIMD::Float(1.0f))); |
@@ -189,9 +189,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
189 | 189 | } |
190 | 190 | case GLSLstd450SmoothStep: |
191 | 191 | { |
192 | - auto edge0 = GenericValue(this, state, insn.word(5)); | |
193 | - auto edge1 = GenericValue(this, state, insn.word(6)); | |
194 | - auto x = GenericValue(this, state, insn.word(7)); | |
192 | + auto edge0 = Operand(this, state, insn.word(5)); | |
193 | + auto edge1 = Operand(this, state, insn.word(6)); | |
194 | + auto x = Operand(this, state, insn.word(7)); | |
195 | 195 | for(auto i = 0u; i < type.sizeInComponents; i++) |
196 | 196 | { |
197 | 197 | auto tx = Min(Max((x.Float(i) - edge0.Float(i)) / |
@@ -204,9 +204,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
204 | 204 | } |
205 | 205 | case GLSLstd450FMix: |
206 | 206 | { |
207 | - auto x = GenericValue(this, state, insn.word(5)); | |
208 | - auto y = GenericValue(this, state, insn.word(6)); | |
209 | - auto a = GenericValue(this, state, insn.word(7)); | |
207 | + auto x = Operand(this, state, insn.word(5)); | |
208 | + auto y = Operand(this, state, insn.word(6)); | |
209 | + auto a = Operand(this, state, insn.word(7)); | |
210 | 210 | for(auto i = 0u; i < type.sizeInComponents; i++) |
211 | 211 | { |
212 | 212 | dst.move(i, a.Float(i) * (y.Float(i) - x.Float(i)) + x.Float(i)); |
@@ -215,9 +215,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
215 | 215 | } |
216 | 216 | case GLSLstd450FClamp: |
217 | 217 | { |
218 | - auto x = GenericValue(this, state, insn.word(5)); | |
219 | - auto minVal = GenericValue(this, state, insn.word(6)); | |
220 | - auto maxVal = GenericValue(this, state, insn.word(7)); | |
218 | + auto x = Operand(this, state, insn.word(5)); | |
219 | + auto minVal = Operand(this, state, insn.word(6)); | |
220 | + auto maxVal = Operand(this, state, insn.word(7)); | |
221 | 221 | for(auto i = 0u; i < type.sizeInComponents; i++) |
222 | 222 | { |
223 | 223 | dst.move(i, Min(Max(x.Float(i), minVal.Float(i)), maxVal.Float(i))); |
@@ -226,9 +226,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
226 | 226 | } |
227 | 227 | case GLSLstd450SClamp: |
228 | 228 | { |
229 | - auto x = GenericValue(this, state, insn.word(5)); | |
230 | - auto minVal = GenericValue(this, state, insn.word(6)); | |
231 | - auto maxVal = GenericValue(this, state, insn.word(7)); | |
229 | + auto x = Operand(this, state, insn.word(5)); | |
230 | + auto minVal = Operand(this, state, insn.word(6)); | |
231 | + auto maxVal = Operand(this, state, insn.word(7)); | |
232 | 232 | for(auto i = 0u; i < type.sizeInComponents; i++) |
233 | 233 | { |
234 | 234 | dst.move(i, Min(Max(x.Int(i), minVal.Int(i)), maxVal.Int(i))); |
@@ -237,9 +237,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
237 | 237 | } |
238 | 238 | case GLSLstd450UClamp: |
239 | 239 | { |
240 | - auto x = GenericValue(this, state, insn.word(5)); | |
241 | - auto minVal = GenericValue(this, state, insn.word(6)); | |
242 | - auto maxVal = GenericValue(this, state, insn.word(7)); | |
240 | + auto x = Operand(this, state, insn.word(5)); | |
241 | + auto minVal = Operand(this, state, insn.word(6)); | |
242 | + auto maxVal = Operand(this, state, insn.word(7)); | |
243 | 243 | for(auto i = 0u; i < type.sizeInComponents; i++) |
244 | 244 | { |
245 | 245 | dst.move(i, Min(Max(x.UInt(i), minVal.UInt(i)), maxVal.UInt(i))); |
@@ -248,7 +248,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
248 | 248 | } |
249 | 249 | case GLSLstd450FSign: |
250 | 250 | { |
251 | - auto src = GenericValue(this, state, insn.word(5)); | |
251 | + auto src = Operand(this, state, insn.word(5)); | |
252 | 252 | for(auto i = 0u; i < type.sizeInComponents; i++) |
253 | 253 | { |
254 | 254 | auto neg = As<SIMD::Int>(CmpLT(src.Float(i), SIMD::Float(-0.0f))) & As<SIMD::Int>(SIMD::Float(-1.0f)); |
@@ -259,7 +259,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
259 | 259 | } |
260 | 260 | case GLSLstd450SSign: |
261 | 261 | { |
262 | - auto src = GenericValue(this, state, insn.word(5)); | |
262 | + auto src = Operand(this, state, insn.word(5)); | |
263 | 263 | for(auto i = 0u; i < type.sizeInComponents; i++) |
264 | 264 | { |
265 | 265 | auto neg = CmpLT(src.Int(i), SIMD::Int(0)) & SIMD::Int(-1); |
@@ -270,8 +270,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
270 | 270 | } |
271 | 271 | case GLSLstd450Reflect: |
272 | 272 | { |
273 | - auto I = GenericValue(this, state, insn.word(5)); | |
274 | - auto N = GenericValue(this, state, insn.word(6)); | |
273 | + auto I = Operand(this, state, insn.word(5)); | |
274 | + auto N = Operand(this, state, insn.word(6)); | |
275 | 275 | |
276 | 276 | SIMD::Float d = Dot(type.sizeInComponents, I, N); |
277 | 277 |
@@ -283,9 +283,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
283 | 283 | } |
284 | 284 | case GLSLstd450Refract: |
285 | 285 | { |
286 | - auto I = GenericValue(this, state, insn.word(5)); | |
287 | - auto N = GenericValue(this, state, insn.word(6)); | |
288 | - auto eta = GenericValue(this, state, insn.word(7)); | |
286 | + auto I = Operand(this, state, insn.word(5)); | |
287 | + auto N = Operand(this, state, insn.word(6)); | |
288 | + auto eta = Operand(this, state, insn.word(7)); | |
289 | 289 | |
290 | 290 | SIMD::Float d = Dot(type.sizeInComponents, I, N); |
291 | 291 | SIMD::Float k = SIMD::Float(1.0f) - eta.Float(0) * eta.Float(0) * (SIMD::Float(1.0f) - d * d); |
@@ -300,9 +300,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
300 | 300 | } |
301 | 301 | case GLSLstd450FaceForward: |
302 | 302 | { |
303 | - auto N = GenericValue(this, state, insn.word(5)); | |
304 | - auto I = GenericValue(this, state, insn.word(6)); | |
305 | - auto Nref = GenericValue(this, state, insn.word(7)); | |
303 | + auto N = Operand(this, state, insn.word(5)); | |
304 | + auto I = Operand(this, state, insn.word(6)); | |
305 | + auto Nref = Operand(this, state, insn.word(7)); | |
306 | 306 | |
307 | 307 | SIMD::Float d = Dot(type.sizeInComponents, I, Nref); |
308 | 308 | SIMD::Int neg = CmpLT(d, SIMD::Float(0.0f)); |
@@ -316,7 +316,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
316 | 316 | } |
317 | 317 | case GLSLstd450Length: |
318 | 318 | { |
319 | - auto x = GenericValue(this, state, insn.word(5)); | |
319 | + auto x = Operand(this, state, insn.word(5)); | |
320 | 320 | SIMD::Float d = Dot(getType(getObject(insn.word(5)).type).sizeInComponents, x, x); |
321 | 321 | |
322 | 322 | dst.move(0, Sqrt(d)); |
@@ -324,7 +324,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
324 | 324 | } |
325 | 325 | case GLSLstd450Normalize: |
326 | 326 | { |
327 | - auto x = GenericValue(this, state, insn.word(5)); | |
327 | + auto x = Operand(this, state, insn.word(5)); | |
328 | 328 | SIMD::Float d = Dot(getType(getObject(insn.word(5)).type).sizeInComponents, x, x); |
329 | 329 | SIMD::Float invLength = SIMD::Float(1.0f) / Sqrt(d); |
330 | 330 |
@@ -336,8 +336,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
336 | 336 | } |
337 | 337 | case GLSLstd450Distance: |
338 | 338 | { |
339 | - auto p0 = GenericValue(this, state, insn.word(5)); | |
340 | - auto p1 = GenericValue(this, state, insn.word(6)); | |
339 | + auto p0 = Operand(this, state, insn.word(5)); | |
340 | + auto p1 = Operand(this, state, insn.word(6)); | |
341 | 341 | auto p0Type = getType(p0.type); |
342 | 342 | |
343 | 343 | // sqrt(dot(p0-p1, p0-p1)) |
@@ -353,7 +353,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
353 | 353 | } |
354 | 354 | case GLSLstd450Modf: |
355 | 355 | { |
356 | - auto val = GenericValue(this, state, insn.word(5)); | |
356 | + auto val = Operand(this, state, insn.word(5)); | |
357 | 357 | auto ptrId = Object::ID(insn.word(6)); |
358 | 358 | auto ptrTy = getType(getObject(ptrId).type); |
359 | 359 | auto ptr = GetPointerToData(ptrId, 0, state); |
@@ -377,7 +377,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
377 | 377 | } |
378 | 378 | case GLSLstd450ModfStruct: |
379 | 379 | { |
380 | - auto val = GenericValue(this, state, insn.word(5)); | |
380 | + auto val = Operand(this, state, insn.word(5)); | |
381 | 381 | auto valTy = getType(val.type); |
382 | 382 | |
383 | 383 | for(auto i = 0u; i < valTy.sizeInComponents; i++) |
@@ -391,7 +391,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
391 | 391 | } |
392 | 392 | case GLSLstd450PackSnorm4x8: |
393 | 393 | { |
394 | - auto val = GenericValue(this, state, insn.word(5)); | |
394 | + auto val = Operand(this, state, insn.word(5)); | |
395 | 395 | dst.move(0, (SIMD::Int(Round(Min(Max(val.Float(0), SIMD::Float(-1.0f)), SIMD::Float(1.0f)) * SIMD::Float(127.0f))) & |
396 | 396 | SIMD::Int(0xFF)) | |
397 | 397 | ((SIMD::Int(Round(Min(Max(val.Float(1), SIMD::Float(-1.0f)), SIMD::Float(1.0f)) * SIMD::Float(127.0f))) & |
@@ -407,7 +407,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
407 | 407 | } |
408 | 408 | case GLSLstd450PackUnorm4x8: |
409 | 409 | { |
410 | - auto val = GenericValue(this, state, insn.word(5)); | |
410 | + auto val = Operand(this, state, insn.word(5)); | |
411 | 411 | dst.move(0, (SIMD::UInt(Round(Min(Max(val.Float(0), SIMD::Float(0.0f)), SIMD::Float(1.0f)) * SIMD::Float(255.0f)))) | |
412 | 412 | ((SIMD::UInt(Round(Min(Max(val.Float(1), SIMD::Float(0.0f)), SIMD::Float(1.0f)) * SIMD::Float(255.0f)))) << 8) | |
413 | 413 | ((SIMD::UInt(Round(Min(Max(val.Float(2), SIMD::Float(0.0f)), SIMD::Float(1.0f)) * SIMD::Float(255.0f)))) << 16) | |
@@ -416,7 +416,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
416 | 416 | } |
417 | 417 | case GLSLstd450PackSnorm2x16: |
418 | 418 | { |
419 | - auto val = GenericValue(this, state, insn.word(5)); | |
419 | + auto val = Operand(this, state, insn.word(5)); | |
420 | 420 | dst.move(0, (SIMD::Int(Round(Min(Max(val.Float(0), SIMD::Float(-1.0f)), SIMD::Float(1.0f)) * SIMD::Float(32767.0f))) & |
421 | 421 | SIMD::Int(0xFFFF)) | |
422 | 422 | ((SIMD::Int(Round(Min(Max(val.Float(1), SIMD::Float(-1.0f)), SIMD::Float(1.0f)) * SIMD::Float(32767.0f))) & |
@@ -426,7 +426,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
426 | 426 | } |
427 | 427 | case GLSLstd450PackUnorm2x16: |
428 | 428 | { |
429 | - auto val = GenericValue(this, state, insn.word(5)); | |
429 | + auto val = Operand(this, state, insn.word(5)); | |
430 | 430 | dst.move(0, (SIMD::UInt(Round(Min(Max(val.Float(0), SIMD::Float(0.0f)), SIMD::Float(1.0f)) * SIMD::Float(65535.0f))) & |
431 | 431 | SIMD::UInt(0xFFFF)) | |
432 | 432 | ((SIMD::UInt(Round(Min(Max(val.Float(1), SIMD::Float(0.0f)), SIMD::Float(1.0f)) * SIMD::Float(65535.0f))) & |
@@ -436,13 +436,13 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
436 | 436 | } |
437 | 437 | case GLSLstd450PackHalf2x16: |
438 | 438 | { |
439 | - auto val = GenericValue(this, state, insn.word(5)); | |
439 | + auto val = Operand(this, state, insn.word(5)); | |
440 | 440 | dst.move(0, floatToHalfBits(val.UInt(0), false) | floatToHalfBits(val.UInt(1), true)); |
441 | 441 | break; |
442 | 442 | } |
443 | 443 | case GLSLstd450UnpackSnorm4x8: |
444 | 444 | { |
445 | - auto val = GenericValue(this, state, insn.word(5)); | |
445 | + auto val = Operand(this, state, insn.word(5)); | |
446 | 446 | dst.move(0, Min(Max(SIMD::Float(((val.Int(0) << 24) & SIMD::Int(0xFF000000))) * SIMD::Float(1.0f / float(0x7f000000)), SIMD::Float(-1.0f)), SIMD::Float(1.0f))); |
447 | 447 | dst.move(1, Min(Max(SIMD::Float(((val.Int(0) << 16) & SIMD::Int(0xFF000000))) * SIMD::Float(1.0f / float(0x7f000000)), SIMD::Float(-1.0f)), SIMD::Float(1.0f))); |
448 | 448 | dst.move(2, Min(Max(SIMD::Float(((val.Int(0) << 8) & SIMD::Int(0xFF000000))) * SIMD::Float(1.0f / float(0x7f000000)), SIMD::Float(-1.0f)), SIMD::Float(1.0f))); |
@@ -451,7 +451,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
451 | 451 | } |
452 | 452 | case GLSLstd450UnpackUnorm4x8: |
453 | 453 | { |
454 | - auto val = GenericValue(this, state, insn.word(5)); | |
454 | + auto val = Operand(this, state, insn.word(5)); | |
455 | 455 | dst.move(0, SIMD::Float((val.UInt(0) & SIMD::UInt(0xFF))) * SIMD::Float(1.0f / 255.f)); |
456 | 456 | dst.move(1, SIMD::Float(((val.UInt(0) >> 8) & SIMD::UInt(0xFF))) * SIMD::Float(1.0f / 255.f)); |
457 | 457 | dst.move(2, SIMD::Float(((val.UInt(0) >> 16) & SIMD::UInt(0xFF))) * SIMD::Float(1.0f / 255.f)); |
@@ -460,7 +460,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
460 | 460 | } |
461 | 461 | case GLSLstd450UnpackSnorm2x16: |
462 | 462 | { |
463 | - auto val = GenericValue(this, state, insn.word(5)); | |
463 | + auto val = Operand(this, state, insn.word(5)); | |
464 | 464 | // clamp(f / 32767.0, -1.0, 1.0) |
465 | 465 | dst.move(0, Min(Max(SIMD::Float(As<SIMD::Int>((val.UInt(0) & SIMD::UInt(0x0000FFFF)) << 16)) * |
466 | 466 | SIMD::Float(1.0f / float(0x7FFF0000)), |
@@ -473,7 +473,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
473 | 473 | } |
474 | 474 | case GLSLstd450UnpackUnorm2x16: |
475 | 475 | { |
476 | - auto val = GenericValue(this, state, insn.word(5)); | |
476 | + auto val = Operand(this, state, insn.word(5)); | |
477 | 477 | // f / 65535.0 |
478 | 478 | dst.move(0, SIMD::Float((val.UInt(0) & SIMD::UInt(0x0000FFFF)) << 16) * SIMD::Float(1.0f / float(0xFFFF0000))); |
479 | 479 | dst.move(1, SIMD::Float(val.UInt(0) & SIMD::UInt(0xFFFF0000)) * SIMD::Float(1.0f / float(0xFFFF0000))); |
@@ -481,16 +481,16 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
481 | 481 | } |
482 | 482 | case GLSLstd450UnpackHalf2x16: |
483 | 483 | { |
484 | - auto val = GenericValue(this, state, insn.word(5)); | |
484 | + auto val = Operand(this, state, insn.word(5)); | |
485 | 485 | dst.move(0, halfToFloatBits(val.UInt(0) & SIMD::UInt(0x0000FFFF))); |
486 | 486 | dst.move(1, halfToFloatBits((val.UInt(0) & SIMD::UInt(0xFFFF0000)) >> 16)); |
487 | 487 | break; |
488 | 488 | } |
489 | 489 | case GLSLstd450Fma: |
490 | 490 | { |
491 | - auto a = GenericValue(this, state, insn.word(5)); | |
492 | - auto b = GenericValue(this, state, insn.word(6)); | |
493 | - auto c = GenericValue(this, state, insn.word(7)); | |
491 | + auto a = Operand(this, state, insn.word(5)); | |
492 | + auto b = Operand(this, state, insn.word(6)); | |
493 | + auto c = Operand(this, state, insn.word(7)); | |
494 | 494 | for(auto i = 0u; i < type.sizeInComponents; i++) |
495 | 495 | { |
496 | 496 | dst.move(i, FMA(a.Float(i), b.Float(i), c.Float(i))); |
@@ -499,7 +499,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
499 | 499 | } |
500 | 500 | case GLSLstd450Frexp: |
501 | 501 | { |
502 | - auto val = GenericValue(this, state, insn.word(5)); | |
502 | + auto val = Operand(this, state, insn.word(5)); | |
503 | 503 | auto ptrId = Object::ID(insn.word(6)); |
504 | 504 | auto ptrTy = getType(getObject(ptrId).type); |
505 | 505 | auto ptr = GetPointerToData(ptrId, 0, state); |
@@ -526,7 +526,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
526 | 526 | } |
527 | 527 | case GLSLstd450FrexpStruct: |
528 | 528 | { |
529 | - auto val = GenericValue(this, state, insn.word(5)); | |
529 | + auto val = Operand(this, state, insn.word(5)); | |
530 | 530 | auto numComponents = getType(val.type).sizeInComponents; |
531 | 531 | for(auto i = 0u; i < numComponents; i++) |
532 | 532 | { |
@@ -538,8 +538,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
538 | 538 | } |
539 | 539 | case GLSLstd450Ldexp: |
540 | 540 | { |
541 | - auto significand = GenericValue(this, state, insn.word(5)); | |
542 | - auto exponent = GenericValue(this, state, insn.word(6)); | |
541 | + auto significand = Operand(this, state, insn.word(5)); | |
542 | + auto exponent = Operand(this, state, insn.word(6)); | |
543 | 543 | for(auto i = 0u; i < type.sizeInComponents; i++) |
544 | 544 | { |
545 | 545 | // Assumes IEEE 754 |
@@ -572,7 +572,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
572 | 572 | } |
573 | 573 | case GLSLstd450Radians: |
574 | 574 | { |
575 | - auto degrees = GenericValue(this, state, insn.word(5)); | |
575 | + auto degrees = Operand(this, state, insn.word(5)); | |
576 | 576 | for(auto i = 0u; i < type.sizeInComponents; i++) |
577 | 577 | { |
578 | 578 | dst.move(i, degrees.Float(i) * SIMD::Float(PI / 180.0f)); |
@@ -581,7 +581,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
581 | 581 | } |
582 | 582 | case GLSLstd450Degrees: |
583 | 583 | { |
584 | - auto radians = GenericValue(this, state, insn.word(5)); | |
584 | + auto radians = Operand(this, state, insn.word(5)); | |
585 | 585 | for(auto i = 0u; i < type.sizeInComponents; i++) |
586 | 586 | { |
587 | 587 | dst.move(i, radians.Float(i) * SIMD::Float(180.0f / PI)); |
@@ -590,7 +590,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
590 | 590 | } |
591 | 591 | case GLSLstd450Sin: |
592 | 592 | { |
593 | - auto radians = GenericValue(this, state, insn.word(5)); | |
593 | + auto radians = Operand(this, state, insn.word(5)); | |
594 | 594 | for(auto i = 0u; i < type.sizeInComponents; i++) |
595 | 595 | { |
596 | 596 | dst.move(i, Sin(radians.Float(i))); |
@@ -599,7 +599,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
599 | 599 | } |
600 | 600 | case GLSLstd450Cos: |
601 | 601 | { |
602 | - auto radians = GenericValue(this, state, insn.word(5)); | |
602 | + auto radians = Operand(this, state, insn.word(5)); | |
603 | 603 | for(auto i = 0u; i < type.sizeInComponents; i++) |
604 | 604 | { |
605 | 605 | dst.move(i, Cos(radians.Float(i))); |
@@ -608,7 +608,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
608 | 608 | } |
609 | 609 | case GLSLstd450Tan: |
610 | 610 | { |
611 | - auto radians = GenericValue(this, state, insn.word(5)); | |
611 | + auto radians = Operand(this, state, insn.word(5)); | |
612 | 612 | for(auto i = 0u; i < type.sizeInComponents; i++) |
613 | 613 | { |
614 | 614 | dst.move(i, Tan(radians.Float(i))); |
@@ -617,7 +617,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
617 | 617 | } |
618 | 618 | case GLSLstd450Asin: |
619 | 619 | { |
620 | - auto val = GenericValue(this, state, insn.word(5)); | |
620 | + auto val = Operand(this, state, insn.word(5)); | |
621 | 621 | for(auto i = 0u; i < type.sizeInComponents; i++) |
622 | 622 | { |
623 | 623 | dst.move(i, Asin(val.Float(i))); |
@@ -626,7 +626,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
626 | 626 | } |
627 | 627 | case GLSLstd450Acos: |
628 | 628 | { |
629 | - auto val = GenericValue(this, state, insn.word(5)); | |
629 | + auto val = Operand(this, state, insn.word(5)); | |
630 | 630 | for(auto i = 0u; i < type.sizeInComponents; i++) |
631 | 631 | { |
632 | 632 | dst.move(i, Acos(val.Float(i))); |
@@ -635,7 +635,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
635 | 635 | } |
636 | 636 | case GLSLstd450Atan: |
637 | 637 | { |
638 | - auto val = GenericValue(this, state, insn.word(5)); | |
638 | + auto val = Operand(this, state, insn.word(5)); | |
639 | 639 | for(auto i = 0u; i < type.sizeInComponents; i++) |
640 | 640 | { |
641 | 641 | dst.move(i, Atan(val.Float(i))); |
@@ -644,7 +644,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
644 | 644 | } |
645 | 645 | case GLSLstd450Sinh: |
646 | 646 | { |
647 | - auto val = GenericValue(this, state, insn.word(5)); | |
647 | + auto val = Operand(this, state, insn.word(5)); | |
648 | 648 | for(auto i = 0u; i < type.sizeInComponents; i++) |
649 | 649 | { |
650 | 650 | dst.move(i, Sinh(val.Float(i))); |
@@ -653,7 +653,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
653 | 653 | } |
654 | 654 | case GLSLstd450Cosh: |
655 | 655 | { |
656 | - auto val = GenericValue(this, state, insn.word(5)); | |
656 | + auto val = Operand(this, state, insn.word(5)); | |
657 | 657 | for(auto i = 0u; i < type.sizeInComponents; i++) |
658 | 658 | { |
659 | 659 | dst.move(i, Cosh(val.Float(i))); |
@@ -662,7 +662,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
662 | 662 | } |
663 | 663 | case GLSLstd450Tanh: |
664 | 664 | { |
665 | - auto val = GenericValue(this, state, insn.word(5)); | |
665 | + auto val = Operand(this, state, insn.word(5)); | |
666 | 666 | for(auto i = 0u; i < type.sizeInComponents; i++) |
667 | 667 | { |
668 | 668 | dst.move(i, Tanh(val.Float(i))); |
@@ -671,7 +671,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
671 | 671 | } |
672 | 672 | case GLSLstd450Asinh: |
673 | 673 | { |
674 | - auto val = GenericValue(this, state, insn.word(5)); | |
674 | + auto val = Operand(this, state, insn.word(5)); | |
675 | 675 | for(auto i = 0u; i < type.sizeInComponents; i++) |
676 | 676 | { |
677 | 677 | dst.move(i, Asinh(val.Float(i))); |
@@ -680,7 +680,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
680 | 680 | } |
681 | 681 | case GLSLstd450Acosh: |
682 | 682 | { |
683 | - auto val = GenericValue(this, state, insn.word(5)); | |
683 | + auto val = Operand(this, state, insn.word(5)); | |
684 | 684 | for(auto i = 0u; i < type.sizeInComponents; i++) |
685 | 685 | { |
686 | 686 | dst.move(i, Acosh(val.Float(i))); |
@@ -689,7 +689,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
689 | 689 | } |
690 | 690 | case GLSLstd450Atanh: |
691 | 691 | { |
692 | - auto val = GenericValue(this, state, insn.word(5)); | |
692 | + auto val = Operand(this, state, insn.word(5)); | |
693 | 693 | for(auto i = 0u; i < type.sizeInComponents; i++) |
694 | 694 | { |
695 | 695 | dst.move(i, Atanh(val.Float(i))); |
@@ -698,8 +698,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
698 | 698 | } |
699 | 699 | case GLSLstd450Atan2: |
700 | 700 | { |
701 | - auto x = GenericValue(this, state, insn.word(5)); | |
702 | - auto y = GenericValue(this, state, insn.word(6)); | |
701 | + auto x = Operand(this, state, insn.word(5)); | |
702 | + auto y = Operand(this, state, insn.word(6)); | |
703 | 703 | for(auto i = 0u; i < type.sizeInComponents; i++) |
704 | 704 | { |
705 | 705 | dst.move(i, Atan2(x.Float(i), y.Float(i))); |
@@ -708,8 +708,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
708 | 708 | } |
709 | 709 | case GLSLstd450Pow: |
710 | 710 | { |
711 | - auto x = GenericValue(this, state, insn.word(5)); | |
712 | - auto y = GenericValue(this, state, insn.word(6)); | |
711 | + auto x = Operand(this, state, insn.word(5)); | |
712 | + auto y = Operand(this, state, insn.word(6)); | |
713 | 713 | for(auto i = 0u; i < type.sizeInComponents; i++) |
714 | 714 | { |
715 | 715 | dst.move(i, Pow(x.Float(i), y.Float(i))); |
@@ -718,7 +718,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
718 | 718 | } |
719 | 719 | case GLSLstd450Exp: |
720 | 720 | { |
721 | - auto val = GenericValue(this, state, insn.word(5)); | |
721 | + auto val = Operand(this, state, insn.word(5)); | |
722 | 722 | for(auto i = 0u; i < type.sizeInComponents; i++) |
723 | 723 | { |
724 | 724 | dst.move(i, Exp(val.Float(i))); |
@@ -727,7 +727,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
727 | 727 | } |
728 | 728 | case GLSLstd450Log: |
729 | 729 | { |
730 | - auto val = GenericValue(this, state, insn.word(5)); | |
730 | + auto val = Operand(this, state, insn.word(5)); | |
731 | 731 | for(auto i = 0u; i < type.sizeInComponents; i++) |
732 | 732 | { |
733 | 733 | dst.move(i, Log(val.Float(i))); |
@@ -736,7 +736,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
736 | 736 | } |
737 | 737 | case GLSLstd450Exp2: |
738 | 738 | { |
739 | - auto val = GenericValue(this, state, insn.word(5)); | |
739 | + auto val = Operand(this, state, insn.word(5)); | |
740 | 740 | for(auto i = 0u; i < type.sizeInComponents; i++) |
741 | 741 | { |
742 | 742 | dst.move(i, Exp2(val.Float(i))); |
@@ -745,7 +745,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
745 | 745 | } |
746 | 746 | case GLSLstd450Log2: |
747 | 747 | { |
748 | - auto val = GenericValue(this, state, insn.word(5)); | |
748 | + auto val = Operand(this, state, insn.word(5)); | |
749 | 749 | for(auto i = 0u; i < type.sizeInComponents; i++) |
750 | 750 | { |
751 | 751 | dst.move(i, Log2(val.Float(i))); |
@@ -754,7 +754,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
754 | 754 | } |
755 | 755 | case GLSLstd450Sqrt: |
756 | 756 | { |
757 | - auto val = GenericValue(this, state, insn.word(5)); | |
757 | + auto val = Operand(this, state, insn.word(5)); | |
758 | 758 | for(auto i = 0u; i < type.sizeInComponents; i++) |
759 | 759 | { |
760 | 760 | dst.move(i, Sqrt(val.Float(i))); |
@@ -763,7 +763,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
763 | 763 | } |
764 | 764 | case GLSLstd450InverseSqrt: |
765 | 765 | { |
766 | - auto val = GenericValue(this, state, insn.word(5)); | |
766 | + auto val = Operand(this, state, insn.word(5)); | |
767 | 767 | Decorations d; |
768 | 768 | ApplyDecorationsForId(&d, insn.word(5)); |
769 | 769 | if(d.RelaxedPrecision) |
@@ -784,7 +784,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
784 | 784 | } |
785 | 785 | case GLSLstd450Determinant: |
786 | 786 | { |
787 | - auto mat = GenericValue(this, state, insn.word(5)); | |
787 | + auto mat = Operand(this, state, insn.word(5)); | |
788 | 788 | auto numComponents = getType(mat.type).sizeInComponents; |
789 | 789 | switch(numComponents) |
790 | 790 | { |
@@ -813,7 +813,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
813 | 813 | } |
814 | 814 | case GLSLstd450MatrixInverse: |
815 | 815 | { |
816 | - auto mat = GenericValue(this, state, insn.word(5)); | |
816 | + auto mat = Operand(this, state, insn.word(5)); | |
817 | 817 | auto numComponents = getType(mat.type).sizeInComponents; |
818 | 818 | switch(numComponents) |
819 | 819 | { |
@@ -875,7 +875,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
875 | 875 | } |
876 | 876 | case GLSLstd450FindILsb: |
877 | 877 | { |
878 | - auto val = GenericValue(this, state, insn.word(5)); | |
878 | + auto val = Operand(this, state, insn.word(5)); | |
879 | 879 | for(auto i = 0u; i < type.sizeInComponents; i++) |
880 | 880 | { |
881 | 881 | auto v = val.UInt(i); |
@@ -885,7 +885,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
885 | 885 | } |
886 | 886 | case GLSLstd450FindSMsb: |
887 | 887 | { |
888 | - auto val = GenericValue(this, state, insn.word(5)); | |
888 | + auto val = Operand(this, state, insn.word(5)); | |
889 | 889 | for(auto i = 0u; i < type.sizeInComponents; i++) |
890 | 890 | { |
891 | 891 | auto v = val.UInt(i) ^ As<SIMD::UInt>(CmpLT(val.Int(i), SIMD::Int(0))); |
@@ -895,7 +895,7 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
895 | 895 | } |
896 | 896 | case GLSLstd450FindUMsb: |
897 | 897 | { |
898 | - auto val = GenericValue(this, state, insn.word(5)); | |
898 | + auto val = Operand(this, state, insn.word(5)); | |
899 | 899 | for(auto i = 0u; i < type.sizeInComponents; i++) |
900 | 900 | { |
901 | 901 | dst.move(i, SIMD::UInt(31) - Ctlz(val.UInt(i), false)); |
@@ -919,8 +919,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
919 | 919 | } |
920 | 920 | case GLSLstd450NMin: |
921 | 921 | { |
922 | - auto x = GenericValue(this, state, insn.word(5)); | |
923 | - auto y = GenericValue(this, state, insn.word(6)); | |
922 | + auto x = Operand(this, state, insn.word(5)); | |
923 | + auto y = Operand(this, state, insn.word(6)); | |
924 | 924 | for(auto i = 0u; i < type.sizeInComponents; i++) |
925 | 925 | { |
926 | 926 | dst.move(i, NMin(x.Float(i), y.Float(i))); |
@@ -929,8 +929,8 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
929 | 929 | } |
930 | 930 | case GLSLstd450NMax: |
931 | 931 | { |
932 | - auto x = GenericValue(this, state, insn.word(5)); | |
933 | - auto y = GenericValue(this, state, insn.word(6)); | |
932 | + auto x = Operand(this, state, insn.word(5)); | |
933 | + auto y = Operand(this, state, insn.word(6)); | |
934 | 934 | for(auto i = 0u; i < type.sizeInComponents; i++) |
935 | 935 | { |
936 | 936 | dst.move(i, NMax(x.Float(i), y.Float(i))); |
@@ -939,9 +939,9 @@ SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitSt | ||
939 | 939 | } |
940 | 940 | case GLSLstd450NClamp: |
941 | 941 | { |
942 | - auto x = GenericValue(this, state, insn.word(5)); | |
943 | - auto minVal = GenericValue(this, state, insn.word(6)); | |
944 | - auto maxVal = GenericValue(this, state, insn.word(7)); | |
942 | + auto x = Operand(this, state, insn.word(5)); | |
943 | + auto minVal = Operand(this, state, insn.word(6)); | |
944 | + auto maxVal = Operand(this, state, insn.word(7)); | |
945 | 945 | for(auto i = 0u; i < type.sizeInComponents; i++) |
946 | 946 | { |
947 | 947 | auto clamp = NMin(NMax(x.Float(i), minVal.Float(i)), maxVal.Float(i)); |
@@ -34,7 +34,7 @@ struct SpirvShader::Impl::Group | ||
34 | 34 | const I identityValue, |
35 | 35 | APPLY &&apply) |
36 | 36 | { |
37 | - SpirvShader::GenericValue value(shader, state, insn.word(5)); | |
37 | + SpirvShader::Operand value(shader, state, insn.word(5)); | |
38 | 38 | auto &type = shader->getType(SpirvShader::Type::ID(insn.word(1))); |
39 | 39 | for(auto i = 0u; i < type.sizeInComponents; i++) |
40 | 40 | { |
@@ -104,21 +104,21 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
104 | 104 | |
105 | 105 | case spv::OpGroupNonUniformAll: |
106 | 106 | { |
107 | - GenericValue predicate(this, state, insn.word(4)); | |
107 | + Operand predicate(this, state, insn.word(4)); | |
108 | 108 | dst.move(0, AndAll(predicate.UInt(0) | ~As<SIMD::UInt>(state->activeLaneMask()))); |
109 | 109 | break; |
110 | 110 | } |
111 | 111 | |
112 | 112 | case spv::OpGroupNonUniformAny: |
113 | 113 | { |
114 | - GenericValue predicate(this, state, insn.word(4)); | |
114 | + Operand predicate(this, state, insn.word(4)); | |
115 | 115 | dst.move(0, OrAll(predicate.UInt(0) & As<SIMD::UInt>(state->activeLaneMask()))); |
116 | 116 | break; |
117 | 117 | } |
118 | 118 | |
119 | 119 | case spv::OpGroupNonUniformAllEqual: |
120 | 120 | { |
121 | - GenericValue value(this, state, insn.word(4)); | |
121 | + Operand value(this, state, insn.word(4)); | |
122 | 122 | auto res = SIMD::UInt(0xffffffff); |
123 | 123 | SIMD::UInt active = As<SIMD::UInt>(state->activeLaneMask()); |
124 | 124 | SIMD::UInt inactive = ~active; |
@@ -140,7 +140,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
140 | 140 | { |
141 | 141 | auto valueId = Object::ID(insn.word(4)); |
142 | 142 | auto id = SIMD::Int(GetConstScalarInt(insn.word(5))); |
143 | - GenericValue value(this, state, valueId); | |
143 | + Operand value(this, state, valueId); | |
144 | 144 | auto mask = CmpEQ(id, SIMD::Int(0, 1, 2, 3)); |
145 | 145 | for(auto i = 0u; i < type.sizeInComponents; i++) |
146 | 146 | { |
@@ -152,7 +152,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
152 | 152 | case spv::OpGroupNonUniformBroadcastFirst: |
153 | 153 | { |
154 | 154 | auto valueId = Object::ID(insn.word(4)); |
155 | - GenericValue value(this, state, valueId); | |
155 | + Operand value(this, state, valueId); | |
156 | 156 | // Result is true only in the active invocation with the lowest id |
157 | 157 | // in the group, otherwise result is false. |
158 | 158 | SIMD::Int active = state->activeLaneMask(); |
@@ -170,7 +170,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
170 | 170 | case spv::OpGroupNonUniformBallot: |
171 | 171 | { |
172 | 172 | ASSERT(type.sizeInComponents == 4); |
173 | - GenericValue predicate(this, state, insn.word(4)); | |
173 | + Operand predicate(this, state, insn.word(4)); | |
174 | 174 | dst.move(0, SIMD::Int(SignMask(state->activeLaneMask() & predicate.Int(0)))); |
175 | 175 | dst.move(1, SIMD::Int(0)); |
176 | 176 | dst.move(2, SIMD::Int(0)); |
@@ -183,7 +183,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
183 | 183 | auto valueId = Object::ID(insn.word(4)); |
184 | 184 | ASSERT(type.sizeInComponents == 1); |
185 | 185 | ASSERT(getType(getObject(valueId).type).sizeInComponents == 4); |
186 | - GenericValue value(this, state, valueId); | |
186 | + Operand value(this, state, valueId); | |
187 | 187 | auto bit = (value.Int(0) >> SIMD::Int(0, 1, 2, 3)) & SIMD::Int(1); |
188 | 188 | dst.move(0, -bit); |
189 | 189 | break; |
@@ -196,8 +196,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
196 | 196 | ASSERT(type.sizeInComponents == 1); |
197 | 197 | ASSERT(getType(getObject(valueId).type).sizeInComponents == 4); |
198 | 198 | ASSERT(getType(getObject(indexId).type).sizeInComponents == 1); |
199 | - GenericValue value(this, state, valueId); | |
200 | - GenericValue index(this, state, indexId); | |
199 | + Operand value(this, state, valueId); | |
200 | + Operand index(this, state, indexId); | |
201 | 201 | auto vecIdx = index.Int(0) / SIMD::Int(32); |
202 | 202 | auto bitIdx = index.Int(0) & SIMD::Int(31); |
203 | 203 | auto bits = (value.Int(0) & CmpEQ(vecIdx, SIMD::Int(0))) | |
@@ -214,7 +214,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
214 | 214 | auto valueId = Object::ID(insn.word(5)); |
215 | 215 | ASSERT(type.sizeInComponents == 1); |
216 | 216 | ASSERT(getType(getObject(valueId).type).sizeInComponents == 4); |
217 | - GenericValue value(this, state, valueId); | |
217 | + Operand value(this, state, valueId); | |
218 | 218 | switch(operation) |
219 | 219 | { |
220 | 220 | case spv::GroupOperationReduce: |
@@ -237,7 +237,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
237 | 237 | auto valueId = Object::ID(insn.word(4)); |
238 | 238 | ASSERT(type.sizeInComponents == 1); |
239 | 239 | ASSERT(getType(getObject(valueId).type).sizeInComponents == 4); |
240 | - GenericValue value(this, state, valueId); | |
240 | + Operand value(this, state, valueId); | |
241 | 241 | dst.move(0, Cttz(value.UInt(0) & SIMD::UInt(15), true)); |
242 | 242 | break; |
243 | 243 | } |
@@ -247,15 +247,15 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
247 | 247 | auto valueId = Object::ID(insn.word(4)); |
248 | 248 | ASSERT(type.sizeInComponents == 1); |
249 | 249 | ASSERT(getType(getObject(valueId).type).sizeInComponents == 4); |
250 | - GenericValue value(this, state, valueId); | |
250 | + Operand value(this, state, valueId); | |
251 | 251 | dst.move(0, SIMD::UInt(31) - Ctlz(value.UInt(0) & SIMD::UInt(15), false)); |
252 | 252 | break; |
253 | 253 | } |
254 | 254 | |
255 | 255 | case spv::OpGroupNonUniformShuffle: |
256 | 256 | { |
257 | - GenericValue value(this, state, insn.word(4)); | |
258 | - GenericValue id(this, state, insn.word(5)); | |
257 | + Operand value(this, state, insn.word(4)); | |
258 | + Operand id(this, state, insn.word(5)); | |
259 | 259 | auto x = CmpEQ(SIMD::Int(0), id.Int(0)); |
260 | 260 | auto y = CmpEQ(SIMD::Int(1), id.Int(0)); |
261 | 261 | auto z = CmpEQ(SIMD::Int(2), id.Int(0)); |
@@ -270,8 +270,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
270 | 270 | |
271 | 271 | case spv::OpGroupNonUniformShuffleXor: |
272 | 272 | { |
273 | - GenericValue value(this, state, insn.word(4)); | |
274 | - GenericValue mask(this, state, insn.word(5)); | |
273 | + Operand value(this, state, insn.word(4)); | |
274 | + Operand mask(this, state, insn.word(5)); | |
275 | 275 | auto x = CmpEQ(SIMD::Int(0), SIMD::Int(0, 1, 2, 3) ^ mask.Int(0)); |
276 | 276 | auto y = CmpEQ(SIMD::Int(1), SIMD::Int(0, 1, 2, 3) ^ mask.Int(0)); |
277 | 277 | auto z = CmpEQ(SIMD::Int(2), SIMD::Int(0, 1, 2, 3) ^ mask.Int(0)); |
@@ -286,8 +286,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
286 | 286 | |
287 | 287 | case spv::OpGroupNonUniformShuffleUp: |
288 | 288 | { |
289 | - GenericValue value(this, state, insn.word(4)); | |
290 | - GenericValue delta(this, state, insn.word(5)); | |
289 | + Operand value(this, state, insn.word(4)); | |
290 | + Operand delta(this, state, insn.word(5)); | |
291 | 291 | auto d0 = CmpEQ(SIMD::Int(0), delta.Int(0)); |
292 | 292 | auto d1 = CmpEQ(SIMD::Int(1), delta.Int(0)); |
293 | 293 | auto d2 = CmpEQ(SIMD::Int(2), delta.Int(0)); |
@@ -302,8 +302,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit | ||
302 | 302 | |
303 | 303 | case spv::OpGroupNonUniformShuffleDown: |
304 | 304 | { |
305 | - GenericValue value(this, state, insn.word(4)); | |
306 | - GenericValue delta(this, state, insn.word(5)); | |
305 | + Operand value(this, state, insn.word(4)); | |
306 | + Operand delta(this, state, insn.word(5)); | |
307 | 307 | auto d0 = CmpEQ(SIMD::Int(0), delta.Int(0)); |
308 | 308 | auto d1 = CmpEQ(SIMD::Int(1), delta.Int(0)); |
309 | 309 | auto d2 = CmpEQ(SIMD::Int(2), delta.Int(0)); |
@@ -120,7 +120,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio | ||
120 | 120 | auto &sampledImage = getObject(sampledImageId); |
121 | 121 | auto samplerDescriptor = (sampledImage.opcode() == spv::OpSampledImage) ? state->getPointer(sampledImage.definition.word(4)).base : imageDescriptor; |
122 | 122 | |
123 | - auto coordinate = GenericValue(this, state, coordinateId); | |
123 | + auto coordinate = Operand(this, state, coordinateId); | |
124 | 124 | auto &coordinateType = getType(coordinate.type); |
125 | 125 | |
126 | 126 | Pointer<Byte> sampler = samplerDescriptor + OFFSET(vk::SampledImageDescriptor, sampler); // vk::Sampler* |
@@ -224,7 +224,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio | ||
224 | 224 | |
225 | 225 | if(instruction.isDref()) |
226 | 226 | { |
227 | - auto drefValue = GenericValue(this, state, insn.word(5)); | |
227 | + auto drefValue = Operand(this, state, insn.word(5)); | |
228 | 228 | |
229 | 229 | if(instruction.isProj()) |
230 | 230 | { |
@@ -240,14 +240,14 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio | ||
240 | 240 | |
241 | 241 | if(lodOrBias) |
242 | 242 | { |
243 | - auto lodValue = GenericValue(this, state, lodOrBiasId); | |
243 | + auto lodValue = Operand(this, state, lodOrBiasId); | |
244 | 244 | in[i] = lodValue.Float(0); |
245 | 245 | i++; |
246 | 246 | } |
247 | 247 | else if(grad) |
248 | 248 | { |
249 | - auto dxValue = GenericValue(this, state, gradDxId); | |
250 | - auto dyValue = GenericValue(this, state, gradDyId); | |
249 | + auto dxValue = Operand(this, state, gradDxId); | |
250 | + auto dyValue = Operand(this, state, gradDyId); | |
251 | 251 | auto &dxyType = getType(dxValue.type); |
252 | 252 | ASSERT(dxyType.sizeInComponents == getType(dyValue.type).sizeInComponents); |
253 | 253 |
@@ -274,7 +274,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio | ||
274 | 274 | |
275 | 275 | if(constOffset) |
276 | 276 | { |
277 | - auto offsetValue = GenericValue(this, state, offsetId); | |
277 | + auto offsetValue = Operand(this, state, offsetId); | |
278 | 278 | auto &offsetType = getType(offsetValue.type); |
279 | 279 | |
280 | 280 | instruction.offset = offsetType.sizeInComponents; |
@@ -287,7 +287,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio | ||
287 | 287 | |
288 | 288 | if(sample) |
289 | 289 | { |
290 | - auto sampleValue = GenericValue(this, state, sampleId); | |
290 | + auto sampleValue = Operand(this, state, sampleId); | |
291 | 291 | in[i] = As<SIMD::Float>(sampleValue.Int(0)); |
292 | 292 | } |
293 | 293 |
@@ -386,7 +386,7 @@ void SpirvShader::GetImageDimensions(EmitState const *state, Type const &resultT | ||
386 | 386 | std::vector<Int> out; |
387 | 387 | if(lodId != 0) |
388 | 388 | { |
389 | - auto lodVal = GenericValue(this, state, lodId); | |
389 | + auto lodVal = Operand(this, state, lodId); | |
390 | 390 | ASSERT(getType(lodVal.type).sizeInComponents == 1); |
391 | 391 | auto lod = lodVal.Int(0); |
392 | 392 | auto one = SIMD::Int(1); |
@@ -477,7 +477,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQuerySamples(InsnIterator insn, Em | ||
477 | 477 | return EmitResult::Continue; |
478 | 478 | } |
479 | 479 | |
480 | -SIMD::Pointer SpirvShader::GetTexelAddress(EmitState const *state, SIMD::Pointer ptr, GenericValue const &coordinate, Type const &imageType, Pointer<Byte> descriptor, int texelSize, Object::ID sampleId, bool useStencilAspect) const | |
480 | +SIMD::Pointer SpirvShader::GetTexelAddress(EmitState const *state, SIMD::Pointer ptr, Operand const &coordinate, Type const &imageType, Pointer<Byte> descriptor, int texelSize, Object::ID sampleId, bool useStencilAspect) const | |
481 | 481 | { |
482 | 482 | auto routine = state->routine; |
483 | 483 | bool isArrayed = imageType.definition.word(5) != 0; |
@@ -532,7 +532,7 @@ SIMD::Pointer SpirvShader::GetTexelAddress(EmitState const *state, SIMD::Pointer | ||
532 | 532 | |
533 | 533 | if(sampleId.value()) |
534 | 534 | { |
535 | - GenericValue sample(this, state, sampleId); | |
535 | + Operand sample(this, state, sampleId); | |
536 | 536 | ptr += sample.Int(0) * samplePitch; |
537 | 537 | } |
538 | 538 |
@@ -566,7 +566,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageRead(InsnIterator insn, EmitState | ||
566 | 566 | ASSERT(imageType.definition.opcode() == spv::OpTypeImage); |
567 | 567 | auto dim = static_cast<spv::Dim>(imageType.definition.word(3)); |
568 | 568 | |
569 | - auto coordinate = GenericValue(this, state, insn.word(4)); | |
569 | + auto coordinate = Operand(this, state, insn.word(4)); | |
570 | 570 | const DescriptorDecorations &d = descriptorDecorations.at(imageId); |
571 | 571 | |
572 | 572 | // For subpass data, format in the instruction is spv::ImageFormatUnknown. Get it from |
@@ -855,8 +855,8 @@ SpirvShader::EmitResult SpirvShader::EmitImageWrite(InsnIterator insn, EmitState | ||
855 | 855 | // TODO(b/131171141): Not handling any image operands yet. |
856 | 856 | ASSERT(insn.wordCount() == 4); |
857 | 857 | |
858 | - auto coordinate = GenericValue(this, state, insn.word(2)); | |
859 | - auto texel = GenericValue(this, state, insn.word(3)); | |
858 | + auto coordinate = Operand(this, state, insn.word(2)); | |
859 | + auto texel = Operand(this, state, insn.word(3)); | |
860 | 860 | |
861 | 861 | Pointer<Byte> binding = state->getPointer(imageId).base; |
862 | 862 | Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr)); |
@@ -1007,7 +1007,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageTexelPointer(InsnIterator insn, Em | ||
1007 | 1007 | ASSERT(resultType.storageClass == spv::StorageClassImage); |
1008 | 1008 | ASSERT(getType(resultType.element).opcode() == spv::OpTypeInt); |
1009 | 1009 | |
1010 | - auto coordinate = GenericValue(this, state, insn.word(4)); | |
1010 | + auto coordinate = Operand(this, state, insn.word(4)); | |
1011 | 1011 | |
1012 | 1012 | Pointer<Byte> binding = state->getPointer(imageId).base; |
1013 | 1013 | Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr)); |
@@ -236,7 +236,7 @@ SpirvShader::EmitResult SpirvShader::EmitVariable(InsnIterator insn, EmitState * | ||
236 | 236 | { |
237 | 237 | bool interleavedByLane = IsStorageInterleavedByLane(objectTy.storageClass); |
238 | 238 | auto ptr = GetPointerToData(resultId, 0, state); |
239 | - GenericValue initialValue(this, state, initializerId); | |
239 | + Operand initialValue(this, state, initializerId); | |
240 | 240 | VisitMemoryObject(resultId, [&](const MemoryElement &el) { |
241 | 241 | auto p = ptr + el.offset; |
242 | 242 | if(interleavedByLane) { p = InterleaveByLane(p); } |