Commit fd33f0f9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Convert samplerState to a bitmap in struct SAVEDSTATES.

parent c33b3811
...@@ -485,9 +485,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, ...@@ -485,9 +485,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
} }
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; 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; DWORD state = SavedPixelStates_S[i];
object->changed.samplerState[j] |= 1 << state;
object->contained_sampler_states[object->num_contained_sampler_states].stage = j; 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->contained_sampler_states[object->num_contained_sampler_states].state = state;
object->num_contained_sampler_states++; object->num_contained_sampler_states++;
} }
} }
...@@ -543,9 +544,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, ...@@ -543,9 +544,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
} }
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; 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; DWORD state = SavedVertexStates_S[i];
object->changed.samplerState[j] |= 1 << state;
object->contained_sampler_states[object->num_contained_sampler_states].stage = j; 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->contained_sampler_states[object->num_contained_sampler_states].state = state;
object->num_contained_sampler_states++; object->num_contained_sampler_states++;
} }
} }
...@@ -3327,7 +3329,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, ...@@ -3327,7 +3329,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface,
oldValue = This->stateBlock->samplerState[Sampler][Type]; oldValue = This->stateBlock->samplerState[Sampler][Type];
This->updateStateBlock->samplerState[Sampler][Type] = Value; This->updateStateBlock->samplerState[Sampler][Type] = Value;
This->updateStateBlock->changed.samplerState[Sampler][Type] = Value; This->updateStateBlock->changed.samplerState[Sampler] |= 1 << Type;
/* Handle recording of state blocks */ /* Handle recording of state blocks */
if (This->isRecordingState) { if (This->isRecordingState) {
...@@ -4821,12 +4823,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW ...@@ -4821,12 +4823,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
} }
} }
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++){ for(i = 0; i < MAX_COMBINED_SAMPLERS; i++){
for (j = 1; j < WINED3D_HIGHEST_SAMPLER_STATE; j++) { DWORD map = object->changed.samplerState[i];
if(object->changed.samplerState[i][j]) {
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
object->contained_sampler_states[object->num_contained_sampler_states].stage = i; object->contained_sampler_states[object->num_contained_sampler_states].stage = i;
object->contained_sampler_states[object->num_contained_sampler_states].state = j; object->contained_sampler_states[object->num_contained_sampler_states].state = j;
object->num_contained_sampler_states++; ++object->num_contained_sampler_states;
}
} }
} }
......
...@@ -92,7 +92,7 @@ static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES * ...@@ -92,7 +92,7 @@ static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *
memcpy(dest->transform, source->transform, sizeof(source->transform)); memcpy(dest->transform, source->transform, sizeof(source->transform));
memcpy(dest->renderState, source->renderState, sizeof(source->renderState)); 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, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
memcpy(dest->samplerState, source->samplerState, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1)); memcpy(dest->samplerState, source->samplerState, sizeof(source->samplerState));
dest->clipplane = source->clipplane; dest->clipplane = source->clipplane;
dest->pixelShaderConstantsB = source->pixelShaderConstantsB; dest->pixelShaderConstantsB = source->pixelShaderConstantsB;
dest->pixelShaderConstantsI = source->pixelShaderConstantsI; dest->pixelShaderConstantsI = source->pixelShaderConstantsI;
...@@ -132,11 +132,13 @@ void stateblock_savedstates_set( ...@@ -132,11 +132,13 @@ void stateblock_savedstates_set(
/* Fixed size arrays */ /* Fixed size arrays */
if (value) if (value)
{ {
int i;
states->streamSource = 0xffff; states->streamSource = 0xffff;
states->streamFreq = 0xffff; states->streamFreq = 0xffff;
states->textures = 0xfffff; states->textures = 0xfffff;
stateblock_set_bits(states->transform, HIGHEST_TRANSFORMSTATE + 1); stateblock_set_bits(states->transform, HIGHEST_TRANSFORMSTATE + 1);
stateblock_set_bits(states->renderState, WINEHIGHEST_RENDER_STATE + 1); stateblock_set_bits(states->renderState, WINEHIGHEST_RENDER_STATE + 1);
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3fff;
states->clipplane = 0xffffffff; states->clipplane = 0xffffffff;
states->pixelShaderConstantsB = 0xffff; states->pixelShaderConstantsB = 0xffff;
states->pixelShaderConstantsI = 0xffff; states->pixelShaderConstantsI = 0xffff;
...@@ -150,6 +152,7 @@ void stateblock_savedstates_set( ...@@ -150,6 +152,7 @@ void stateblock_savedstates_set(
states->textures = 0; states->textures = 0;
memset(states->transform, 0, sizeof(states->transform)); memset(states->transform, 0, sizeof(states->transform));
memset(states->renderState, 0, sizeof(states->renderState)); memset(states->renderState, 0, sizeof(states->renderState));
memset(states->samplerState, 0, sizeof(states->samplerState));
states->clipplane = 0; states->clipplane = 0;
states->pixelShaderConstantsB = 0; states->pixelShaderConstantsB = 0;
states->pixelShaderConstantsI = 0; states->pixelShaderConstantsI = 0;
...@@ -157,7 +160,6 @@ void stateblock_savedstates_set( ...@@ -157,7 +160,6 @@ void stateblock_savedstates_set(
states->vertexShaderConstantsI = 0; states->vertexShaderConstantsI = 0;
} }
memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)); memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
memset(states->samplerState, value, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
/* Dynamically sized arrays */ /* Dynamically sized arrays */
memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF)); memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF));
...@@ -815,7 +817,7 @@ should really perform a delta so that only the changes get updated*/ ...@@ -815,7 +817,7 @@ should really perform a delta so that only the changes get updated*/
DWORD stage = This->contained_sampler_states[i].stage; DWORD stage = This->contained_sampler_states[i].stage;
DWORD state = This->contained_sampler_states[i].state; DWORD state = This->contained_sampler_states[i].state;
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[stage][state] = This->samplerState[stage][state]; ((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[stage][state] = This->samplerState[stage][state];
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.samplerState[stage][state] = TRUE; ((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.samplerState[stage] |= 1 << state;
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_SAMPLER(stage)); IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_SAMPLER(stage));
} }
......
...@@ -1764,7 +1764,7 @@ typedef struct SAVEDSTATES { ...@@ -1764,7 +1764,7 @@ typedef struct SAVEDSTATES {
DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */ DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */
DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1]; DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1]; BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
BOOL samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14*/
DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */ DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */
WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */ WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */
WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */ WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment