Add utility function to count input components

This cl adds a new utility function to count the number of components used by an input. Bug: b/171415086 Change-Id: I348959ccd8945d2f336384cf7d905d3140231e4e Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51736 Commit-Queue: Alexis Hétu <sugoi@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 377716d1
......@@ -899,6 +899,25 @@ void SpirvShader::ProcessInterfaceVariable(Object &object)
}
}
uint32_t SpirvShader::GetNumInputComponents(int32_t location) const
{
ASSERT(location >= 0);
// Verify how many component(s) per input
// 1 to 4, for float, vec2, vec3, vec4.
// Note that matrices are divided over multiple inputs
uint32_t num_components_per_input = 0;
for(; num_components_per_input < 4; ++num_components_per_input)
{
if(inputs[(location << 2) | num_components_per_input].Type == ATTRIBTYPE_UNUSED)
{
break;
}
}
return num_components_per_input;
}
void SpirvShader::ProcessExecutionMode(InsnIterator insn)
{
Function::ID function = insn.word(1);
......
......@@ -1229,6 +1229,8 @@ private:
void EvalSpecConstantUnaryOp(InsnIterator insn);
void EvalSpecConstantBinaryOp(InsnIterator insn);
uint32_t GetNumInputComponents(int32_t location) const;
// Helper for implementing OpStore, which doesn't take an InsnIterator so it
// can also store independent operands.
void Store(Object::ID pointerId, const Operand &value, bool atomic, std::memory_order memoryOrder, EmitState *state) const;
......
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