Commit 2e7f35b4 by Chris Forbes

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/23708Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 739a7fbe
......@@ -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++)
......
......@@ -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
......
......@@ -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;
......
......@@ -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));
......
......@@ -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];
}
......
......@@ -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;
......
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