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/4547
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/D3D9/Direct3DDevice9.cpp b/src/D3D9/Direct3DDevice9.cpp
index b70dfac..45cd865 100644
--- a/src/D3D9/Direct3DDevice9.cpp
+++ b/src/D3D9/Direct3DDevice9.cpp
@@ -145,14 +145,14 @@
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};
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};
@@ -2993,7 +2993,7 @@
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][1] = constantData[i * 4 + 1];
@@ -5269,7 +5269,7 @@
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][1] = constantData[i * 4 + 1];
diff --git a/src/D3D9/Direct3DDevice9.hpp b/src/D3D9/Direct3DDevice9.hpp
index 3416dd9..c854678 100644
--- a/src/D3D9/Direct3DDevice9.hpp
+++ b/src/D3D9/Direct3DDevice9.hpp
@@ -264,11 +264,11 @@
unsigned int vertexShaderConstantsFDirty;
unsigned int vertexShaderConstantsIDirty;
- float pixelShaderConstantF[224][4];
+ float pixelShaderConstantF[FRAGMENT_UNIFORM_VECTORS][4];
int pixelShaderConstantI[16][4];
int pixelShaderConstantB[16];
- float vertexShaderConstantF[256][4];
+ float vertexShaderConstantF[VERTEX_UNIFORM_VECTORS][4];
int vertexShaderConstantI[16][4];
int vertexShaderConstantB[16];
diff --git a/src/D3D9/Direct3DStateBlock9.cpp b/src/D3D9/Direct3DStateBlock9.cpp
index 9c5d02a..da0611a 100644
--- a/src/D3D9/Direct3DStateBlock9.cpp
+++ b/src/D3D9/Direct3DStateBlock9.cpp
@@ -248,7 +248,7 @@
device->SetViewport(&viewport);
}
- for(int i = 0; i < 224; i++)
+ for(int i = 0; i < FRAGMENT_UNIFORM_VECTORS; i++)
{
if(*(int*)pixelShaderConstantF[i] != 0x80000000)
{
@@ -272,7 +272,7 @@
}
}
- for(int i = 0; i < 256; i++)
+ for(int i = 0; i < VERTEX_UNIFORM_VECTORS; i++)
{
if(*(int*)vertexShaderConstantF[i] != 0x80000000)
{
@@ -525,7 +525,7 @@
device->GetViewport(&viewport);
}
- for(int i = 0; i < 224; i++)
+ for(int i = 0; i < FRAGMENT_UNIFORM_VECTORS; i++)
{
if(*(int*)pixelShaderConstantF[i] != 0x80000000)
{
@@ -549,7 +549,7 @@
}
}
- for(int i = 0; i < 256; i++)
+ for(int i = 0; i < VERTEX_UNIFORM_VECTORS; i++)
{
if(*(int*)vertexShaderConstantF[i] != 0x80000000)
{
@@ -872,7 +872,7 @@
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][1] = 0x80000000;
@@ -880,7 +880,7 @@
(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][1] = 0x80000000;
@@ -1213,7 +1213,7 @@
vertexShader->Release();
}
- device->GetVertexShaderConstantF(0, vertexShaderConstantF[0], 256);
+ device->GetVertexShaderConstantF(0, vertexShaderConstantF[0], VERTEX_UNIFORM_VECTORS);
device->GetVertexShaderConstantI(0, vertexShaderConstantI[0], 16);
device->GetVertexShaderConstantB(0, vertexShaderConstantB, 16);
}
diff --git a/src/D3D9/Direct3DStateBlock9.hpp b/src/D3D9/Direct3DStateBlock9.hpp
index 5ae4e0b..3fd4bbc 100644
--- a/src/D3D9/Direct3DStateBlock9.hpp
+++ b/src/D3D9/Direct3DStateBlock9.hpp
@@ -12,6 +12,7 @@
#ifndef D3D9_Direct3DStateBlock9_hpp
#define D3D9_Direct3DStateBlock9_hpp
+#include "Config.hpp"
#include "Unknown.hpp"
#include <vector>
@@ -171,11 +172,11 @@
bool viewportCaptured;
D3DVIEWPORT9 viewport;
- float pixelShaderConstantF[224][4];
+ float pixelShaderConstantF[FRAGMENT_UNIFORM_VECTORS][4];
int pixelShaderConstantI[16][4];
int pixelShaderConstantB[16];
- float vertexShaderConstantF[256][4];
+ float vertexShaderConstantF[VERTEX_UNIFORM_VECTORS][4];
int vertexShaderConstantI[16][4];
int vertexShaderConstantB[16];
diff --git a/src/OpenGL/libGL/Context.h b/src/OpenGL/libGL/Context.h
index 101f074..6b12f0f 100644
--- a/src/OpenGL/libGL/Context.h
+++ b/src/OpenGL/libGL/Context.h
@@ -311,12 +311,12 @@
{
MAX_VERTEX_ATTRIBS = 9,
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_TEXTURE_IMAGE_UNITS = 2,
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 1,
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,
IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB,
diff --git a/src/OpenGL/libGL/Device.cpp b/src/OpenGL/libGL/Device.cpp
index 32cb2f9..01ad08b 100644
--- a/src/OpenGL/libGL/Device.cpp
+++ b/src/OpenGL/libGL/Device.cpp
@@ -127,14 +127,14 @@
vertexShaderDirty = true;
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};
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};
diff --git a/src/Renderer/Renderer.hpp b/src/Renderer/Renderer.hpp
index c443219..28afc42 100644
--- a/src/Renderer/Renderer.hpp
+++ b/src/Renderer/Renderer.hpp
@@ -120,7 +120,7 @@
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];
bool b[16];
};
diff --git a/src/Renderer/VertexProcessor.cpp b/src/Renderer/VertexProcessor.cpp
index 516fdc5..30e8cd5 100644
--- a/src/Renderer/VertexProcessor.cpp
+++ b/src/Renderer/VertexProcessor.cpp
@@ -126,7 +126,7 @@
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][1] = value[1];
diff --git a/src/Renderer/VertexProcessor.hpp b/src/Renderer/VertexProcessor.hpp
index a8ba461..06dfa4e 100644
--- a/src/Renderer/VertexProcessor.hpp
+++ b/src/Renderer/VertexProcessor.hpp
@@ -266,7 +266,7 @@
void setRoutineCacheSize(int cacheSize);
// 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];
bool b[16];
diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp
index e4587cc..94c2b9e 100644
--- a/src/Shader/VertexProgram.cpp
+++ b/src/Shader/VertexProgram.cpp
@@ -837,7 +837,7 @@
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 index1 = Extract(index, 1);