Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-swiftshader: Commit

external/swiftshader


Commit MetaInfo

Revision711867566999bc34b019a4666302f990a08fd1cd (tree)
Time2020-04-14 10:16:06
AuthorNicolas Capens <capn@goog...>
CommiterNicolas Capens

Log Message

Use the type and result ID helpers

Avoid directly accessing SPIR-V instruction words. The helper methods
provide self-explanatory semantics so we can eliminate local variables
to store these IDs.

Bug: b/129000021
Change-Id: Ie42782d53b9c24014b6a1b1f51b82085b6c2ebef
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43694
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>

Change Summary

Incremental Difference

--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -816,15 +816,16 @@ void SpirvShader::ProcessInterfaceVariable(Object &object)
816816
817817 if(objectTy.isBuiltInBlock)
818818 {
819- // walk the builtin block, registering each of its members separately.
819+ // Walk the builtin block, registering each of its members separately.
820820 auto m = memberDecorations.find(objectTy.element);
821- ASSERT(m != memberDecorations.end()); // otherwise we wouldn't have marked the type chain
821+ ASSERT(m != memberDecorations.end()); // Otherwise we wouldn't have marked the type chain
822822 auto &structType = pointeeTy.definition;
823+ auto memberIndex = 0u;
823824 auto offset = 0u;
824- auto word = 2u;
825+
825826 for(auto &member : m->second)
826827 {
827- auto &memberType = getType(structType.word(word));
828+ auto &memberType = getType(structType.word(2 + memberIndex));
828829
829830 if(member.HasBuiltIn)
830831 {
@@ -832,8 +833,9 @@ void SpirvShader::ProcessInterfaceVariable(Object &object)
832833 }
833834
834835 offset += memberType.sizeInComponents;
835- ++word;
836+ ++memberIndex;
836837 }
838+
837839 return;
838840 }
839841
@@ -1510,22 +1512,19 @@ void SpirvShader::emitProlog(SpirvRoutine *routine) const
15101512 {
15111513 case spv::OpVariable:
15121514 {
1513- Type::ID resultPointerTypeId = insn.word(1);
1514- auto resultPointerType = getType(resultPointerTypeId);
1515+ auto resultPointerType = getType(insn.resultTypeId());
15151516 auto pointeeType = getType(resultPointerType.element);
15161517
15171518 if(pointeeType.sizeInComponents > 0) // TODO: what to do about zero-slot objects?
15181519 {
1519- Object::ID resultId = insn.word(2);
1520- routine->createVariable(resultId, pointeeType.sizeInComponents);
1520+ routine->createVariable(insn.resultId(), pointeeType.sizeInComponents);
15211521 }
15221522 break;
15231523 }
15241524 case spv::OpPhi:
15251525 {
1526- auto type = getType(insn.word(1));
1527- Object::ID resultId = insn.word(2);
1528- routine->phis.emplace(resultId, SpirvRoutine::Variable(type.sizeInComponents));
1526+ auto type = getType(insn.resultTypeId());
1527+ routine->phis.emplace(insn.resultId(), SpirvRoutine::Variable(type.sizeInComponents));
15291528 break;
15301529 }
15311530
@@ -1541,11 +1540,8 @@ void SpirvShader::emitProlog(SpirvRoutine *routine) const
15411540 case spv::OpImageSampleProjDrefImplicitLod:
15421541 case spv::OpImageSampleProjExplicitLod:
15431542 case spv::OpImageSampleProjImplicitLod:
1544- {
1545- Object::ID resultId = insn.word(2);
1546- routine->samplerCache.emplace(resultId, SpirvRoutine::SamplerCache{});
1543+ routine->samplerCache.emplace(insn.resultId(), SpirvRoutine::SamplerCache{});
15471544 break;
1548- }
15491545
15501546 default:
15511547 // Nothing else produces interface variables, so can all be safely ignored.
@@ -1998,8 +1994,8 @@ SpirvShader::EmitResult SpirvShader::EmitAccessChain(InsnIterator insn, EmitStat
19981994
19991995 SpirvShader::EmitResult SpirvShader::EmitCompositeConstruct(InsnIterator insn, EmitState *state) const
20001996 {
2001- auto &type = getType(insn.word(1));
2002- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
1997+ auto &type = getType(insn.resultTypeId());
1998+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
20031999 auto offset = 0u;
20042000
20052001 for(auto i = 0u; i < insn.wordCount() - 3; i++)
@@ -2022,7 +2018,7 @@ SpirvShader::EmitResult SpirvShader::EmitCompositeInsert(InsnIterator insn, Emit
20222018 {
20232019 Type::ID resultTypeId = insn.word(1);
20242020 auto &type = getType(resultTypeId);
2025- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2021+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
20262022 auto &newPartObject = getObject(insn.word(3));
20272023 auto &newPartObjectTy = getType(newPartObject);
20282024 auto firstNewComponent = WalkLiteralAccessChain(resultTypeId, insn.wordCount() - 5, insn.wordPointer(5));
@@ -2051,8 +2047,8 @@ SpirvShader::EmitResult SpirvShader::EmitCompositeInsert(InsnIterator insn, Emit
20512047
20522048 SpirvShader::EmitResult SpirvShader::EmitCompositeExtract(InsnIterator insn, EmitState *state) const
20532049 {
2054- auto &type = getType(insn.word(1));
2055- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2050+ auto &type = getType(insn.resultTypeId());
2051+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
20562052 auto &compositeObject = getObject(insn.word(3));
20572053 Type::ID compositeTypeId = compositeObject.definition.word(1);
20582054 auto firstComponent = WalkLiteralAccessChain(compositeTypeId, insn.wordCount() - 4, insn.wordPointer(4));
@@ -2068,8 +2064,8 @@ SpirvShader::EmitResult SpirvShader::EmitCompositeExtract(InsnIterator insn, Emi
20682064
20692065 SpirvShader::EmitResult SpirvShader::EmitVectorShuffle(InsnIterator insn, EmitState *state) const
20702066 {
2071- auto &type = getType(insn.word(1));
2072- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2067+ auto &type = getType(insn.resultTypeId());
2068+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
20732069
20742070 // Note: number of components in result type, first half type, and second
20752071 // half type are all independent.
@@ -2102,8 +2098,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorShuffle(InsnIterator insn, EmitSt
21022098
21032099 SpirvShader::EmitResult SpirvShader::EmitVectorExtractDynamic(InsnIterator insn, EmitState *state) const
21042100 {
2105- auto &type = getType(insn.word(1));
2106- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2101+ auto &type = getType(insn.resultTypeId());
2102+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
21072103 auto &srcType = getType(getObject(insn.word(3)));
21082104
21092105 Operand src(this, state, insn.word(3));
@@ -2122,8 +2118,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorExtractDynamic(InsnIterator insn,
21222118
21232119 SpirvShader::EmitResult SpirvShader::EmitVectorInsertDynamic(InsnIterator insn, EmitState *state) const
21242120 {
2125- auto &type = getType(insn.word(1));
2126- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2121+ auto &type = getType(insn.resultTypeId());
2122+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
21272123
21282124 Operand src(this, state, insn.word(3));
21292125 Operand component(this, state, insn.word(4));
@@ -2139,8 +2135,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorInsertDynamic(InsnIterator insn,
21392135
21402136 SpirvShader::EmitResult SpirvShader::EmitSelect(InsnIterator insn, EmitState *state) const
21412137 {
2142- auto &type = getType(insn.word(1));
2143- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2138+ auto &type = getType(insn.resultTypeId());
2139+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
21442140 auto cond = Operand(this, state, insn.word(3));
21452141 auto condIsScalar = (getType(cond).sizeInComponents == 1);
21462142 auto lhs = Operand(this, state, insn.word(4));
@@ -2157,9 +2153,9 @@ SpirvShader::EmitResult SpirvShader::EmitSelect(InsnIterator insn, EmitState *st
21572153
21582154 SpirvShader::EmitResult SpirvShader::EmitAny(InsnIterator insn, EmitState *state) const
21592155 {
2160- auto &type = getType(insn.word(1));
2156+ auto &type = getType(insn.resultTypeId());
21612157 ASSERT(type.sizeInComponents == 1);
2162- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2158+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
21632159 auto &srcType = getType(getObject(insn.word(3)));
21642160 auto src = Operand(this, state, insn.word(3));
21652161
@@ -2176,9 +2172,9 @@ SpirvShader::EmitResult SpirvShader::EmitAny(InsnIterator insn, EmitState *state
21762172
21772173 SpirvShader::EmitResult SpirvShader::EmitAll(InsnIterator insn, EmitState *state) const
21782174 {
2179- auto &type = getType(insn.word(1));
2175+ auto &type = getType(insn.resultTypeId());
21802176 ASSERT(type.sizeInComponents == 1);
2181- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
2177+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
21822178 auto &srcType = getType(getObject(insn.word(3)));
21832179 auto src = Operand(this, state, insn.word(3));
21842180
@@ -2298,10 +2294,10 @@ SpirvShader::EmitResult SpirvShader::EmitAtomicCompareExchange(InsnIterator insn
22982294
22992295 SpirvShader::EmitResult SpirvShader::EmitCopyObject(InsnIterator insn, EmitState *state) const
23002296 {
2301- auto ty = getType(insn.word(1));
2302- auto &dst = state->createIntermediate(insn.word(2), ty.sizeInComponents);
2297+ auto type = getType(insn.resultTypeId());
2298+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
23032299 auto src = Operand(this, state, insn.word(3));
2304- for(uint32_t i = 0; i < ty.sizeInComponents; i++)
2300+ for(uint32_t i = 0; i < type.sizeInComponents; i++)
23052301 {
23062302 dst.move(i, src.Int(i));
23072303 }
@@ -2310,12 +2306,10 @@ SpirvShader::EmitResult SpirvShader::EmitCopyObject(InsnIterator insn, EmitState
23102306
23112307 SpirvShader::EmitResult SpirvShader::EmitArrayLength(InsnIterator insn, EmitState *state) const
23122308 {
2313- auto resultTyId = Type::ID(insn.word(1));
2314- auto resultId = Object::ID(insn.word(2));
23152309 auto structPtrId = Object::ID(insn.word(3));
23162310 auto arrayFieldIdx = insn.word(4);
23172311
2318- auto &resultType = getType(resultTyId);
2312+ auto &resultType = getType(insn.resultTypeId());
23192313 ASSERT(resultType.sizeInComponents == 1);
23202314 ASSERT(resultType.definition.opcode() == spv::OpTypeInt);
23212315
@@ -2323,7 +2317,7 @@ SpirvShader::EmitResult SpirvShader::EmitArrayLength(InsnIterator insn, EmitStat
23232317 auto &structTy = getType(structPtrTy.element);
23242318 auto arrayId = Type::ID(structTy.definition.word(2 + arrayFieldIdx));
23252319
2326- auto &result = state->createIntermediate(resultId, 1);
2320+ auto &result = state->createIntermediate(insn.resultId(), 1);
23272321 auto structBase = GetPointerToData(structPtrId, 0, state);
23282322
23292323 Decorations structDecorations = {};
@@ -2374,14 +2368,13 @@ void SpirvShader::emitEpilog(SpirvRoutine *routine) const
23742368 {
23752369 case spv::OpVariable:
23762370 {
2377- Object::ID resultId = insn.word(2);
2378- auto &object = getObject(resultId);
2371+ auto &object = getObject(insn.resultId());
23792372 auto &objectTy = getType(object);
23802373 if(object.kind == Object::Kind::InterfaceVariable && objectTy.storageClass == spv::StorageClassOutput)
23812374 {
2382- auto &dst = routine->getVariable(resultId);
2375+ auto &dst = routine->getVariable(insn.resultId());
23832376 int offset = 0;
2384- VisitInterface(resultId,
2377+ VisitInterface(insn.resultId(),
23852378 [&](Decorations const &d, AttribType type) {
23862379 auto scalarSlot = d.Location << 2 | d.Component;
23872380 routine->outputs[scalarSlot] = dst[offset++];
--- a/src/Pipeline/SpirvShaderArithmetic.cpp
+++ b/src/Pipeline/SpirvShaderArithmetic.cpp
@@ -22,8 +22,8 @@ namespace sw {
2222
2323 SpirvShader::EmitResult SpirvShader::EmitVectorTimesScalar(InsnIterator insn, EmitState *state) const
2424 {
25- auto &type = getType(insn.word(1));
26- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
25+ auto &type = getType(insn.resultTypeId());
26+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
2727 auto lhs = Operand(this, state, insn.word(3));
2828 auto rhs = Operand(this, state, insn.word(4));
2929
@@ -37,8 +37,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorTimesScalar(InsnIterator insn, Em
3737
3838 SpirvShader::EmitResult SpirvShader::EmitMatrixTimesVector(InsnIterator insn, EmitState *state) const
3939 {
40- auto &type = getType(insn.word(1));
41- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
40+ auto &type = getType(insn.resultTypeId());
41+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
4242 auto lhs = Operand(this, state, insn.word(3));
4343 auto rhs = Operand(this, state, insn.word(4));
4444 auto rhsType = getType(rhs);
@@ -58,8 +58,8 @@ SpirvShader::EmitResult SpirvShader::EmitMatrixTimesVector(InsnIterator insn, Em
5858
5959 SpirvShader::EmitResult SpirvShader::EmitVectorTimesMatrix(InsnIterator insn, EmitState *state) const
6060 {
61- auto &type = getType(insn.word(1));
62- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
61+ auto &type = getType(insn.resultTypeId());
62+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
6363 auto lhs = Operand(this, state, insn.word(3));
6464 auto rhs = Operand(this, state, insn.word(4));
6565 auto lhsType = getType(lhs);
@@ -79,8 +79,8 @@ SpirvShader::EmitResult SpirvShader::EmitVectorTimesMatrix(InsnIterator insn, Em
7979
8080 SpirvShader::EmitResult SpirvShader::EmitMatrixTimesMatrix(InsnIterator insn, EmitState *state) const
8181 {
82- auto &type = getType(insn.word(1));
83- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
82+ auto &type = getType(insn.resultTypeId());
83+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
8484 auto lhs = Operand(this, state, insn.word(3));
8585 auto rhs = Operand(this, state, insn.word(4));
8686
@@ -106,8 +106,8 @@ SpirvShader::EmitResult SpirvShader::EmitMatrixTimesMatrix(InsnIterator insn, Em
106106
107107 SpirvShader::EmitResult SpirvShader::EmitOuterProduct(InsnIterator insn, EmitState *state) const
108108 {
109- auto &type = getType(insn.word(1));
110- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
109+ auto &type = getType(insn.resultTypeId());
110+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
111111 auto lhs = Operand(this, state, insn.word(3));
112112 auto rhs = Operand(this, state, insn.word(4));
113113 auto &lhsType = getType(lhs);
@@ -135,8 +135,8 @@ SpirvShader::EmitResult SpirvShader::EmitOuterProduct(InsnIterator insn, EmitSta
135135
136136 SpirvShader::EmitResult SpirvShader::EmitTranspose(InsnIterator insn, EmitState *state) const
137137 {
138- auto &type = getType(insn.word(1));
139- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
138+ auto &type = getType(insn.resultTypeId());
139+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
140140 auto mat = Operand(this, state, insn.word(3));
141141
142142 auto numCols = type.definition.word(3);
@@ -155,8 +155,8 @@ SpirvShader::EmitResult SpirvShader::EmitTranspose(InsnIterator insn, EmitState
155155
156156 SpirvShader::EmitResult SpirvShader::EmitUnaryOp(InsnIterator insn, EmitState *state) const
157157 {
158- auto &type = getType(insn.word(1));
159- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
158+ auto &type = getType(insn.resultTypeId());
159+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
160160 auto src = Operand(this, state, insn.word(3));
161161
162162 for(auto i = 0u; i < type.sizeInComponents; i++)
@@ -317,8 +317,8 @@ SpirvShader::EmitResult SpirvShader::EmitUnaryOp(InsnIterator insn, EmitState *s
317317
318318 SpirvShader::EmitResult SpirvShader::EmitBinaryOp(InsnIterator insn, EmitState *state) const
319319 {
320- auto &type = getType(insn.word(1));
321- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
320+ auto &type = getType(insn.resultTypeId());
321+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
322322 auto &lhsType = getType(getObject(insn.word(3)));
323323 auto lhs = Operand(this, state, insn.word(3));
324324 auto rhs = Operand(this, state, insn.word(4));
@@ -520,9 +520,9 @@ SpirvShader::EmitResult SpirvShader::EmitBinaryOp(InsnIterator insn, EmitState *
520520
521521 SpirvShader::EmitResult SpirvShader::EmitDot(InsnIterator insn, EmitState *state) const
522522 {
523- auto &type = getType(insn.word(1));
523+ auto &type = getType(insn.resultTypeId());
524524 ASSERT(type.sizeInComponents == 1);
525- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
525+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
526526 auto &lhsType = getType(getObject(insn.word(3)));
527527 auto lhs = Operand(this, state, insn.word(3));
528528 auto rhs = Operand(this, state, insn.word(4));
--- a/src/Pipeline/SpirvShaderGLSLstd450.cpp
+++ b/src/Pipeline/SpirvShaderGLSLstd450.cpp
@@ -27,8 +27,8 @@ namespace sw {
2727
2828 SpirvShader::EmitResult SpirvShader::EmitExtGLSLstd450(InsnIterator insn, EmitState *state) const
2929 {
30- auto &type = getType(insn.word(1));
31- auto &dst = state->createIntermediate(insn.word(2), type.sizeInComponents);
30+ auto &type = getType(insn.resultTypeId());
31+ auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
3232 auto extInstIndex = static_cast<GLSLstd450>(insn.word(4));
3333
3434 switch(extInstIndex)
--- a/src/Pipeline/SpirvShaderImage.cpp
+++ b/src/Pipeline/SpirvShaderImage.cpp
@@ -107,13 +107,11 @@ SpirvShader::EmitResult SpirvShader::EmitImageFetch(InsnIterator insn, EmitState
107107
108108 SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instruction, InsnIterator insn, EmitState *state) const
109109 {
110- Type::ID resultTypeId = insn.word(1);
111- Object::ID resultId = insn.word(2);
112110 Object::ID sampledImageId = insn.word(3); // For OpImageFetch this is just an Image, not a SampledImage.
113111 Object::ID coordinateId = insn.word(4);
114- auto &resultType = getType(resultTypeId);
112+ auto &resultType = getType(insn.resultTypeId());
115113
116- auto &result = state->createIntermediate(resultId, resultType.sizeInComponents);
114+ auto &result = state->createIntermediate(insn.resultId(), resultType.sizeInComponents);
117115 auto imageDescriptor = state->getPointer(sampledImageId).base; // vk::SampledImageDescriptor*
118116
119117 // If using a separate sampler, look through the OpSampledImage instruction to find the sampler descriptor
@@ -291,7 +289,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio
291289 in[i] = As<SIMD::Float>(sampleValue.Int(0));
292290 }
293291
294- auto cacheIt = state->routine->samplerCache.find(resultId);
292+ auto cacheIt = state->routine->samplerCache.find(insn.resultId());
295293 ASSERT(cacheIt != state->routine->samplerCache.end());
296294 auto &cache = cacheIt->second;
297295 auto cacheHit = cache.imageDescriptor == imageDescriptor && cache.sampler == sampler;
@@ -313,12 +311,11 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio
313311
314312 SpirvShader::EmitResult SpirvShader::EmitImageQuerySizeLod(InsnIterator insn, EmitState *state) const
315313 {
316- auto &resultTy = getType(Type::ID(insn.word(1)));
317- auto resultId = Object::ID(insn.word(2));
314+ auto &resultTy = getType(Type::ID(insn.resultTypeId()));
318315 auto imageId = Object::ID(insn.word(3));
319316 auto lodId = Object::ID(insn.word(4));
320317
321- auto &dst = state->createIntermediate(resultId, resultTy.sizeInComponents);
318+ auto &dst = state->createIntermediate(insn.resultId(), resultTy.sizeInComponents);
322319 GetImageDimensions(state, resultTy, imageId, lodId, dst);
323320
324321 return EmitResult::Continue;
@@ -326,12 +323,11 @@ SpirvShader::EmitResult SpirvShader::EmitImageQuerySizeLod(InsnIterator insn, Em
326323
327324 SpirvShader::EmitResult SpirvShader::EmitImageQuerySize(InsnIterator insn, EmitState *state) const
328325 {
329- auto &resultTy = getType(Type::ID(insn.word(1)));
330- auto resultId = Object::ID(insn.word(2));
326+ auto &resultTy = getType(Type::ID(insn.resultTypeId()));
331327 auto imageId = Object::ID(insn.word(3));
332328 auto lodId = Object::ID(0);
333329
334- auto &dst = state->createIntermediate(resultId, resultTy.sizeInComponents);
330+ auto &dst = state->createIntermediate(insn.resultId(), resultTy.sizeInComponents);
335331 GetImageDimensions(state, resultTy, imageId, lodId, dst);
336332
337333 return EmitResult::Continue;
@@ -412,9 +408,8 @@ void SpirvShader::GetImageDimensions(EmitState const *state, Type const &resultT
412408
413409 SpirvShader::EmitResult SpirvShader::EmitImageQueryLevels(InsnIterator insn, EmitState *state) const
414410 {
415- auto &resultTy = getType(Type::ID(insn.word(1)));
411+ auto &resultTy = getType(Type::ID(insn.resultTypeId()));
416412 ASSERT(resultTy.sizeInComponents == 1);
417- auto resultId = Object::ID(insn.word(2));
418413 auto imageId = Object::ID(insn.word(3));
419414
420415 const DescriptorDecorations &d = descriptorDecorations.at(imageId);
@@ -434,7 +429,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQueryLevels(InsnIterator insn, Emi
434429 UNREACHABLE("Image descriptorType: %d", int(bindingLayout.descriptorType));
435430 }
436431
437- auto &dst = state->createIntermediate(resultId, 1);
432+ auto &dst = state->createIntermediate(insn.resultId(), 1);
438433 dst.move(0, SIMD::Int(mipLevels));
439434
440435 return EmitResult::Continue;
@@ -442,9 +437,8 @@ SpirvShader::EmitResult SpirvShader::EmitImageQueryLevels(InsnIterator insn, Emi
442437
443438 SpirvShader::EmitResult SpirvShader::EmitImageQuerySamples(InsnIterator insn, EmitState *state) const
444439 {
445- auto &resultTy = getType(Type::ID(insn.word(1)));
440+ auto &resultTy = getType(Type::ID(insn.resultTypeId()));
446441 ASSERT(resultTy.sizeInComponents == 1);
447- auto resultId = Object::ID(insn.word(2));
448442 auto imageId = Object::ID(insn.word(3));
449443 auto imageTy = getType(getObject(imageId));
450444 ASSERT(imageTy.definition.opcode() == spv::OpTypeImage);
@@ -471,7 +465,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQuerySamples(InsnIterator insn, Em
471465 UNREACHABLE("Image descriptorType: %d", int(bindingLayout.descriptorType));
472466 }
473467
474- auto &dst = state->createIntermediate(resultId, 1);
468+ auto &dst = state->createIntermediate(insn.resultId(), 1);
475469 dst.move(0, SIMD::Int(sampleCount));
476470
477471 return EmitResult::Continue;
@@ -545,7 +539,6 @@ SpirvShader::EmitResult SpirvShader::EmitImageRead(InsnIterator insn, EmitState
545539 auto imageId = Object::ID(insn.word(3));
546540 auto &image = getObject(imageId);
547541 auto &imageType = getType(image);
548- Object::ID resultId = insn.word(2);
549542
550543 Object::ID sampleId = 0;
551544
@@ -593,7 +586,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageRead(InsnIterator insn, EmitState
593586
594587 auto imageSizeInBytes = *Pointer<Int>(binding + OFFSET(vk::StorageImageDescriptor, sizeInBytes));
595588
596- auto &dst = state->createIntermediate(resultId, resultType.sizeInComponents);
589+ auto &dst = state->createIntermediate(insn.resultId(), resultType.sizeInComponents);
597590
598591 auto texelSize = vk::Format(vkFormat).bytes();
599592 auto basePtr = SIMD::Pointer(imageBase, imageSizeInBytes);
Show on old repository browser