OSDN Git Service

Make the number of vertex inputs configurable.
authorNicolas Capens <capn@google.com>
Wed, 18 May 2016 18:44:21 +0000 (14:44 -0400)
committerNicolas Capens <capn@google.com>
Fri, 20 May 2016 18:18:16 +0000 (18:18 +0000)
Change-Id: Ic078acae24dd2b2361a32498b49238b98e0ac0d1
Reviewed-on: https://swiftshader-review.googlesource.com/5386
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
20 files changed:
src/D3D9/Capabilities.hpp
src/D3D9/Direct3DDevice9.cpp
src/D3D9/Direct3DDevice9.hpp
src/D3D9/Direct3DStateBlock9.cpp
src/D3D9/Direct3DStateBlock9.hpp
src/D3D9/Direct3DVertexDeclaration9.cpp
src/Main/Config.hpp
src/OpenGL/compiler/OutputASM.cpp
src/OpenGL/libGLES_CM/Context.h
src/OpenGL/libGLESv2/Context.h
src/Renderer/Context.cpp
src/Renderer/Context.hpp
src/Renderer/Renderer.cpp
src/Renderer/Renderer.hpp
src/Renderer/VertexProcessor.cpp
src/Renderer/VertexProcessor.hpp
src/Shader/VertexRoutine.cpp
src/Shader/VertexRoutine.hpp
src/Shader/VertexShader.cpp
src/Shader/VertexShader.hpp

index 02e5d86..768ad1d 100644 (file)
@@ -473,6 +473,7 @@ namespace D3D9
        {
                MAX_VERTEX_SHADER_CONST = 256,
                MAX_PIXEL_SHADER_CONST = 224,
+               MAX_VERTEX_INPUTS = 16,
                MAX_VERTEX_OUTPUTS = 12,
                MAX_PIXEL_INPUTS = 10,
        };
@@ -480,12 +481,14 @@ namespace D3D9
        // Shader Model 3.0 requirements
        META_ASSERT(MAX_VERTEX_SHADER_CONST >= 256);
        META_ASSERT(MAX_PIXEL_SHADER_CONST == 224);
+       META_ASSERT(MAX_VERTEX_INPUTS == 16);
        META_ASSERT(MAX_VERTEX_OUTPUTS == 12);
        META_ASSERT(MAX_PIXEL_INPUTS == 10);
 
        // Back-end minimum requirements
        META_ASSERT(sw::VERTEX_UNIFORM_VECTORS >= MAX_VERTEX_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_FRAGMENT_INPUTS >= MAX_PIXEL_INPUTS);
 }
index 3414a4a..96a0b9a 100644 (file)
@@ -93,7 +93,7 @@ namespace D3D9
                vertexShaderConstantsFDirty = 0;
                vertexShaderConstantsIDirty = 0;
 
-               for(int i = 0; i < 16; i++)
+               for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
                {
                        dataStream[i] = 0;
                        streamStride[i] = 0;
@@ -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])
                        {
@@ -5787,7 +5787,7 @@ namespace D3D9
 
                                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 &&
                                                   index == shader->input[i].index)
index da78c9b..4ca3442 100644 (file)
@@ -277,10 +277,10 @@ namespace D3D9
                int vertexShaderConstantB[16];
 
                Direct3DVertexDeclaration9 *vertexDeclaration;
-               Direct3DVertexBuffer9 *dataStream[16];
-               int streamStride[16];
-               int streamOffset[16];
-               unsigned int streamSourceFreq[16];
+               Direct3DVertexBuffer9 *dataStream[MAX_VERTEX_INPUTS];
+               int streamStride[MAX_VERTEX_INPUTS];
+               int streamOffset[MAX_VERTEX_INPUTS];
+               unsigned int streamSourceFreq[MAX_VERTEX_INPUTS];
                Direct3DIndexBuffer9 *indexData;
 
                Direct3DSwapChain9 *swapChain;
index 3971413..48ee0c5 100644 (file)
@@ -33,7 +33,7 @@ namespace D3D9
 
                indexBuffer = 0;
 
-               for(int stream = 0; stream < 16; stream++)
+               for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
                {
                        streamSource[stream].vertexBuffer = 0;
                }
@@ -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])
                        {
@@ -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])
                        {
@@ -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;
                        streamSourceFrequencyCaptured[stream] = false;
@@ -928,7 +928,7 @@ namespace D3D9
                        indexBuffer = 0;
                }
 
