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

wined3d: Convert renderState to a bitmap in struct SAVEDSTATES.

parent fc39831e
......@@ -470,8 +470,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->num_contained_ps_consts_i = MAX_CONST_I;
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
object->changed.renderState[SavedPixelStates_R[i]] = TRUE;
object->contained_render_states[i] = SavedPixelStates_R[i];
DWORD rs = SavedPixelStates_R[i];
object->changed.renderState[rs >> 5] |= 1 << (rs & 0x1f);
object->contained_render_states[i] = rs;
}
object->num_contained_render_states = NUM_SAVEDPIXELSTATES_R;
for (j = 0; j < MAX_TEXTURES; j++) {
......@@ -527,8 +528,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
}
object->num_contained_vs_consts_i = MAX_CONST_I;
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
object->changed.renderState[SavedVertexStates_R[i]] = TRUE;
object->contained_render_states[i] = SavedVertexStates_R[i];
DWORD rs = SavedVertexStates_R[i];
object->changed.renderState[rs >> 5] |= 1 << (rs & 0x1f);
object->contained_render_states[i] = rs;
}
object->num_contained_render_states = NUM_SAVEDVERTEXSTATES_R;
for (j = 0; j < MAX_TEXTURES; j++) {
......@@ -3262,7 +3264,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, W
TRACE("(%p)->state = %s(%d), value = %d\n", This, debug_d3drenderstate(State), State, Value);
This->updateStateBlock->changed.renderState[State] = TRUE;
This->updateStateBlock->changed.renderState[State >> 5] |= 1 << (State & 0x1f);
This->updateStateBlock->renderState[State] = Value;
/* Handle recording of state blocks */
......@@ -4746,10 +4748,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
return WINED3DERR_INVALIDCALL;
}
for(i = 1; i <= WINEHIGHEST_RENDER_STATE; i++) {
if(object->changed.renderState[i]) {
object->contained_render_states[object->num_contained_render_states] = i;
object->num_contained_render_states++;
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
{
DWORD map = object->changed.renderState[i];
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
object->contained_render_states[object->num_contained_render_states++] = (i << 5) | j;
}
}
......
......@@ -90,7 +90,7 @@ static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *
dest->streamFreq = source->streamFreq;
dest->textures = source->textures;
memcpy(dest->transform, source->transform, sizeof(source->transform));
memcpy(dest->renderState, source->renderState, bsize * (WINEHIGHEST_RENDER_STATE + 1));
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));
dest->clipplane = source->clipplane;
......@@ -130,19 +130,34 @@ void stateblock_savedstates_set(
states->scissorRect = value;
/* Fixed size arrays */
states->streamSource = value ? 0xffff : 0;
states->streamFreq = value ? 0xffff : 0;
states->textures = value ? 0xfffff : 0;
if (value) stateblock_set_bits(states->transform, HIGHEST_TRANSFORMSTATE + 1);
else memset(states->transform, 0, sizeof(states->transform));
memset(states->renderState, value, bsize * (WINEHIGHEST_RENDER_STATE + 1));
if (value)
{
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);
states->clipplane = 0xffffffff;
states->pixelShaderConstantsB = 0xffff;
states->pixelShaderConstantsI = 0xffff;
states->vertexShaderConstantsB = 0xffff;
states->vertexShaderConstantsI = 0xffff;
}
else
{
states->streamSource = 0;
states->streamFreq = 0;
states->textures = 0;
memset(states->transform, 0, sizeof(states->transform));
memset(states->renderState, 0, sizeof(states->renderState));
states->clipplane = 0;
states->pixelShaderConstantsB = 0;
states->pixelShaderConstantsI = 0;
states->vertexShaderConstantsB = 0;
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));
states->clipplane = value ? 0xffffffff : 0;
states->pixelShaderConstantsB = value ? 0xffff : 0;
states->pixelShaderConstantsI = value ? 0xffff : 0;
states->vertexShaderConstantsB = value ? 0xffff : 0;
states->vertexShaderConstantsI = value ? 0xffff : 0;
/* Dynamically sized arrays */
memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF));
......
......@@ -1762,7 +1762,7 @@ typedef struct SAVEDSTATES {
WORD streamSource; /* MAX_STREAMS, 16 */
WORD streamFreq; /* MAX_STREAMS, 16 */
DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */
BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
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 */
......
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