WINED3D: Cleanup shader constants code a little bit.
H. Verbeet
hverbeet at gmail.com
Mon Dec 19 15:21:04 CST 2005
All the SetShaderConstant functions do pretty much the same thing, so
replace most of that code with a single function. Additionally, none
of those functions checked the array index against
MAX_VSHADER_CONSTANTS / MAX_PSHADER_CONSTANTS when setting their
changed, set and type arrays, causing them to write beyond their
bounds on occasion.
Changelog:
- Cleanup the shader constants code a little bit.
- Improved bounds checking,
-------------- next part --------------
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ee51e1b..da7a99f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3796,146 +3796,140 @@ HRESULT WINAPI IWineD3DDeviceImpl_GetVer
return D3D_OK;
}
-#define GET_SHADER_CONSTANT(_vertexshaderconstant, _count, _sizecount) \
- count = min(_count, MAX_VSHADER_CONSTANTS - (StartRegister + 1)); \
-if (NULL == pConstantData || count < 0 /* || _count != count */ ) \
- return D3DERR_INVALIDCALL; \
-memcpy(pConstantData, This->updateStateBlock->_vertexshaderconstant + (StartRegister * _sizecount), count * (sizeof(*pConstantData) * _sizecount));
-
-#define SET_SHADER_CONSTANT(_vertexshaderconstant, _count, _sizecount) \
-int count = min(_count, MAX_VSHADER_CONSTANTS - (StartRegister + 1)); \
-if (NULL == pConstantData || count < 0 /* || _count != count */ ) \
- return D3DERR_INVALIDCALL; \
-memcpy(This->updateStateBlock->_vertexshaderconstant + (StartRegister * _sizecount), pConstantData, count * (sizeof(*pConstantData) * _sizecount)); \
-This->updateStateBlock->changed.vertexShader = TRUE; \
-This->updateStateBlock->set.vertexShader = TRUE;
-
-HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, CONST BOOL *pConstantData, UINT BoolCount){
+HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) {
+ TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n",
+ iface, dstData, srcData, type, start, count, registersize);
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+
int i;
- SET_SHADER_CONSTANT(vertexShaderConstantB, BoolCount, 1);
+ int cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1));
+
+ if (type != WINESHADERCNST_NONE) {
+ if (srcData == NULL || cnt < 0) {
+ return D3DERR_INVALIDCALL;
+ }
+
+ CopyMemory((char *)dstData + (start * registersize), srcData, cnt * registersize);
+ }
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < BoolCount + StartRegister; ++i) {
+ for (i = start; i < cnt + start; ++i) {
This->updateStateBlock->changed.vertexShaderConstants[i] = TRUE;
This->updateStateBlock->set.vertexShaderConstants[i] = TRUE;
- This->updateStateBlock->vertexShaderConstantT[i] = WINESHADERCNST_BOOL;
- TRACE("(%p) : Setting vsb %d to %d\n", This->updateStateBlock, i, pConstantData[i - StartRegister]);
+ This->updateStateBlock->vertexShaderConstantT[i] = type;
}
return D3D_OK;
}
-HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount){
+HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) {
+ TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n",
+ iface, dstData, srcData, type, start, count, registersize);
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i, count;
- /* verify that the requested shader constant was populated with a boolean */
- for (i = StartRegister; i < BoolCount; ++i) {
- if (This->updateStateBlock->vertexShaderConstantT[i] != WINESHADERCNST_BOOL) {
-
- /* the constant for this register isn't a boolean */
- WARN("(%p) : Caller requested a boolean where stateblock (%p) entry is a %s. Returning D3DERR_INVALIDCALL\n", This,This->updateStateBlock,
- This->updateStateBlock->vertexShaderConstantT[i] == WINESHADERCNST_INTEGER ? "integer" : "float");
+ int i;
+ int cnt = min(count, MAX_VSHADER_CONSTANTS - (start + 1));
+
+ /* 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 D3DERR_INVALIDCALL\n",
+ This, type, This->updateStateBlock->vertexShaderConstantT[i]);
return D3DERR_INVALIDCALL;
}
}
- GET_SHADER_CONSTANT(vertexShaderConstantB, BoolCount, 1);
+ if (dstData == NULL || cnt < 0) {
+ return D3DERR_INVALIDCALL;
+ }
+
+ CopyMemory(dstData, (char *)srcData + (start * registersize), cnt * registersize);
+
return D3D_OK;
}
-HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, CONST int *pConstantData, UINT Vector4iCount){
+HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, CONST BOOL *pConstantData, UINT BoolCount){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i;
-
- SET_SHADER_CONSTANT(vertexShaderConstantI, Vector4iCount, 4);
+
+ return IWineD3DDeviceImpl_SetVertexShaderConstant(iface,
+ This->updateStateBlock->vertexShaderConstantB,
+ pConstantData,
+ WINESHADERCNST_BOOL,
+ StartRegister,
+ BoolCount,
+ sizeof(*pConstantData));
+}
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < StartRegister + Vector4iCount; ++i) {
- This->updateStateBlock->changed.vertexShaderConstants[i] = TRUE;
- This->updateStateBlock->set.vertexShaderConstants[i] = TRUE;
- This->updateStateBlock->vertexShaderConstantT[i] = WINESHADERCNST_INTEGER;
- TRACE("(%p) : Setting vsi %d to %d\n", This->updateStateBlock, i, pConstantData[i - StartRegister]);
- }
+HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount){
+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+
+ return IWineD3DDeviceImpl_GetVertexShaderConstant(iface,
+ pConstantData,
+ This->updateStateBlock->vertexShaderConstantB,
+ WINESHADERCNST_BOOL,
+ StartRegister,
+ BoolCount,
+ sizeof(*pConstantData));
+}
- return D3D_OK;
+HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, CONST int *pConstantData, UINT Vector4iCount){
+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+
+ return IWineD3DDeviceImpl_SetVertexShaderConstant(iface,
+ This->updateStateBlock->vertexShaderConstantI,
+ pConstantData,
+ WINESHADERCNST_INTEGER,
+ StartRegister,
+ Vector4iCount,
+ 4 * sizeof(*pConstantData));
}
HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, int *pConstantData, UINT Vector4iCount){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i, count;
-
- /* verify that the requested shader constant was populated with a integer */
- for (i = StartRegister; i < Vector4iCount; ++i) {
- if (This->updateStateBlock->vertexShaderConstantT[i] != WINESHADERCNST_INTEGER) {
-
- /* the constant for this register isn't a integer */
- WARN("(%p) : Caller requested a integer where stateblock (%p) entry is a %s. Returning D3DERR_INVALIDCALL\n", This, This->updateStateBlock,
- This->updateStateBlock->vertexShaderConstantT[i] == WINESHADERCNST_BOOL ? "boolean" : "float");
- return D3DERR_INVALIDCALL;
- }
- }
-
- GET_SHADER_CONSTANT(vertexShaderConstantI, Vector4iCount, 4);
-
- return D3D_OK;
+
+ return IWineD3DDeviceImpl_GetVertexShaderConstant(iface,
+ pConstantData,
+ This->updateStateBlock->vertexShaderConstantI,
+ WINESHADERCNST_INTEGER,
+ StartRegister,
+ Vector4iCount,
+ 4 * sizeof(*pConstantData));
}
+
HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, CONST float *pConstantData, UINT Vector4fCount){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i;
-
- SET_SHADER_CONSTANT(vertexShaderConstantF, Vector4fCount, 4);
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < StartRegister + Vector4fCount; ++i) {
- This->updateStateBlock->changed.vertexShaderConstants[i] = TRUE;
- This->updateStateBlock->set.vertexShaderConstants[i] = TRUE;
- This->updateStateBlock->vertexShaderConstantT[i] = WINESHADERCNST_FLOAT;
- TRACE("(%p) : Setting vsf %d to %f\n", This->updateStateBlock, i, pConstantData[i - StartRegister]);
- }
- return D3D_OK;
+ return IWineD3DDeviceImpl_SetVertexShaderConstant(iface,
+ This->updateStateBlock->vertexShaderConstantF,
+ pConstantData,
+ WINESHADERCNST_FLOAT,
+ StartRegister,
+ Vector4fCount,
+ 4 * sizeof(*pConstantData));
}
HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, float *pConstantData, UINT Vector4fCount){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i, count;
-
- /* verify that the requested shader constant was populated with a float */
- for (i = StartRegister; i < Vector4fCount; ++i) {
- if (This->updateStateBlock->vertexShaderConstantT[i] != WINESHADERCNST_FLOAT) {
-
- /* the constant for this register isn't a float */
- WARN("(%p) : Caller requested a float where stateblock (%p) entry is a %s. Returning D3DERR_INVALIDCALL\n", This, This->updateStateBlock,
- This->updateStateBlock->vertexShaderConstantT[i] == WINESHADERCNST_BOOL ? "boolean" : "integer");
- return D3DERR_INVALIDCALL;
- }
- }
-
-
-
- GET_SHADER_CONSTANT(vertexShaderConstantF, Vector4fCount, 4);
- return D3D_OK;
+ 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){
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i;
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < StartRegister + VectorNCount; ++i) {
- This->updateStateBlock->changed.vertexShaderConstants[i] = TRUE;
- This->updateStateBlock->set.vertexShaderConstants[i] = TRUE;
- This->updateStateBlock->vertexShaderConstantT[i] = WINESHADERCNST_NONE;
- TRACE("(%p) : Setting vsf %d\n", This, i);
- }
- return D3D_OK;
+ return IWineD3DDeviceImpl_SetVertexShaderConstant(iface,
+ NULL,
+ NULL,
+ WINESHADERCNST_NONE,
+ StartRegister,
+ VectorNCount,
+ 0);
}
-#undef SET_SHADER_CONSTANT
-#undef GET_SHADER_CONSTANT
-
HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DPixelShader *oldShader = This->updateStateBlock->pixelShader;
@@ -3979,150 +3973,139 @@ HRESULT WINAPI IWineD3DDeviceImpl_GetPix
return D3D_OK;
}
-#define GET_SHADER_CONSTANT(_pixelshaderconstant, _count, _sizecount) \
-count = min(_count, MAX_PSHADER_CONSTANTS - (StartRegister + 1)); \
-if (NULL == pConstantData || count < 0 /* || _count != count */ ) \
- return D3DERR_INVALIDCALL; \
-memcpy(pConstantData, This->updateStateBlock->_pixelshaderconstant + (StartRegister * _sizecount), count * (sizeof(*pConstantData) * _sizecount)); \
-
-
-#define SET_SHADER_CONSTANT(_pixelshaderconstant, _count, _sizecount) \
-int count = min(_count, MAX_PSHADER_CONSTANTS - (StartRegister + 1)); \
-if (NULL == pConstantData || count < 0 /* || _count != count */ ) \
- return D3DERR_INVALIDCALL; \
-memcpy(This->updateStateBlock->_pixelshaderconstant + (StartRegister * _sizecount), pConstantData, count * (sizeof(*pConstantData) * _sizecount));
-
-
-HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, CONST BOOL *pConstantData, UINT BoolCount) {
+HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) {
+ TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n",
+ iface, dstData, srcData, type, start, count, registersize);
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+
int i;
+ int cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1));
- SET_SHADER_CONSTANT(pixelShaderConstantB, BoolCount, 1);
+ if (type != WINESHADERCNST_NONE) {
+ if (srcData == NULL || cnt < 0) {
+ return D3DERR_INVALIDCALL;
+ }
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < BoolCount + StartRegister; ++i) {
+ 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] = WINESHADERCNST_BOOL;
- TRACE("(%p) : Setting psb %d to %d\n", This->updateStateBlock, i, pConstantData[i - StartRegister]);
+ This->updateStateBlock->pixelShaderConstantT[i] = type;
}
return D3D_OK;
-
}
-HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount) {
+HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstant(IWineD3DDevice *iface, void *dstData, const void *srcData, UINT type, UINT start, UINT count, UINT registersize) {
+ TRACE("(iface %p, dstData %p, srcData %p, type %d, start %d, count %d, registersize %d)\n",
+ iface, dstData, srcData, type, start, count, registersize);
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i, count;
- /* verify that the requested shader constant was populated with a integer */
- for (i = StartRegister; i < BoolCount; ++i) {
- if (WINESHADERCNST_BOOL != This->updateStateBlock->pixelShaderConstantT[i]) {
-
- /* the constant for this register isn't a boolean */
- WARN("(%p) : Caller requested a integer where stateblock (%p) entry is a %s. Returning D3DERR_INVALIDCALL\n", This, This->updateStateBlock,
- WINESHADERCNST_INTEGER == This->updateStateBlock->vertexShaderConstantT[i] ? "integer" : "float");
+ int i;
+ int cnt = min(count, MAX_PSHADER_CONSTANTS - (start + 1));
+
+ /* 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 D3DERR_INVALIDCALL\n",
+ This, type, This->updateStateBlock->pixelShaderConstantT[i]);
return D3DERR_INVALIDCALL;
}
}
+ if (dstData == NULL || cnt < 0) {
+ return D3DERR_INVALIDCALL;
+ }
- GET_SHADER_CONSTANT(pixelShaderConstantB, BoolCount, 1);
+ CopyMemory(dstData, (char *)srcData + (start * registersize), cnt * registersize);
return D3D_OK;
}
-HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, CONST int *pConstantData, UINT Vector4iCount) {
+HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, CONST BOOL *pConstantData, UINT BoolCount) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i;
-
- SET_SHADER_CONSTANT(pixelShaderConstantI, Vector4iCount, 4);
+
+ return IWineD3DDeviceImpl_SetPixelShaderConstant(iface,
+ This->updateStateBlock->pixelShaderConstantB,
+ pConstantData,
+ WINESHADERCNST_BOOL,
+ StartRegister,
+ BoolCount,
+ sizeof(*pConstantData));
+}
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < Vector4iCount + StartRegister; ++i) {
- This->updateStateBlock->changed.pixelShaderConstants[i] = TRUE;
- This->updateStateBlock->set.pixelShaderConstants[i] = TRUE;
- This->updateStateBlock->pixelShaderConstantT[i] = WINESHADERCNST_INTEGER;
- TRACE("(%p) : Setting psb %d to %d\n", This->updateStateBlock, i, pConstantData[i - StartRegister]);
- }
+HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, BOOL *pConstantData, UINT BoolCount) {
+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- return D3D_OK;
+ return IWineD3DDeviceImpl_GetPixelShaderConstant(iface,
+ pConstantData,
+ This->updateStateBlock->pixelShaderConstantB,
+ WINESHADERCNST_BOOL,
+ StartRegister,
+ BoolCount,
+ sizeof(*pConstantData));
}
-HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, int *pConstantData, UINT Vector4iCount) {
+HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, CONST int *pConstantData, UINT Vector4iCount) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i, count;
- /* verify that the requested shader constant was populated with a integer */
- for (i = StartRegister; i < Vector4iCount; ++i) {
- if (WINESHADERCNST_INTEGER != This->updateStateBlock->pixelShaderConstantT[i]) {
-
- /* the constant for this register isn't a integer */
- WARN("(%p) : Caller requested a integer where stateblock (%p) entry is a %s. Returning D3DERR_INVALIDCALL\n", This, This->updateStateBlock,
- WINESHADERCNST_BOOL == This->updateStateBlock->vertexShaderConstantT[i] ? "boolean" : "float");
- return D3DERR_INVALIDCALL;
- }
- }
-
- GET_SHADER_CONSTANT(pixelShaderConstantI, Vector4iCount, 4);
+ return IWineD3DDeviceImpl_SetPixelShaderConstant(iface,
+ This->updateStateBlock->pixelShaderConstantI,
+ pConstantData,
+ WINESHADERCNST_INTEGER,
+ StartRegister,
+ Vector4iCount,
+ 4 * sizeof(*pConstantData));
+}
- return D3D_OK;
+HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantI(IWineD3DDevice *iface, UINT StartRegister, int *pConstantData, UINT Vector4iCount) {
+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+
+ return IWineD3DDeviceImpl_GetPixelShaderConstant(iface,
+ pConstantData,
+ This->updateStateBlock->pixelShaderConstantI,
+ WINESHADERCNST_INTEGER,
+ StartRegister,
+ Vector4iCount,
+ 4 * sizeof(*pConstantData));
}
HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, CONST float *pConstantData, UINT Vector4fCount) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i;
- SET_SHADER_CONSTANT(pixelShaderConstantF, Vector4fCount, 4);
-
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < Vector4fCount + StartRegister; ++i) {
- This->updateStateBlock->changed.pixelShaderConstants[i] = TRUE;
- This->updateStateBlock->set.pixelShaderConstants[i] = TRUE;
- This->updateStateBlock->pixelShaderConstantT[i] = WINESHADERCNST_FLOAT;
- TRACE("(%p) : Setting psb %d to %f\n", This->updateStateBlock, i, pConstantData[i - StartRegister]);
- }
-
- return D3D_OK;
+
+ return IWineD3DDeviceImpl_SetPixelShaderConstant(iface,
+ This->updateStateBlock->pixelShaderConstantF,
+ pConstantData,
+ WINESHADERCNST_FLOAT,
+ StartRegister,
+ Vector4fCount,
+ 4 * sizeof(*pConstantData));
}
HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, float *pConstantData, UINT Vector4fCount) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i, count;
-
- /* verify that the requested shader constant was populated with a integer */
- for (i = StartRegister; i < Vector4fCount; ++i) {
- if (WINESHADERCNST_FLOAT != This->updateStateBlock->pixelShaderConstantT[i]) {
-
- /* the constant for this register isn't a float */
- WARN("(%p) : Caller requested a integer where stateblock (%p) entry is a %s. Returning D3DERR_INVALIDCALL\n", This, This->updateStateBlock,
- WINESHADERCNST_BOOL == This->updateStateBlock->vertexShaderConstantT[i] ? "boolean" : "integer");
- return D3DERR_INVALIDCALL;
- }
- }
- GET_SHADER_CONSTANT(pixelShaderConstantF, Vector4fCount, 4);
-
- return D3D_OK;
+ return IWineD3DDeviceImpl_GetPixelShaderConstant(iface,
+ pConstantData,
+ This->updateStateBlock->pixelShaderConstantF,
+ WINESHADERCNST_FLOAT,
+ StartRegister,
+ Vector4fCount,
+ 4 * sizeof(*pConstantData));
}
HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantN(IWineD3DDevice *iface, UINT StartRegister, UINT VectorNCount){
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i;
-
- /* populate the bitmap that says which constant type we should load */
- for (i = StartRegister; i < StartRegister + VectorNCount; ++i) {
- This->updateStateBlock->changed.pixelShaderConstants[i] = TRUE;
- This->updateStateBlock->set.pixelShaderConstants[i] = TRUE;
- This->updateStateBlock->pixelShaderConstantT[i] = WINESHADERCNST_NONE;
- TRACE("(%p) : Setting vsf %d\n", This, i);
- }
-
- return D3D_OK;
+ return IWineD3DDeviceImpl_SetPixelShaderConstant(iface,
+ NULL,
+ NULL,
+ WINESHADERCNST_NONE,
+ StartRegister,
+ VectorNCount,
+ 0);
}
-#undef SET_SHADER_CONSTANT
-#undef GET_SHADER_CONSTANT
-
HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IWineD3DVertexBuffer* pDestBuffer, IWineD3DVertexBuffer* pVertexDecl, DWORD Flags) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
FIXME("(%p) : stub\n", This);
@@ -6456,6 +6439,8 @@ const IWineD3DDeviceVtbl IWineD3DDevice_
IWineD3DDeviceImpl_GetPaletteEntries,
IWineD3DDeviceImpl_SetPixelShader,
IWineD3DDeviceImpl_GetPixelShader,
+ IWineD3DDeviceImpl_SetPixelShaderConstant,
+ IWineD3DDeviceImpl_GetPixelShaderConstant,
IWineD3DDeviceImpl_SetPixelShaderConstantB,
IWineD3DDeviceImpl_GetPixelShaderConstantB,
IWineD3DDeviceImpl_SetPixelShaderConstantI,
@@ -6487,6 +6472,8 @@ const IWineD3DDeviceVtbl IWineD3DDevice_
IWineD3DDeviceImpl_GetVertexDeclaration,
IWineD3DDeviceImpl_SetVertexShader,
IWineD3DDeviceImpl_GetVertexShader,
+ IWineD3DDeviceImpl_SetVertexShaderConstant,
+ IWineD3DDeviceImpl_GetVertexShaderConstant,
IWineD3DDeviceImpl_SetVertexShaderConstantB,
IWineD3DDeviceImpl_GetVertexShaderConstantB,
IWineD3DDeviceImpl_SetVertexShaderConstantI,
diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h
index 1f2ba02..7452a4a 100644
--- a/include/wine/wined3d_interface.h
+++ b/include/wine/wined3d_interface.h
@@ -326,6 +326,8 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnkno
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;
@@ -357,6 +359,8 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnkno
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;
@@ -456,6 +460,8 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnkno
#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)
@@ -489,6 +495,8 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnkno
#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)
More information about the wine-patches
mailing list