OSDN Git Service

Move AttribType enum to SpirvShader
authorChris Forbes <chrisforbes@google.com>
Thu, 17 Jan 2019 17:51:39 +0000 (09:51 -0800)
committerChris Forbes <chrisforbes@google.com>
Thu, 17 Jan 2019 18:43:23 +0000 (18:43 +0000)
We're about to remove VertexShader, but we still care about types of
vertex attributes.

Bug: b/120799499

Change-Id: I80bed181479651e9d2470b81c7223e3381fbf4a7
Reviewed-on: https://swiftshader-review.googlesource.com/c/23708
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
src/Device/VertexProcessor.cpp
src/Device/VertexProcessor.hpp
src/Pipeline/SpirvShader.hpp
src/Pipeline/VertexRoutine.cpp
src/Pipeline/VertexShader.cpp
src/Pipeline/VertexShader.hpp

index 9fc7308..7f7d265 100644 (file)
@@ -412,7 +412,7 @@ namespace sw
                        state.input[i].type = context->input[i].type;
                        state.input[i].count = context->input[i].count;
                        state.input[i].normalized = context->input[i].normalized;
-                       state.input[i].attribType = context->vertexShader ? context->vertexShader->getAttribType(i) : VertexShader::ATTRIBTYPE_FLOAT;
+                       state.input[i].attribType = context->vertexShader ? context->vertexShader->getAttribType(i) : SpirvShader::ATTRIBTYPE_FLOAT;
                }
 
                for(unsigned int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++)
index 83383e3..7a14864 100644 (file)
@@ -19,6 +19,7 @@
 #include "Context.hpp"
 #include "RoutineCache.hpp"
 #include "Pipeline/VertexShader.hpp"
+#include "Pipeline/SpirvShader.hpp"
 
 namespace sw
 {
@@ -73,7 +74,7 @@ namespace sw
                                StreamType type    : BITS(STREAMTYPE_LAST);
                                unsigned int count : 3;
                                bool normalized    : 1;
-                               unsigned int attribType : BITS(VertexShader::ATTRIBTYPE_LAST);
+                               unsigned int attribType : BITS(SpirvShader::ATTRIBTYPE_LAST);
                        };
 
                        struct Output
index 4a7d249..0d64a0e 100644 (file)
@@ -137,6 +137,15 @@ namespace sw
                        return modes;
                }
 
+               enum AttribType : unsigned char
+               {
+                       ATTRIBTYPE_FLOAT,
+                       ATTRIBTYPE_INT,
+                       ATTRIBTYPE_UINT,
+
+                       ATTRIBTYPE_LAST = ATTRIBTYPE_UINT
+               };
+
        private:
                const int serialID;
                static volatile int serialCounter;
index 9a82819..1db071b 100644 (file)
@@ -143,7 +143,7 @@ namespace sw
                Pointer<Byte> source2 = source1 + (!textureSampling ? stride : 0);
                Pointer<Byte> source3 = source2 + (!textureSampling ? stride : 0);
 
-               bool isNativeFloatAttrib = (stream.attribType == VertexShader::ATTRIBTYPE_FLOAT) || stream.normalized;
+               bool isNativeFloatAttrib = (stream.attribType == SpirvShader::ATTRIBTYPE_FLOAT) || stream.normalized;
 
                switch(stream.type)
                {
@@ -174,13 +174,13 @@ namespace sw
 
                                        switch(stream.attribType)
                                        {
-                                       case VertexShader::ATTRIBTYPE_INT:
+                                       case SpirvShader::ATTRIBTYPE_INT:
                                                if(stream.count >= 1) v.x = As<Float4>(Int4(v.x));
                                                if(stream.count >= 2) v.x = As<Float4>(Int4(v.y));
                                                if(stream.count >= 3) v.x = As<Float4>(Int4(v.z));
                                                if(stream.count >= 4) v.x = As<Float4>(Int4(v.w));
                                                break;
-                                       case VertexShader::ATTRIBTYPE_UINT:
+                                       case SpirvShader::ATTRIBTYPE_UINT:
                                                if(stream.count >= 1) v.x = As<Float4>(UInt4(v.x));
                                                if(stream.count >= 2) v.x = As<Float4>(UInt4(v.y));
                                                if(stream.count >= 3) v.x = As<Float4>(UInt4(v.z));
index 425ed4d..50e33c0 100644 (file)
@@ -33,7 +33,7 @@ namespace sw
                for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
                {
                        input[i] = Semantic();
-                       attribType[i] = ATTRIBTYPE_FLOAT;
+                       attribType[i] = SpirvShader::ATTRIBTYPE_FLOAT;
                }
 
                if(vs)   // Make a copy
@@ -70,7 +70,7 @@ namespace sw
                for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
                {
                        input[i] = Semantic();
-                       attribType[i] = ATTRIBTYPE_FLOAT;
+                       attribType[i] = SpirvShader::ATTRIBTYPE_FLOAT;
                }
 
                optimize();
@@ -157,7 +157,7 @@ namespace sw
                return textureSampling;
        }
 
-       void VertexShader::setInput(int inputIdx, const sw::Shader::Semantic& semantic, AttribType aType)
+       void VertexShader::setInput(int inputIdx, const sw::Shader::Semantic& semantic, SpirvShader::AttribType aType)
        {
                input[inputIdx] = semantic;
                attribType[inputIdx] = aType;
@@ -188,7 +188,7 @@ namespace sw
                return input[inputIdx];
        }
 
-       VertexShader::AttribType VertexShader::getAttribType(int inputIdx) const
+       SpirvShader::AttribType VertexShader::getAttribType(int inputIdx) const
        {
                return attribType[inputIdx];
        }
index fc0a405..c6ae335 100644 (file)
@@ -16,6 +16,7 @@
 #define sw_VertexShader_hpp
 
 #include "Shader.hpp"
+#include "SpirvShader.hpp"
 #include "Device/Config.hpp"
 
 namespace sw
@@ -23,15 +24,6 @@ namespace sw
        class VertexShader : public Shader
        {
        public:
-               enum AttribType : unsigned char
-               {
-                       ATTRIBTYPE_FLOAT,
-                       ATTRIBTYPE_INT,
-                       ATTRIBTYPE_UINT,
-
-                       ATTRIBTYPE_LAST = ATTRIBTYPE_UINT
-               };
-
                explicit VertexShader(const VertexShader *vs = 0);
                explicit VertexShader(const unsigned long *token);
 
@@ -40,7 +32,7 @@ namespace sw
                static int validate(const unsigned long *const token);   // Returns number of instructions if valid
                bool containsTextureSampling() const;
 
-               void setInput(int inputIdx, const Semantic& semantic, AttribType attribType = ATTRIBTYPE_FLOAT);
+               void setInput(int inputIdx, const Semantic& semantic, SpirvShader::AttribType attribType = SpirvShader::ATTRIBTYPE_FLOAT);
                void setOutput(int outputIdx, int nbComponents, const Semantic& semantic);
                void setPositionRegister(int posReg);
                void setPointSizeRegister(int ptSizeReg);
@@ -49,7 +41,7 @@ namespace sw
 
                const Semantic& getInput(int inputIdx) const;
                const Semantic& getOutput(int outputIdx, int component) const;
-               AttribType getAttribType(int inputIndex) const;
+               SpirvShader::AttribType getAttribType(int inputIndex) const;
                int getPositionRegister() const { return positionRegister; }
                int getPointSizeRegister() const { return pointSizeRegister; }
                bool isInstanceIdDeclared() const { return instanceIdDeclared; }
@@ -64,7 +56,7 @@ namespace sw
                Semantic input[MAX_VERTEX_INPUTS];
                Semantic output[MAX_VERTEX_OUTPUTS][4];
 
-               AttribType attribType[MAX_VERTEX_INPUTS];
+               SpirvShader::AttribType attribType[MAX_VERTEX_INPUTS];
 
                int positionRegister;
                int pointSizeRegister;