Move parameter reading to a prototype constructor.
Bug 22652760
Change-Id: I317275cd2c15012da3a859735409af07ea9b2923
Reviewed-on: https://swiftshader-review.googlesource.com/4559
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Shader/VertexRoutine.cpp b/src/Shader/VertexRoutine.cpp
index 50bbf14..87d1fa0 100644
--- a/src/Shader/VertexRoutine.cpp
+++ b/src/Shader/VertexRoutine.cpp
@@ -33,11 +33,6 @@
void VertexRoutine::generate()
{
- Pointer<Byte> vertex(Arg<0>());
- Pointer<Byte> batch(Arg<1>());
- Pointer<Byte> task(Arg<2>());
- Pointer<Byte> data(Arg<3>());
-
const bool texldl = state.shaderContainsTexldl;
Pointer<Byte> cache = task + OFFSET(VertexTask,vertexCache);
@@ -47,7 +42,7 @@
UInt vertexCount = *Pointer<UInt>(task + OFFSET(VertexTask,vertexCount));
r.data = data;
- r.constants = *Pointer<Pointer<Byte> >(data + OFFSET(DrawData,constants));
+ r.constants = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,constants));
if(shader && shader->instanceIdDeclared)
{
r.instanceID = *Pointer<Int>(data + OFFSET(DrawData, instanceID));
@@ -89,7 +84,7 @@
{
for(int i = 0; i < VERTEX_ATTRIBUTES; i++)
{
- Pointer<Byte> input = *Pointer<Pointer<Byte> >(r.data + OFFSET(DrawData,input) + sizeof(void*) * i);
+ Pointer<Byte> input = *Pointer<Pointer<Byte>>(r.data + OFFSET(DrawData,input) + sizeof(void*) * i);
UInt stride = *Pointer<UInt>(r.data + OFFSET(DrawData,stride) + sizeof(unsigned int) * i);
r.v[i] = readStream(input, stride, state.input[i], index);
@@ -573,7 +568,7 @@
*Pointer<Float4>(cacheLine + OFFSET(Vertex,X) + sizeof(Vertex) * 3, 16) = v.w;
}
- void VertexRoutine::writeVertex(Pointer<Byte> &vertex, Pointer<Byte> &cache)
+ void VertexRoutine::writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cache)
{
for(int i = 0; i < 12; i++)
{
diff --git a/src/Shader/VertexRoutine.hpp b/src/Shader/VertexRoutine.hpp
index 66ec137..3eec924 100644
--- a/src/Shader/VertexRoutine.hpp
+++ b/src/Shader/VertexRoutine.hpp
@@ -19,8 +19,27 @@
namespace sw
{
- class VertexRoutine : public Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)>
+ class VertexRoutinePrototype : public Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)>
{
+ public:
+ VertexRoutinePrototype() : vertex(Arg<0>()), batch(Arg<1>()), task(Arg<2>()), data(Arg<3>()) {}
+ virtual ~VertexRoutinePrototype() {};
+
+ protected:
+ const Pointer<Byte> vertex;
+ const Pointer<Byte> batch;
+ const Pointer<Byte> task;
+ const Pointer<Byte> data;
+ };
+
+ class VertexRoutine : public VertexRoutinePrototype
+ {
+ public:
+ VertexRoutine(const VertexProcessor::State &state, const VertexShader *shader);
+ virtual ~VertexRoutine();
+
+ void generate();
+
protected:
struct Registers
{
@@ -73,14 +92,6 @@
Registers r;
- public:
- VertexRoutine(const VertexProcessor::State &state, const VertexShader *shader);
-
- virtual ~VertexRoutine();
-
- void generate();
-
- protected:
const VertexProcessor::State &state;
const VertexShader *const shader;
@@ -94,7 +105,7 @@
void computeClipFlags();
void postTransform();
void writeCache(Pointer<Byte> &cacheLine);
- void writeVertex(Pointer<Byte> &vertex, Pointer<Byte> &cacheLine);
+ void writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cacheLine);
};
}