Commit 028f41ba by Alexis Hetu Committed by Alexis Hétu

Added some uses of FRAGMENT_UNIFORM_VECTORS and VERTEX_UNIFORM_VECTORS

Replaced a few instances of 224 and 256 that were actually used to represent FRAGMENT_UNIFORM_VECTORS and VERTEX_UNIFORM_VECTORS. This cl should not change any behavior. Change-Id: I4b82341f32223fcee559aaf70df2ee83c9936d11 Reviewed-on: https://swiftshader-review.googlesource.com/4547Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent ba53fbf9
...@@ -145,14 +145,14 @@ namespace D3D9 ...@@ -145,14 +145,14 @@ namespace D3D9
SetTransform(D3DTS_WORLDMATRIX(i), &identity); SetTransform(D3DTS_WORLDMATRIX(i), &identity);
} }
for(int i = 0; i < 224; i++) for(int i = 0; i < FRAGMENT_UNIFORM_VECTORS; i++)
{ {
float zero[4] = {0, 0, 0, 0}; float zero[4] = {0, 0, 0, 0};
SetPixelShaderConstantF(i, zero, 1); SetPixelShaderConstantF(i, zero, 1);
} }
for(int i = 0; i < 256; i++) for(int i = 0; i < VERTEX_UNIFORM_VECTORS; i++)
{ {
float zero[4] = {0, 0, 0, 0}; float zero[4] = {0, 0, 0, 0};
...@@ -2993,7 +2993,7 @@ namespace D3D9 ...@@ -2993,7 +2993,7 @@ namespace D3D9
if(!stateRecorder) if(!stateRecorder)
{ {
for(unsigned int i = 0; i < count && startRegister + i < 224; i++) for(unsigned int i = 0; i < count && startRegister + i < FRAGMENT_UNIFORM_VECTORS; i++)
{ {
pixelShaderConstantF[startRegister + i][0] = constantData[i * 4 + 0]; pixelShaderConstantF[startRegister + i][0] = constantData[i * 4 + 0];
pixelShaderConstantF[startRegister + i][1] = constantData[i * 4 + 1]; pixelShaderConstantF[startRegister + i][1] = constantData[i * 4 + 1];
...@@ -5269,7 +5269,7 @@ namespace D3D9 ...@@ -5269,7 +5269,7 @@ namespace D3D9
if(!stateRecorder) if(!stateRecorder)
{ {
for(unsigned int i = 0; i < count && startRegister + i < 256; i++) for(unsigned int i = 0; i < count && startRegister + i < VERTEX_UNIFORM_VECTORS; i++)
{ {
vertexShaderConstantF[startRegister + i][0] = constantData[i * 4 + 0]; vertexShaderConstantF[startRegister + i][0] = constantData[i * 4 + 0];
vertexShaderConstantF[startRegister + i][1] = constantData[i * 4 + 1]; vertexShaderConstantF[startRegister + i][1] = constantData[i * 4 + 1];
......
...@@ -264,11 +264,11 @@ namespace D3D9 ...@@ -264,11 +264,11 @@ namespace D3D9
unsigned int vertexShaderConstantsFDirty; unsigned int vertexShaderConstantsFDirty;
unsigned int vertexShaderConstantsIDirty; unsigned int vertexShaderConstantsIDirty;
float pixelShaderConstantF[224][4]; float pixelShaderConstantF[FRAGMENT_UNIFORM_VECTORS][4];
int pixelShaderConstantI[16][4]; int pixelShaderConstantI[16][4];
int pixelShaderConstantB[16]; int pixelShaderConstantB[16];
float vertexShaderConstantF[256][4]; float vertexShaderConstantF[VERTEX_UNIFORM_VECTORS][4];
int vertexShaderConstantI[16][4]; int vertexShaderConstantI[16][4];
int vertexShaderConstantB[16]; int vertexShaderConstantB[16];
......
...@@ -248,7 +248,7 @@ namespace D3D9 ...@@ -248,7 +248,7 @@ namespace D3D9
device->SetViewport(&viewport); device->SetViewport(&viewport);
} }
for(int i = 0; i < 224; i++) for(int i = 0; i < FRAGMENT_UNIFORM_VECTORS; i++)
{ {
if(*(int*)pixelShaderConstantF[i] != 0x80000000) if(*(int*)pixelShaderConstantF[i] != 0x80000000)
{ {
...@@ -272,7 +272,7 @@ namespace D3D9 ...@@ -272,7 +272,7 @@ namespace D3D9
} }
} }
for(int i = 0; i < 256; i++) for(int i = 0; i < VERTEX_UNIFORM_VECTORS; i++)
{ {
if(*(int*)vertexShaderConstantF[i] != 0x80000000) if(*(int*)vertexShaderConstantF[i] != 0x80000000)
{ {
...@@ -525,7 +525,7 @@ namespace D3D9 ...@@ -525,7 +525,7 @@ namespace D3D9
device->GetViewport(&viewport); device->GetViewport(&viewport);
} }
for(int i = 0; i < 224; i++) for(int i = 0; i < FRAGMENT_UNIFORM_VECTORS; i++)
{ {
if(*(int*)pixelShaderConstantF[i] != 0x80000000) if(*(int*)pixelShaderConstantF[i] != 0x80000000)
{ {
...@@ -549,7 +549,7 @@ namespace D3D9 ...@@ -549,7 +549,7 @@ namespace D3D9
} }
} }
for(int i = 0; i < 256; i++) for(int i = 0; i < VERTEX_UNIFORM_VECTORS; i++)
{ {
if(*(int*)vertexShaderConstantF[i] != 0x80000000) if(*(int*)vertexShaderConstantF[i] != 0x80000000)
{ {
...@@ -872,7 +872,7 @@ namespace D3D9 ...@@ -872,7 +872,7 @@ namespace D3D9
viewportCaptured = false; viewportCaptured = false;
for(int i = 0; i < 224; i++) for(int i = 0; i < FRAGMENT_UNIFORM_VECTORS; i++)
{ {
(int&)pixelShaderConstantF[i][0] = 0x80000000; (int&)pixelShaderConstantF[i][0] = 0x80000000;
(int&)pixelShaderConstantF[i][1] = 0x80000000; (int&)pixelShaderConstantF[i][1] = 0x80000000;
...@@ -880,7 +880,7 @@ namespace D3D9 ...@@ -880,7 +880,7 @@ namespace D3D9
(int&)pixelShaderConstantF[i][3] = 0x80000000; (int&)pixelShaderConstantF[i][3] = 0x80000000;
} }
for(int i = 0; i < 256; i++) for(int i = 0; i < VERTEX_UNIFORM_VECTORS; i++)
{ {
(int&)vertexShaderConstantF[i][0] = 0x80000000; (int&)vertexShaderConstantF[i][0] = 0x80000000;
(int&)vertexShaderConstantF[i][1] = 0x80000000; (int&)vertexShaderConstantF[i][1] = 0x80000000;
...@@ -1213,7 +1213,7 @@ namespace D3D9 ...@@ -1213,7 +1213,7 @@ namespace D3D9
vertexShader->Release(); vertexShader->Release();
} }
device->GetVertexShaderConstantF(0, vertexShaderConstantF[0], 256); device->GetVertexShaderConstantF(0, vertexShaderConstantF[0], VERTEX_UNIFORM_VECTORS);
device->GetVertexShaderConstantI(0, vertexShaderConstantI[0], 16); device->GetVertexShaderConstantI(0, vertexShaderConstantI[0], 16);
device->GetVertexShaderConstantB(0, vertexShaderConstantB, 16); device->GetVertexShaderConstantB(0, vertexShaderConstantB, 16);
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#ifndef D3D9_Direct3DStateBlock9_hpp #ifndef D3D9_Direct3DStateBlock9_hpp
#define D3D9_Direct3DStateBlock9_hpp #define D3D9_Direct3DStateBlock9_hpp
#include "Config.hpp"
#include "Unknown.hpp" #include "Unknown.hpp"
#include <vector> #include <vector>
...@@ -171,11 +172,11 @@ namespace D3D9 ...@@ -171,11 +172,11 @@ namespace D3D9
bool viewportCaptured; bool viewportCaptured;
D3DVIEWPORT9 viewport; D3DVIEWPORT9 viewport;
float pixelShaderConstantF[224][4]; float pixelShaderConstantF[FRAGMENT_UNIFORM_VECTORS][4];
int pixelShaderConstantI[16][4]; int pixelShaderConstantI[16][4];
int pixelShaderConstantB[16]; int pixelShaderConstantB[16];
float vertexShaderConstantF[256][4]; float vertexShaderConstantF[VERTEX_UNIFORM_VECTORS][4];
int vertexShaderConstantI[16][4]; int vertexShaderConstantI[16][4];
int vertexShaderConstantB[16]; int vertexShaderConstantB[16];
......
...@@ -311,12 +311,12 @@ enum ...@@ -311,12 +311,12 @@ enum
{ {
MAX_VERTEX_ATTRIBS = 9, MAX_VERTEX_ATTRIBS = 9,
MAX_UNIFORM_VECTORS = 256, // Device limit MAX_UNIFORM_VECTORS = 256, // Device limit
MAX_VERTEX_UNIFORM_VECTORS = 256 - 3, // Reserve space for gl_DepthRange MAX_VERTEX_UNIFORM_VECTORS = VERTEX_UNIFORM_VECTORS - 3, // Reserve space for gl_DepthRange
MAX_VARYING_VECTORS = 10, MAX_VARYING_VECTORS = 10,
MAX_TEXTURE_IMAGE_UNITS = 2, MAX_TEXTURE_IMAGE_UNITS = 2,
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 1, MAX_VERTEX_TEXTURE_IMAGE_UNITS = 1,
MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS, MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS,
MAX_FRAGMENT_UNIFORM_VECTORS = 224 - 3, // Reserve space for gl_DepthRange MAX_FRAGMENT_UNIFORM_VECTORS = FRAGMENT_UNIFORM_VECTORS - 3, // Reserve space for gl_DepthRange
MAX_DRAW_BUFFERS = 1, MAX_DRAW_BUFFERS = 1,
IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB, IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB,
......
...@@ -127,14 +127,14 @@ namespace gl ...@@ -127,14 +127,14 @@ namespace gl
vertexShaderDirty = true; vertexShaderDirty = true;
vertexShaderConstantsFDirty = 0; vertexShaderConstantsFDirty = 0;
for(int i = 0; i < 224; i++) for(int i = 0; i < FRAGMENT_UNIFORM_VECTORS; i++)
{ {
float zero[4] = {0, 0, 0, 0}; float zero[4] = {0, 0, 0, 0};
setPixelShaderConstantF(i, zero, 1); setPixelShaderConstantF(i, zero, 1);
} }
for(int i = 0; i < 256; i++) for(int i = 0; i < VERTEX_UNIFORM_VECTORS; i++)
{ {
float zero[4] = {0, 0, 0, 0}; float zero[4] = {0, 0, 0, 0};
......
...@@ -120,7 +120,7 @@ namespace sw ...@@ -120,7 +120,7 @@ namespace sw
struct VS struct VS
{ {
float4 c[256 + 1]; // One extra for indices out of range, c[256] = {0, 0, 0, 0} float4 c[VERTEX_UNIFORM_VECTORS + 1]; // One extra for indices out of range, c[VERTEX_UNIFORM_VECTORS] = {0, 0, 0, 0}
int4 i[16]; int4 i[16];
bool b[16]; bool b[16];
}; };
......
...@@ -126,7 +126,7 @@ namespace sw ...@@ -126,7 +126,7 @@ namespace sw
void VertexProcessor::setFloatConstant(unsigned int index, const float value[4]) void VertexProcessor::setFloatConstant(unsigned int index, const float value[4])
{ {
if(index < 256) if(index < VERTEX_UNIFORM_VECTORS)
{ {
c[index][0] = value[0]; c[index][0] = value[0];
c[index][1] = value[1]; c[index][1] = value[1];
......
...@@ -266,7 +266,7 @@ namespace sw ...@@ -266,7 +266,7 @@ namespace sw
void setRoutineCacheSize(int cacheSize); void setRoutineCacheSize(int cacheSize);
// Shader constants // Shader constants
float4 c[256 + 1]; // One extra for indices out of range, c[256] = {0, 0, 0, 0} float4 c[VERTEX_UNIFORM_VECTORS + 1]; // One extra for indices out of range, c[VERTEX_UNIFORM_VECTORS] = {0, 0, 0, 0}
int4 i[16]; int4 i[16];
bool b[16]; bool b[16];
......
...@@ -837,7 +837,7 @@ namespace sw ...@@ -837,7 +837,7 @@ namespace sw
Int4 index = Int4(i) + As<Int4>(a) * Int4(src.rel.scale); Int4 index = Int4(i) + As<Int4>(a) * Int4(src.rel.scale);
index = Min(As<UInt4>(index), UInt4(256)); // Clamp to constant register range, c[256] = {0, 0, 0, 0} index = Min(As<UInt4>(index), UInt4(VERTEX_UNIFORM_VECTORS)); // Clamp to constant register range, c[VERTEX_UNIFORM_VECTORS] = {0, 0, 0, 0}
Int index0 = Extract(index, 0); Int index0 = Extract(index, 0);
Int index1 = Extract(index, 1); Int index1 = Extract(index, 1);
......
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