Commit 0c2fcf2e authored by Oliver Stieber's avatar Oliver Stieber Committed by Alexandre Julliard

Added support for state management of vertex shader constants via

stateblocks.
parent 489c6b38
...@@ -157,7 +157,22 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){ ...@@ -157,7 +157,22 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
TRACE("Updating vertex shader to %p\n", targetStateBlock->vertexShader); TRACE("Updating vertex shader to %p\n", targetStateBlock->vertexShader);
} }
/* TODO: Vertex Shader Constants */ /* Vertex Shader Constants */
for (i = 0; i < MAX_VSHADER_CONSTANTS; ++i) {
if (This->set.vertexShaderConstants[i]) {
TRACE("Setting %p from %p %d to %f\n", This, targetStateBlock, i, targetStateBlock->vertexShaderConstantF[i * 4 + 1]);
This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
This->vertexShaderConstantF[i * 4] = targetStateBlock->vertexShaderConstantF[i * 4];
This->vertexShaderConstantF[i * 4 + 1] = targetStateBlock->vertexShaderConstantF[i * 4 + 1];
This->vertexShaderConstantF[i * 4 + 2] = targetStateBlock->vertexShaderConstantF[i * 4 + 2];
This->vertexShaderConstantF[i * 4 + 3] = targetStateBlock->vertexShaderConstantF[i * 4 + 3];
This->vertexShaderConstantI[i * 4] = targetStateBlock->vertexShaderConstantI[i * 4];
This->vertexShaderConstantI[i * 4 + 1] = targetStateBlock->vertexShaderConstantI[i * 4 + 1];
This->vertexShaderConstantI[i * 4 + 2] = targetStateBlock->vertexShaderConstantI[i * 4 + 2];
This->vertexShaderConstantI[i * 4 + 3] = targetStateBlock->vertexShaderConstantI[i * 4 + 3];
This->vertexShaderConstantT[i] = targetStateBlock->vertexShaderConstantT[i];
}
}
/* Lights... For a recorded state block, we just had a chain of actions to perform, /* Lights... For a recorded state block, we just had a chain of actions to perform,
so we need to walk that chain and update any actions which differ */ so we need to walk that chain and update any actions which differ */
...@@ -346,14 +361,26 @@ should really perform a delta so that only the changes get updated*/ ...@@ -346,14 +361,26 @@ should really perform a delta so that only the changes get updated*/
toDo = toDo->next; toDo = toDo->next;
} }
/* Vertex Shader */
if (This->set.vertexShader && This->changed.vertexShader) { if (This->set.vertexShader && This->changed.vertexShader) {
IWineD3DDevice_SetVertexShader(pDevice, This->vertexShader); IWineD3DDevice_SetVertexShader(pDevice, This->vertexShader);
/* TODO: Vertex Shader Constants */ }
#if 0 /* FIXME: This isn't the correct place to set vs constants (The Fur demo fails) */
IWineD3DDevice_SetVertexShaderConstantB(pDevice, 0 , This->vertexShaderConstantB , MAX_VSHADER_CONSTANTS); /* Vertex Shader Constants */
IWineD3DDevice_SetVertexShaderConstantI(pDevice, 0 , This->vertexShaderConstantI , MAX_VSHADER_CONSTANTS); for (i = 0; i < MAX_VSHADER_CONSTANTS; ++i) {
IWineD3DDevice_SetVertexShaderConstantF(pDevice, 0 , This->vertexShaderConstantF , MAX_VSHADER_CONSTANTS); if (This->set.vertexShaderConstants[i] && This->changed.vertexShaderConstants[i]) {
#endif switch (This->vertexShaderConstantT[i]) {
case WINESHADERCNST_FLOAT:
IWineD3DDevice_SetVertexShaderConstantF(pDevice, i, This->vertexShaderConstantF + i * 4, 1);
break;
case WINESHADERCNST_BOOL:
IWineD3DDevice_SetVertexShaderConstantB(pDevice, i, This->vertexShaderConstantB + i, 1);
break;
case WINESHADERCNST_INTEGER:
IWineD3DDevice_SetVertexShaderConstantI(pDevice, i, This->vertexShaderConstantI + i * 4, 1);
break;
}
}
} }
} }
......
...@@ -866,8 +866,15 @@ typedef struct SAVEDSTATES { ...@@ -866,8 +866,15 @@ typedef struct SAVEDSTATES {
BOOL vertexDecl; BOOL vertexDecl;
BOOL pixelShader; BOOL pixelShader;
BOOL vertexShader; BOOL vertexShader;
BOOL vertexShaderConstants[MAX_VSHADER_CONSTANTS];
} SAVEDSTATES; } SAVEDSTATES;
typedef enum {
WINESHADERCNST_FLOAT = 0,
WINESHADERCNST_INTEGER = 1,
WINESHADERCNST_BOOL = 2
} WINESHADERCNST;
struct IWineD3DStateBlockImpl struct IWineD3DStateBlockImpl
{ {
/* IUnknown fields */ /* IUnknown fields */
...@@ -894,8 +901,9 @@ struct IWineD3DStateBlockImpl ...@@ -894,8 +901,9 @@ struct IWineD3DStateBlockImpl
BOOL vertexShaderConstantB[MAX_VSHADER_CONSTANTS]; BOOL vertexShaderConstantB[MAX_VSHADER_CONSTANTS];
INT vertexShaderConstantI[MAX_VSHADER_CONSTANTS * 4]; INT vertexShaderConstantI[MAX_VSHADER_CONSTANTS * 4];
float vertexShaderConstantF[MAX_VSHADER_CONSTANTS * 4]; float vertexShaderConstantF[MAX_VSHADER_CONSTANTS * 4];
WINESHADERCNST vertexShaderConstantT[MAX_VSHADER_CONSTANTS]; /* TODO: Think about changing this to a char to possibly save a little memory */
BOOL softwareVertexProcessing; BOOL softwareVertexProcessing;
/* Stream Source */ /* Stream Source */
BOOL streamIsUP; BOOL streamIsUP;
......
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