Allow Operand objects to contain pointers
The CL adds the ability for Operand variables to contains pointers,
similarly to Intermediate variables.
Bug: b/184952772
Change-Id: I3f01012ffe4f8806a7b0ac9034090ed77640189a
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/66456
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 76dce73..22ebf75 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -2730,14 +2730,16 @@
SpirvShader::Operand::Operand(const EmitState *state, const Object &object)
: constant(object.kind == SpirvShader::Object::Kind::Constant ? object.constantValue.data() : nullptr)
, intermediate(object.kind == SpirvShader::Object::Kind::Intermediate ? &state->getIntermediate(object.id()) : nullptr)
+ , pointer(object.kind == SpirvShader::Object::Kind::Pointer ? &state->getPointer(object.id()) : nullptr)
, componentCount(intermediate ? intermediate->componentCount : object.constantValue.size())
{
- ASSERT(intermediate || constant);
+ ASSERT(intermediate || constant || pointer);
}
SpirvShader::Operand::Operand(const Intermediate &value)
: constant(nullptr)
, intermediate(&value)
+ , pointer(nullptr)
, componentCount(value.componentCount)
{
}
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index 5dddf7c..a41b69d 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -1218,6 +1218,18 @@
return SIMD::UInt(constant[i]);
}
+ const SIMD::Pointer &Pointer(uint32_t i) const
+ {
+ ASSERT(intermediate == nullptr);
+
+ return pointer[i];
+ }
+
+ bool isPointer() const
+ {
+ return (pointer != nullptr);
+ }
+
private:
RR_PRINT_ONLY(friend struct rr::PrintValue::Ty<Operand>;)
@@ -1226,6 +1238,7 @@
const uint32_t *constant;
const Intermediate *intermediate;
+ const SIMD::Pointer *pointer;
public:
const uint32_t componentCount;