[WINED3D 2/3] Make register counting pass the same for vertex/pixel
shaders.
Ivan Gyurdiev
ivg2 at cornell.edu
Fri Apr 28 04:22:53 CDT 2006
I have a patch which will merge the counting pass for vertex and pixel
shaders. They're 90% similar, but some things get in the way - get rid
of them here.
- immediate constants are constants which override the ones set with
SetShaderConstantF().
They're allowed for both pixel and vertex shaders. They're handled by
a PARAM declaration, and a bitmap to track which constants were
overriden. However, it doesn't make sense to mark a constant overriden
in the first pass, and make a PARAM declaration later when we see the
DEF instruction. The GL spec says that symbol names can't be used before
they are defined, so we might as well mark it overriden at the point
where it's defined (later). Note that pixel shaders do the same thing
already.
- input parameter usage declaration is necessary for vertex shaders, but
not for pixel shaders. To avoid dealing with this now, move the
declaration related things earlier into SetFunction. This is the correct
thing to do anyway, since this is the GenerateProgramARB() function, and
declaration things don't generate any shader code - they'll be necessary
for GLSL as well.
-------------- next part --------------
---
dlls/wined3d/vertexshader.c | 52 ++++++++++++++++++++-----------------------
1 files changed, 24 insertions(+), 28 deletions(-)
ab3e4fca1ba139cfba22c28cf64d76fccb6116aa
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index 0d3b8d7..10fd07a 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -1173,12 +1173,6 @@ inline static VOID IWineD3DVertexShaderI
buffer.bsize = 0;
buffer.lineNo = 0;
- /* Initialise the shader */
- This->namedArrays = FALSE;
- This->declaredArrays = FALSE;
- for (i = 0; i < WINED3DSHADERDECLUSAGE_MAX_USAGE; i++) {
- This->arrayUsageMap[i] = -1;
- }
/* set all the tmpsUsed to not used */
memset(tmpsUsed, FALSE , sizeof(tmpsUsed));
@@ -1215,18 +1209,14 @@ inline static VOID IWineD3DVertexShaderI
++pToken;
}
} else {
+
+ /* Skip declarations, handled earlier */
if (curOpcode->opcode == D3DSIO_DCL){
- INT usage = *pToken++;
- INT arrayNo = (*pToken++ & D3DSP_REGNUM_MASK);
- parse_decl_usage(This, usage, arrayNo);
+ pToken += 2;
+
+ /* Skip definition of immediate constants, handled later */
} else if(curOpcode->opcode == D3DSIO_DEF) {
- This->constantsUsedBitmap[*pToken & 0xFF] = VS_CONSTANT_CONSTANT;
- FIXME("Constant %ld\n", *pToken & 0xFF);
- ++pToken;
- ++pToken;
- ++pToken;
- ++pToken;
- ++pToken;
+ pToken += 5;
} else {
/* Check to see if and tmp or addressing redisters are used */
@@ -1262,19 +1252,7 @@ inline static VOID IWineD3DVertexShaderI
}
}
}
-#if 1
-#define VSHADER_ALWAYS_NUMBERED
-#endif
-
-#ifdef VSHADER_ALWAYS_NUMBERED /* handy for debugging using numbered arrays instead of named arrays */
- /* TODO: using numbered arrays for software shaders makes things easier */
- This->declaredArrays = TRUE;
-#endif
- /* named arrays and declared arrays are mutually exclusive */
- if (This->declaredArrays) {
- This->namedArrays = FALSE;
- }
/* TODO: validate
nUseAddressRegister < = GL_MAX_PROGRAM_ADDRESS_REGISTERS_AR
nUseTempRegister <= GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
@@ -1356,6 +1334,7 @@ inline static VOID IWineD3DVertexShaderI
*(float *) (pToken + 3),
*(float *) (pToken + 4));
+ This->constantsUsedBitmap[*pToken & 0xFF] = VS_CONSTANT_CONSTANT;
pToken += 5;
continue;
@@ -1947,6 +1926,12 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_
DWORD i;
TRACE("(%p) : Parsing programme\n", This);
+ /* Initialise vertex input arrays */
+ This->namedArrays = FALSE;
+ This->declaredArrays = FALSE;
+ for (i = 0; i < WINED3DSHADERDECLUSAGE_MAX_USAGE; i++)
+ This->arrayUsageMap[i] = -1;
+
if (NULL != pToken) {
while (D3DVS_END() != *pToken) {
if (vshader_is_version_token(*pToken)) { /** version */
@@ -1979,6 +1964,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_
} else {
if (curOpcode->opcode == D3DSIO_DCL) {
vshader_program_dump_decl_usage(This, *pToken, *(pToken + 1));
+ parse_decl_usage(This, *pToken, *(pToken + 1) & D3DSP_REGNUM_MASK);
++pToken;
++len;
vshader_program_dump_vs_param(*pToken, 0);
@@ -2023,6 +2009,16 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_
This->baseShader.functionLength = 1; /* no Function defined use fixed function vertex processing */
}
+/* Handy for debugging using numbered arrays instead of named arrays */
+#if 1
+ /* TODO: using numbered arrays for software shaders makes things easier */
+ This->declaredArrays = TRUE;
+#endif
+
+ /* named arrays and declared arrays are mutually exclusive */
+ if (This->declaredArrays)
+ This->namedArrays = FALSE;
+
/* Generate HW shader in needed */
if (NULL != pFunction && wined3d_settings.vs_mode == VS_HW) {
#if 1
--
1.2.6
More information about the wine-patches
mailing list