diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 70ac58defd4..ed3f6bc641e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -500,7 +500,9 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, WINED3 /* Pixel Shader Constants */ for (i = 0; i < MAX_PSHADER_CONSTANTS; ++i) { - object->changed.pixelShaderConstants[i] = TRUE; + object->changed.pixelShaderConstantsF[i] = TRUE; + object->changed.pixelShaderConstantsB[i] = TRUE; + object->changed.pixelShaderConstantsI[i] = TRUE; } for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) { object->changed.renderState[SavedPixelStates_R[i]] = TRUE; @@ -526,7 +528,9 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, WINED3 /* Vertex Shader Constants */ for (i = 0; i < MAX_VSHADER_CONSTANTS; ++i) { - object->changed.vertexShaderConstants[i] = TRUE; + object->changed.vertexShaderConstantsF[i] = TRUE; + object->changed.vertexShaderConstantsB[i] = TRUE; + object->changed.vertexShaderConstantsI[i] = TRUE; } for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) { object->changed.renderState[SavedVertexStates_R[i]] = TRUE; @@ -4353,140 +4357,136 @@ HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShader(IWineD3DDevice *iface, IWineD3 return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) { +HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB( + IWineD3DDevice *iface, + UINT start, + CONST BOOL *srcData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + int i, cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); - int i; - int cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); + TRACE("(iface %p, srcData %p, start %d, count %d)\n", + iface, srcData, start, count); - TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n", - iface, dstData, srcData, type, start, count, registersize); - - if (type != WINESHADERCNST_NONE) { - if (srcData == NULL || cnt < 0) { - return WINED3DERR_INVALIDCALL; - } - - CopyMemory((char *)dstData + (start * registersize), srcData, cnt * registersize); - } - - for (i = start; i < cnt + start; ++i) { - This->updateStateBlock->changed.vertexShaderConstants[i] = TRUE; - This->updateStateBlock->set.vertexShaderConstants[i] = TRUE; - This->updateStateBlock->vertexShaderConstantT[i] = type; - } - - return WINED3D_OK; -} - -HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - int i; - int cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); - - TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n", - iface, dstData, srcData, type, start, count, registersize); - - /* Verify that the requested shader constant was populated with the correct type */ - for (i = start; i < cnt + start; ++i) { - if (This->updateStateBlock->vertexShaderConstantT[i] != type) { - TRACE("(%p) : Caller requested 0x%x while type is 0x%x. Returning WINED3DERR_INVALIDCALL\n", - This, type, This->updateStateBlock->vertexShaderConstantT[i]); - return WINED3DERR_INVALIDCALL; - } - } - - if (dstData == NULL || cnt < 0) { + if (srcData == NULL || cnt < 0) return WINED3DERR_INVALIDCALL; - } - CopyMemory(dstData, (char *)srcData + (start * registersize), cnt * registersize); + memcpy(&This->updateStateBlock->vertexShaderConstantB[start], srcData, cnt); + + for (i = start; i < cnt + start; ++i) { + This->updateStateBlock->changed.vertexShaderConstantsB[i] = TRUE; + This->updateStateBlock->set.vertexShaderConstantsB[i] = TRUE; + } return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, CONST BOOL *pConstantData, UINT BoolCount){ +HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantB( + IWineD3DDevice *iface, + UINT start, + BOOL *dstData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - return IWineD3DDeviceImpl_SetVertexShaderConstant(iface, - This->updateStateBlock->vertexShaderConstantB, - pConstantData, - WINESHADERCNST_BOOL, - StartRegister, - BoolCount, - sizeof(*pConstantData)); + int cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, dstData %p, start %d, count %d)\n", + iface, dstData, start, count); + + if (dstData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(dstData, &This->updateStateBlock->vertexShaderConstantB[start], cnt); + return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount){ +HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI( + IWineD3DDevice *iface, + UINT start, + CONST int *srcData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - return IWineD3DDeviceImpl_GetVertexShaderConstant(iface, - pConstantData, - This->updateStateBlock->vertexShaderConstantB, - WINESHADERCNST_BOOL, - StartRegister, - BoolCount, - sizeof(*pConstantData)); + int i, cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, srcData %p, start %d, count %d)\n", + iface, srcData, start, count); + + if (srcData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(&This->updateStateBlock->vertexShaderConstantI[start * 4], srcData, cnt * 16); + + for (i = start; i < cnt + start; ++i) { + This->updateStateBlock->changed.vertexShaderConstantsI[i] = TRUE; + This->updateStateBlock->set.vertexShaderConstantsI[i] = TRUE; + } + + return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, CONST int *pConstantData, UINT Vector4iCount){ +HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantI( + IWineD3DDevice *iface, + UINT start, + int *dstData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - return IWineD3DDeviceImpl_SetVertexShaderConstant(iface, - This->updateStateBlock->vertexShaderConstantI, - pConstantData, - WINESHADERCNST_INTEGER, - StartRegister, - Vector4iCount, - 4 * sizeof(*pConstantData)); + int cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, dstData %p, start %d, count %d)\n", + iface, dstData, start, count); + + if (dstData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(dstData, &This->updateStateBlock->vertexShaderConstantI[start * 4], cnt * 16); + return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, int *pConstantData, UINT Vector4iCount){ +HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF( + IWineD3DDevice *iface, + UINT start, + CONST float *srcData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - return IWineD3DDeviceImpl_GetVertexShaderConstant(iface, - pConstantData, - This->updateStateBlock->vertexShaderConstantI, - WINESHADERCNST_INTEGER, - StartRegister, - Vector4iCount, - 4 * sizeof(*pConstantData)); + int i, cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, srcData %p, start %d, count %d)\n", + iface, srcData, start, count); + + if (srcData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(&This->updateStateBlock->vertexShaderConstantF[start * 4], srcData, cnt * 16); + + for (i = start; i < cnt + start; ++i) { + This->updateStateBlock->changed.vertexShaderConstantsF[i] = TRUE; + This->updateStateBlock->set.vertexShaderConstantsF[i] = TRUE; + } + + return WINED3D_OK; } +HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF( + IWineD3DDevice *iface, + UINT start, + float *dstData, + UINT count) { -HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, CONST float *pConstantData, UINT Vector4fCount){ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + int cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1)); - return IWineD3DDeviceImpl_SetVertexShaderConstant(iface, - This->updateStateBlock->vertexShaderConstantF, - pConstantData, - WINESHADERCNST_FLOAT, - StartRegister, - Vector4fCount, - 4 * sizeof(*pConstantData)); -} + TRACE("(iface %p, dstData %p, start %d, count %d)\n", + iface, dstData, start, count); -HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, float *pConstantData, UINT Vector4fCount){ - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + if (dstData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; - return IWineD3DDeviceImpl_GetVertexShaderConstant(iface, - pConstantData, - This->updateStateBlock->vertexShaderConstantF, - WINESHADERCNST_FLOAT, - StartRegister, - Vector4fCount, - 4 * sizeof(*pConstantData)); -} - -HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantN(IWineD3DDevice *iface, UINT StartRegister, UINT VectorNCount){ - return IWineD3DDeviceImpl_SetVertexShaderConstant(iface, - NULL, - NULL, - WINESHADERCNST_NONE, - StartRegister, - VectorNCount, - 0); + memcpy(dstData, &This->updateStateBlock->vertexShaderConstantF[start * 4], cnt * 16); + return WINED3D_OK; } HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader) { @@ -4531,139 +4531,136 @@ HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShader(IWineD3DDevice *iface, IWineD3D return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) { +HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB( + IWineD3DDevice *iface, + UINT start, + CONST BOOL *srcData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + int i, cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); - int i; - int cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); + TRACE("(iface %p, srcData %p, start %d, count %d)\n", + iface, srcData, start, count); - TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n", - iface, dstData, srcData, type, start, count, registersize); - - if (type != WINESHADERCNST_NONE) { - if (srcData == NULL || cnt < 0) { - return WINED3DERR_INVALIDCALL; - } - - CopyMemory((char *)dstData + (start * registersize), srcData, cnt * registersize); - } - - for (i = start; i < cnt + start; ++i) { - This->updateStateBlock->changed.pixelShaderConstants[i] = TRUE; - This->updateStateBlock->set.pixelShaderConstants[i] = TRUE; - This->updateStateBlock->pixelShaderConstantT[i] = type; - } - - return WINED3D_OK; -} - -HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - int i; - int cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); - - TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n", - iface, dstData, srcData, type, start, count, registersize); - - /* Verify that the requested shader constant was populated with the correct type */ - for (i = start; i < cnt + start; ++i) { - if (This->updateStateBlock->pixelShaderConstantT[i] != type) { - TRACE("(%p) : Caller requested 0x%x while type is 0x%x. Returning WINED3DERR_INVALIDCALL\n", - This, type, This->updateStateBlock->pixelShaderConstantT[i]); - return WINED3DERR_INVALIDCALL; - } - } - - if (dstData == NULL || cnt < 0) { + if (srcData == NULL || cnt < 0) return WINED3DERR_INVALIDCALL; - } - CopyMemory(dstData, (char *)srcData + (start * registersize), cnt * registersize); + memcpy(&This->updateStateBlock->pixelShaderConstantB[start], srcData, cnt); + + for (i = start; i < cnt + start; ++i) { + This->updateStateBlock->changed.pixelShaderConstantsB[i] = TRUE; + This->updateStateBlock->set.pixelShaderConstantsB[i] = TRUE; + } return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, CONST BOOL *pConstantData, UINT BoolCount) { +HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantB( + IWineD3DDevice *iface, + UINT start, + BOOL *dstData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - return IWineD3DDeviceImpl_SetPixelShaderConstant(iface, - This->updateStateBlock->pixelShaderConstantB, - pConstantData, - WINESHADERCNST_BOOL, - StartRegister, - BoolCount, - sizeof(*pConstantData)); + int cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, dstData %p, start %d, count %d)\n", + iface, dstData, start, count); + + if (dstData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(dstData, &This->updateStateBlock->pixelShaderConstantB[start], cnt); + return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; +HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI( + IWineD3DDevice *iface, + UINT start, + CONST int *srcData, + UINT count) { - return IWineD3DDeviceImpl_GetPixelShaderConstant(iface, - pConstantData, - This->updateStateBlock->pixelShaderConstantB, - WINESHADERCNST_BOOL, - StartRegister, - BoolCount, - sizeof(*pConstantData)); + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + int i, cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, srcData %p, start %d, count %d)\n", + iface, srcData, start, count); + + if (srcData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(&This->updateStateBlock->pixelShaderConstantI[start * 4], srcData, cnt * 16); + + for (i = start; i < cnt + start; ++i) { + This->updateStateBlock->changed.pixelShaderConstantsI[i] = TRUE; + This->updateStateBlock->set.pixelShaderConstantsI[i] = TRUE; + } + + return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, CONST int *pConstantData, UINT Vector4iCount) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; +HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantI( + IWineD3DDevice *iface, + UINT start, + int *dstData, + UINT count) { - return IWineD3DDeviceImpl_SetPixelShaderConstant(iface, - This->updateStateBlock->pixelShaderConstantI, - pConstantData, - WINESHADERCNST_INTEGER, - StartRegister, - Vector4iCount, - 4 * sizeof(*pConstantData)); + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + int cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, dstData %p, start %d, count %d)\n", + iface, dstData, start, count); + + if (dstData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(dstData, &This->updateStateBlock->pixelShaderConstantI[start * 4], cnt * 16); + return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, int *pConstantData, UINT Vector4iCount) { +HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantF( + IWineD3DDevice *iface, + UINT start, + CONST float *srcData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - return IWineD3DDeviceImpl_GetPixelShaderConstant(iface, - pConstantData, - This->updateStateBlock->pixelShaderConstantI, - WINESHADERCNST_INTEGER, - StartRegister, - Vector4iCount, - 4 * sizeof(*pConstantData)); + int i, cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); + + TRACE("(iface %p, srcData %p, start %d, count %d)\n", + iface, srcData, start, count); + + if (srcData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; + + memcpy(&This->updateStateBlock->pixelShaderConstantF[start * 4], srcData, cnt * 16); + + for (i = start; i < cnt + start; ++i) { + This->updateStateBlock->changed.pixelShaderConstantsF[i] = TRUE; + This->updateStateBlock->set.pixelShaderConstantsF[i] = TRUE; + } + + return WINED3D_OK; } -HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, CONST float *pConstantData, UINT Vector4fCount) { +HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantF( + IWineD3DDevice *iface, + UINT start, + float *dstData, + UINT count) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - return IWineD3DDeviceImpl_SetPixelShaderConstant(iface, - This->updateStateBlock->pixelShaderConstantF, - pConstantData, - WINESHADERCNST_FLOAT, - StartRegister, - Vector4fCount, - 4 * sizeof(*pConstantData)); -} + int cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1)); -HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, float *pConstantData, UINT Vector4fCount) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + TRACE("(iface %p, dstData %p, start %d, count %d)\n", + iface, dstData, start, count); - return IWineD3DDeviceImpl_GetPixelShaderConstant(iface, - pConstantData, - This->updateStateBlock->pixelShaderConstantF, - WINESHADERCNST_FLOAT, - StartRegister, - Vector4fCount, - 4 * sizeof(*pConstantData)); -} + if (dstData == NULL || cnt < 0) + return WINED3DERR_INVALIDCALL; -HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantN(IWineD3DDevice *iface, UINT StartRegister, UINT VectorNCount){ - return IWineD3DDeviceImpl_SetPixelShaderConstant(iface, - NULL, - NULL, - WINESHADERCNST_NONE, - StartRegister, - VectorNCount, - 0); + memcpy(dstData, &This->updateStateBlock->pixelShaderConstantF[start * 4], cnt * 16); + return WINED3D_OK; } #define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size) @@ -7470,15 +7467,12 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_GetPaletteEntries, IWineD3DDeviceImpl_SetPixelShader, IWineD3DDeviceImpl_GetPixelShader, - IWineD3DDeviceImpl_SetPixelShaderConstant, - IWineD3DDeviceImpl_GetPixelShaderConstant, IWineD3DDeviceImpl_SetPixelShaderConstantB, IWineD3DDeviceImpl_GetPixelShaderConstantB, IWineD3DDeviceImpl_SetPixelShaderConstantI, IWineD3DDeviceImpl_GetPixelShaderConstantI, IWineD3DDeviceImpl_SetPixelShaderConstantF, IWineD3DDeviceImpl_GetPixelShaderConstantF, - IWineD3DDeviceImpl_SetPixelShaderConstantN, IWineD3DDeviceImpl_SetRenderState, IWineD3DDeviceImpl_GetRenderState, IWineD3DDeviceImpl_SetRenderTarget, @@ -7504,15 +7498,12 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_GetVertexDeclaration, IWineD3DDeviceImpl_SetVertexShader, IWineD3DDeviceImpl_GetVertexShader, - IWineD3DDeviceImpl_SetVertexShaderConstant, - IWineD3DDeviceImpl_GetVertexShaderConstant, IWineD3DDeviceImpl_SetVertexShaderConstantB, IWineD3DDeviceImpl_GetVertexShaderConstantB, IWineD3DDeviceImpl_SetVertexShaderConstantI, IWineD3DDeviceImpl_GetVertexShaderConstantI, IWineD3DDeviceImpl_SetVertexShaderConstantF, IWineD3DDeviceImpl_GetVertexShaderConstantF, - IWineD3DDeviceImpl_SetVertexShaderConstantN, IWineD3DDeviceImpl_SetViewport, IWineD3DDeviceImpl_GetViewport, IWineD3DDeviceImpl_MultiplyTransform, diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 1f29634b6ae..83b878c9411 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -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"); } } } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index af1a265547d..c694f440679 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -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); } } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5148c01d688..d9c74061289 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -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; diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h index 944e7642d66..c4fea2532a2 100644 --- a/include/wine/wined3d_interface.h +++ b/include/wine/wined3d_interface.h @@ -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)