wined3d: Convert textureState to a bitmap in struct SAVEDSTATES.

This commit is contained in:
Henri Verbeet 2009-01-06 11:43:45 +01:00 committed by Alexandre Julliard
parent a8697d90e4
commit bddf5e76ea
3 changed files with 22 additions and 17 deletions

View File

@ -478,9 +478,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->num_contained_render_states = NUM_SAVEDPIXELSTATES_R;
for (j = 0; j < MAX_TEXTURES; j++) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
object->changed.textureState[j][SavedPixelStates_T[i]] = TRUE;
DWORD state = SavedPixelStates_T[i];
object->changed.textureState[j] |= 1 << state;
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->contained_tss_states[object->num_contained_tss_states].state = state;
object->num_contained_tss_states++;
}
}
@ -537,9 +538,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->num_contained_render_states = NUM_SAVEDVERTEXSTATES_R;
for (j = 0; j < MAX_TEXTURES; j++) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
object->changed.textureState[j][SavedVertexStates_T[i]] = TRUE;
DWORD state = SavedVertexStates_T[i];
object->changed.textureState[j] |= 1 << state;
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->contained_tss_states[object->num_contained_tss_states].state = state;
object->num_contained_tss_states++;
}
}
@ -4448,7 +4450,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if
return WINED3D_OK;
}
This->updateStateBlock->changed.textureState[Stage][Type] = TRUE;
This->updateStateBlock->changed.textureState[Stage] |= 1 << Type;
This->updateStateBlock->textureState[Stage][Type] = Value;
if (This->isRecordingState) {
@ -4816,13 +4818,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
}
}
for(i = 0; i < MAX_TEXTURES; i++) {
for (j = 0; j <= WINED3D_HIGHEST_TEXTURE_STATE; ++j)
DWORD map = object->changed.textureState[i];
for(j = 0; map; map >>= 1, ++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++;
}
if (!(map & 1)) continue;
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;
}
}
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++){

View File

@ -91,7 +91,7 @@ static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *
dest->textures = source->textures;
memcpy(dest->transform, source->transform, sizeof(source->transform));
memcpy(dest->renderState, source->renderState, sizeof(source->renderState));
memcpy(dest->textureState, source->textureState, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
memcpy(dest->textureState, source->textureState, sizeof(source->textureState));
memcpy(dest->samplerState, source->samplerState, sizeof(source->samplerState));
dest->clipplane = source->clipplane;
dest->pixelShaderConstantsB = source->pixelShaderConstantsB;
@ -138,6 +138,7 @@ void stateblock_savedstates_set(
states->textures = 0xfffff;
stateblock_set_bits(states->transform, HIGHEST_TRANSFORMSTATE + 1);
stateblock_set_bits(states->renderState, WINEHIGHEST_RENDER_STATE + 1);
for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = 0x3ffff;
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3fff;
states->clipplane = 0xffffffff;
states->pixelShaderConstantsB = 0xffff;
@ -152,6 +153,7 @@ void stateblock_savedstates_set(
states->textures = 0;
memset(states->transform, 0, sizeof(states->transform));
memset(states->renderState, 0, sizeof(states->renderState));
memset(states->textureState, 0, sizeof(states->textureState));
memset(states->samplerState, 0, sizeof(states->samplerState));
states->clipplane = 0;
states->pixelShaderConstantsB = 0;
@ -159,7 +161,6 @@ void stateblock_savedstates_set(
states->vertexShaderConstantsB = 0;
states->vertexShaderConstantsI = 0;
}
memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
/* Dynamically sized arrays */
memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF));
@ -808,7 +809,7 @@ should really perform a delta so that only the changes get updated*/
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;
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[stage] |= 1 << state;
/* TODO: Record a display list to apply all gl states. For now apply by brute force */
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(stage, state));
}

View File

@ -1761,10 +1761,10 @@ typedef struct SAVEDSTATES {
DWORD transform[(HIGHEST_TRANSFORMSTATE >> 5) + 1];
WORD streamSource; /* MAX_STREAMS, 16 */
WORD streamFreq; /* MAX_STREAMS, 16 */
DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */
DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14*/
DWORD textureState[MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */
DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */
WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */
WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */