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