wined3d: Optimize sampler states in stateblocks.
This commit is contained in:
parent
6e7a10f550
commit
59fb2928b8
@ -497,6 +497,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
|
|||||||
object->num_contained_tss_states++;
|
object->num_contained_tss_states++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++) {
|
||||||
|
for(j = 1; j <= WINED3D_HIGHEST_SAMPLER_STATE; j++) {
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].stage = i;
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].state = j;
|
||||||
|
object->num_contained_sampler_states++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (Type == WINED3DSBT_PIXELSTATE) {
|
} else if (Type == WINED3DSBT_PIXELSTATE) {
|
||||||
|
|
||||||
@ -532,10 +539,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
|
|||||||
object->num_contained_tss_states++;
|
object->num_contained_tss_states++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (j = 0 ; j < 16; j++) {
|
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++) {
|
||||||
for (i =0; i < NUM_SAVEDPIXELSTATES_S;i++) {
|
for (i =0; i < NUM_SAVEDPIXELSTATES_S;i++) {
|
||||||
|
|
||||||
object->changed.samplerState[j][SavedPixelStates_S[i]] = TRUE;
|
object->changed.samplerState[j][SavedPixelStates_S[i]] = TRUE;
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].stage = j;
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].state = SavedPixelStates_S[i];
|
||||||
|
object->num_contained_sampler_states++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,9 +581,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
|
|||||||
object->num_contained_tss_states++;
|
object->num_contained_tss_states++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (j = 0 ; j < 16; j++){
|
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++){
|
||||||
for (i =0; i < NUM_SAVEDVERTEXSTATES_S;i++) {
|
for (i =0; i < NUM_SAVEDVERTEXSTATES_S;i++) {
|
||||||
object->changed.samplerState[j][SavedVertexStates_S[i]] = TRUE;
|
object->changed.samplerState[j][SavedVertexStates_S[i]] = TRUE;
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].stage = j;
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].state = SavedVertexStates_S[i];
|
||||||
|
object->num_contained_sampler_states++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4407,6 +4419,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++){
|
||||||
|
for (j = 1; j < WINED3D_HIGHEST_SAMPLER_STATE; j++) {
|
||||||
|
if(object->changed.samplerState[i][j]) {
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].stage = i;
|
||||||
|
object->contained_sampler_states[object->num_contained_sampler_states].state = j;
|
||||||
|
object->num_contained_sampler_states++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*ppStateBlock = (IWineD3DStateBlock*) object;
|
*ppStateBlock = (IWineD3DStateBlock*) object;
|
||||||
This->isRecordingState = FALSE;
|
This->isRecordingState = FALSE;
|
||||||
|
@ -583,14 +583,15 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
|||||||
TRACE("Updating texture %d to %p (was %p)\n", j, targetStateBlock->textures[j], This->textures[j]);
|
TRACE("Updating texture %d to %p (was %p)\n", j, targetStateBlock->textures[j], This->textures[j]);
|
||||||
This->textures[j] = targetStateBlock->textures[j];
|
This->textures[j] = targetStateBlock->textures[j];
|
||||||
}
|
}
|
||||||
for (i = 1; i <= WINED3D_HIGHEST_SAMPLER_STATE ; i++){ /* States are 1 based */
|
}
|
||||||
if (This->changed.samplerState[j][i]) {
|
|
||||||
|
for (j = 0; j < This->num_contained_sampler_states; j++) {
|
||||||
|
DWORD stage = This->contained_sampler_states[j].stage;
|
||||||
|
DWORD state = This->contained_sampler_states[j].state;
|
||||||
TRACE("Updating sampler state %d,%d to %d (was %d)\n",
|
TRACE("Updating sampler state %d,%d to %d (was %d)\n",
|
||||||
j, i, targetStateBlock->samplerState[j][i],
|
stage, state, targetStateBlock->samplerState[stage][state],
|
||||||
This->samplerState[j][i]);
|
This->samplerState[stage][state]);
|
||||||
This->samplerState[j][i] = targetStateBlock->samplerState[j][i];
|
This->samplerState[stage][state] = targetStateBlock->samplerState[stage][state];
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,33 +739,12 @@ should really perform a delta so that only the changes get updated*/
|
|||||||
IWineD3DDevice_SetTexture(pDevice, WINED3DVERTEXTEXTURESAMPLER0 + j - MAX_FRAGMENT_SAMPLERS, This->textures[j]);
|
IWineD3DDevice_SetTexture(pDevice, WINED3DVERTEXTEXTURESAMPLER0 + j - MAX_FRAGMENT_SAMPLERS, This->textures[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 1; i <= WINED3D_HIGHEST_SAMPLER_STATE; i++){
|
|
||||||
if (This->changed.samplerState[j][i]) {
|
|
||||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[j][i] = This->samplerState[j][i];
|
|
||||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.samplerState[j][i] = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* SetTexture catches nop changes, so the above call does not assure that the sampler is updated */
|
|
||||||
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_SAMPLER(j));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (This->blockType == WINED3DSBT_PIXELSTATE) {
|
} else if (This->blockType == WINED3DSBT_PIXELSTATE) {
|
||||||
|
|
||||||
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]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (This->blockType == WINED3DSBT_VERTEXSTATE) {
|
} else if (This->blockType == WINED3DSBT_VERTEXSTATE) {
|
||||||
|
|
||||||
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]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
FIXME("Unrecognized state block type %d\n", This->blockType);
|
FIXME("Unrecognized state block type %d\n", This->blockType);
|
||||||
}
|
}
|
||||||
@ -783,6 +763,14 @@ should really perform a delta so that only the changes get updated*/
|
|||||||
/* TODO: Record a display list to apply all gl states. For now apply by brute force */
|
/* 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_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(stage, state));
|
||||||
}
|
}
|
||||||
|
/* Sampler states */
|
||||||
|
for (i = 0; i < This->num_contained_sampler_states; i++) {
|
||||||
|
DWORD stage = This->contained_sampler_states[i].stage;
|
||||||
|
DWORD state = This->contained_sampler_states[i].state;
|
||||||
|
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[stage][state] = This->samplerState[stage][state];
|
||||||
|
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.samplerState[stage][state] = TRUE;
|
||||||
|
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_SAMPLER(stage));
|
||||||
|
}
|
||||||
|
|
||||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->lowest_disabled_stage = MAX_TEXTURES - 1;
|
((IWineD3DDeviceImpl *)pDevice)->stateBlock->lowest_disabled_stage = MAX_TEXTURES - 1;
|
||||||
for(j = 0; j < MAX_TEXTURES - 1; j++) {
|
for(j = 0; j < MAX_TEXTURES - 1; j++) {
|
||||||
|
@ -1386,6 +1386,8 @@ struct IWineD3DStateBlockImpl
|
|||||||
unsigned int num_contained_ps_consts_b;
|
unsigned int num_contained_ps_consts_b;
|
||||||
struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE)];
|
struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE)];
|
||||||
unsigned int num_contained_tss_states;
|
unsigned int num_contained_tss_states;
|
||||||
|
struct StageState contained_sampler_states[MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
|
||||||
|
unsigned int num_contained_sampler_states;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void stateblock_savedstates_set(
|
extern void stateblock_savedstates_set(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user