Stefan Dösinger : wined3d: Optimize bool and int vs constants.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Aug 14 07:12:54 CDT 2007
Module: wine
Branch: master
Commit: 4673b1c68ec089efbd97a465043974102c8e1325
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4673b1c68ec089efbd97a465043974102c8e1325
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Fri Aug 3 20:07:30 2007 +0200
wined3d: Optimize bool and int vs constants.
---
dlls/wined3d/device.c | 31 ++++++++++++++++++++--
dlls/wined3d/stateblock.c | 54 +++++++++++++++++++--------------------
dlls/wined3d/wined3d_private.h | 4 +++
3 files changed, 58 insertions(+), 31 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 8522dac..e4fdeb9 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -474,6 +474,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->contained_transform_states[j - 1] = j;
}
object->num_contained_transform_states = HIGHEST_TRANSFORMSTATE;
+ for(j = 0; j < MAX_CONST_I; j++) {
+ object->contained_vs_consts_i[j] = j;
+ }
+ object->num_contained_vs_consts_i = MAX_CONST_I;
+ for(j = 0; j < MAX_CONST_B; j++) {
+ object->contained_vs_consts_b[j] = j;
+ }
+ object->num_contained_vs_consts_b = MAX_CONST_B;
} else if (Type == WINED3DSBT_PIXELSTATE) {
@@ -517,11 +525,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
/* Vertex Shader Constants */
for (i = 0; i < GL_LIMITS(vshader_constantsF); ++i)
object->changed.vertexShaderConstantsF[i] = TRUE;
- for (i = 0; i < MAX_CONST_B; ++i)
+ for (i = 0; i < MAX_CONST_B; ++i) {
object->changed.vertexShaderConstantsB[i] = TRUE;
- for (i = 0; i < MAX_CONST_I; ++i)
+ object->contained_vs_consts_b[i] = i;
+ }
+ object->num_contained_vs_consts_b = MAX_CONST_B;
+ for (i = 0; i < MAX_CONST_I; ++i) {
object->changed.vertexShaderConstantsI[i] = TRUE;
-
+ object->contained_vs_consts_i[i] = i;
+ }
+ object->num_contained_vs_consts_i = MAX_CONST_I;
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
object->changed.renderState[SavedVertexStates_R[i]] = TRUE;
object->contained_render_states[i] = SavedVertexStates_R[i];
@@ -4334,6 +4347,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
object->num_contained_transform_states++;
}
}
+ for(i = 0; i < MAX_CONST_I; i++) {
+ if(object->changed.vertexShaderConstantsI[i]) {
+ object->contained_vs_consts_i[object->num_contained_vs_consts_i] = i;
+ object->num_contained_vs_consts_i++;
+ }
+ }
+ for(i = 0; i < MAX_CONST_B; i++) {
+ if(object->changed.vertexShaderConstantsB[i]) {
+ object->contained_vs_consts_b[object->num_contained_vs_consts_b] = i;
+ object->num_contained_vs_consts_b++;
+ }
+ }
*ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 5b98ff7..ba71dc3 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -363,29 +363,27 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
}
/* Vertex Shader Integer Constants */
- for (i = 0; i < MAX_CONST_I; ++i) {
- if (This->changed.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];
- }
+ for (j = 0; j < This->num_contained_vs_consts_i; ++j) {
+ i = This->contained_vs_consts_i[j];
+ 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];
}
-
+
/* Vertex Shader Boolean Constants */
- for (i = 0; i < MAX_CONST_B; ++i) {
- if (This->changed.vertexShaderConstantsB[i]) {
- TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
- targetStateBlock->vertexShaderConstantB[i]? "TRUE":"FALSE");
+ for (j = 0; j < This->num_contained_vs_consts_b; ++j) {
+ i = This->contained_vs_consts_b[j];
+ TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
+ targetStateBlock->vertexShaderConstantB[i]? "TRUE":"FALSE");
- This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
- }
+ This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
}
/* Lights... For a recorded state block, we just had a chain of actions to perform,
@@ -647,15 +645,15 @@ should really perform a delta so that only the changes get updated*/
if (This->changed.vertexShaderConstantsF[i])
IWineD3DDevice_SetVertexShaderConstantF(pDevice, i, This->vertexShaderConstantF + i * 4, 1);
}
-
- for (i = 0; i < MAX_CONST_I; i++) {
- if (This->changed.vertexShaderConstantsI[i])
- IWineD3DDevice_SetVertexShaderConstantI(pDevice, i, This->vertexShaderConstantI + i * 4, 1);
+
+ for (i = 0; i < This->num_contained_vs_consts_i; i++) {
+ IWineD3DDevice_SetVertexShaderConstantI(pDevice, This->contained_vs_consts_i[i],
+ This->vertexShaderConstantI + This->contained_vs_consts_i[i] * 4, 1);
}
-
- for (i = 0; i < MAX_CONST_B; i++) {
- if (This->changed.vertexShaderConstantsB[i])
- IWineD3DDevice_SetVertexShaderConstantB(pDevice, i, This->vertexShaderConstantB + i, 1);
+
+ for (i = 0; i < This->num_contained_vs_consts_b; i++) {
+ IWineD3DDevice_SetVertexShaderConstantB(pDevice, This->contained_vs_consts_b[i],
+ This->vertexShaderConstantB + This->contained_vs_consts_b[i], 1);
}
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f31e7dc..948cf2e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1371,6 +1371,10 @@ struct IWineD3DStateBlockImpl
unsigned int num_contained_render_states;
DWORD contained_transform_states[WINEHIGHEST_RENDER_STATE + 1];
unsigned int num_contained_transform_states;
+ DWORD contained_vs_consts_i[MAX_CONST_I];
+ unsigned int num_contained_vs_consts_i;
+ DWORD contained_vs_consts_b[MAX_CONST_B];
+ unsigned int num_contained_vs_consts_b;
};
extern void stateblock_savedstates_set(
More information about the wine-cvs
mailing list