Commit 53ad4afc by Alexis Hetu Committed by Alexis Hétu

Rename version to shaderModel

In order to avoid creating confusion between shader model and the actual shader's version, as specified by the #version token in a glsl shader, version was renamed to shaderModel. Change-Id: I481b6e3fc43168b504c2f2d9506422a697abc3a2 Reviewed-on: https://swiftshader-review.googlesource.com/14629Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 10c74a62
......@@ -484,7 +484,7 @@ namespace sw
{
if(!colorUsed()) return false;
if(pixelShaderVersion() >= 0x0300) return false;
if(pixelShaderModel() >= 0x0300) return false;
return fogEnable;
}
......@@ -616,7 +616,7 @@ namespace sw
bool Context::isProjectionComponent(unsigned int coordinate, int component)
{
if(pixelShaderVersion() <= 0x0103 && coordinate < 8 && textureTransformProject[coordinate])
if(pixelShaderModel() <= 0x0103 && coordinate < 8 && textureTransformProject[coordinate])
{
if(textureTransformCount[coordinate] == 2)
{
......@@ -1382,7 +1382,7 @@ namespace sw
return false;
}
if(textureTransformProject[coordinate] && pixelShaderVersion() <= 0x0103)
if(textureTransformProject[coordinate] && pixelShaderModel() <= 0x0103)
{
if(textureTransformCount[coordinate] == 2)
{
......@@ -1435,14 +1435,14 @@ namespace sw
return false;
}
unsigned short Context::pixelShaderVersion() const
unsigned short Context::pixelShaderModel() const
{
return pixelShader ? pixelShader->getVersion() : 0x0000;
return pixelShader ? pixelShader->getShaderModel() : 0x0000;
}
unsigned short Context::vertexShaderVersion() const
unsigned short Context::vertexShaderModel() const
{
return vertexShader ? vertexShader->getVersion() : 0x0000;
return vertexShader ? vertexShader->getShaderModel() : 0x0000;
}
int Context::getMultiSampleCount() const
......
......@@ -399,8 +399,8 @@ namespace sw
bool textureActive(int coordinate);
bool textureActive(int coordinate, int component);
unsigned short pixelShaderVersion() const;
unsigned short vertexShaderVersion() const;
unsigned short pixelShaderModel() const;
unsigned short vertexShaderModel() const;
int getMultiSampleCount() const;
int getSuperSampleCount() const;
......
......@@ -1062,7 +1062,7 @@ namespace sw
const bool sprite = context->pointSpriteActive();
const bool flatShading = (context->shadingMode == SHADING_FLAT) || point;
if(context->pixelShaderVersion() < 0x0300)
if(context->pixelShaderModel() < 0x0300)
{
for(int coordinate = 0; coordinate < 8; coordinate++)
{
......@@ -1079,7 +1079,7 @@ namespace sw
}
}
if(context->textureTransformProject[coordinate] && context->pixelShaderVersion() <= 0x0103)
if(context->textureTransformProject[coordinate] && context->pixelShaderModel() <= 0x0103)
{
if(context->textureTransformCount[coordinate] == 2)
{
......@@ -1173,7 +1173,7 @@ namespace sw
if(!routine)
{
const bool integerPipeline = (context->pixelShaderVersion() <= 0x0104);
const bool integerPipeline = (context->pixelShaderModel() <= 0x0104);
QuadRasterizer *generator = nullptr;
if(integerPipeline)
......
......@@ -401,7 +401,7 @@ namespace sw
}
}
if(context->pixelShaderVersion() <= 0x0104)
if(context->pixelShaderModel() <= 0x0104)
{
for(int stage = 0; stage < 8; stage++)
{
......@@ -415,7 +415,7 @@ namespace sw
if(context->vertexShader)
{
if(context->vertexShader->getVersion() >= 0x0300)
if(context->vertexShader->getShaderModel() >= 0x0300)
{
for(int sampler = 0; sampler < VERTEX_TEXTURE_IMAGE_UNITS; sampler++)
{
......
......@@ -183,7 +183,7 @@ namespace sw
}
}
}
else if(context->pixelShaderVersion() < 0x0300)
else if(context->pixelShaderModel() < 0x0300)
{
for(int coordinate = 0; coordinate < 8; coordinate++)
{
......
......@@ -925,7 +925,7 @@ namespace sw
state.shaderID = 0;
}
state.fixedFunction = !context->vertexShader && context->pixelShaderVersion() < 0x0300;
state.fixedFunction = !context->vertexShader && context->pixelShaderModel() < 0x0300;
state.textureSampling = context->vertexShader ? context->vertexShader->containsTextureSampling() : false;
state.positionRegister = context->vertexShader ? context->vertexShader->getPositionRegister() : Pos;
state.pointSizeRegister = context->vertexShader ? context->vertexShader->getPointSizeRegister() : Pts;
......@@ -1010,7 +1010,7 @@ namespace sw
state.output[i].wWrite = context->vertexShader->getOutput(i, 3).active();
}
}
else if(!context->preTransformed || context->pixelShaderVersion() < 0x0300)
else if(!context->preTransformed || context->pixelShaderModel() < 0x0300)
{
state.output[Pos].write = 0xF;
......@@ -1068,7 +1068,7 @@ namespace sw
}
}
if(context->vertexShaderVersion() < 0x0300)
if(context->vertexShaderModel() < 0x0300)
{
state.output[C0].clamp = 0xF;
state.output[C1].clamp = 0xF;
......
......@@ -88,7 +88,7 @@ namespace sw
const Src &src1 = instruction->src[1];
const Src &src2 = instruction->src[2];
unsigned short version = shader->getVersion();
unsigned short shaderModel = shader->getShaderModel();
bool pairing = i + 1 < shader->getLength() && shader->getInstruction(i + 1)->coissue; // First instruction of pair
bool coissue = instruction->coissue; // Second instruction of pair
......@@ -101,10 +101,10 @@ namespace sw
if(src1.type != Shader::PARAMETER_VOID) s1 = fetchRegister(src1);
if(src2.type != Shader::PARAMETER_VOID) s2 = fetchRegister(src2);
Float4 x = version < 0x0104 ? v[2 + dst.index].x : v[2 + src0.index].x;
Float4 y = version < 0x0104 ? v[2 + dst.index].y : v[2 + src0.index].y;
Float4 z = version < 0x0104 ? v[2 + dst.index].z : v[2 + src0.index].z;
Float4 w = version < 0x0104 ? v[2 + dst.index].w : v[2 + src0.index].w;
Float4 x = shaderModel < 0x0104 ? v[2 + dst.index].x : v[2 + src0.index].x;
Float4 y = shaderModel < 0x0104 ? v[2 + dst.index].y : v[2 + src0.index].y;
Float4 z = shaderModel < 0x0104 ? v[2 + dst.index].z : v[2 + src0.index].z;
Float4 w = shaderModel < 0x0104 ? v[2 + dst.index].w : v[2 + src0.index].w;
switch(opcode)
{
......@@ -126,7 +126,7 @@ namespace sw
case Shader::OPCODE_DP4: DP4(d, s0, s1); break;
case Shader::OPCODE_LRP: LRP(d, s0, s1, s2); break;
case Shader::OPCODE_TEXCOORD:
if(version < 0x0104)
if(shaderModel < 0x0104)
{
TEXCOORD(d, x, y, z, dst.index);
}
......@@ -143,11 +143,11 @@ namespace sw
}
break;
case Shader::OPCODE_TEXKILL:
if(version < 0x0104)
if(shaderModel < 0x0104)
{
TEXKILL(cMask, x, y, z);
}
else if(version == 0x0104)
else if(shaderModel == 0x0104)
{
if(dst.type == Shader::PARAMETER_TEXTURE)
{
......@@ -161,11 +161,11 @@ namespace sw
else ASSERT(false);
break;
case Shader::OPCODE_TEX:
if(version < 0x0104)
if(shaderModel < 0x0104)
{
TEX(d, x, y, z, dst.index, false);
}
else if(version == 0x0104)
else if(shaderModel == 0x0104)
{
if(src0.type == Shader::PARAMETER_TEXTURE)
{
......
......@@ -27,7 +27,7 @@ namespace sw
void PixelProgram::setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w)
{
if(shader->getVersion() >= 0x0300)
if(shader->getShaderModel() >= 0x0300)
{
if(shader->isVPosDeclared())
{
......
......@@ -31,7 +31,7 @@ namespace sw
PixelRoutine::PixelRoutine(const PixelProcessor::State &state, const PixelShader *shader) : QuadRasterizer(state, shader), v(shader && shader->dynamicallyIndexedInput)
{
if(!shader || shader->getVersion() < 0x0200 || forceClearRegisters)
if(!shader || shader->getShaderModel() < 0x0200 || forceClearRegisters)
{
for(int i = 0; i < MAX_FRAGMENT_INPUTS; i++)
{
......
......@@ -22,7 +22,7 @@ namespace sw
{
PixelShader::PixelShader(const PixelShader *ps) : Shader()
{
version = 0x0300;
shaderModel = 0x0300;
vPosDeclared = false;
vFaceDeclared = false;
centroid = false;
......@@ -198,7 +198,7 @@ namespace sw
void PixelShader::analyzeInterpolants()
{
if(version < 0x0300)
if(shaderModel < 0x0300)
{
// Set default mapping; disable unused interpolants below
input[0][0] = Semantic(Shader::USAGE_COLOR, 0);
......@@ -288,7 +288,7 @@ namespace sw
case Shader::OPCODE_DCL:
break; // Ignore
default: // Arithmetic instruction
if(version >= 0x0104)
if(shaderModel >= 0x0104)
{
ASSERT(false);
}
......@@ -329,7 +329,7 @@ namespace sw
switch(samplerType[sampler])
{
case Shader::SAMPLER_UNKNOWN:
if(version == 0x0104)
if(shaderModel == 0x0104)
{
if((inst->src[0].swizzle & 0x30) == 0x20) // .xyz
{
......@@ -380,7 +380,7 @@ namespace sw
interpolant[index][3] = true;
}
if(version == 0x0104 && inst->opcode == Shader::OPCODE_TEX)
if(shaderModel == 0x0104 && inst->opcode == Shader::OPCODE_TEX)
{
if(inst->src[0].modifier == Shader::MODIFIER_DZ)
{
......@@ -717,7 +717,7 @@ namespace sw
}
}
if(version >= 0x0200)
if(shaderModel >= 0x0200)
{
for(const auto &inst : instruction)
{
......
......@@ -1183,12 +1183,12 @@ namespace sw
int Shader::size(unsigned long opcode) const
{
return size(opcode, version);
return size(opcode, shaderModel);
}
int Shader::size(unsigned long opcode, unsigned short version)
int Shader::size(unsigned long opcode, unsigned short shaderModel)
{
if(version > 0x0300)
if(shaderModel > 0x0300)
{
ASSERT(false);
}
......@@ -1335,7 +1335,7 @@ namespace sw
opcode != OPCODE_PHASE &&
opcode != OPCODE_END)
{
if(version >= 0x0200)
if(shaderModel >= 0x0200)
{
length = (opcode & 0x0F000000) >> 24;
}
......@@ -1350,7 +1350,7 @@ namespace sw
ASSERT(false);
}
if(version == 0x0104)
if(shaderModel == 0x0104)
{
switch(opcode & 0x0000FFFF)
{
......@@ -1438,9 +1438,9 @@ namespace sw
return shaderType;
}
unsigned short Shader::getVersion() const
unsigned short Shader::getShaderModel() const
{
return version;
return shaderModel;
}
void Shader::print(const char *fileName, ...) const
......@@ -1456,7 +1456,7 @@ namespace sw
for(const auto &inst : instruction)
{
file << inst->string(shaderType, version) << std::endl;
file << inst->string(shaderType, shaderModel) << std::endl;
}
}
......@@ -1464,7 +1464,7 @@ namespace sw
{
std::ofstream file(fileName, std::ofstream::out | std::ofstream::app);
file << instruction[index]->string(shaderType, version) << std::endl;
file << instruction[index]->string(shaderType, shaderModel) << std::endl;
}
void Shader::append(Instruction *instruction)
......
......@@ -560,14 +560,14 @@ namespace sw
int getSerialID() const;
size_t getLength() const;
ShaderType getShaderType() const;
unsigned short getVersion() const;
unsigned short getShaderModel() const;
void append(Instruction *instruction);
void declareSampler(int i);
const Instruction *getInstruction(size_t i) const;
int size(unsigned long opcode) const;
static int size(unsigned long opcode, unsigned short version);
static int size(unsigned long opcode, unsigned short shaderModel);
void print(const char *fileName, ...) const;
void printInstruction(int index, const char *fileName) const;
......@@ -634,7 +634,7 @@ namespace sw
union
{
unsigned short version;
unsigned short shaderModel;
struct
{
......
......@@ -1605,9 +1605,9 @@ namespace sw
dst.w = arctanh(src.w, pp);
}
void ShaderCore::expp(Vector4f &dst, const Vector4f &src, unsigned short version)
void ShaderCore::expp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel)
{
if(version < 0x0200)
if(shaderModel < 0x0200)
{
Float4 frc = Frac(src.x);
Float4 floor = src.x - frc;
......@@ -1623,9 +1623,9 @@ namespace sw
}
}
void ShaderCore::logp(Vector4f &dst, const Vector4f &src, unsigned short version)
void ShaderCore::logp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel)
{
if(version < 0x0200)
if(shaderModel < 0x0200)
{
Float4 tmp0;
Float4 tmp1;
......
......@@ -334,8 +334,8 @@ namespace sw
void acosh(Vector4f &dst, const Vector4f &src, bool pp = false);
void asinh(Vector4f &dst, const Vector4f &src, bool pp = false);
void atanh(Vector4f &dst, const Vector4f &src, bool pp = false);
void expp(Vector4f &dst, const Vector4f &src, unsigned short version);
void logp(Vector4f &dst, const Vector4f &src, unsigned short version);
void expp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel);
void logp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel);
void cmp0(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void cmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control);
void icmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control);
......
......@@ -76,7 +76,7 @@ namespace sw
{
// shader->print("VertexShader-%0.8X.txt", state.shaderID);
unsigned short version = shader->getVersion();
unsigned short shaderModel = shader->getShaderModel();
enableIndex = 0;
stackIndex = 0;
......@@ -192,7 +192,7 @@ namespace sw
case Shader::OPCODE_ATT: att(d, s0, s1); break;
case Shader::OPCODE_EXP2X: exp2x(d, s0, pp); break;
case Shader::OPCODE_EXP2: exp2(d, s0, pp); break;
case Shader::OPCODE_EXPP: expp(d, s0, version); break;
case Shader::OPCODE_EXPP: expp(d, s0, shaderModel); break;
case Shader::OPCODE_EXP: exp(d, s0, pp); break;
case Shader::OPCODE_FRC: frc(d, s0); break;
case Shader::OPCODE_TRUNC: trunc(d, s0); break;
......@@ -203,7 +203,7 @@ namespace sw
case Shader::OPCODE_LIT: lit(d, s0); break;
case Shader::OPCODE_LOG2X: log2x(d, s0, pp); break;
case Shader::OPCODE_LOG2: log2(d, s0, pp); break;
case Shader::OPCODE_LOGP: logp(d, s0, version); break;
case Shader::OPCODE_LOGP: logp(d, s0, shaderModel); break;
case Shader::OPCODE_LOG: log(d, s0, pp); break;
case Shader::OPCODE_LRP: lrp(d, s0, s1, s2); break;
case Shader::OPCODE_STEP: step(d, s0, s1); break;
......@@ -411,7 +411,7 @@ namespace sw
break;
case Shader::PARAMETER_TEXCRDOUT:
// case Shader::PARAMETER_OUTPUT:
if(version < 0x0300)
if(shaderModel < 0x0300)
{
if(dst.x) pDst.x = o[T0 + dst.index].x;
if(dst.y) pDst.y = o[T0 + dst.index].y;
......@@ -542,7 +542,7 @@ namespace sw
break;
case Shader::PARAMETER_TEXCRDOUT:
// case Shader::PARAMETER_OUTPUT:
if(version < 0x0300)
if(shaderModel < 0x0300)
{
if(dst.x) o[T0 + dst.index].x = d.x;
if(dst.y) o[T0 + dst.index].y = d.y;
......
......@@ -23,7 +23,7 @@ namespace sw
{
VertexShader::VertexShader(const VertexShader *vs) : Shader()
{
version = 0x0300;
shaderModel = 0x0300;
positionRegister = Pos;
pointSizeRegister = Unused;
instanceIdDeclared = false;
......@@ -226,7 +226,7 @@ namespace sw
void VertexShader::analyzeOutput()
{
if(version < 0x0300)
if(shaderModel < 0x0300)
{
output[Pos][0] = Semantic(Shader::USAGE_POSITION, 0);
output[Pos][1] = Semantic(Shader::USAGE_POSITION, 0);
......
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