wined3d: Convert samplerState to a bitmap in struct SAVEDSTATES.
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 4dc0806..212184c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -485,9 +485,10 @@
}
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++) {
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].state = SavedPixelStates_S[i];
+ object->contained_sampler_states[object->num_contained_sampler_states].state = state;
object->num_contained_sampler_states++;
}
}
@@ -543,9 +544,10 @@
}
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++){
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].state = SavedVertexStates_S[i];
+ object->contained_sampler_states[object->num_contained_sampler_states].state = state;
object->num_contained_sampler_states++;
}
}
@@ -3327,7 +3329,7 @@
oldValue = This->stateBlock->samplerState[Sampler][Type];
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 */
if (This->isRecordingState) {
@@ -4821,12 +4823,15 @@
}
}
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++;
- }
+ DWORD map = object->changed.samplerState[i];
+
+ 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].state = j;
+ ++object->num_contained_sampler_states;
}
}
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 2d19b53..445e281 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -92,7 +92,7 @@
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->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->pixelShaderConstantsB = source->pixelShaderConstantsB;
dest->pixelShaderConstantsI = source->pixelShaderConstantsI;
@@ -132,11 +132,13 @@
/* Fixed size arrays */
if (value)
{
+ int i;
states->streamSource = 0xffff;
states->streamFreq = 0xffff;
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_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3fff;
states->clipplane = 0xffffffff;
states->pixelShaderConstantsB = 0xffff;
states->pixelShaderConstantsI = 0xffff;
@@ -150,6 +152,7 @@
states->textures = 0;
memset(states->transform, 0, sizeof(states->transform));
memset(states->renderState, 0, sizeof(states->renderState));
+ memset(states->samplerState, 0, sizeof(states->samplerState));
states->clipplane = 0;
states->pixelShaderConstantsB = 0;
states->pixelShaderConstantsI = 0;
@@ -157,7 +160,6 @@
states->vertexShaderConstantsI = 0;
}
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 */
memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF));
@@ -815,7 +817,7 @@
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 *)pDevice)->stateBlock->changed.samplerState[stage] |= 1 << state;
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_SAMPLER(stage));
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 83f716f..a9abe07 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1759,18 +1759,18 @@
/* to resolve everything we need, so doing it manually for now */
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 */
+ 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];
- BOOL samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
- DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */
- WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */
- WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */
+ WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14*/
+ DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */
+ WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */
+ WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */
BOOL *pixelShaderConstantsF;
- WORD vertexShaderConstantsB; /* MAX_CONST_B, 16 */
- WORD vertexShaderConstantsI; /* MAX_CONST_I, 16 */
+ WORD vertexShaderConstantsB; /* MAX_CONST_B, 16 */
+ WORD vertexShaderConstantsI; /* MAX_CONST_I, 16 */
BOOL *vertexShaderConstantsF;
BYTE indices : 1;
BYTE material : 1;