Commit ec0936c4 by Nicolas Capens

Make the number of vertex outputs configurable.

Change-Id: I17ae53e5274232e9e3b482daac56d507788e822c Reviewed-on: https://swiftshader-review.googlesource.com/5383Reviewed-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 2543bd73
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#ifndef D3D9_Capabilities_hpp #ifndef D3D9_Capabilities_hpp
#define D3D9_Capabilities_hpp #define D3D9_Capabilities_hpp
#include "Config.hpp"
#include "MetaMacro.hpp"
#include <d3d9.h> #include <d3d9.h>
namespace D3D9 namespace D3D9
...@@ -465,6 +468,23 @@ namespace D3D9 ...@@ -465,6 +468,23 @@ namespace D3D9
extern unsigned int textureMemory; extern unsigned int textureMemory;
extern unsigned int maxAnisotropy; extern unsigned int maxAnisotropy;
enum
{
MAX_VERTEX_SHADER_CONST = 256,
MAX_PIXEL_SHADER_CONST = 224,
MAX_VERTEX_OUTPUTS = 12,
};
// Shader Model 3.0 requirements
META_ASSERT(MAX_VERTEX_SHADER_CONST >= 256);
META_ASSERT(MAX_PIXEL_SHADER_CONST == 224);
META_ASSERT(MAX_VERTEX_OUTPUTS == 12);
// 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_OUTPUTS >= MAX_VERTEX_OUTPUTS);
} }
#endif // D3D9_Capabilities_hpp #endif // D3D9_Capabilities_hpp
...@@ -5800,7 +5800,7 @@ namespace D3D9 ...@@ -5800,7 +5800,7 @@ namespace D3D9
} }
else // Bind directly to the output else // Bind directly to the output
{ {
for(int i = 0; i < 12; i++) for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{ {
if((usage == shader->output[i][0].usage || (usage == D3DDECLUSAGE_POSITIONT && shader->output[i][0].usage == D3DDECLUSAGE_POSITION)) && if((usage == shader->output[i][0].usage || (usage == D3DDECLUSAGE_POSITIONT && shader->output[i][0].usage == D3DDECLUSAGE_POSITION)) &&
index == shader->output[i][0].index) index == shader->output[i][0].index)
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "Direct3D9.hpp" #include "Direct3D9.hpp"
#include "Direct3DSwapChain9.hpp" #include "Direct3DSwapChain9.hpp"
#include "Capabilities.hpp"
#include "Stream.hpp" #include "Stream.hpp"
...@@ -45,12 +46,6 @@ namespace D3D9 ...@@ -45,12 +46,6 @@ namespace D3D9
class Direct3DIndexBuffer9; class Direct3DIndexBuffer9;
class CriticalSection; class CriticalSection;
enum
{
MAX_VERTEX_SHADER_CONST = MIN(256, sw::VERTEX_UNIFORM_VECTORS),
MAX_PIXEL_SHADER_CONST = MIN(224, sw::FRAGMENT_UNIFORM_VECTORS),
};
class Direct3DDevice9 : public IDirect3DDevice9, public Unknown class Direct3DDevice9 : public IDirect3DDevice9, public Unknown
{ {
friend CriticalSection; friend CriticalSection;
......
...@@ -87,6 +87,7 @@ namespace sw ...@@ -87,6 +87,7 @@ namespace sw
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_OUTPUTS = 12,
MAX_FRAGMENT_UNIFORM_BLOCKS = 12, MAX_FRAGMENT_UNIFORM_BLOCKS = 12,
MAX_VERTEX_UNIFORM_BLOCKS = 12, MAX_VERTEX_UNIFORM_BLOCKS = 12,
MAX_UNIFORM_BUFFER_BINDINGS = MAX_FRAGMENT_UNIFORM_BLOCKS + MAX_VERTEX_UNIFORM_BLOCKS, // Limited to 127 by SourceParameter.bufferIndex in Shader.hpp MAX_UNIFORM_BUFFER_BINDINGS = MAX_FRAGMENT_UNIFORM_BLOCKS + MAX_VERTEX_UNIFORM_BLOCKS, // Limited to 127 by SourceParameter.bufferIndex in Shader.hpp
......
...@@ -2787,7 +2787,7 @@ namespace glsl ...@@ -2787,7 +2787,7 @@ namespace glsl
} }
else if(vertexShader) else if(vertexShader)
{ {
if((var + registerCount) > sw::VertexShader::MAX_OUTPUT_VARYINGS) if((var + registerCount) > sw::MAX_VERTEX_OUTPUTS)
{ {
mContext.error(varying->getLine(), "Varyings packing failed: Too many varyings", "vertex shader"); mContext.error(varying->getLine(), "Varyings packing failed: Too many varyings", "vertex shader");
return 0; return 0;
......
...@@ -1878,7 +1878,7 @@ namespace sw ...@@ -1878,7 +1878,7 @@ namespace sw
int pts = state.pointSizeRegister; int pts = state.pointSizeRegister;
if(state.pointSizeRegister != 0xF) if(state.pointSizeRegister != Unused)
{ {
pSize = v.v[pts].y; pSize = v.v[pts].y;
} }
......
...@@ -89,7 +89,7 @@ namespace sw ...@@ -89,7 +89,7 @@ namespace sw
state.vFace = context->pixelShader && context->pixelShader->vFaceDeclared; state.vFace = context->pixelShader && context->pixelShader->vFaceDeclared;
state.positionRegister = Pos; state.positionRegister = Pos;
state.pointSizeRegister = 0xF; // No vertex point size state.pointSizeRegister = Unused;
state.multiSample = context->getMultiSampleCount(); state.multiSample = context->getMultiSampleCount();
state.rasterizerDiscard = context->rasterizerDiscard; state.rasterizerDiscard = context->rasterizerDiscard;
...@@ -133,7 +133,7 @@ namespace sw ...@@ -133,7 +133,7 @@ namespace sw
if(context->pixelShader->semantic[interpolant][component - project].active()) if(context->pixelShader->semantic[interpolant][component - project].active())
{ {
int input = interpolant; int input = interpolant;
for(int i = 0; i < 12; i++) for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{ {
if(context->pixelShader->semantic[interpolant][component - project] == context->vertexShader->output[i][component - project]) if(context->pixelShader->semantic[interpolant][component - project] == context->vertexShader->output[i][component - project])
{ {
......
...@@ -45,8 +45,8 @@ namespace sw ...@@ -45,8 +45,8 @@ namespace sw
bool interpolateW : 1; bool interpolateW : 1;
bool perspective : 1; bool perspective : 1;
bool pointSprite : 1; bool pointSprite : 1;
unsigned int positionRegister : 4; unsigned int positionRegister : BITS(VERTEX_OUTPUT_LAST);
unsigned int pointSizeRegister : 4; unsigned int pointSizeRegister : BITS(VERTEX_OUTPUT_LAST);
CullMode cullMode : BITS(CULL_LAST); CullMode cullMode : BITS(CULL_LAST);
bool twoSidedStencil : 1; bool twoSidedStencil : 1;
bool slopeDepthBias : 1; bool slopeDepthBias : 1;
...@@ -56,7 +56,7 @@ namespace sw ...@@ -56,7 +56,7 @@ namespace sw
struct Gradient struct Gradient
{ {
unsigned char attribute : BITS(Unused); unsigned char attribute : BITS(VERTEX_OUTPUT_LAST);
bool flat : 1; bool flat : 1;
bool wrap : 1; bool wrap : 1;
}; };
......
...@@ -18,11 +18,13 @@ ...@@ -18,11 +18,13 @@
#include "Color.hpp" #include "Color.hpp"
#include "Common/MetaMacro.hpp" #include "Common/MetaMacro.hpp"
#include "Common/Types.hpp" #include "Common/Types.hpp"
#include "Main/Config.hpp"
namespace sw namespace sw
{ {
enum Out // Default vertex output semantic enum Out
{ {
// Default vertex output semantics
Pos = 0, Pos = 0,
C0 = 1, // Diffuse C0 = 1, // Diffuse
C1 = 2, // Specular C1 = 2, // Specular
...@@ -36,7 +38,13 @@ namespace sw ...@@ -36,7 +38,13 @@ namespace sw
T7 = 10, T7 = 10,
Fog = 11, // x component Fog = 11, // x component
Pts = Fog, // y component Pts = Fog, // y component
Unused
// Variable semantics
V0 = 0,
Vn_1 = MAX_VERTEX_OUTPUTS - 1,
Unused,
VERTEX_OUTPUT_LAST = Unused,
}; };
struct UVWQ struct UVWQ
...@@ -72,7 +80,7 @@ namespace sw ...@@ -72,7 +80,7 @@ namespace sw
float pSize; // Point size float pSize; // Point size
}; };
float4 v[12]; // Generic components using semantic declaration float4 v[MAX_VERTEX_OUTPUTS]; // Generic components using semantic declaration
}; };
// Projected coordinates // Projected coordinates
......
...@@ -942,7 +942,7 @@ namespace sw ...@@ -942,7 +942,7 @@ namespace sw
if(context->vertexShader) // FIXME: Also when pre-transformed? if(context->vertexShader) // FIXME: Also when pre-transformed?
{ {
for(int i = 0; i < 12; i++) for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{ {
state.output[i].xWrite = context->vertexShader->output[i][0].active(); state.output[i].xWrite = context->vertexShader->output[i][0].active();
state.output[i].yWrite = context->vertexShader->output[i][1].active(); state.output[i].yWrite = context->vertexShader->output[i][1].active();
......
...@@ -52,8 +52,8 @@ namespace sw ...@@ -52,8 +52,8 @@ namespace sw
bool fixedFunction : 1; bool fixedFunction : 1;
bool textureSampling : 1; bool textureSampling : 1;
unsigned int positionRegister : 4; unsigned int positionRegister : BITS(MAX_VERTEX_OUTPUTS);
unsigned int pointSizeRegister : 4; // 0xF signifies no vertex point size unsigned int pointSizeRegister : BITS(MAX_VERTEX_OUTPUTS);
unsigned int vertexBlendMatrixCount : 3; unsigned int vertexBlendMatrixCount : 3;
bool indexedVertexBlendEnable : 1; bool indexedVertexBlendEnable : 1;
...@@ -134,7 +134,7 @@ namespace sw ...@@ -134,7 +134,7 @@ namespace sw
}; };
Input input[VERTEX_ATTRIBUTES]; Input input[VERTEX_ATTRIBUTES];
Output output[12]; Output output[MAX_VERTEX_OUTPUTS];
}; };
struct State : States struct State : States
......
...@@ -594,7 +594,7 @@ namespace sw ...@@ -594,7 +594,7 @@ namespace sw
{ {
if(shader) if(shader)
{ {
for(int i = 0; i < 12; i++) for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{ {
unsigned char usage = shader->output[i][0].usage; unsigned char usage = shader->output[i][0].usage;
......
...@@ -580,7 +580,7 @@ namespace sw ...@@ -580,7 +580,7 @@ namespace sw
{ {
Vector4f v; Vector4f v;
for(int i = 0; i < 12; i++) for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{ {
if(state.output[i].write) if(state.output[i].write)
{ {
...@@ -669,7 +669,7 @@ namespace sw ...@@ -669,7 +669,7 @@ namespace sw
void VertexRoutine::writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cache) void VertexRoutine::writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cache)
{ {
for(int i = 0; i < 12; i++) for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{ {
if(state.output[i].write) if(state.output[i].write)
{ {
......
...@@ -49,7 +49,7 @@ namespace sw ...@@ -49,7 +49,7 @@ namespace sw
Int clipFlags; Int clipFlags;
RegisterArray<16> v; // Varying registers RegisterArray<16> v; // Varying registers
RegisterArray<12> o; // Output registers RegisterArray<MAX_VERTEX_OUTPUTS> o; // Output registers
const VertexProcessor::State &state; const VertexProcessor::State &state;
......
...@@ -25,7 +25,7 @@ namespace sw ...@@ -25,7 +25,7 @@ namespace sw
{ {
version = 0x0300; version = 0x0300;
positionRegister = Pos; positionRegister = Pos;
pointSizeRegister = -1; // No vertex point size pointSizeRegister = Unused;
instanceIdDeclared = false; instanceIdDeclared = false;
for(int i = 0; i < MAX_INPUT_ATTRIBUTES; i++) for(int i = 0; i < MAX_INPUT_ATTRIBUTES; i++)
...@@ -57,7 +57,7 @@ namespace sw ...@@ -57,7 +57,7 @@ namespace sw
parse(token); parse(token);
positionRegister = Pos; positionRegister = Pos;
pointSizeRegister = -1; // No vertex point size pointSizeRegister = Unused;
instanceIdDeclared = false; instanceIdDeclared = false;
for(int i = 0; i < MAX_INPUT_ATTRIBUTES; i++) for(int i = 0; i < MAX_INPUT_ATTRIBUTES; i++)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define sw_VertexShader_hpp #define sw_VertexShader_hpp
#include "Shader.hpp" #include "Shader.hpp"
#include "Main/Config.hpp"
namespace sw namespace sw
{ {
...@@ -40,8 +41,7 @@ namespace sw ...@@ -40,8 +41,7 @@ namespace sw
enum {MAX_INPUT_ATTRIBUTES = 16}; enum {MAX_INPUT_ATTRIBUTES = 16};
Semantic input[MAX_INPUT_ATTRIBUTES]; // FIXME: Private Semantic input[MAX_INPUT_ATTRIBUTES]; // FIXME: Private
enum {MAX_OUTPUT_VARYINGS = 12}; Semantic output[MAX_VERTEX_OUTPUTS][4]; // FIXME: Private
Semantic output[MAX_OUTPUT_VARYINGS][4]; // FIXME: Private
private: private:
void analyzeInput(); void analyzeInput();
......
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