Commit 6abe1cbc by Nicolas Capens

Detect all texture sampling shader instructions.

Change-Id: If557db7db89659e6c2b043b21e5712fb34eafd8d Reviewed-on: https://swiftshader-review.googlesource.com/4561Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent a893e903
......@@ -1298,8 +1298,8 @@ namespace glsl
if(textureFunction.proj)
{
Instruction *div = emit(sw::Shader::OPCODE_DIV, &proj, arg[1], arg[1]);
div->dst.mask = 0x3;
Instruction *div = emit(sw::Shader::OPCODE_DIV, &proj, arg[1], arg[1]);
div->dst.mask = 0x3;
switch(t->getNominalSize())
{
......
......@@ -805,7 +805,7 @@ namespace sw
}
state.fixedFunction = !context->vertexShader && context->pixelShaderVersion() < 0x0300;
state.shaderContainsTexldl = context->vertexShader ? context->vertexShader->containsTexldl() : false;
state.textureSampling = context->vertexShader ? context->vertexShader->containsTextureSampling() : false;
state.positionRegister = context->vertexShader ? context->vertexShader->positionRegister : Pos;
state.pointSizeRegister = context->vertexShader ? context->vertexShader->pointSizeRegister : Pts;
......
......@@ -46,10 +46,10 @@ namespace sw
uint64_t shaderID;
bool fixedFunction : 1;
bool shaderContainsTexldl : 1;
bool textureSampling : 1;
unsigned int positionRegister : 4;
unsigned int pointSizeRegister : 4; // 0xF signifies no vertex point size
unsigned int vertexBlendMatrixCount : 3;
bool indexedVertexBlendEnable : 1;
bool vertexNormalActive : 1;
......@@ -115,7 +115,7 @@ namespace sw
union
{
unsigned char clamp : 4;
struct
{
unsigned char xClamp : 1;
......@@ -145,7 +145,7 @@ namespace sw
float4 cameraTransformT[12][4];
float4 normalTransformT[12][4];
float4 textureTransform[8][4];
float4 lightPosition[8];
float4 lightAmbient[8];
float4 lightSpecular[8];
......
......@@ -225,7 +225,7 @@ namespace sw
for(unsigned int i = 0; i < instruction.size(); i++)
{
if(instruction[i]->dst.type == Shader::PARAMETER_TEXTURE)
{
{
int index = instruction[i]->dst.index + 2;
int mask = instruction[i]->dst.mask;
......@@ -288,7 +288,7 @@ namespace sw
int index = instruction[i]->src[argument].index;
int swizzle = instruction[i]->src[argument].swizzle;
int mask = instruction[i]->dst.mask;
if(instruction[i]->src[argument].type == Shader::PARAMETER_TEXTURE)
{
index += 2;
......
......@@ -36,7 +36,7 @@ namespace sw
void VertexRoutine::generate()
{
const bool texldl = state.shaderContainsTexldl;
const bool textureSampling = state.textureSampling;
Pointer<Byte> cache = task + OFFSET(VertexTask,vertexCache);
Pointer<Byte> vertexCache = cache + OFFSET(VertexCache,vertex);
......@@ -50,7 +50,7 @@ namespace sw
{
UInt index = *Pointer<UInt>(batch);
UInt tagIndex = index & 0x0000003C;
UInt indexQ = !texldl ? UInt(index & 0xFFFFFFFC) : index; // FIXME: TEXLDL hack to have independent LODs, hurts performance.
UInt indexQ = !textureSampling ? UInt(index & 0xFFFFFFFC) : index; // FIXME: TEXLDL hack to have independent LODs, hurts performance.
If(*Pointer<UInt>(tagCache + tagIndex) != indexQ)
{
......@@ -131,14 +131,14 @@ namespace sw
Vector4f VertexRoutine::readStream(Pointer<Byte> &buffer, UInt &stride, const Stream &stream, const UInt &index)
{
const bool texldl = state.shaderContainsTexldl;
const bool textureSampling = state.textureSampling;
Vector4f v;
Pointer<Byte> source0 = buffer + index * stride;
Pointer<Byte> source1 = source0 + (!texldl ? stride : 0);
Pointer<Byte> source2 = source1 + (!texldl ? stride : 0);
Pointer<Byte> source3 = source2 + (!texldl ? stride : 0);
Pointer<Byte> source1 = source0 + (!textureSampling ? stride : 0);
Pointer<Byte> source2 = source1 + (!textureSampling ? stride : 0);
Pointer<Byte> source3 = source2 + (!textureSampling ? stride : 0);
switch(stream.type)
{
......
......@@ -141,9 +141,9 @@ namespace sw
return instructionCount;
}
bool VertexShader::containsTexldl() const
bool VertexShader::containsTextureSampling() const
{
return texldl;
return textureSampling;
}
void VertexShader::analyze()
......@@ -151,7 +151,7 @@ namespace sw
analyzeInput();
analyzeOutput();
analyzeDirtyConstants();
analyzeTexldl();
analyzeTextureSampling();
analyzeDynamicBranching();
analyzeSamplers();
analyzeCallSites();
......@@ -262,17 +262,15 @@ namespace sw
}
}
void VertexShader::analyzeTexldl()
void VertexShader::analyzeTextureSampling()
{
texldl = false;
textureSampling = false;
for(unsigned int i = 0; i < instruction.size(); i++)
for(unsigned int i = 0; i < instruction.size() && !textureSampling; i++)
{
if(instruction[i]->opcode == Shader::OPCODE_TEXLDL)
if(instruction[i]->src[1].type == PARAMETER_SAMPLER)
{
texldl = true;
break;
textureSampling = true;
}
}
}
......
......@@ -25,8 +25,8 @@ namespace sw
virtual ~VertexShader();
static int validate(const unsigned long *const token); // Returns number of instructions if valid
bool containsTexldl() const;
bool containsTextureSampling() const;
virtual void analyze();
int positionRegister; // FIXME: Private
......@@ -43,9 +43,9 @@ namespace sw
private:
void analyzeInput();
void analyzeOutput();
void analyzeTexldl();
void analyzeTextureSampling();
bool texldl;
bool textureSampling;
};
}
......
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