Commit f0aef1a4 by Nicolas Capens

Make the number of vertex inputs configurable.

Change-Id: Ic078acae24dd2b2361a32498b49238b98e0ac0d1 Reviewed-on: https://swiftshader-review.googlesource.com/5386Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 3b4c93fe
...@@ -473,6 +473,7 @@ namespace D3D9 ...@@ -473,6 +473,7 @@ namespace D3D9
{ {
MAX_VERTEX_SHADER_CONST = 256, MAX_VERTEX_SHADER_CONST = 256,
MAX_PIXEL_SHADER_CONST = 224, MAX_PIXEL_SHADER_CONST = 224,
MAX_VERTEX_INPUTS = 16,
MAX_VERTEX_OUTPUTS = 12, MAX_VERTEX_OUTPUTS = 12,
MAX_PIXEL_INPUTS = 10, MAX_PIXEL_INPUTS = 10,
}; };
...@@ -480,12 +481,14 @@ namespace D3D9 ...@@ -480,12 +481,14 @@ namespace D3D9
// Shader Model 3.0 requirements // Shader Model 3.0 requirements
META_ASSERT(MAX_VERTEX_SHADER_CONST >= 256); META_ASSERT(MAX_VERTEX_SHADER_CONST >= 256);
META_ASSERT(MAX_PIXEL_SHADER_CONST == 224); META_ASSERT(MAX_PIXEL_SHADER_CONST == 224);
META_ASSERT(MAX_VERTEX_INPUTS == 16);
META_ASSERT(MAX_VERTEX_OUTPUTS == 12); META_ASSERT(MAX_VERTEX_OUTPUTS == 12);
META_ASSERT(MAX_PIXEL_INPUTS == 10); META_ASSERT(MAX_PIXEL_INPUTS == 10);
// Back-end minimum requirements // Back-end minimum requirements
META_ASSERT(sw::VERTEX_UNIFORM_VECTORS >= MAX_VERTEX_SHADER_CONST); META_ASSERT(sw::VERTEX_UNIFORM_VECTORS >= MAX_VERTEX_SHADER_CONST);
META_ASSERT(sw::FRAGMENT_UNIFORM_VECTORS >= MAX_PIXEL_SHADER_CONST); META_ASSERT(sw::FRAGMENT_UNIFORM_VECTORS >= MAX_PIXEL_SHADER_CONST);
META_ASSERT(sw::MAX_VERTEX_INPUTS >= MAX_VERTEX_INPUTS);
META_ASSERT(sw::MAX_VERTEX_OUTPUTS >= MAX_VERTEX_OUTPUTS); META_ASSERT(sw::MAX_VERTEX_OUTPUTS >= MAX_VERTEX_OUTPUTS);
META_ASSERT(sw::MAX_FRAGMENT_INPUTS >= MAX_PIXEL_INPUTS); META_ASSERT(sw::MAX_FRAGMENT_INPUTS >= MAX_PIXEL_INPUTS);
} }
......
...@@ -93,7 +93,7 @@ namespace D3D9 ...@@ -93,7 +93,7 @@ namespace D3D9
vertexShaderConstantsFDirty = 0; vertexShaderConstantsFDirty = 0;
vertexShaderConstantsIDirty = 0; vertexShaderConstantsIDirty = 0;
for(int i = 0; i < 16; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
dataStream[i] = 0; dataStream[i] = 0;
streamStride[i] = 0; streamStride[i] = 0;
...@@ -231,7 +231,7 @@ namespace D3D9 ...@@ -231,7 +231,7 @@ namespace D3D9
} }
} }
for(int i = 0; i < 16; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
if(dataStream[i]) if(dataStream[i])
{ {
...@@ -5787,7 +5787,7 @@ namespace D3D9 ...@@ -5787,7 +5787,7 @@ namespace D3D9
if(!vertexDeclaration->isPreTransformed()) if(!vertexDeclaration->isPreTransformed())
{ {
for(int i = 0; i < 16; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
if(usage == shader->input[i].usage && if(usage == shader->input[i].usage &&
index == shader->input[i].index) index == shader->input[i].index)
......
...@@ -277,10 +277,10 @@ namespace D3D9 ...@@ -277,10 +277,10 @@ namespace D3D9
int vertexShaderConstantB[16]; int vertexShaderConstantB[16];
Direct3DVertexDeclaration9 *vertexDeclaration; Direct3DVertexDeclaration9 *vertexDeclaration;
Direct3DVertexBuffer9 *dataStream[16]; Direct3DVertexBuffer9 *dataStream[MAX_VERTEX_INPUTS];
int streamStride[16]; int streamStride[MAX_VERTEX_INPUTS];
int streamOffset[16]; int streamOffset[MAX_VERTEX_INPUTS];
unsigned int streamSourceFreq[16]; unsigned int streamSourceFreq[MAX_VERTEX_INPUTS];
Direct3DIndexBuffer9 *indexData; Direct3DIndexBuffer9 *indexData;
Direct3DSwapChain9 *swapChain; Direct3DSwapChain9 *swapChain;
......
...@@ -33,7 +33,7 @@ namespace D3D9 ...@@ -33,7 +33,7 @@ namespace D3D9
indexBuffer = 0; indexBuffer = 0;
for(int stream = 0; stream < 16; stream++) for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
{ {
streamSource[stream].vertexBuffer = 0; streamSource[stream].vertexBuffer = 0;
} }
...@@ -185,7 +185,7 @@ namespace D3D9 ...@@ -185,7 +185,7 @@ namespace D3D9
} }
} }
for(int stream = 0; stream < 16; stream++) for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
{ {
if(streamSourceCaptured[stream]) if(streamSourceCaptured[stream])
{ {
...@@ -405,7 +405,7 @@ namespace D3D9 ...@@ -405,7 +405,7 @@ namespace D3D9
} }
} }
for(int stream = 0; stream < 16; stream++) for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
{ {
if(streamSourceCaptured[stream]) if(streamSourceCaptured[stream])
{ {
...@@ -840,7 +840,7 @@ namespace D3D9 ...@@ -840,7 +840,7 @@ namespace D3D9
} }
} }
for(int stream = 0; stream < 16; stream++) for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
{ {
streamSourceCaptured[stream] = false; streamSourceCaptured[stream] = false;
streamSourceFrequencyCaptured[stream] = false; streamSourceFrequencyCaptured[stream] = false;
...@@ -928,7 +928,7 @@ namespace D3D9 ...@@ -928,7 +928,7 @@ namespace D3D9
indexBuffer = 0; indexBuffer = 0;
} }
for(int stream = 0; stream < 16; stream++) for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
{ {
if(streamSource[stream].vertexBuffer) if(streamSource[stream].vertexBuffer)
{ {
...@@ -1223,7 +1223,7 @@ namespace D3D9 ...@@ -1223,7 +1223,7 @@ namespace D3D9
void Direct3DStateBlock9::captureStreamSourceFrequencies() void Direct3DStateBlock9::captureStreamSourceFrequencies()
{ {
for(int stream = 0; stream < 16; stream++) for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
{ {
streamSourceFrequencyCaptured[stream] = true; streamSourceFrequencyCaptured[stream] = true;
device->GetStreamSourceFreq(stream, &streamSourceFrequency[stream]); device->GetStreamSourceFreq(stream, &streamSourceFrequency[stream]);
...@@ -1272,7 +1272,7 @@ namespace D3D9 ...@@ -1272,7 +1272,7 @@ namespace D3D9
void Direct3DStateBlock9::captureVertexStreams() void Direct3DStateBlock9::captureVertexStreams()
{ {
for(int stream = 0; stream < 16; stream++) for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
{ {
streamSourceCaptured[stream] = true; streamSourceCaptured[stream] = true;
device->GetStreamSource(stream, reinterpret_cast<IDirect3DVertexBuffer9**>(&streamSource[stream].vertexBuffer), &streamSource[stream].offset, &streamSource[stream].stride); device->GetStreamSource(stream, reinterpret_cast<IDirect3DVertexBuffer9**>(&streamSource[stream].vertexBuffer), &streamSource[stream].offset, &streamSource[stream].stride);
......
...@@ -139,17 +139,17 @@ namespace D3D9 ...@@ -139,17 +139,17 @@ namespace D3D9
bool samplerStateCaptured[16 + 4][D3DSAMP_DMAPOFFSET + 1]; bool samplerStateCaptured[16 + 4][D3DSAMP_DMAPOFFSET + 1];
unsigned long samplerState[16 + 4][D3DSAMP_DMAPOFFSET + 1]; unsigned long samplerState[16 + 4][D3DSAMP_DMAPOFFSET + 1];
bool streamSourceCaptured[16]; bool streamSourceCaptured[MAX_VERTEX_INPUTS];
struct StreamSource struct StreamSource
{ {
Direct3DVertexBuffer9 *vertexBuffer; Direct3DVertexBuffer9 *vertexBuffer;
unsigned int offset; unsigned int offset;
unsigned int stride; unsigned int stride;
}; };
StreamSource streamSource[16]; StreamSource streamSource[MAX_VERTEX_INPUTS];
bool streamSourceFrequencyCaptured[16]; bool streamSourceFrequencyCaptured[MAX_VERTEX_INPUTS];
unsigned int streamSourceFrequency[16]; unsigned int streamSourceFrequency[MAX_VERTEX_INPUTS];
bool textureCaptured[16 + 4]; bool textureCaptured[16 + 4];
Direct3DBaseTexture9 *texture[16 + 4]; Direct3DBaseTexture9 *texture[16 + 4];
......
...@@ -51,7 +51,7 @@ namespace D3D9 ...@@ -51,7 +51,7 @@ namespace D3D9
{ {
this->FVF = FVF; this->FVF = FVF;
vertexElement = new D3DVERTEXELEMENT9[16]; vertexElement = new D3DVERTEXELEMENT9[MAX_VERTEX_INPUTS];
numElements = 0; numElements = 0;
int offset = 0; int offset = 0;
......
...@@ -81,12 +81,12 @@ namespace sw ...@@ -81,12 +81,12 @@ namespace sw
{ {
OUTLINE_RESOLUTION = 4096, // Maximum vertical resolution of the render target OUTLINE_RESOLUTION = 4096, // Maximum vertical resolution of the render target
MIPMAP_LEVELS = 14, MIPMAP_LEVELS = 14,
VERTEX_ATTRIBUTES = 16,
TEXTURE_IMAGE_UNITS = 16, TEXTURE_IMAGE_UNITS = 16,
VERTEX_TEXTURE_IMAGE_UNITS = 16, VERTEX_TEXTURE_IMAGE_UNITS = 16,
TOTAL_IMAGE_UNITS = TEXTURE_IMAGE_UNITS + VERTEX_TEXTURE_IMAGE_UNITS, TOTAL_IMAGE_UNITS = TEXTURE_IMAGE_UNITS + VERTEX_TEXTURE_IMAGE_UNITS,
FRAGMENT_UNIFORM_VECTORS = 224, FRAGMENT_UNIFORM_VECTORS = 224,
VERTEX_UNIFORM_VECTORS = 256, VERTEX_UNIFORM_VECTORS = 256,
MAX_VERTEX_INPUTS = 16,
MAX_VERTEX_OUTPUTS = 12, MAX_VERTEX_OUTPUTS = 12,
MAX_FRAGMENT_INPUTS = 10, MAX_FRAGMENT_INPUTS = 10,
MAX_FRAGMENT_UNIFORM_BLOCKS = 12, MAX_FRAGMENT_UNIFORM_BLOCKS = 12,
......
...@@ -2908,7 +2908,7 @@ namespace glsl ...@@ -2908,7 +2908,7 @@ namespace glsl
const TType &type = attribute->getType(); const TType &type = attribute->getType();
int registerCount = attribute->totalRegisterCount(); int registerCount = attribute->totalRegisterCount();
if(vertexShader && (index + registerCount) <= sw::VertexShader::MAX_INPUT_ATTRIBUTES) if(vertexShader && (index + registerCount) <= sw::MAX_VERTEX_INPUTS)
{ {
for(int i = 0; i < registerCount; i++) for(int i = 0; i < registerCount; i++)
{ {
......
...@@ -63,7 +63,7 @@ class IndexDataManager; ...@@ -63,7 +63,7 @@ class IndexDataManager;
enum enum
{ {
MAX_VERTEX_ATTRIBS = sw::VERTEX_ATTRIBUTES, MAX_VERTEX_ATTRIBS = sw::MAX_VERTEX_INPUTS,
MAX_VARYING_VECTORS = 10, MAX_VARYING_VECTORS = 10,
MAX_TEXTURE_UNITS = 2, MAX_TEXTURE_UNITS = 2,
MAX_DRAW_BUFFERS = 1, MAX_DRAW_BUFFERS = 1,
......
...@@ -74,7 +74,7 @@ class TransformFeedback; ...@@ -74,7 +74,7 @@ class TransformFeedback;
enum enum
{ {
MAX_VERTEX_ATTRIBS = sw::VERTEX_ATTRIBUTES, MAX_VERTEX_ATTRIBS = sw::MAX_VERTEX_INPUTS,
MAX_UNIFORM_VECTORS = 256, // Device limit MAX_UNIFORM_VECTORS = 256, // Device limit
MAX_VERTEX_UNIFORM_VECTORS = sw::VERTEX_UNIFORM_VECTORS - 3, // Reserve space for gl_DepthRange MAX_VERTEX_UNIFORM_VECTORS = sw::VERTEX_UNIFORM_VECTORS - 3, // Reserve space for gl_DepthRange
MAX_VARYING_VECTORS = 10, MAX_VARYING_VECTORS = 10,
......
...@@ -204,7 +204,7 @@ namespace sw ...@@ -204,7 +204,7 @@ namespace sw
} }
// Set vertex streams to null stream // Set vertex streams to null stream
for(int i = 0; i < VERTEX_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
input[i].defaults(); input[i].defaults();
} }
......
...@@ -442,7 +442,7 @@ namespace sw ...@@ -442,7 +442,7 @@ namespace sw
bool colorUsed(); bool colorUsed();
Resource *texture[TOTAL_IMAGE_UNITS]; Resource *texture[TOTAL_IMAGE_UNITS];
Stream input[VERTEX_ATTRIBUTES]; Stream input[MAX_VERTEX_INPUTS];
Resource *indexBuffer; Resource *indexBuffer;
bool preTransformed; // FIXME: Private bool preTransformed; // FIXME: Private
......
...@@ -335,7 +335,7 @@ namespace sw ...@@ -335,7 +335,7 @@ namespace sw
draw->setupPrimitives = setupPrimitives; draw->setupPrimitives = setupPrimitives;
draw->setupState = setupState; draw->setupState = setupState;
for(int i = 0; i < VERTEX_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
draw->vertexStream[i] = context->input[i].resource; draw->vertexStream[i] = context->input[i].resource;
data->input[i] = context->input[i].buffer; data->input[i] = context->input[i].buffer;
...@@ -990,7 +990,7 @@ namespace sw ...@@ -990,7 +990,7 @@ namespace sw
} }
} }
for(int i = 0; i < VERTEX_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
if(draw.vertexStream[i]) if(draw.vertexStream[i])
{ {
......
...@@ -117,8 +117,8 @@ namespace sw ...@@ -117,8 +117,8 @@ namespace sw
{ {
const Constants *constants; const Constants *constants;
const void *input[VERTEX_ATTRIBUTES]; const void *input[MAX_VERTEX_INPUTS];
unsigned int stride[VERTEX_ATTRIBUTES]; unsigned int stride[MAX_VERTEX_INPUTS];
Texture mipmap[TOTAL_IMAGE_UNITS]; Texture mipmap[TOTAL_IMAGE_UNITS];
const void *indices; const void *indices;
...@@ -224,7 +224,7 @@ namespace sw ...@@ -224,7 +224,7 @@ namespace sw
int (*setupPrimitives)(Renderer *renderer, int batch, int count); int (*setupPrimitives)(Renderer *renderer, int batch, int count);
SetupProcessor::State setupState; SetupProcessor::State setupState;
Resource *vertexStream[VERTEX_ATTRIBUTES]; Resource *vertexStream[MAX_VERTEX_INPUTS];
Resource *indexBuffer; Resource *indexBuffer;
Surface *renderTarget[RENDERTARGETS]; Surface *renderTarget[RENDERTARGETS];
Surface *depthBuffer; Surface *depthBuffer;
......
...@@ -135,7 +135,7 @@ namespace sw ...@@ -135,7 +135,7 @@ namespace sw
void VertexProcessor::resetInputStreams(bool preTransformed) void VertexProcessor::resetInputStreams(bool preTransformed)
{ {
for(int i = 0; i < VERTEX_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
context->input[i].defaults(); context->input[i].defaults();
} }
...@@ -912,7 +912,7 @@ namespace sw ...@@ -912,7 +912,7 @@ namespace sw
state.transformFeedbackQueryEnabled = context->transformFeedbackQueryEnabled; state.transformFeedbackQueryEnabled = context->transformFeedbackQueryEnabled;
state.transformFeedbackEnabled = context->transformFeedbackEnabled; state.transformFeedbackEnabled = context->transformFeedbackEnabled;
for(int i = 0; i < VERTEX_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
state.input[i].type = context->input[i].type; state.input[i].type = context->input[i].type;
state.input[i].count = context->input[i].count; state.input[i].count = context->input[i].count;
......
...@@ -133,7 +133,7 @@ namespace sw ...@@ -133,7 +133,7 @@ namespace sw
}; };
}; };
Input input[VERTEX_ATTRIBUTES]; Input input[MAX_VERTEX_INPUTS];
Output output[MAX_VERTEX_OUTPUTS]; Output output[MAX_VERTEX_OUTPUTS];
}; };
......
...@@ -83,7 +83,7 @@ namespace sw ...@@ -83,7 +83,7 @@ namespace sw
void VertexRoutine::readInput(UInt &index) void VertexRoutine::readInput(UInt &index)
{ {
for(int i = 0; i < VERTEX_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
Pointer<Byte> input = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,input) + sizeof(void*) * i); Pointer<Byte> input = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,input) + sizeof(void*) * i);
UInt stride = *Pointer<UInt>(data + OFFSET(DrawData,stride) + sizeof(unsigned int) * i); UInt stride = *Pointer<UInt>(data + OFFSET(DrawData,stride) + sizeof(unsigned int) * i);
......
...@@ -48,7 +48,7 @@ namespace sw ...@@ -48,7 +48,7 @@ namespace sw
Int clipFlags; Int clipFlags;
RegisterArray<16> v; // Varying registers RegisterArray<MAX_VERTEX_INPUTS> v; // Input registers
RegisterArray<MAX_VERTEX_OUTPUTS> o; // Output registers RegisterArray<MAX_VERTEX_OUTPUTS> o; // Output registers
const VertexProcessor::State &state; const VertexProcessor::State &state;
......
...@@ -28,7 +28,7 @@ namespace sw ...@@ -28,7 +28,7 @@ namespace sw
pointSizeRegister = Unused; pointSizeRegister = Unused;
instanceIdDeclared = false; instanceIdDeclared = false;
for(int i = 0; i < MAX_INPUT_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
input[i] = Semantic(-1, -1); input[i] = Semantic(-1, -1);
} }
...@@ -60,7 +60,7 @@ namespace sw ...@@ -60,7 +60,7 @@ namespace sw
pointSizeRegister = Unused; pointSizeRegister = Unused;
instanceIdDeclared = false; instanceIdDeclared = false;
for(int i = 0; i < MAX_INPUT_ATTRIBUTES; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
input[i] = Semantic(-1, -1); input[i] = Semantic(-1, -1);
} }
......
...@@ -38,9 +38,7 @@ namespace sw ...@@ -38,9 +38,7 @@ namespace sw
bool instanceIdDeclared; bool instanceIdDeclared;
enum {MAX_INPUT_ATTRIBUTES = 16}; Semantic input[MAX_VERTEX_INPUTS]; // FIXME: Private
Semantic input[MAX_INPUT_ATTRIBUTES]; // FIXME: Private
Semantic output[MAX_VERTEX_OUTPUTS][4]; // FIXME: Private Semantic output[MAX_VERTEX_OUTPUTS][4]; // FIXME: Private
private: private:
......
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