wined3d: Optimize texture stage state applying.
This commit is contained in:
parent
865b82af2c
commit
03ffb73450
|
@ -490,6 +490,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
|
|||
object->contained_ps_consts_b[j] = j;
|
||||
}
|
||||
object->num_contained_ps_consts_b = MAX_CONST_B;
|
||||
for(i = 0; i < MAX_TEXTURES; i++) {
|
||||
for(j = 1; j <= WINED3D_HIGHEST_TEXTURE_STATE; j++) {
|
||||
object->contained_tss_states[object->num_contained_tss_states].stage = i;
|
||||
object->contained_tss_states[object->num_contained_tss_states].state = j;
|
||||
object->num_contained_tss_states++;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (Type == WINED3DSBT_PIXELSTATE) {
|
||||
|
||||
|
@ -520,6 +527,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
|
|||
for (j = 0; j < MAX_TEXTURES; j++) {
|
||||
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
|
||||
object->changed.textureState[j][SavedPixelStates_T[i]] = TRUE;
|
||||
object->contained_tss_states[object->num_contained_tss_states].stage = j;
|
||||
object->contained_tss_states[object->num_contained_tss_states].state = SavedPixelStates_T[i];
|
||||
object->num_contained_tss_states++;
|
||||
}
|
||||
}
|
||||
for (j = 0 ; j < 16; j++) {
|
||||
|
@ -557,6 +567,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
|
|||
for (j = 0; j < MAX_TEXTURES; j++) {
|
||||
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
|
||||
object->changed.textureState[j][SavedVertexStates_T[i]] = TRUE;
|
||||
object->contained_tss_states[object->num_contained_tss_states].stage = j;
|
||||
object->contained_tss_states[object->num_contained_tss_states].state = SavedVertexStates_T[i];
|
||||
object->num_contained_tss_states++;
|
||||
}
|
||||
}
|
||||
for (j = 0 ; j < 16; j++){
|
||||
|
@ -4303,7 +4316,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface)
|
|||
HRESULT temp_result;
|
||||
int i;
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
ERR("(%p)\n", This);
|
||||
|
||||
if (This->isRecordingState) {
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
@ -4340,7 +4353,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface)
|
|||
|
||||
static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IWineD3DStateBlock** ppStateBlock) {
|
||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||
unsigned int i;
|
||||
unsigned int i, j;
|
||||
IWineD3DStateBlockImpl *object = This->updateStateBlock;
|
||||
|
||||
if (!This->isRecordingState) {
|
||||
|
@ -4385,6 +4398,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
|
|||
object->num_contained_ps_consts_b++;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < MAX_TEXTURES; i++) {
|
||||
for(j = 1; j <= WINED3D_HIGHEST_TEXTURE_STATE; j++) {
|
||||
if(object->changed.textureState[i][j]) {
|
||||
object->contained_tss_states[object->num_contained_tss_states].stage = i;
|
||||
object->contained_tss_states[object->num_contained_tss_states].state = j;
|
||||
object->num_contained_tss_states++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*ppStateBlock = (IWineD3DStateBlock*) object;
|
||||
This->isRecordingState = FALSE;
|
||||
|
|
|
@ -567,15 +567,13 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
|||
}
|
||||
|
||||
/* Texture states */
|
||||
for (j = 0; j < MAX_TEXTURES; j++) {
|
||||
/* TODO: move over to using memcpy */
|
||||
for (i = 1; i <= WINED3D_HIGHEST_TEXTURE_STATE ; i++) {
|
||||
if (This->changed.textureState[j][i]) {
|
||||
TRACE("Updating texturestagestate %d,%d to %d (was %d)\n", j,i, targetStateBlock->textureState[j][i],
|
||||
This->textureState[j][i]);
|
||||
This->textureState[j][i] = targetStateBlock->textureState[j][i];
|
||||
}
|
||||
}
|
||||
for (j = 0; j < This->num_contained_tss_states; j++) {
|
||||
DWORD stage = This->contained_tss_states[j].stage;
|
||||
DWORD state = This->contained_tss_states[j].state;
|
||||
|
||||
TRACE("Updating texturestagestate %d,%d to %d (was %d)\n", stage,state,
|
||||
targetStateBlock->textureState[stage][state], This->textureState[stage][state]);
|
||||
This->textureState[stage][state] = targetStateBlock->textureState[stage][state];
|
||||
}
|
||||
|
||||
/* Samplers */
|
||||
|
@ -614,6 +612,7 @@ should really perform a delta so that only the changes get updated*/
|
|||
|
||||
TRACE("(%p) : Applying state block %p ------------------v\n", This, pDevice);
|
||||
|
||||
TRACE("Blocktype: %d\n", This->blockType);
|
||||
/* FIXME: Only apply applicable states not all states */
|
||||
|
||||
if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */This->blockType == WINED3DSBT_INIT || This->blockType == WINED3DSBT_ALL || This->blockType == WINED3DSBT_VERTEXSTATE) {
|
||||
|
@ -729,19 +728,6 @@ should really perform a delta so that only the changes get updated*/
|
|||
}
|
||||
}
|
||||
|
||||
/* Texture states */
|
||||
for (j = 0; j < MAX_TEXTURES; j++) { /* Set The texture first, just in case it resets the states? */
|
||||
/* TODO: move over to memcpy */
|
||||
for (i = 1; i <= WINED3D_HIGHEST_TEXTURE_STATE; i++) {
|
||||
if (This->changed.textureState[j][i]) { /* tb_dx9_10 failes without this test */
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[j][i] = This->textureState[j][i];
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[j][i] = TRUE;
|
||||
/* TODO: Record a display list to apply all gl states. For now apply by brute force */
|
||||
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(j, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Samplers */
|
||||
/* TODO: move over to memcpy */
|
||||
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++){
|
||||
|
@ -764,13 +750,6 @@ should really perform a delta so that only the changes get updated*/
|
|||
|
||||
} else if (This->blockType == WINED3DSBT_PIXELSTATE) {
|
||||
|
||||
for (j = 0; j < MAX_TEXTURES; j++) {
|
||||
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[j][SavedPixelStates_T[i]] = This->textureState[j][SavedPixelStates_T[i]];
|
||||
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(j, SavedPixelStates_T[i]));
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) {
|
||||
for (i = 0; i < NUM_SAVEDPIXELSTATES_S; i++) {
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[j][SavedPixelStates_S[i]] = This->samplerState[j][SavedPixelStates_S[i]];
|
||||
|
@ -779,13 +758,6 @@ should really perform a delta so that only the changes get updated*/
|
|||
|
||||
} else if (This->blockType == WINED3DSBT_VERTEXSTATE) {
|
||||
|
||||
for (j = 0; j < MAX_TEXTURES; j++) {
|
||||
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[j][SavedVertexStates_T[i]] = This->textureState[j][SavedVertexStates_T[i]];
|
||||
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(j, SavedVertexStates_T[i]));
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) {
|
||||
for (i = 0; i < NUM_SAVEDVERTEXSTATES_S; i++) {
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[j][SavedVertexStates_S[i]] = This->samplerState[j][SavedVertexStates_S[i]];
|
||||
|
@ -802,6 +774,15 @@ should really perform a delta so that only the changes get updated*/
|
|||
IWineD3DDevice_SetRenderState(pDevice, This->contained_render_states[i],
|
||||
This->renderState[This->contained_render_states[i]]);
|
||||
}
|
||||
/* Texture states */
|
||||
for (i = 0; i < This->num_contained_tss_states; i++) {
|
||||
DWORD stage = This->contained_tss_states[i].stage;
|
||||
DWORD state = This->contained_tss_states[i].state;
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[stage][state] = This->textureState[stage][state];
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[stage][state] = TRUE;
|
||||
/* TODO: Record a display list to apply all gl states. For now apply by brute force */
|
||||
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(stage, state));
|
||||
}
|
||||
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->lowest_disabled_stage = MAX_TEXTURES - 1;
|
||||
for(j = 0; j < MAX_TEXTURES - 1; j++) {
|
||||
|
|
|
@ -1279,6 +1279,11 @@ typedef struct {
|
|||
DWORD idx[13];
|
||||
} constants_entry;
|
||||
|
||||
struct StageState {
|
||||
DWORD stage;
|
||||
DWORD state;
|
||||
};
|
||||
|
||||
struct IWineD3DStateBlockImpl
|
||||
{
|
||||
/* IUnknown fields */
|
||||
|
@ -1379,6 +1384,8 @@ struct IWineD3DStateBlockImpl
|
|||
unsigned int num_contained_ps_consts_i;
|
||||
DWORD contained_ps_consts_b[MAX_CONST_B];
|
||||
unsigned int num_contained_ps_consts_b;
|
||||
struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE)];
|
||||
unsigned int num_contained_tss_states;
|
||||
};
|
||||
|
||||
extern void stateblock_savedstates_set(
|
||||
|
|
Loading…
Reference in New Issue