Commit 5f5969b3 authored by Ivan Gyurdiev's avatar Ivan Gyurdiev Committed by Alexandre Julliard

wined3d: Remove constant type field in stateblock.

It is wrong to maintain a mapping from a constant index to a type field, because different constant types do not share an index - boolean constant 0 is supposed to co-exist with floating point constant 0, not replace it. Drawprim and other code using the type array to decide whether to look up a constant in bools, floats, or ints is wrong - you can't make that decision based on the index.
parent 0909df67
......@@ -1824,9 +1824,8 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx
/* Update the constants */
for (i = 0; i < WINED3D_VSHADER_MAX_CONSTANTS; ++i) {
/* TODO: add support for Integer and Boolean constants */
if (WINESHADERCNST_FLOAT == This->stateBlock->vertexShaderConstantT[i]) {
if (This->stateBlock->set.vertexShaderConstantsF[i]) {
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i,
&This->stateBlock->vertexShaderConstantF[i * 4]));
......@@ -1836,8 +1835,11 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx
This->stateBlock->vertexShaderConstantF[i * 4 + 2],
This->stateBlock->vertexShaderConstantF[i * 4 + 3]);
checkGLcall("glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB");
checkGLcall("glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB");
}
}
}
if (usePixelShaderFunction) {
......@@ -1858,16 +1860,19 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx
/* Update the constants */
for (i = 0; i < WINED3D_PSHADER_MAX_CONSTANTS; ++i) {
/* TODO: add support for Integer and Boolean constants */
if (WINESHADERCNST_FLOAT == This->stateBlock->pixelShaderConstantT[i]) {
if (This->stateBlock->set.pixelShaderConstantsF[i]) {
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i,
&This->stateBlock->pixelShaderConstantF[i * 4]));
TRACE_(d3d_shader)("Loading constants %u = %f %f %f %f\n", i,
This->stateBlock->pixelShaderConstantF[i * 4],
This->stateBlock->pixelShaderConstantF[i * 4 + 1],
This->stateBlock->pixelShaderConstantF[i * 4 + 2],
This->stateBlock->pixelShaderConstantF[i * 4 + 3]);
checkGLcall("glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB");
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB");
}
}
}
......
......@@ -168,18 +168,38 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
/* 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];
if (This->set.vertexShaderConstantsF[i]) {
TRACE("Setting %p from %p %d to { %f, %f, %f, %f }\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantF[i * 4],
targetStateBlock->vertexShaderConstantF[i * 4 + 1],
targetStateBlock->vertexShaderConstantF[i * 4 + 2],
targetStateBlock->vertexShaderConstantF[i * 4 + 3]);
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];
}
if (This->set.vertexShaderConstantsI[i]) {
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantI[i * 4],
targetStateBlock->vertexShaderConstantI[i * 4 + 1],
targetStateBlock->vertexShaderConstantI[i * 4 + 2],
targetStateBlock->vertexShaderConstantI[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];
}
if (This->set.vertexShaderConstantsB[i]) {
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantB[i]? "TRUE":"FALSE");
This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
}
}
......@@ -230,20 +250,39 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
This->pixelShader = targetStateBlock->pixelShader;
}
/* Pixel Shader Constants */
for (i = 0; i < MAX_PSHADER_CONSTANTS; ++i) {
if (This->set.pixelShaderConstants[i]) {
TRACE("Setting %p from %p %d to %f\n", This, targetStateBlock, i, targetStateBlock->pixelShaderConstantF[i * 4 + 1]);
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
if (This->set.pixelShaderConstantsF[i]) {
TRACE("Setting %p from %p %d to { %f, %f, %f, %f }\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantF[i * 4],
targetStateBlock->pixelShaderConstantF[i * 4 + 1],
targetStateBlock->pixelShaderConstantF[i * 4 + 2],
targetStateBlock->pixelShaderConstantF[i * 4 + 3]);
This->pixelShaderConstantF[i * 4] = targetStateBlock->pixelShaderConstantF[i * 4];
This->pixelShaderConstantF[i * 4 + 1] = targetStateBlock->pixelShaderConstantF[i * 4 + 1];
This->pixelShaderConstantF[i * 4 + 2] = targetStateBlock->pixelShaderConstantF[i * 4 + 2];
This->pixelShaderConstantF[i * 4 + 3] = targetStateBlock->pixelShaderConstantF[i * 4 + 3];
}
if (This->set.pixelShaderConstantsI[i]) {
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantI[i * 4],
targetStateBlock->pixelShaderConstantI[i * 4 + 1],
targetStateBlock->pixelShaderConstantI[i * 4 + 2],
targetStateBlock->pixelShaderConstantI[i * 4 + 3]);
This->pixelShaderConstantI[i * 4] = targetStateBlock->pixelShaderConstantI[i * 4];
This->pixelShaderConstantI[i * 4 + 1] = targetStateBlock->pixelShaderConstantI[i * 4 + 1];
This->pixelShaderConstantI[i * 4 + 2] = targetStateBlock->pixelShaderConstantI[i * 4 + 2];
This->pixelShaderConstantI[i * 4 + 3] = targetStateBlock->pixelShaderConstantI[i * 4 + 3];
This->pixelShaderConstantT[i] = targetStateBlock->pixelShaderConstantT[i];
}
if (This->set.pixelShaderConstantsB[i]) {
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE");
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
}
}
......@@ -408,24 +447,15 @@ should really perform a delta so that only the changes get updated*/
/* Vertex Shader Constants */
for (i = 0; i < MAX_VSHADER_CONSTANTS; ++i) {
if (This->set.vertexShaderConstants[i] && This->changed.vertexShaderConstants[i]) {
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;
case WINESHADERCNST_NONE:
IWineD3DDevice_SetVertexShaderConstantN(pDevice, i, 1);
break;
}
}
}
if (This->set.vertexShaderConstantsF[i] && This->changed.vertexShaderConstantsF[i])
IWineD3DDevice_SetVertexShaderConstantF(pDevice, i, This->vertexShaderConstantF + i * 4, 1);
if (This->set.vertexShaderConstantsI[i] && This->changed.vertexShaderConstantsI[i])
IWineD3DDevice_SetVertexShaderConstantI(pDevice, i, This->vertexShaderConstantI + i * 4, 1);
if (This->set.vertexShaderConstantsB[i] && This->changed.vertexShaderConstantsB[i])
IWineD3DDevice_SetVertexShaderConstantB(pDevice, i, This->vertexShaderConstantB + i, 1);
}
}
if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */ This->blockType == D3DSBT_ALL || This->blockType == D3DSBT_PIXELSTATE) {
......@@ -437,22 +467,14 @@ should really perform a delta so that only the changes get updated*/
/* Pixel Shader Constants */
for (i = 0; i < MAX_PSHADER_CONSTANTS; ++i) {
if (This->set.pixelShaderConstants[i] && This->changed.pixelShaderConstants[i]) {
switch (This->pixelShaderConstantT[i]) {
case WINESHADERCNST_FLOAT:
IWineD3DDevice_SetPixelShaderConstantF(pDevice, i, This->pixelShaderConstantF + i * 4, 1);
break;
case WINESHADERCNST_BOOL:
IWineD3DDevice_SetPixelShaderConstantB(pDevice, i, This->pixelShaderConstantB + i, 1);
break;
case WINESHADERCNST_INTEGER:
IWineD3DDevice_SetPixelShaderConstantI(pDevice, i, This->pixelShaderConstantI + i * 4, 1);
break;
case WINESHADERCNST_NONE:
IWineD3DDevice_SetPixelShaderConstantN(pDevice, i, 1);
break;
}
}
if (This->set.pixelShaderConstantsF[i] && This->changed.pixelShaderConstantsF[i])
IWineD3DDevice_SetPixelShaderConstantF(pDevice, i, This->pixelShaderConstantF + i * 4, 1);
if (This->set.pixelShaderConstantsI[i] && This->changed.pixelShaderConstantsI[i])
IWineD3DDevice_SetPixelShaderConstantI(pDevice, i, This->pixelShaderConstantI + i * 4, 1);
if (This->set.pixelShaderConstantsB[i] && This->changed.pixelShaderConstantsB[i])
IWineD3DDevice_SetPixelShaderConstantB(pDevice, i, This->pixelShaderConstantB + i, 1);
}
}
......
......@@ -979,18 +979,15 @@ typedef struct SAVEDSTATES {
BOOL clipplane[MAX_CLIPPLANES];
BOOL vertexDecl;
BOOL pixelShader;
BOOL pixelShaderConstants[MAX_PSHADER_CONSTANTS];
BOOL pixelShaderConstantsB[MAX_PSHADER_CONSTANTS];
BOOL pixelShaderConstantsI[MAX_PSHADER_CONSTANTS];
BOOL pixelShaderConstantsF[MAX_PSHADER_CONSTANTS];
BOOL vertexShader;
BOOL vertexShaderConstants[MAX_VSHADER_CONSTANTS];
BOOL vertexShaderConstantsB[MAX_VSHADER_CONSTANTS];
BOOL vertexShaderConstantsI[MAX_VSHADER_CONSTANTS];
BOOL vertexShaderConstantsF[MAX_VSHADER_CONSTANTS];
} SAVEDSTATES;
typedef enum {
WINESHADERCNST_NONE = 0,
WINESHADERCNST_FLOAT = 1,
WINESHADERCNST_INTEGER = 2,
WINESHADERCNST_BOOL = 3
} WINESHADERCNST;
struct IWineD3DStateBlockImpl
{
/* IUnknown fields */
......@@ -1017,7 +1014,6 @@ struct IWineD3DStateBlockImpl
BOOL vertexShaderConstantB[MAX_VSHADER_CONSTANTS];
INT vertexShaderConstantI[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 */
/* Stream Source */
BOOL streamIsUP;
......@@ -1054,7 +1050,6 @@ struct IWineD3DStateBlockImpl
BOOL pixelShaderConstantB[MAX_PSHADER_CONSTANTS];
INT pixelShaderConstantI[MAX_PSHADER_CONSTANTS * 4];
float pixelShaderConstantF[MAX_PSHADER_CONSTANTS * 4];
WINESHADERCNST pixelShaderConstantT[MAX_PSHADER_CONSTANTS]; /* TODO: Think about changing this to a char to possibly save a little memory */
/* Indexed Vertex Blending */
D3DVERTEXBLENDFLAGS vertex_blend;
......
......@@ -433,15 +433,12 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE;
STDMETHOD(SetPixelShader)(THIS_ struct IWineD3DPixelShader *pShader) PURE;
STDMETHOD(GetPixelShader)(THIS_ struct IWineD3DPixelShader **ppShader) PURE;
STDMETHOD(SetPixelShaderConstant)(THIS_ void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT countsize);
STDMETHOD(GetPixelShaderConstant)(THIS_ void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT countsize);
STDMETHOD(SetPixelShaderConstantB)(THIS_ UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) PURE;
STDMETHOD(GetPixelShaderConstantB)(THIS_ UINT StartRegister, BOOL* pConstantData, UINT BoolCount) PURE;
STDMETHOD(SetPixelShaderConstantI)(THIS_ UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) PURE;
STDMETHOD(GetPixelShaderConstantI)(THIS_ UINT StartRegister, int* pConstantData, UINT Vector4iCount) PURE;
STDMETHOD(SetPixelShaderConstantF)(THIS_ UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) PURE;
STDMETHOD(GetPixelShaderConstantF)(THIS_ UINT StartRegister, float* pConstantData, UINT Vector4fCount) PURE;
STDMETHOD(SetPixelShaderConstantN)(THIS_ UINT StartRegister, UINT VectorNCount) PURE;
STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE;
STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD * pValue) PURE;
STDMETHOD(SetRenderTarget)(THIS_ DWORD RenderTargetIndex, struct IWineD3DSurface* pRenderTarget) PURE;
......@@ -467,15 +464,12 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
STDMETHOD(GetVertexDeclaration)(THIS_ struct IWineD3DVertexDeclaration** ppDecl) PURE;
STDMETHOD(SetVertexShader)(THIS_ struct IWineD3DVertexShader* pShader) PURE;
STDMETHOD(GetVertexShader)(THIS_ struct IWineD3DVertexShader** ppShader) PURE;
STDMETHOD(SetVertexShaderConstant)(THIS_ void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT countsize);
STDMETHOD(GetVertexShaderConstant)(THIS_ void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT countsize);
STDMETHOD(SetVertexShaderConstantB)(THIS_ UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) PURE;
STDMETHOD(GetVertexShaderConstantB)(THIS_ UINT StartRegister, BOOL* pConstantData, UINT BoolCount) PURE;
STDMETHOD(SetVertexShaderConstantI)(THIS_ UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) PURE;
STDMETHOD(GetVertexShaderConstantI)(THIS_ UINT StartRegister, int* pConstantData, UINT Vector4iCount) PURE;
STDMETHOD(SetVertexShaderConstantF)(THIS_ UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) PURE;
STDMETHOD(GetVertexShaderConstantF)(THIS_ UINT StartRegister, float* pConstantData, UINT Vector4fCount) PURE;
STDMETHOD(SetVertexShaderConstantN)(THIS_ UINT StartRegister, UINT VectorNCount) PURE;
STDMETHOD(SetViewport)(THIS_ CONST WINED3DVIEWPORT * pViewport) PURE;
STDMETHOD(GetViewport)(THIS_ WINED3DVIEWPORT * pViewport) PURE;
STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX * pMatrix) PURE;
......@@ -579,15 +573,12 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
#define IWineD3DDevice_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b)
#define IWineD3DDevice_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a)
#define IWineD3DDevice_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a)
#define IWineD3DDevice_SetPixelShaderConstant(p,a,b,c,d,e,f); (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c,d,e,f)
#define IWineD3DDevice_GetPixelShaderConstant(p,a,b,c,d,e,f); (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c,d,e,f)
#define IWineD3DDevice_SetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantB(p,a,b,c)
#define IWineD3DDevice_GetPixelShaderConstantB(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantB(p,a,b,c)
#define IWineD3DDevice_SetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantI(p,a,b,c)
#define IWineD3DDevice_GetPixelShaderConstantI(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantI(p,a,b,c)
#define IWineD3DDevice_SetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstantF(p,a,b,c)
#define IWineD3DDevice_GetPixelShaderConstantF(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstantF(p,a,b,c)
#define IWineD3DDevice_SetPixelShaderConstantN(p,a,b) (p)->lpVtbl->SetPixelShaderConstantN(p,a,b)
#define IWineD3DDevice_GetRasterStatus(p,a,b) (p)->lpVtbl->GetRasterStatus(p,a,b)
#define IWineD3DDevice_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b)
#define IWineD3DDevice_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b)
......@@ -615,15 +606,12 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
#define IWineD3DDevice_GetVertexDeclaration(p,a) (p)->lpVtbl->GetVertexDeclaration(p,a)
#define IWineD3DDevice_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a)
#define IWineD3DDevice_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a)
#define IWineD3DDevice_SetVertexShaderConstant(p,a,b,c,d,e,f); (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c,d,e,f)
#define IWineD3DDevice_GetVertexShaderConstant(p,a,b,c,d,e,f); (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c,d,e,f)
#define IWineD3DDevice_SetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantB(p,a,b,c)
#define IWineD3DDevice_GetVertexShaderConstantB(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantB(p,a,b,c)
#define IWineD3DDevice_SetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantI(p,a,b,c)
#define IWineD3DDevice_GetVertexShaderConstantI(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantI(p,a,b,c)
#define IWineD3DDevice_SetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstantF(p,a,b,c)
#define IWineD3DDevice_GetVertexShaderConstantF(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstantF(p,a,b,c)
#define IWineD3DDevice_SetVertexShaderConstantN(p,a,b) (p)->lpVtbl->SetVertexShaderConstantN(p,a,b)
#define IWineD3DDevice_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a)
#define IWineD3DDevice_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a)
#define IWineD3DDevice_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b)
......
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