Commit 865b82af authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Optimize bool and int pixel shader constants.

parent 4673b1c6
......@@ -482,6 +482,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->contained_vs_consts_b[j] = j;
}
object->num_contained_vs_consts_b = MAX_CONST_B;
for(j = 0; j < MAX_CONST_I; j++) {
object->contained_ps_consts_i[j] = j;
}
object->num_contained_ps_consts_i = MAX_CONST_I;
for(j = 0; j < MAX_CONST_B; j++) {
object->contained_ps_consts_b[j] = j;
}
object->num_contained_ps_consts_b = MAX_CONST_B;
} else if (Type == WINED3DSBT_PIXELSTATE) {
......@@ -493,10 +501,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
/* Pixel Shader Constants */
for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i)
object->changed.pixelShaderConstantsF[i] = TRUE;
for (i = 0; i < MAX_CONST_B; ++i)
for (i = 0; i < MAX_CONST_B; ++i) {
object->contained_ps_consts_b[i] = i;
object->changed.pixelShaderConstantsB[i] = TRUE;
for (i = 0; i < MAX_CONST_I; ++i)
}
object->num_contained_ps_consts_b = MAX_CONST_B;
for (i = 0; i < MAX_CONST_I; ++i) {
object->contained_ps_consts_i[i] = i;
object->changed.pixelShaderConstantsI[i] = TRUE;
}
object->num_contained_ps_consts_i = MAX_CONST_I;
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
object->changed.renderState[SavedPixelStates_R[i]] = TRUE;
......@@ -4359,6 +4373,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
object->num_contained_vs_consts_b++;
}
}
for(i = 0; i < MAX_CONST_I; i++) {
if(object->changed.pixelShaderConstantsI[i]) {
object->contained_ps_consts_i[object->num_contained_ps_consts_i] = i;
object->num_contained_ps_consts_i++;
}
}
for(i = 0; i < MAX_CONST_B; i++) {
if(object->changed.pixelShaderConstantsB[i]) {
object->contained_ps_consts_b[object->num_contained_ps_consts_b] = i;
object->num_contained_ps_consts_b++;
}
}
*ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE;
......
......@@ -455,31 +455,29 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
This->pixelShaderConstantF[i * 4 + 3] = targetStateBlock->pixelShaderConstantF[i * 4 + 3];
}
}
/* Pixel Shader Integer Constants */
for (i = 0; i < MAX_CONST_I; ++i) {
if (This->changed.pixelShaderConstantsI[i]) {
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantI[i * 4],
targetStateBlock->pixelShaderConstantI[i * 4 + 1],
targetStateBlock->pixelShaderConstantI[i * 4 + 2],
targetStateBlock->pixelShaderConstantI[i * 4 + 3]);
This->pixelShaderConstantI[i * 4] = targetStateBlock->pixelShaderConstantI[i * 4];
This->pixelShaderConstantI[i * 4 + 1] = targetStateBlock->pixelShaderConstantI[i * 4 + 1];
This->pixelShaderConstantI[i * 4 + 2] = targetStateBlock->pixelShaderConstantI[i * 4 + 2];
This->pixelShaderConstantI[i * 4 + 3] = targetStateBlock->pixelShaderConstantI[i * 4 + 3];
}
for (j = 0; j < This->num_contained_ps_consts_i; ++j) {
i = This->contained_ps_consts_i[j];
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantI[i * 4],
targetStateBlock->pixelShaderConstantI[i * 4 + 1],
targetStateBlock->pixelShaderConstantI[i * 4 + 2],
targetStateBlock->pixelShaderConstantI[i * 4 + 3]);
This->pixelShaderConstantI[i * 4] = targetStateBlock->pixelShaderConstantI[i * 4];
This->pixelShaderConstantI[i * 4 + 1] = targetStateBlock->pixelShaderConstantI[i * 4 + 1];
This->pixelShaderConstantI[i * 4 + 2] = targetStateBlock->pixelShaderConstantI[i * 4 + 2];
This->pixelShaderConstantI[i * 4 + 3] = targetStateBlock->pixelShaderConstantI[i * 4 + 3];
}
/* Pixel Shader Boolean Constants */
for (i = 0; i < MAX_CONST_B; ++i) {
if (This->changed.pixelShaderConstantsB[i]) {
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE");
for (j = 0; j < This->num_contained_ps_consts_b; ++j) {
i = This->contained_ps_consts_b[j];
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE");
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
}
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
}
/* Others + Render & Texture */
......@@ -670,14 +668,14 @@ should really perform a delta so that only the changes get updated*/
IWineD3DDevice_SetPixelShaderConstantF(pDevice, i, This->pixelShaderConstantF + i * 4, 1);
}
for (i = 0; i < MAX_CONST_I; ++i) {
if (This->changed.pixelShaderConstantsI[i])
IWineD3DDevice_SetPixelShaderConstantI(pDevice, i, This->pixelShaderConstantI + i * 4, 1);
for (i = 0; i < This->num_contained_ps_consts_i; i++) {
IWineD3DDevice_SetPixelShaderConstantI(pDevice, This->contained_ps_consts_i[i],
This->pixelShaderConstantI + This->contained_ps_consts_i[i] * 4, 1);
}
for (i = 0; i < MAX_CONST_B; ++i) {
if (This->changed.pixelShaderConstantsB[i])
IWineD3DDevice_SetPixelShaderConstantB(pDevice, i, This->pixelShaderConstantB + i, 1);
for (i = 0; i < This->num_contained_ps_consts_b; i++) {
IWineD3DDevice_SetPixelShaderConstantB(pDevice, This->contained_ps_consts_b[i],
This->pixelShaderConstantB + This->contained_ps_consts_b[i], 1);
}
}
......
......@@ -1375,6 +1375,10 @@ struct IWineD3DStateBlockImpl
unsigned int num_contained_vs_consts_i;
DWORD contained_vs_consts_b[MAX_CONST_B];
unsigned int num_contained_vs_consts_b;
DWORD contained_ps_consts_i[MAX_CONST_I];
unsigned int num_contained_ps_consts_i;
DWORD contained_ps_consts_b[MAX_CONST_B];
unsigned int num_contained_ps_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