Commit ff9f9b5d by Nicolas Capens Committed by Nicolas Capens

Rename size/sizeInComponents to componentCount

Bug: b/129000021 Change-Id: I36401de649eb53474ca74acb069351ce37f7529f Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43828 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 71186756
......@@ -65,17 +65,17 @@ class SpirvRoutine;
// Incrementally constructed complex bundle of rvalues
// Effectively a restricted vector, supporting only:
// - allocation to a (runtime-known) fixed size
// - allocation to a (runtime-known) fixed component count
// - in-place construction of elements
// - const operator[]
class Intermediate
{
public:
Intermediate(uint32_t size)
: scalar(new rr::Value *[size])
, size(size)
Intermediate(uint32_t componentCount)
: scalar(new rr::Value *[componentCount])
, componentCount(componentCount)
{
memset(scalar, 0, sizeof(rr::Value *) * size);
memset(scalar, 0, sizeof(rr::Value *) * componentCount);
}
~Intermediate()
......@@ -94,21 +94,21 @@ public:
// Value retrieval functions.
RValue<SIMD::Float> Float(uint32_t i) const
{
ASSERT(i < size);
ASSERT(i < componentCount);
ASSERT(scalar[i] != nullptr);
return As<SIMD::Float>(scalar[i]); // TODO(b/128539387): RValue<SIMD::Float>(scalar)
}
RValue<SIMD::Int> Int(uint32_t i) const
{
ASSERT(i < size);
ASSERT(i < componentCount);
ASSERT(scalar[i] != nullptr);
return As<SIMD::Int>(scalar[i]); // TODO(b/128539387): RValue<SIMD::Int>(scalar)
}
RValue<SIMD::UInt> UInt(uint32_t i) const
{
ASSERT(i < size);
ASSERT(i < componentCount);
ASSERT(scalar[i] != nullptr);
return As<SIMD::UInt>(scalar[i]); // TODO(b/128539387): RValue<SIMD::UInt>(scalar)
}
......@@ -122,13 +122,13 @@ public:
private:
void emplace(uint32_t i, rr::Value *value)
{
ASSERT(i < size);
ASSERT(i < componentCount);
ASSERT(scalar[i] == nullptr);
scalar[i] = value;
}
rr::Value **const scalar;
uint32_t size;
uint32_t componentCount;
};
class SpirvShader
......@@ -259,7 +259,7 @@ public:
InsnIterator definition;
spv::StorageClass storageClass = static_cast<spv::StorageClass>(-1);
uint32_t sizeInComponents = 0;
uint32_t componentCount = 0;
bool isBuiltInBlock = false;
// Inner element type for pointers, arrays, vectors and matrices.
......@@ -939,11 +939,11 @@ private:
OutOfBoundsBehavior getOutOfBoundsBehavior(spv::StorageClass storageClass) const;
Intermediate &createIntermediate(Object::ID id, uint32_t size)
Intermediate &createIntermediate(Object::ID id, uint32_t componentCount)
{
auto it = intermediates.emplace(std::piecewise_construct,
std::forward_as_tuple(id),
std::forward_as_tuple(size));
std::forward_as_tuple(componentCount));
ASSERT_MSG(it.second, "Intermediate %d created twice", id.value());
return it.first->second;
}
......@@ -1336,9 +1336,9 @@ public:
Pointer<Byte> dbgState; // Pointer to a debugger state.
void createVariable(SpirvShader::Object::ID id, uint32_t size)
void createVariable(SpirvShader::Object::ID id, uint32_t componentCount)
{
bool added = variables.emplace(id, Variable(size)).second;
bool added = variables.emplace(id, Variable(componentCount)).second;
ASSERT_MSG(added, "Variable %d created twice", id.value());
}
......
......@@ -23,11 +23,11 @@ namespace sw {
SpirvShader::EmitResult SpirvShader::EmitVectorTimesScalar(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto lhs = Operand(this, state, insn.word(3));
auto rhs = Operand(this, state, insn.word(4));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
dst.move(i, lhs.Float(i) * rhs.Float(0));
}
......@@ -38,17 +38,17 @@ SpirvShader::EmitResult SpirvShader::EmitVectorTimesScalar(InsnIterator insn, Em
SpirvShader::EmitResult SpirvShader::EmitMatrixTimesVector(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto lhs = Operand(this, state, insn.word(3));
auto rhs = Operand(this, state, insn.word(4));
auto rhsType = getType(rhs);
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
SIMD::Float v = lhs.Float(i) * rhs.Float(0);
for(auto j = 1u; j < rhsType.sizeInComponents; j++)
for(auto j = 1u; j < rhsType.componentCount; j++)
{
v += lhs.Float(i + type.sizeInComponents * j) * rhs.Float(j);
v += lhs.Float(i + type.componentCount * j) * rhs.Float(j);
}
dst.move(i, v);
}
......@@ -59,17 +59,17 @@ SpirvShader::EmitResult SpirvShader::EmitMatrixTimesVector(InsnIterator insn, Em
SpirvShader::EmitResult SpirvShader::EmitVectorTimesMatrix(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto lhs = Operand(this, state, insn.word(3));
auto rhs = Operand(this, state, insn.word(4));
auto lhsType = getType(lhs);
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
SIMD::Float v = lhs.Float(0) * rhs.Float(i * lhsType.sizeInComponents);
for(auto j = 1u; j < lhsType.sizeInComponents; j++)
SIMD::Float v = lhs.Float(0) * rhs.Float(i * lhsType.componentCount);
for(auto j = 1u; j < lhsType.componentCount; j++)
{
v += lhs.Float(j) * rhs.Float(i * lhsType.sizeInComponents + j);
v += lhs.Float(j) * rhs.Float(i * lhsType.componentCount + j);
}
dst.move(i, v);
}
......@@ -80,7 +80,7 @@ SpirvShader::EmitResult SpirvShader::EmitVectorTimesMatrix(InsnIterator insn, Em
SpirvShader::EmitResult SpirvShader::EmitMatrixTimesMatrix(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto lhs = Operand(this, state, insn.word(3));
auto rhs = Operand(this, state, insn.word(4));
......@@ -107,7 +107,7 @@ SpirvShader::EmitResult SpirvShader::EmitMatrixTimesMatrix(InsnIterator insn, Em
SpirvShader::EmitResult SpirvShader::EmitOuterProduct(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto lhs = Operand(this, state, insn.word(3));
auto rhs = Operand(this, state, insn.word(4));
auto &lhsType = getType(lhs);
......@@ -136,11 +136,11 @@ SpirvShader::EmitResult SpirvShader::EmitOuterProduct(InsnIterator insn, EmitSta
SpirvShader::EmitResult SpirvShader::EmitTranspose(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto mat = Operand(this, state, insn.word(3));
auto numCols = type.definition.word(3);
auto numRows = getType(type.definition.word(2)).sizeInComponents;
auto numRows = getType(type.definition.word(2)).componentCount;
for(auto col = 0u; col < numCols; col++)
{
......@@ -156,10 +156,10 @@ SpirvShader::EmitResult SpirvShader::EmitTranspose(InsnIterator insn, EmitState
SpirvShader::EmitResult SpirvShader::EmitUnaryOp(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto src = Operand(this, state, insn.word(3));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
switch(insn.opcode())
{
......@@ -318,12 +318,12 @@ SpirvShader::EmitResult SpirvShader::EmitUnaryOp(InsnIterator insn, EmitState *s
SpirvShader::EmitResult SpirvShader::EmitBinaryOp(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto &lhsType = getType(getObject(insn.word(3)));
auto lhs = Operand(this, state, insn.word(3));
auto rhs = Operand(this, state, insn.word(4));
for(auto i = 0u; i < lhsType.sizeInComponents; i++)
for(auto i = 0u; i < lhsType.componentCount; i++)
{
switch(insn.opcode())
{
......@@ -496,19 +496,19 @@ SpirvShader::EmitResult SpirvShader::EmitBinaryOp(InsnIterator insn, EmitState *
// In our flat view then, component i is the i'th component of the first member;
// component i + N is the i'th component of the second member.
dst.move(i, lhs.Int(i) * rhs.Int(i));
dst.move(i + lhsType.sizeInComponents, MulHigh(lhs.Int(i), rhs.Int(i)));
dst.move(i + lhsType.componentCount, MulHigh(lhs.Int(i), rhs.Int(i)));
break;
case spv::OpUMulExtended:
dst.move(i, lhs.UInt(i) * rhs.UInt(i));
dst.move(i + lhsType.sizeInComponents, MulHigh(lhs.UInt(i), rhs.UInt(i)));
dst.move(i + lhsType.componentCount, MulHigh(lhs.UInt(i), rhs.UInt(i)));
break;
case spv::OpIAddCarry:
dst.move(i, lhs.UInt(i) + rhs.UInt(i));
dst.move(i + lhsType.sizeInComponents, CmpLT(dst.UInt(i), lhs.UInt(i)) >> 31);
dst.move(i + lhsType.componentCount, CmpLT(dst.UInt(i), lhs.UInt(i)) >> 31);
break;
case spv::OpISubBorrow:
dst.move(i, lhs.UInt(i) - rhs.UInt(i));
dst.move(i + lhsType.sizeInComponents, CmpLT(lhs.UInt(i), rhs.UInt(i)) >> 31);
dst.move(i + lhsType.componentCount, CmpLT(lhs.UInt(i), rhs.UInt(i)) >> 31);
break;
default:
UNREACHABLE("%s", OpcodeName(insn.opcode()).c_str());
......@@ -521,13 +521,13 @@ SpirvShader::EmitResult SpirvShader::EmitBinaryOp(InsnIterator insn, EmitState *
SpirvShader::EmitResult SpirvShader::EmitDot(InsnIterator insn, EmitState *state) const
{
auto &type = getType(insn.resultTypeId());
ASSERT(type.sizeInComponents == 1);
auto &dst = state->createIntermediate(insn.resultId(), type.sizeInComponents);
ASSERT(type.componentCount == 1);
auto &dst = state->createIntermediate(insn.resultId(), type.componentCount);
auto &lhsType = getType(getObject(insn.word(3)));
auto lhs = Operand(this, state, insn.word(3));
auto rhs = Operand(this, state, insn.word(4));
dst.move(0, Dot(lhsType.sizeInComponents, lhs, rhs));
dst.move(0, Dot(lhsType.componentCount, lhs, rhs));
return EmitResult::Continue;
}
......
......@@ -496,7 +496,7 @@ SpirvShader::EmitResult SpirvShader::EmitBranchConditional(InsnIterator insn, Em
auto falseBlockId = Block::ID(block.branchInstruction.word(3));
auto cond = Operand(this, state, condId);
ASSERT_MSG(getType(cond).sizeInComponents == 1, "Condition must be a Boolean type scalar");
ASSERT_MSG(getType(cond).componentCount == 1, "Condition must be a Boolean type scalar");
// TODO: Optimize for case where all lanes take same path.
......@@ -515,7 +515,7 @@ SpirvShader::EmitResult SpirvShader::EmitSwitch(InsnIterator insn, EmitState *st
auto selId = Object::ID(block.branchInstruction.word(1));
auto sel = Operand(this, state, selId);
ASSERT_MSG(getType(sel).sizeInComponents == 1, "Selector must be a scalar");
ASSERT_MSG(getType(sel).componentCount == 1, "Selector must be a scalar");
auto numCases = (block.branchInstruction.wordCount() - 3) / 2;
......@@ -650,8 +650,8 @@ void SpirvShader::LoadPhi(InsnIterator insn, EmitState *state) const
ASSERT(storageIt != state->routine->phis.end());
auto &storage = storageIt->second;
auto &dst = state->createIntermediate(objectId, type.sizeInComponents);
for(uint32_t i = 0; i < type.sizeInComponents; i++)
auto &dst = state->createIntermediate(objectId, type.componentCount);
for(uint32_t i = 0; i < type.componentCount; i++)
{
dst.move(i, storage[i]);
}
......@@ -680,7 +680,7 @@ void SpirvShader::StorePhi(Block::ID currentBlock, InsnIterator insn, EmitState
auto mask = GetActiveLaneMaskEdge(state, blockId, currentBlock);
auto in = Operand(this, state, varId);
for(uint32_t i = 0; i < type.sizeInComponents; i++)
for(uint32_t i = 0; i < type.componentCount; i++)
{
storage[i] = As<SIMD::Float>((As<SIMD::Int>(storage[i]) & ~mask) | (in.Int(i) & mask));
}
......
......@@ -36,7 +36,7 @@ struct SpirvShader::Impl::Group
{
SpirvShader::Operand value(shader, state, insn.word(5));
auto &type = shader->getType(SpirvShader::Type::ID(insn.word(1)));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
auto mask = As<SIMD::UInt>(state->activeLaneMask());
auto identity = TYPE(identityValue);
......@@ -85,7 +85,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
auto scope = spv::Scope(GetConstScalarInt(insn.word(3)));
ASSERT_MSG(scope == spv::ScopeSubgroup, "Scope for Non Uniform Group Operations must be Subgroup for Vulkan 1.1");
auto &dst = state->createIntermediate(resultId, type.sizeInComponents);
auto &dst = state->createIntermediate(resultId, type.componentCount);
switch(insn.opcode())
{
......@@ -122,7 +122,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
auto res = SIMD::UInt(0xffffffff);
SIMD::UInt active = As<SIMD::UInt>(state->activeLaneMask());
SIMD::UInt inactive = ~active;
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
SIMD::UInt v = value.UInt(i) & active;
SIMD::UInt filled = v;
......@@ -142,7 +142,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
auto id = SIMD::Int(GetConstScalarInt(insn.word(5)));
Operand value(this, state, valueId);
auto mask = CmpEQ(id, SIMD::Int(0, 1, 2, 3));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
dst.move(i, OrAll(value.Int(i) & mask));
}
......@@ -160,7 +160,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
// elect = active & ~(active.Oxyz | active.OOxy | active.OOOx)
auto v0111 = SIMD::Int(0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
auto elect = active & ~(v0111 & (active.xxyz | active.xxxy | active.xxxx));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
dst.move(i, OrAll(value.Int(i) & elect));
}
......@@ -169,7 +169,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
case spv::OpGroupNonUniformBallot:
{
ASSERT(type.sizeInComponents == 4);
ASSERT(type.componentCount == 4);
Operand predicate(this, state, insn.word(4));
dst.move(0, SIMD::Int(SignMask(state->activeLaneMask() & predicate.Int(0))));
dst.move(1, SIMD::Int(0));
......@@ -181,8 +181,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
case spv::OpGroupNonUniformInverseBallot:
{
auto valueId = Object::ID(insn.word(4));
ASSERT(type.sizeInComponents == 1);
ASSERT(getType(getObject(valueId)).sizeInComponents == 4);
ASSERT(type.componentCount == 1);
ASSERT(getType(getObject(valueId)).componentCount == 4);
Operand value(this, state, valueId);
auto bit = (value.Int(0) >> SIMD::Int(0, 1, 2, 3)) & SIMD::Int(1);
dst.move(0, -bit);
......@@ -193,9 +193,9 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
{
auto valueId = Object::ID(insn.word(4));
auto indexId = Object::ID(insn.word(5));
ASSERT(type.sizeInComponents == 1);
ASSERT(getType(getObject(valueId)).sizeInComponents == 4);
ASSERT(getType(getObject(indexId)).sizeInComponents == 1);
ASSERT(type.componentCount == 1);
ASSERT(getType(getObject(valueId)).componentCount == 4);
ASSERT(getType(getObject(indexId)).componentCount == 1);
Operand value(this, state, valueId);
Operand index(this, state, indexId);
auto vecIdx = index.Int(0) / SIMD::Int(32);
......@@ -212,8 +212,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
{
auto operation = spv::GroupOperation(insn.word(4));
auto valueId = Object::ID(insn.word(5));
ASSERT(type.sizeInComponents == 1);
ASSERT(getType(getObject(valueId)).sizeInComponents == 4);
ASSERT(type.componentCount == 1);
ASSERT(getType(getObject(valueId)).componentCount == 4);
Operand value(this, state, valueId);
switch(operation)
{
......@@ -235,8 +235,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
case spv::OpGroupNonUniformBallotFindLSB:
{
auto valueId = Object::ID(insn.word(4));
ASSERT(type.sizeInComponents == 1);
ASSERT(getType(getObject(valueId)).sizeInComponents == 4);
ASSERT(type.componentCount == 1);
ASSERT(getType(getObject(valueId)).componentCount == 4);
Operand value(this, state, valueId);
dst.move(0, Cttz(value.UInt(0) & SIMD::UInt(15), true));
break;
......@@ -245,8 +245,8 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
case spv::OpGroupNonUniformBallotFindMSB:
{
auto valueId = Object::ID(insn.word(4));
ASSERT(type.sizeInComponents == 1);
ASSERT(getType(getObject(valueId)).sizeInComponents == 4);
ASSERT(type.componentCount == 1);
ASSERT(getType(getObject(valueId)).componentCount == 4);
Operand value(this, state, valueId);
dst.move(0, SIMD::UInt(31) - Ctlz(value.UInt(0) & SIMD::UInt(15), false));
break;
......@@ -260,7 +260,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
auto y = CmpEQ(SIMD::Int(1), id.Int(0));
auto z = CmpEQ(SIMD::Int(2), id.Int(0));
auto w = CmpEQ(SIMD::Int(3), id.Int(0));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
SIMD::Int v = value.Int(i);
dst.move(i, (x & v.xxxx) | (y & v.yyyy) | (z & v.zzzz) | (w & v.wwww));
......@@ -276,7 +276,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
auto y = CmpEQ(SIMD::Int(1), SIMD::Int(0, 1, 2, 3) ^ mask.Int(0));
auto z = CmpEQ(SIMD::Int(2), SIMD::Int(0, 1, 2, 3) ^ mask.Int(0));
auto w = CmpEQ(SIMD::Int(3), SIMD::Int(0, 1, 2, 3) ^ mask.Int(0));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
SIMD::Int v = value.Int(i);
dst.move(i, (x & v.xxxx) | (y & v.yyyy) | (z & v.zzzz) | (w & v.wwww));
......@@ -292,7 +292,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
auto d1 = CmpEQ(SIMD::Int(1), delta.Int(0));
auto d2 = CmpEQ(SIMD::Int(2), delta.Int(0));
auto d3 = CmpEQ(SIMD::Int(3), delta.Int(0));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
SIMD::Int v = value.Int(i);
dst.move(i, (d0 & v.xyzw) | (d1 & v.xxyz) | (d2 & v.xxxy) | (d3 & v.xxxx));
......@@ -308,7 +308,7 @@ SpirvShader::EmitResult SpirvShader::EmitGroupNonUniform(InsnIterator insn, Emit
auto d1 = CmpEQ(SIMD::Int(1), delta.Int(0));
auto d2 = CmpEQ(SIMD::Int(2), delta.Int(0));
auto d3 = CmpEQ(SIMD::Int(3), delta.Int(0));
for(auto i = 0u; i < type.sizeInComponents; i++)
for(auto i = 0u; i < type.componentCount; i++)
{
SIMD::Int v = value.Int(i);
dst.move(i, (d0 & v.xyzw) | (d1 & v.yzww) | (d2 & v.zwww) | (d3 & v.wwww));
......
......@@ -111,7 +111,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio
Object::ID coordinateId = insn.word(4);
auto &resultType = getType(insn.resultTypeId());
auto &result = state->createIntermediate(insn.resultId(), resultType.sizeInComponents);
auto &result = state->createIntermediate(insn.resultId(), resultType.componentCount);
auto imageDescriptor = state->getPointer(sampledImageId).base; // vk::SampledImageDescriptor*
// If using a separate sampler, look through the OpSampledImage instruction to find the sampler descriptor
......@@ -204,7 +204,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio
Array<SIMD::Float> in(16); // Maximum 16 input parameter components.
uint32_t coordinates = coordinateType.sizeInComponents - instruction.isProj();
uint32_t coordinates = coordinateType.componentCount - instruction.isProj();
instruction.coordinates = coordinates;
uint32_t i = 0;
......@@ -247,16 +247,16 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio
auto dxValue = Operand(this, state, gradDxId);
auto dyValue = Operand(this, state, gradDyId);
auto &dxyType = getType(dxValue);
ASSERT(dxyType.sizeInComponents == getType(dyValue).sizeInComponents);
ASSERT(dxyType.componentCount == getType(dyValue).componentCount);
instruction.grad = dxyType.sizeInComponents;
instruction.grad = dxyType.componentCount;
for(uint32_t j = 0; j < dxyType.sizeInComponents; j++, i++)
for(uint32_t j = 0; j < dxyType.componentCount; j++, i++)
{
in[i] = dxValue.Float(j);
}
for(uint32_t j = 0; j < dxyType.sizeInComponents; j++, i++)
for(uint32_t j = 0; j < dxyType.componentCount; j++, i++)
{
in[i] = dyValue.Float(j);
}
......@@ -275,9 +275,9 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio
auto offsetValue = Operand(this, state, offsetId);
auto &offsetType = getType(offsetValue);
instruction.offset = offsetType.sizeInComponents;
instruction.offset = offsetType.componentCount;
for(uint32_t j = 0; j < offsetType.sizeInComponents; j++, i++)
for(uint32_t j = 0; j < offsetType.componentCount; j++, i++)
{
in[i] = As<SIMD::Float>(offsetValue.Int(j)); // Integer values, but transfered as float.
}
......@@ -304,7 +304,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageSample(ImageInstruction instructio
Array<SIMD::Float> out(4);
Call<ImageSampler>(cache.function, texture, &in[0], &out[0], state->routine->constants);
for(auto i = 0u; i < resultType.sizeInComponents; i++) { result.move(i, out[i]); }
for(auto i = 0u; i < resultType.componentCount; i++) { result.move(i, out[i]); }
return EmitResult::Continue;
}
......@@ -315,7 +315,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQuerySizeLod(InsnIterator insn, Em
auto imageId = Object::ID(insn.word(3));
auto lodId = Object::ID(insn.word(4));
auto &dst = state->createIntermediate(insn.resultId(), resultTy.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), resultTy.componentCount);
GetImageDimensions(state, resultTy, imageId, lodId, dst);
return EmitResult::Continue;
......@@ -327,7 +327,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQuerySize(InsnIterator insn, EmitS
auto imageId = Object::ID(insn.word(3));
auto lodId = Object::ID(0);
auto &dst = state->createIntermediate(insn.resultId(), resultTy.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), resultTy.componentCount);
GetImageDimensions(state, resultTy, imageId, lodId, dst);
return EmitResult::Continue;
......@@ -378,12 +378,12 @@ void SpirvShader::GetImageDimensions(EmitState const *state, Type const &resultT
UNREACHABLE("Image descriptorType: %d", int(bindingLayout.descriptorType));
}
auto dimensions = resultTy.sizeInComponents - (isArrayed ? 1 : 0);
auto dimensions = resultTy.componentCount - (isArrayed ? 1 : 0);
std::vector<Int> out;
if(lodId != 0)
{
auto lodVal = Operand(this, state, lodId);
ASSERT(getType(lodVal).sizeInComponents == 1);
ASSERT(getType(lodVal).componentCount == 1);
auto lod = lodVal.Int(0);
auto one = SIMD::Int(1);
for(uint32_t i = 0; i < dimensions; i++)
......@@ -409,7 +409,7 @@ void SpirvShader::GetImageDimensions(EmitState const *state, Type const &resultT
SpirvShader::EmitResult SpirvShader::EmitImageQueryLevels(InsnIterator insn, EmitState *state) const
{
auto &resultTy = getType(Type::ID(insn.resultTypeId()));
ASSERT(resultTy.sizeInComponents == 1);
ASSERT(resultTy.componentCount == 1);
auto imageId = Object::ID(insn.word(3));
const DescriptorDecorations &d = descriptorDecorations.at(imageId);
......@@ -438,7 +438,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQueryLevels(InsnIterator insn, Emi
SpirvShader::EmitResult SpirvShader::EmitImageQuerySamples(InsnIterator insn, EmitState *state) const
{
auto &resultTy = getType(Type::ID(insn.resultTypeId()));
ASSERT(resultTy.sizeInComponents == 1);
ASSERT(resultTy.componentCount == 1);
auto imageId = Object::ID(insn.word(3));
auto imageTy = getType(getObject(imageId));
ASSERT(imageTy.definition.opcode() == spv::OpTypeImage);
......@@ -476,12 +476,12 @@ SIMD::Pointer SpirvShader::GetTexelAddress(EmitState const *state, SIMD::Pointer
auto routine = state->routine;
bool isArrayed = imageType.definition.word(5) != 0;
auto dim = static_cast<spv::Dim>(imageType.definition.word(3));
int dims = getType(coordinate).sizeInComponents - (isArrayed ? 1 : 0);
int dims = getType(coordinate).componentCount - (isArrayed ? 1 : 0);
SIMD::Int u = coordinate.Int(0);
SIMD::Int v = SIMD::Int(0);
if(getType(coordinate).sizeInComponents > 1)
if(getType(coordinate).componentCount > 1)
{
v = coordinate.Int(1);
}
......@@ -586,7 +586,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageRead(InsnIterator insn, EmitState
auto imageSizeInBytes = *Pointer<Int>(binding + OFFSET(vk::StorageImageDescriptor, sizeInBytes));
auto &dst = state->createIntermediate(insn.resultId(), resultType.sizeInComponents);
auto &dst = state->createIntermediate(insn.resultId(), resultType.componentCount);
auto texelSize = vk::Format(vkFormat).bytes();
auto basePtr = SIMD::Pointer(imageBase, imageSizeInBytes);
......
......@@ -54,7 +54,7 @@ SpirvShader::EmitResult SpirvShader::EmitLoad(InsnIterator insn, EmitState *stat
auto ptr = GetPointerToData(pointerId, 0, state);
bool interleavedByLane = IsStorageInterleavedByLane(pointerTy.storageClass);
auto &dst = state->createIntermediate(resultId, resultTy.sizeInComponents);
auto &dst = state->createIntermediate(resultId, resultTy.componentCount);
auto robustness = state->getOutOfBoundsBehavior(pointerTy.storageClass);
VisitMemoryObject(pointerId, [&](const MemoryElement &el) {
......@@ -136,7 +136,7 @@ SpirvShader::EmitResult SpirvShader::EmitVariable(InsnIterator insn, EmitState *
ASSERT(objectTy.opcode() == spv::OpTypePointer);
auto base = &routine->getVariable(resultId)[0];
auto elementTy = getType(objectTy.element);
auto size = elementTy.sizeInComponents * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
auto size = elementTy.componentCount * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
state->createPointer(resultId, SIMD::Pointer(base, size));
break;
}
......@@ -163,7 +163,7 @@ SpirvShader::EmitResult SpirvShader::EmitVariable(InsnIterator insn, EmitState *
ASSERT(objectTy.opcode() == spv::OpTypePointer);
auto base = &routine->getVariable(resultId)[0];
auto elementTy = getType(objectTy.element);
auto size = elementTy.sizeInComponents * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
auto size = elementTy.componentCount * static_cast<uint32_t>(sizeof(float)) * SIMD::Width;
state->createPointer(resultId, SIMD::Pointer(base, size));
break;
}
......@@ -378,7 +378,7 @@ void SpirvShader::VisitMemoryObject(Object::ID id, const MemoryVisitor &f) const
{
// Objects without explicit layout are tightly packed.
auto &elType = getType(type.element);
for(auto index = 0u; index < elType.sizeInComponents; index++)
for(auto index = 0u; index < elType.componentCount; index++)
{
auto offset = static_cast<uint32_t>(index * sizeof(float));
f({ index, offset, elType });
......
......@@ -69,11 +69,11 @@ void SpirvShader::EvalSpecConstantOp(InsnIterator insn)
{
auto &result = CreateConstant(insn);
auto const &cond = getObject(insn.word(4));
auto condIsScalar = (getType(cond).sizeInComponents == 1);
auto condIsScalar = (getType(cond).componentCount == 1);
auto const &left = getObject(insn.word(5));
auto const &right = getObject(insn.word(6));
for(auto i = 0u; i < getType(result).sizeInComponents; i++)
for(auto i = 0u; i < getType(result).componentCount; i++)
{
auto sel = cond.constantValue[condIsScalar ? 0 : i];
result.constantValue[i] = sel ? left.constantValue[i] : right.constantValue[i];
......@@ -87,7 +87,7 @@ void SpirvShader::EvalSpecConstantOp(InsnIterator insn)
auto const &compositeObject = getObject(insn.word(4));
auto firstComponent = WalkLiteralAccessChain(compositeObject.typeId(), insn.wordCount() - 5, insn.wordPointer(5));
for(auto i = 0u; i < getType(result).sizeInComponents; i++)
for(auto i = 0u; i < getType(result).componentCount; i++)
{
result.constantValue[i] = compositeObject.constantValue[firstComponent + i];
}
......@@ -107,12 +107,12 @@ void SpirvShader::EvalSpecConstantOp(InsnIterator insn)
result.constantValue[i] = oldObject.constantValue[i];
}
// new part
for(auto i = 0u; i < getType(newPart).sizeInComponents; i++)
for(auto i = 0u; i < getType(newPart).componentCount; i++)
{
result.constantValue[firstNewComponent + i] = newPart.constantValue[i];
}
// old components after
for(auto i = firstNewComponent + getType(newPart).sizeInComponents; i < getType(result).sizeInComponents; i++)
for(auto i = firstNewComponent + getType(newPart).componentCount; i < getType(result).componentCount; i++)
{
result.constantValue[i] = oldObject.constantValue[i];
}
......@@ -125,7 +125,7 @@ void SpirvShader::EvalSpecConstantOp(InsnIterator insn)
auto const &firstHalf = getObject(insn.word(4));
auto const &secondHalf = getObject(insn.word(5));
for(auto i = 0u; i < getType(result).sizeInComponents; i++)
for(auto i = 0u; i < getType(result).componentCount; i++)
{
auto selector = insn.word(6 + i);
if(selector == static_cast<uint32_t>(-1))
......@@ -133,13 +133,13 @@ void SpirvShader::EvalSpecConstantOp(InsnIterator insn)
// Undefined value, we'll use zero
result.constantValue[i] = 0;
}
else if(selector < getType(firstHalf).sizeInComponents)
else if(selector < getType(firstHalf).componentCount)
{
result.constantValue[i] = firstHalf.constantValue[selector];
}
else
{
result.constantValue[i] = secondHalf.constantValue[selector - getType(firstHalf).sizeInComponents];
result.constantValue[i] = secondHalf.constantValue[selector - getType(firstHalf).componentCount];
}
}
break;
......@@ -159,7 +159,7 @@ void SpirvShader::EvalSpecConstantUnaryOp(InsnIterator insn)
auto opcode = static_cast<spv::Op>(insn.word(3));
auto const &lhs = getObject(insn.word(4));
auto size = getType(lhs).sizeInComponents;
auto size = getType(lhs).componentCount;
for(auto i = 0u; i < size; i++)
{
......@@ -210,7 +210,7 @@ void SpirvShader::EvalSpecConstantBinaryOp(InsnIterator insn)
auto opcode = static_cast<spv::Op>(insn.word(3));
auto const &lhs = getObject(insn.word(4));
auto const &rhs = getObject(insn.word(5));
auto size = getType(lhs).sizeInComponents;
auto size = getType(lhs).componentCount;
for(auto i = 0u; i < size; i++)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment