Stefan Dösinger : wined3d: Optimize bool and int pixel shader constants.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Aug 14 07:12:54 CDT 2007
Module: wine
Branch: master
Commit: 865b82af2c3e9d48d350827db622ddb02df16477
URL: http://source.winehq.org/git/wine.git/?a=commit;h=865b82af2c3e9d48d350827db622ddb02df16477
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Fri Aug 3 20:12:54 2007 +0200
wined3d: Optimize bool and int pixel shader constants.
---
dlls/wined3d/device.c | 30 ++++++++++++++++++++-
dlls/wined3d/stateblock.c | 54 +++++++++++++++++++--------------------
dlls/wined3d/wined3d_private.h | 4 +++
3 files changed, 58 insertions(+), 30 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index e4fdeb9..9165e71 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -482,6 +482,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->contained_vs_consts_b[j] = j;
}
object->num_contained_vs_consts_b = MAX_CONST_B;
+ for(j = 0; j < MAX_CONST_I; j++) {
+ object->contained_ps_consts_i[j] = j;
+ }
+ object->num_contained_ps_consts_i = MAX_CONST_I;
+ for(j = 0; j < MAX_CONST_B; j++) {
+ object->contained_ps_consts_b[j] = j;
+ }
+ object->num_contained_ps_consts_b = MAX_CONST_B;
} else if (Type == WINED3DSBT_PIXELSTATE) {
@@ -493,10 +501,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
/* Pixel Shader Constants */
for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i)
object->changed.pixelShaderConstantsF[i] = TRUE;
- for (i = 0; i < MAX_CONST_B; ++i)
+ for (i = 0; i < MAX_CONST_B; ++i) {
+ object->contained_ps_consts_b[i] = i;
object->changed.pixelShaderConstantsB[i] = TRUE;
- for (i = 0; i < MAX_CONST_I; ++i)
+ }
+ object->num_contained_ps_consts_b = MAX_CONST_B;
+ for (i = 0; i < MAX_CONST_I; ++i) {
+ object->contained_ps_consts_i[i] = i;
object->changed.pixelShaderConstantsI[i] = TRUE;
+ }
+ object->num_contained_ps_consts_i = MAX_CONST_I;
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
object->changed.renderState[SavedPixelStates_R[i]] = TRUE;
@@ -4359,6 +4373,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
object->num_contained_vs_consts_b++;
}
}
+ for(i = 0; i < MAX_CONST_I; i++) {
+ if(object->changed.pixelShaderConstantsI[i]) {
+ object->contained_ps_consts_i[object->num_contained_ps_consts_i] = i;
+ object->num_contained_ps_consts_i++;
+ }
+ }
+ for(i = 0; i < MAX_CONST_B; i++) {
+ if(object->changed.pixelShaderConstantsB[i]) {
+ object->contained_ps_consts_b[object->num_contained_ps_consts_b] = i;
+ object->num_contained_ps_consts_b++;
+ }
+ }
*ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index ba71dc3..9ce8ea8 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -455,31 +455,29 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
This->pixelShaderConstantF[i * 4 + 3] = targetStateBlock->pixelShaderConstantF[i * 4 + 3];
}
}
-
+
/* Pixel Shader Integer Constants */
- for (i = 0; i < MAX_CONST_I; ++i) {
- if (This->changed.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];
- }
+ for (j = 0; j < This->num_contained_ps_consts_i; ++j) {
+ i = This->contained_ps_consts_i[j];
+ 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];
}
-
+
/* Pixel Shader Boolean Constants */
- for (i = 0; i < MAX_CONST_B; ++i) {
- if (This->changed.pixelShaderConstantsB[i]) {
- TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
- targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE");
+ for (j = 0; j < This->num_contained_ps_consts_b; ++j) {
+ i = This->contained_ps_consts_b[j];
+ TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
+ targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE");
- This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
- }
+ This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
}
/* Others + Render & Texture */
@@ -670,14 +668,14 @@ should really perform a delta so that only the changes get updated*/
IWineD3DDevice_SetPixelShaderConstantF(pDevice, i, This->pixelShaderConstantF + i * 4, 1);
}
- for (i = 0; i < MAX_CONST_I; ++i) {
- if (This->changed.pixelShaderConstantsI[i])
- IWineD3DDevice_SetPixelShaderConstantI(pDevice, i, This->pixelShaderConstantI + i * 4, 1);
+ for (i = 0; i < This->num_contained_ps_consts_i; i++) {
+ IWineD3DDevice_SetPixelShaderConstantI(pDevice, This->contained_ps_consts_i[i],
+ This->pixelShaderConstantI + This->contained_ps_consts_i[i] * 4, 1);
}
-
- for (i = 0; i < MAX_CONST_B; ++i) {
- if (This->changed.pixelShaderConstantsB[i])
- IWineD3DDevice_SetPixelShaderConstantB(pDevice, i, This->pixelShaderConstantB + i, 1);
+
+ for (i = 0; i < This->num_contained_ps_consts_b; i++) {
+ IWineD3DDevice_SetPixelShaderConstantB(pDevice, This->contained_ps_consts_b[i],
+ This->pixelShaderConstantB + This->contained_ps_consts_b[i], 1);
}
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 948cf2e..62be55e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1375,6 +1375,10 @@ struct IWineD3DStateBlockImpl
unsigned int num_contained_vs_consts_i;
DWORD contained_vs_consts_b[MAX_CONST_B];
unsigned int num_contained_vs_consts_b;
+ DWORD contained_ps_consts_i[MAX_CONST_I];
+ unsigned int num_contained_ps_consts_i;
+ DWORD contained_ps_consts_b[MAX_CONST_B];
+ unsigned int num_contained_ps_consts_b;
};
extern void stateblock_savedstates_set(
More information about the wine-cvs
mailing list