Commit 4673b1c6 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Optimize bool and int vs constants.

parent 274f77d4
......@@ -474,6 +474,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->contained_transform_states[j - 1] = j;
}
object->num_contained_transform_states = HIGHEST_TRANSFORMSTATE;
for(j = 0; j < MAX_CONST_I; j++) {
object->contained_vs_consts_i[j] = j;
}
object->num_contained_vs_consts_i = MAX_CONST_I;
for(j = 0; j < MAX_CONST_B; j++) {
object->contained_vs_consts_b[j] = j;
}
object->num_contained_vs_consts_b = MAX_CONST_B;
} else if (Type == WINED3DSBT_PIXELSTATE) {
......@@ -517,11 +525,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
/* Vertex Shader Constants */
for (i = 0; i < GL_LIMITS(vshader_constantsF); ++i)
object->changed.vertexShaderConstantsF[i] = TRUE;
for (i = 0; i < MAX_CONST_B; ++i)
for (i = 0; i < MAX_CONST_B; ++i) {
object->changed.vertexShaderConstantsB[i] = TRUE;
for (i = 0; i < MAX_CONST_I; ++i)
object->contained_vs_consts_b[i] = i;
}
object->num_contained_vs_consts_b = MAX_CONST_B;
for (i = 0; i < MAX_CONST_I; ++i) {
object->changed.vertexShaderConstantsI[i] = TRUE;
object->contained_vs_consts_i[i] = i;
}
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];
......@@ -4334,6 +4347,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
object->num_contained_transform_states++;
}
}
for(i = 0; i < MAX_CONST_I; i++) {
if(object->changed.vertexShaderConstantsI[i]) {
object->contained_vs_consts_i[object->num_contained_vs_consts_i] = i;
object->num_contained_vs_consts_i++;
}
}
for(i = 0; i < MAX_CONST_B; i++) {
if(object->changed.vertexShaderConstantsB[i]) {
object->contained_vs_consts_b[object->num_contained_vs_consts_b] = i;
object->num_contained_vs_consts_b++;
}
}
*ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE;
......
......@@ -363,29 +363,27 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
}
/* Vertex Shader Integer Constants */
for (i = 0; i < MAX_CONST_I; ++i) {
if (This->changed.vertexShaderConstantsI[i]) {
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantI[i * 4],
targetStateBlock->vertexShaderConstantI[i * 4 + 1],
targetStateBlock->vertexShaderConstantI[i * 4 + 2],
targetStateBlock->vertexShaderConstantI[i * 4 + 3]);
This->vertexShaderConstantI[i * 4] = targetStateBlock->vertexShaderConstantI[i * 4];
This->vertexShaderConstantI[i * 4 + 1] = targetStateBlock->vertexShaderConstantI[i * 4 + 1];
This->vertexShaderConstantI[i * 4 + 2] = targetStateBlock->vertexShaderConstantI[i * 4 + 2];
This->vertexShaderConstantI[i * 4 + 3] = targetStateBlock->vertexShaderConstantI[i * 4 + 3];
}
for (j = 0; j < This->num_contained_vs_consts_i; ++j) {
i = This->contained_vs_consts_i[j];
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantI[i * 4],
targetStateBlock->vertexShaderConstantI[i * 4 + 1],
targetStateBlock->vertexShaderConstantI[i * 4 + 2],
targetStateBlock->vertexShaderConstantI[i * 4 + 3]);
This->vertexShaderConstantI[i * 4] = targetStateBlock->vertexShaderConstantI[i * 4];
This->vertexShaderConstantI[i * 4 + 1] = targetStateBlock->vertexShaderConstantI[i * 4 + 1];
This->vertexShaderConstantI[i * 4 + 2] = targetStateBlock->vertexShaderConstantI[i * 4 + 2];
This->vertexShaderConstantI[i * 4 + 3] = targetStateBlock->vertexShaderConstantI[i * 4 + 3];
}
/* Vertex Shader Boolean Constants */
for (i = 0; i < MAX_CONST_B; ++i) {
if (This->changed.vertexShaderConstantsB[i]) {
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantB[i]? "TRUE":"FALSE");
for (j = 0; j < This->num_contained_vs_consts_b; ++j) {
i = This->contained_vs_consts_b[j];
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantB[i]? "TRUE":"FALSE");
This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
}
This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
}
/* Lights... For a recorded state block, we just had a chain of actions to perform,
......@@ -647,15 +645,15 @@ should really perform a delta so that only the changes get updated*/
if (This->changed.vertexShaderConstantsF[i])
IWineD3DDevice_SetVertexShaderConstantF(pDevice, i, This->vertexShaderConstantF + i * 4, 1);
}
for (i = 0; i < MAX_CONST_I; i++) {
if (This->changed.vertexShaderConstantsI[i])
IWineD3DDevice_SetVertexShaderConstantI(pDevice, i, This->vertexShaderConstantI + i * 4, 1);
for (i = 0; i < This->num_contained_vs_consts_i; i++) {
IWineD3DDevice_SetVertexShaderConstantI(pDevice, This->contained_vs_consts_i[i],
This->vertexShaderConstantI + This->contained_vs_consts_i[i] * 4, 1);
}
for (i = 0; i < MAX_CONST_B; i++) {
if (This->changed.vertexShaderConstantsB[i])
IWineD3DDevice_SetVertexShaderConstantB(pDevice, i, This->vertexShaderConstantB + i, 1);
for (i = 0; i < This->num_contained_vs_consts_b; i++) {
IWineD3DDevice_SetVertexShaderConstantB(pDevice, This->contained_vs_consts_b[i],
This->vertexShaderConstantB + This->contained_vs_consts_b[i], 1);
}
}
......
......@@ -1371,6 +1371,10 @@ struct IWineD3DStateBlockImpl
unsigned int num_contained_render_states;
DWORD contained_transform_states[WINEHIGHEST_RENDER_STATE + 1];
unsigned int num_contained_transform_states;
DWORD contained_vs_consts_i[MAX_CONST_I];
unsigned int num_contained_vs_consts_i;
DWORD contained_vs_consts_b[MAX_CONST_B];
unsigned int num_contained_vs_consts_b;
};
extern void stateblock_savedstates_set(
......
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