Commit 0b65c5e3 by Alexis Hetu Committed by Alexis Hétu

Replacing numbers by constants

In order to be able to easily modify values in between OpenGL ES versions, some constants were added to replace hardcoded numbers. Change-Id: Ic35bf8e45341addf5315acaa9ffac01095b8907c Reviewed-on: https://swiftshader-review.googlesource.com/2761Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent de6b75c6
......@@ -67,7 +67,15 @@ extern Profiler profiler;
enum
{
OUTLINE_RESOLUTION = 4096, // Maximum vertical resolution of the render target
MIPMAP_LEVELS = 14
MIPMAP_LEVELS = 14,
TEXTURE_IMAGE_UNITS = 16,
VERTEX_TEXTURE_IMAGE_UNITS = 4,
TOTAL_IMAGE_UNITS = TEXTURE_IMAGE_UNITS + VERTEX_TEXTURE_IMAGE_UNITS,
FRAGMENT_UNIFORM_VECTORS = 224,
VERTEX_UNIFORM_VECTORS = 256,
MAX_UNIFORM_BLOCKS_COMPONENTS = 49152,
MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = MAX_UNIFORM_BLOCKS_COMPONENTS + 4 * FRAGMENT_UNIFORM_VECTORS,
MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = MAX_UNIFORM_BLOCKS_COMPONENTS + 4 * VERTEX_UNIFORM_VECTORS,
};
#endif // sw_Config_hpp
......@@ -426,7 +426,7 @@ namespace gl
void Device::setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
{
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];
......@@ -473,7 +473,7 @@ namespace gl
void Device::setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
{
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];
......
......@@ -89,8 +89,8 @@ namespace gl
bool vertexShaderDirty;
unsigned int vertexShaderConstantsFDirty;
float pixelShaderConstantF[224][4];
float vertexShaderConstantF[256][4];
float pixelShaderConstantF[FRAGMENT_UNIFORM_VECTORS][4];
float vertexShaderConstantF[VERTEX_UNIFORM_VECTORS][4];
Image *renderTarget;
Image *depthStencil;
......
......@@ -1587,21 +1587,21 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
UNIMPLEMENTED();
*params = IMPLEMENTATION_MAX_COLOR_ATTACHMENTS;
break;
case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: // integer, at least 1
case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: // integer, at least 50048
UNIMPLEMENTED();
*params = 1;
*params = MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS;
break;
case GL_MAX_COMBINED_UNIFORM_BLOCKS: // integer, at least 70
UNIMPLEMENTED();
*params = 70;
break;
case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: // integer, at least 1
case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: // integer, at least 50176
UNIMPLEMENTED();
*params = 1;
*params = MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS;
break;
case GL_MAX_DRAW_BUFFERS: // integer, at least 8
UNIMPLEMENTED();
*params = 8;
*params = IMPLEMENTATION_MAX_DRAW_BUFFERS;
break;
case GL_MAX_ELEMENT_INDEX: // integer, at least 16777215
UNIMPLEMENTED();
......@@ -1645,7 +1645,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break;
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: // integer, at least 4
UNIMPLEMENTED();
*params = 4;
*params = IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS;
break;
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: // integer, at least 4
UNIMPLEMENTED();
......@@ -1657,7 +1657,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break;
case GL_MAX_UNIFORM_BUFFER_BINDINGS: // integer, at least 36
UNIMPLEMENTED();
*params = 36;
*params = IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS;
break;
case GL_MAX_VARYING_COMPONENTS: // integer, at least 60
UNIMPLEMENTED();
......@@ -1729,7 +1729,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break;
case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: // integer, defaults to 1
UNIMPLEMENTED();
*params = 1;
*params = IMPLEMENTATION_UNIFORM_BUFFER_OFFSET_ALIGNMENT;
break;
case GL_UNIFORM_BUFFER_SIZE: // indexed[n] 64-bit integer, initially 0
UNIMPLEMENTED();
......
......@@ -70,12 +70,12 @@ enum
{
MAX_VERTEX_ATTRIBS = 16,
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 = 16,
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 4,
MAX_TEXTURE_IMAGE_UNITS = TEXTURE_IMAGE_UNITS,
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 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,
};
......
......@@ -406,7 +406,7 @@ namespace es2
void Device::setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
{
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];
......@@ -453,7 +453,7 @@ namespace es2
void Device::setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
{
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];
......
......@@ -95,8 +95,8 @@ namespace es2
bool vertexShaderDirty;
unsigned int vertexShaderConstantsFDirty;
float pixelShaderConstantF[224][4];
float vertexShaderConstantF[256][4];
float pixelShaderConstantF[FRAGMENT_UNIFORM_VECTORS][4];
float vertexShaderConstantF[VERTEX_UNIFORM_VECTORS][4];
egl::Image *renderTarget;
egl::Image *depthStencil;
......
......@@ -47,6 +47,8 @@ enum
IMPLEMENTATION_MAX_COLOR_ATTACHMENTS = 8,
IMPLEMENTATION_MAX_DRAW_BUFFERS = 8,
IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 4,
IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS = 36,
IMPLEMENTATION_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 1,
};
class Texture : public egl::Texture
......
......@@ -406,7 +406,7 @@ namespace es2
void Device::setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
{
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];
......@@ -453,7 +453,7 @@ namespace es2
void Device::setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
{
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];
......
......@@ -93,8 +93,8 @@ namespace es2
bool vertexShaderDirty;
unsigned int vertexShaderConstantsFDirty;
float pixelShaderConstantF[224][4];
float vertexShaderConstantF[256][4];
float pixelShaderConstantF[FRAGMENT_UNIFORM_VECTORS][4];
float vertexShaderConstantF[VERTEX_UNIFORM_VECTORS][4];
egl::Image *renderTarget;
egl::Image *depthStencil;
......
......@@ -200,7 +200,7 @@ namespace sw
}
// Set vertex streams to null stream
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
input[i].defaults();
}
......@@ -208,7 +208,7 @@ namespace sw
fogStart = 0.0f;
fogEnd = 1.0f;
for(int i = 0; i < 16; i++) textureWrap[i] = 0;
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++) textureWrap[i] = 0;
for(int i = 0; i < 8; i++) texGen[i] = TEXGEN_PASSTHRU;
for(int i = 0; i < 8; i++) textureTransformCount[i] = 0;
for(int i = 0; i < 8; i++) textureTransformProject[i] = false;
......
......@@ -395,15 +395,15 @@ namespace sw
int alphaReference;
TextureStage textureStage[8];
Sampler sampler[16 + 4];
Sampler sampler[TOTAL_IMAGE_UNITS];
Format renderTargetInternalFormat(int index);
int colorWriteActive();
int colorWriteActive(int index);
bool colorUsed();
Resource *texture[16 + 4];
Stream input[16];
Resource *texture[TOTAL_IMAGE_UNITS];
Stream input[TEXTURE_IMAGE_UNITS];
Resource *indexBuffer;
bool preTransformed; // FIXME: Private
......@@ -414,7 +414,7 @@ namespace sw
void computeIllumination();
bool textureWrapActive;
unsigned char textureWrap[16];
unsigned char textureWrap[TEXTURE_IMAGE_UNITS];
TexGen texGen[8];
bool localViewer;
bool normalizeNormals;
......
......@@ -327,7 +327,7 @@ namespace sw
void PixelProcessor::setTextureFilter(unsigned int sampler, FilterType textureFilter)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setTextureFilter(textureFilter);
}
......@@ -336,7 +336,7 @@ namespace sw
void PixelProcessor::setMipmapFilter(unsigned int sampler, MipmapType mipmapFilter)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setMipmapFilter(mipmapFilter);
}
......@@ -345,7 +345,7 @@ namespace sw
void PixelProcessor::setGatherEnable(unsigned int sampler, bool enable)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setGatherEnable(enable);
}
......@@ -354,7 +354,7 @@ namespace sw
void PixelProcessor::setAddressingModeU(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setAddressingModeU(addressMode);
}
......@@ -363,7 +363,7 @@ namespace sw
void PixelProcessor::setAddressingModeV(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setAddressingModeV(addressMode);
}
......@@ -372,7 +372,7 @@ namespace sw
void PixelProcessor::setAddressingModeW(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setAddressingModeW(addressMode);
}
......@@ -381,7 +381,7 @@ namespace sw
void PixelProcessor::setReadSRGB(unsigned int sampler, bool sRGB)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setReadSRGB(sRGB);
}
......@@ -390,7 +390,7 @@ namespace sw
void PixelProcessor::setMipmapLOD(unsigned int sampler, float bias)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setMipmapLOD(bias);
}
......@@ -399,7 +399,7 @@ namespace sw
void PixelProcessor::setBorderColor(unsigned int sampler, const Color<float> &borderColor)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setBorderColor(borderColor);
}
......@@ -408,7 +408,7 @@ namespace sw
void PixelProcessor::setMaxAnisotropy(unsigned int sampler, float maxAnisotropy)
{
if(sampler < 16)
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setMaxAnisotropy(maxAnisotropy);
}
......
......@@ -80,7 +80,7 @@ namespace sw
TransparencyAntialiasing transparencyAntialiasing : BITS(TRANSPARENCY_LAST);
bool centroid : 1;
Sampler::State sampler[16];
Sampler::State sampler[TEXTURE_IMAGE_UNITS];
TextureStage::State textureStage[8];
struct Interpolant
......@@ -287,7 +287,7 @@ namespace sw
// Shader constants
word4 cW[8][4];
float4 c[224];
float4 c[FRAGMENT_UNIFORM_VECTORS];
int4 i[16];
bool b[16];
......
......@@ -341,12 +341,12 @@ namespace sw
draw->indexBuffer = context->indexBuffer;
for(int sampler = 0; sampler < 20; sampler++)
for(int sampler = 0; sampler < TOTAL_IMAGE_UNITS; sampler++)
{
draw->texture[sampler] = 0;
}
for(int sampler = 0; sampler < 16; sampler++)
for(int sampler = 0; sampler < TEXTURE_IMAGE_UNITS; sampler++)
{
if(pixelState.sampler[sampler].textureType != TEXTURE_NULL)
{
......@@ -395,14 +395,14 @@ namespace sw
{
if(context->vertexShader->getVersion() >= 0x0300)
{
for(int sampler = 0; sampler < 4; sampler++)
for(int sampler = 0; sampler < VERTEX_TEXTURE_IMAGE_UNITS; sampler++)
{
if(vertexState.samplerState[sampler].textureType != TEXTURE_NULL)
{
draw->texture[16 + sampler] = context->texture[16 + sampler];
draw->texture[16 + sampler]->lock(PUBLIC, PRIVATE);
draw->texture[TEXTURE_IMAGE_UNITS + sampler] = context->texture[TEXTURE_IMAGE_UNITS + sampler];
draw->texture[TEXTURE_IMAGE_UNITS + sampler]->lock(PUBLIC, PRIVATE);
data->mipmap[16 + sampler] = context->sampler[16 + sampler].getTextureData();
data->mipmap[TEXTURE_IMAGE_UNITS + sampler] = context->sampler[TEXTURE_IMAGE_UNITS + sampler].getTextureData();
}
}
}
......@@ -913,7 +913,7 @@ namespace sw
draw.depthStencil->unlockStencil();
}
for(int i = 0; i < 16 + 4; i++)
for(int i = 0; i < TOTAL_IMAGE_UNITS; i++)
{
if(draw.texture[i])
{
......@@ -921,7 +921,7 @@ namespace sw
}
}
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
if(draw.vertexStream[i])
{
......@@ -2085,14 +2085,14 @@ namespace sw
void Renderer::setTextureResource(unsigned int sampler, Resource *resource)
{
ASSERT(sampler < (16 + 4));
ASSERT(sampler < TOTAL_IMAGE_UNITS);
context->texture[sampler] = resource;
}
void Renderer::setTextureLevel(unsigned int sampler, unsigned int face, unsigned int level, Surface *surface, TextureType type)
{
ASSERT(sampler < (16 + 4) && face < 6 && level < MIPMAP_LEVELS);
ASSERT(sampler < TOTAL_IMAGE_UNITS && face < 6 && level < MIPMAP_LEVELS);
context->sampler[sampler].setTextureLevel(face, level, surface, type);
}
......
......@@ -82,9 +82,9 @@ namespace sw
{
const void *constants;
const void *input[16];
unsigned int stride[16];
Texture mipmap[16 + 4];
const void *input[TEXTURE_IMAGE_UNITS];
unsigned int stride[TEXTURE_IMAGE_UNITS];
Texture mipmap[TOTAL_IMAGE_UNITS];
const void *indices;
struct VS
......@@ -97,7 +97,7 @@ namespace sw
struct PS
{
word4 cW[8][4];
float4 c[224];
float4 c[FRAGMENT_UNIFORM_VECTORS];
int4 i[16];
bool b[16];
};
......@@ -180,11 +180,11 @@ namespace sw
int (*setupPrimitives)(Renderer *renderer, int batch, int count);
SetupProcessor::State setupState;
Resource *vertexStream[16];
Resource *vertexStream[TEXTURE_IMAGE_UNITS];
Resource *indexBuffer;
Surface *renderTarget[4];
Surface *depthStencil;
Resource *texture[16 + 4];
Resource *texture[TOTAL_IMAGE_UNITS];
int vsDirtyConstF;
int vsDirtyConstI;
......
......@@ -116,7 +116,7 @@ namespace sw
void VertexProcessor::resetInputStreams(bool preTransformed)
{
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
context->input[i].defaults();
}
......@@ -400,7 +400,7 @@ namespace sw
void VertexProcessor::setTextureWrap(unsigned int stage, int mask)
{
if(stage < 16)
if(stage < TEXTURE_IMAGE_UNITS)
{
context->textureWrap[stage] = mask;
}
......@@ -408,7 +408,7 @@ namespace sw
context->textureWrapActive = false;
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
context->textureWrapActive |= (context->textureWrap[i] != 0x00);
}
......@@ -452,90 +452,90 @@ namespace sw
void VertexProcessor::setTextureFilter(unsigned int sampler, FilterType textureFilter)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setTextureFilter(textureFilter);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setTextureFilter(textureFilter);
}
else ASSERT(false);
}
void VertexProcessor::setMipmapFilter(unsigned int sampler, MipmapType mipmapFilter)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setMipmapFilter(mipmapFilter);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMipmapFilter(mipmapFilter);
}
else ASSERT(false);
}
void VertexProcessor::setGatherEnable(unsigned int sampler, bool enable)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setGatherEnable(enable);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setGatherEnable(enable);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeU(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setAddressingModeU(addressMode);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeU(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeV(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setAddressingModeV(addressMode);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeV(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeW(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setAddressingModeW(addressMode);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeW(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setReadSRGB(unsigned int sampler, bool sRGB)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setReadSRGB(sRGB);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setReadSRGB(sRGB);
}
else ASSERT(false);
}
void VertexProcessor::setMipmapLOD(unsigned int sampler, float bias)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setMipmapLOD(bias);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMipmapLOD(bias);
}
else ASSERT(false);
}
void VertexProcessor::setBorderColor(unsigned int sampler, const Color<float> &borderColor)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setBorderColor(borderColor);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setBorderColor(borderColor);
}
else ASSERT(false);
}
void VertexProcessor::setMaxAnisotropy(unsigned int sampler, float maxAnisotropy)
{
if(sampler < 4)
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[16 + sampler].setMaxAnisotropy(maxAnisotropy);
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxAnisotropy(maxAnisotropy);
}
else ASSERT(false);
}
......@@ -801,7 +801,7 @@ namespace sw
state.superSampling = context->getSuperSampleCount() > 1;
state.multiSampling = context->getMultiSampleCount() > 1;
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
state.input[i].type = context->input[i].type;
state.input[i].count = context->input[i].count;
......@@ -820,11 +820,11 @@ namespace sw
}
else
{
for(unsigned int i = 0; i < 4; i++)
for(unsigned int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++)
{
if(context->vertexShader->usesSampler(i))
{
state.samplerState[i] = context->sampler[16 + i].samplerState();
state.samplerState[i] = context->sampler[TEXTURE_IMAGE_UNITS + i].samplerState();
}
}
}
......
......@@ -83,7 +83,7 @@ namespace sw
TextureState textureState[8];
Sampler::State samplerState[4];
Sampler::State samplerState[VERTEX_TEXTURE_IMAGE_UNITS];
struct Input
{
......@@ -126,7 +126,7 @@ namespace sw
};
};
Input input[16];
Input input[TEXTURE_IMAGE_UNITS];
Output output[12];
};
......
......@@ -53,7 +53,7 @@ namespace sw
PixelRoutine::~PixelRoutine()
{
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
delete sampler[i];
}
......@@ -65,7 +65,7 @@ namespace sw
Long pipeTime = Ticks();
#endif
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
sampler[i] = new SamplerCore(r.constants, state.sampler[i]);
}
......@@ -2078,7 +2078,7 @@ namespace sw
{
Int index = As<Int>(Float(reg(r, sampler).x.x));
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
if(shader->usesSampler(i))
{
......
......@@ -296,7 +296,7 @@ namespace sw
const PixelShader *const shader;
private:
SamplerCore *sampler[16];
SamplerCore *sampler[TEXTURE_IMAGE_UNITS];
bool perturbate;
bool luminance;
......
......@@ -38,7 +38,7 @@ namespace sw
VertexProgram::~VertexProgram()
{
for(int i = 0; i < 4; i++)
for(int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++)
{
delete sampler[i];
}
......@@ -46,7 +46,7 @@ namespace sw
void VertexProgram::pipeline(Registers &r)
{
for(int i = 0; i < 4; i++)
for(int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++)
{
sampler[i] = new SamplerCore(r.constants, state.samplerState[i]);
}
......
......@@ -82,7 +82,7 @@ namespace sw
void sampleTexture(Registers &r, Vector4f &c, const Src &s, Float4 &u, Float4 &v, Float4 &w, Float4 &q);
SamplerCore *sampler[4];
SamplerCore *sampler[VERTEX_TEXTURE_IMAGE_UNITS];
int ifDepth;
int loopRepDepth;
......
......@@ -95,7 +95,7 @@ namespace sw
void VertexRoutine::readInput(Registers &r, UInt &index)
{
for(int i = 0; i < 16; i++)
for(int i = 0; i < TEXTURE_IMAGE_UNITS; i++)
{
Pointer<Byte> input = *Pointer<Pointer<Byte> >(r.data + OFFSET(DrawData,input) + sizeof(void*) * i);
UInt stride = *Pointer<UInt>(r.data + OFFSET(DrawData,stride) + sizeof(unsigned int) * i);
......
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