-               for(int stream = 0; stream < 16; stream++)
+               for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
                {
                        if(streamSource[stream].vertexBuffer)
                        {
@@ -1223,7 +1223,7 @@ namespace D3D9
 
        void Direct3DStateBlock9::captureStreamSourceFrequencies()
        {
-               for(int stream = 0; stream < 16; stream++)
+               for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
                {
                        streamSourceFrequencyCaptured[stream] = true;
                        device->GetStreamSourceFreq(stream, &streamSourceFrequency[stream]);
@@ -1272,7 +1272,7 @@ namespace D3D9
 
        void Direct3DStateBlock9::captureVertexStreams()
        {
-               for(int stream = 0; stream < 16; stream++)
+               for(int stream = 0; stream < MAX_VERTEX_INPUTS; stream++)
                {
                        streamSourceCaptured[stream] = true;
                        device->GetStreamSource(stream, reinterpret_cast<IDirect3DVertexBuffer9**>(&streamSource[stream].vertexBuffer), &streamSource[stream].offset, &streamSource[stream].stride);
index 31fa6e8..ed709b0 100644 (file)
@@ -139,17 +139,17 @@ namespace D3D9
                bool samplerStateCaptured[16 + 4][D3DSAMP_DMAPOFFSET + 1];
                unsigned long samplerState[16 + 4][D3DSAMP_DMAPOFFSET + 1];
 
-               bool streamSourceCaptured[16];
+               bool streamSourceCaptured[MAX_VERTEX_INPUTS];
                struct StreamSource
                {
                        Direct3DVertexBuffer9 *vertexBuffer;
                        unsigned int offset;
                        unsigned int stride;
                };
-               StreamSource streamSource[16];
+               StreamSource streamSource[MAX_VERTEX_INPUTS];
 
-               bool streamSourceFrequencyCaptured[16];
-               unsigned int streamSourceFrequency[16];
+               bool streamSourceFrequencyCaptured[MAX_VERTEX_INPUTS];
+               unsigned int streamSourceFrequency[MAX_VERTEX_INPUTS];
 
                bool textureCaptured[16 + 4];
                Direct3DBaseTexture9 *texture[16 + 4];
index 1cb5b2b..56718a1 100644 (file)
@@ -51,7 +51,7 @@ namespace D3D9
        {
                this->FVF = FVF;
 
-               vertexElement = new D3DVERTEXELEMENT9[16];
+               vertexElement = new D3DVERTEXELEMENT9[MAX_VERTEX_INPUTS];
 
                numElements = 0;
                int offset = 0;
index b0839b5..9b67ac1 100644 (file)
@@ -81,12 +81,12 @@ namespace sw
        {
                OUTLINE_RESOLUTION = 4096,   // Maximum vertical resolution of the render target
                MIPMAP_LEVELS = 14,
-               VERTEX_ATTRIBUTES = 16,
                TEXTURE_IMAGE_UNITS = 16,
                VERTEX_TEXTURE_IMAGE_UNITS = 16,
                TOTAL_IMAGE_UNITS = TEXTURE_IMAGE_UNITS + VERTEX_TEXTURE_IMAGE_UNITS,
                FRAGMENT_UNIFORM_VECTORS = 224,
                VERTEX_UNIFORM_VECTORS = 256,
+               MAX_VERTEX_INPUTS = 16,
                MAX_VERTEX_OUTPUTS = 12,
                MAX_FRAGMENT_INPUTS = 10,
                MAX_FRAGMENT_UNIFORM_BLOCKS = 12,
index 43ba172..8cf572b 100644 (file)
@@ -2908,7 +2908,7 @@ namespace glsl
                                const TType &type = attribute->getType();
                                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++)
                                        {
index 9051e02..1ee5699 100644 (file)
@@ -63,7 +63,7 @@ class IndexDataManager;
 
 enum
 {
-       MAX_VERTEX_ATTRIBS = sw::VERTEX_ATTRIBUTES,
+       MAX_VERTEX_ATTRIBS = sw::MAX_VERTEX_INPUTS,
        MAX_VARYING_VECTORS = 10,
        MAX_TEXTURE_UNITS = 2,
        MAX_DRAW_BUFFERS = 1,
index 6477734..d6e09ee 100644 (file)
@@ -74,7 +74,7 @@ class TransformFeedback;
 
 enum
 {
-       MAX_VERTEX_ATTRIBS = sw::VERTEX_ATTRIBUTES,
+       MAX_VERTEX_ATTRIBS = sw::MAX_VERTEX_INPUTS,
        MAX_UNIFORM_VECTORS = 256,   // Device limit
        MAX_VERTEX_UNIFORM_VECTORS = sw::VERTEX_UNIFORM_VECTORS - 3,   // Reserve space for gl_DepthRange
        MAX_VARYING_VECTORS = 10,
index bc7f37f..b206dde 100644 (file)
@@ -204,7 +204,7 @@ namespace sw
                }
 
                // 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();
                }
index 6e68ecb..f1e59ba 100644 (file)
@@ -442,7 +442,7 @@ namespace sw
                bool colorUsed();
 
                Resource *texture[TOTAL_IMAGE_UNITS];
-               Stream input[VERTEX_ATTRIBUTES];
+               Stream input[MAX_VERTEX_INPUTS];
                Resource *indexBuffer;
 
                bool preTransformed;   // FIXME: Private
index 712d74a..2cb19e3 100644 (file)
@@ -335,7 +335,7 @@ namespace sw
                        draw->setupPrimitives = setupPrimitives;
                        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;
                                data->input[i] = context->input[i].buffer;
@@ -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])
                                        {
index 4b3abbe..cf3cbc1 100644 (file)
@@ -117,8 +117,8 @@ namespace sw
        {
                const Constants *constants;
 
-               const void *input[VERTEX_ATTRIBUTES];
-               unsigned int stride[VERTEX_ATTRIBUTES];
+               const void *input[MAX_VERTEX_INPUTS];
+               unsigned int stride[MAX_VERTEX_INPUTS];
                Texture mipmap[TOTAL_IMAGE_UNITS];
                const void *indices;
 
@@ -224,7 +224,7 @@ namespace sw
                int (*setupPrimitives)(Renderer *renderer, int batch, int count);
                SetupProcessor::State setupState;
 
-               Resource *vertexStream[VERTEX_ATTRIBUTES];
+               Resource *vertexStream[MAX_VERTEX_INPUTS];
                Resource *indexBuffer;
                Surface *renderTarget[RENDERTARGETS];
                Surface *depthBuffer;
index 291e532..90c954f 100644 (file)
@@ -135,7 +135,7 @@ namespace sw
 
        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();
                }
@@ -912,7 +912,7 @@ namespace sw
                state.transformFeedbackQueryEnabled = context->transformFeedbackQueryEnabled;
                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].count = context->input[i].count;
index bcbf4fd..9629c47 100644 (file)
@@ -133,7 +133,7 @@ namespace sw
                                };
                        };
 
-                       Input input[VERTEX_ATTRIBUTES];
+                       Input input[MAX_VERTEX_INPUTS];
                        Output output[MAX_VERTEX_OUTPUTS];
                };
 
index 1affb45..dce0dc2 100644 (file)
@@ -83,7 +83,7 @@ namespace sw
 
        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);
                        UInt stride = *Pointer<UInt>(data + OFFSET(DrawData,stride) + sizeof(unsigned int) * i);
index d97d8ed..7f29ff5 100644 (file)
@@ -48,7 +48,7 @@ namespace sw
 
                Int clipFlags;
 
-               RegisterArray<16> v;   // Varying registers
+               RegisterArray<MAX_VERTEX_INPUTS> v;    // Input registers
                RegisterArray<MAX_VERTEX_OUTPUTS> o;   // Output registers
 
                const VertexProcessor::State &state;
index c488630..06dd1b2 100644 (file)
@@ -28,7 +28,7 @@ namespace sw
                pointSizeRegister = Unused;
                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);
                }
@@ -60,7 +60,7 @@ namespace sw
                pointSizeRegister = Unused;
                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);
                }
index 2a76cd2..0fdd09c 100644 (file)
@@ -38,9 +38,7 @@ namespace sw
 
                bool instanceIdDeclared;
 
-               enum {MAX_INPUT_ATTRIBUTES = 16};
-               Semantic input[MAX_INPUT_ATTRIBUTES];       // FIXME: Private
-
+               Semantic input[MAX_VERTEX_INPUTS];        // FIXME: Private
                Semantic output[MAX_VERTEX_OUTPUTS][4];   // FIXME: Private
 
        private: