From: Chris Forbes Date: Thu, 17 Jan 2019 17:51:39 +0000 (-0800) Subject: Move AttribType enum to SpirvShader X-Git-Tag: android-x86-9.0-r1~443 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=2e7f35b477f5c864910b420d5d17b25320b9b266;p=android-x86%2Fexternal-swiftshader.git Move AttribType enum to SpirvShader 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 Reviewed-by: Alexis Hétu --- diff --git a/src/Device/VertexProcessor.cpp b/src/Device/VertexProcessor.cpp index 9fc73080b..7f7d265b9 100644 --- a/src/Device/VertexProcessor.cpp +++ b/src/Device/VertexProcessor.cpp @@ -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++) diff --git a/src/Device/VertexProcessor.hpp b/src/Device/VertexProcessor.hpp index 83383e30e..7a148648b 100644 --- a/src/Device/VertexProcessor.hpp +++ b/src/Device/VertexProcessor.hpp @@ -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 diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp index 4a7d24937..0d64a0e89 100644 --- a/src/Pipeline/SpirvShader.hpp +++ b/src/Pipeline/SpirvShader.hpp @@ -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; diff --git a/src/Pipeline/VertexRoutine.cpp b/src/Pipeline/VertexRoutine.cpp index 9a8281991..1db071ba9 100644 --- a/src/Pipeline/VertexRoutine.cpp +++ b/src/Pipeline/VertexRoutine.cpp @@ -143,7 +143,7 @@ namespace sw Pointer source2 = source1 + (!textureSampling ? stride : 0); Pointer 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(Int4(v.x)); if(stream.count >= 2) v.x = As(Int4(v.y)); if(stream.count >= 3) v.x = As(Int4(v.z)); if(stream.count >= 4) v.x = As(Int4(v.w)); break; - case VertexShader::ATTRIBTYPE_UINT: + case SpirvShader::ATTRIBTYPE_UINT: if(stream.count >= 1) v.x = As(UInt4(v.x)); if(stream.count >= 2) v.x = As(UInt4(v.y)); if(stream.count >= 3) v.x = As(UInt4(v.z)); diff --git a/src/Pipeline/VertexShader.cpp b/src/Pipeline/VertexShader.cpp index 425ed4d38..50e33c052 100644 --- a/src/Pipeline/VertexShader.cpp +++ b/src/Pipeline/VertexShader.cpp @@ -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]; } diff --git a/src/Pipeline/VertexShader.hpp b/src/Pipeline/VertexShader.hpp index fc0a40565..c6ae335c8 100644 --- a/src/Pipeline/VertexShader.hpp +++ b/src/Pipeline/VertexShader.hpp @@ -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;