wined3d: Optimize transform state in stateblocks.

This commit is contained in:
Stefan Dösinger 2007-07-31 15:44:13 +02:00 committed by Alexandre Julliard
parent b56afd0cff
commit 92ce028a0b
3 changed files with 21 additions and 11 deletions

View File

@ -469,7 +469,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
for(j = 1; j <= WINEHIGHEST_RENDER_STATE; j++) {
object->contained_render_states[j - 1] = j;
}
object->num_contained_render_states = WINEHIGHEST_RENDER_STATE;
/* TODO: Filter unused transforms between TEXTURE8 and WORLD0? */
for(j = 1; j <= HIGHEST_TRANSFORMSTATE; j++) {
object->contained_transform_states[j - 1] = j;
}
object->num_contained_transform_states = HIGHEST_TRANSFORMSTATE;
} else if (Type == WINED3DSBT_PIXELSTATE) {
@ -4324,6 +4328,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
object->num_contained_render_states++;
}
}
for(i = 1; i <= HIGHEST_TRANSFORMSTATE; i++) {
if(object->changed.transform[i]) {
object->contained_transform_states[object->num_contained_transform_states] = i;
object->num_contained_transform_states++;
}
}
*ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE;

View File

@ -485,13 +485,11 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
}
/* Others + Render & Texture */
for (i = 1; i <= HIGHEST_TRANSFORMSTATE; i++) {
if (This->changed.transform[i] && memcmp(&targetStateBlock->transforms[i],
&This->transforms[i],
sizeof(WINED3DMATRIX)) != 0) {
TRACE("Updating transform %d\n", i);
memcpy(&This->transforms[i], &targetStateBlock->transforms[i], sizeof(WINED3DMATRIX));
}
for (i = 0; i < This->num_contained_transform_states; i++) {
TRACE("Updating transform %d\n", i);
memcpy(&This->transforms[This->contained_transform_states[i]],
&targetStateBlock->transforms[This->contained_transform_states[i]],
sizeof(WINED3DMATRIX));
}
if (This->changed.indices && ((This->pIndexData != targetStateBlock->pIndexData)
@ -695,9 +693,9 @@ should really perform a delta so that only the changes get updated*/
/* Others + Render & Texture */
if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */ This->blockType == WINED3DSBT_ALL || This->blockType == WINED3DSBT_INIT) {
for (i = 1; i <= HIGHEST_TRANSFORMSTATE; i++) {
if (This->changed.transform[i])
IWineD3DDevice_SetTransform(pDevice, i, &This->transforms[i]);
for (i = 0; i < This->num_contained_transform_states; i++) {
IWineD3DDevice_SetTransform(pDevice, This->contained_transform_states[i],
&This->transforms[This->contained_transform_states[i]]);
}
if (This->changed.indices) {

View File

@ -1369,6 +1369,8 @@ struct IWineD3DStateBlockImpl
/* Contained state management */
DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
unsigned int num_contained_render_states;
DWORD contained_transform_states[WINEHIGHEST_RENDER_STATE + 1];
unsigned int num_contained_transform_states;
};
extern void stateblock_savedstates_set(