wined3d: Optimize bool and int pixel shader constants.

This commit is contained in:
Stefan Dösinger 2007-08-03 20:12:54 +02:00 committed by Alexandre Julliard
parent 4673b1c68e
commit 865b82af2c
3 changed files with 58 additions and 30 deletions

View File

@ -482,6 +482,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->contained_vs_consts_b[j] = j; object->contained_vs_consts_b[j] = j;
} }
object->num_contained_vs_consts_b = MAX_CONST_B; 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) { } else if (Type == WINED3DSBT_PIXELSTATE) {
@ -493,10 +501,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
/* Pixel Shader Constants */ /* Pixel Shader Constants */
for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i) for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i)
object->changed.pixelShaderConstantsF[i] = TRUE; 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; 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->changed.pixelShaderConstantsI[i] = TRUE;
}
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; 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++; 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; *ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE; This->isRecordingState = FALSE;

View File

@ -457,8 +457,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
} }
/* Pixel Shader Integer Constants */ /* Pixel Shader Integer Constants */
for (i = 0; i < MAX_CONST_I; ++i) { for (j = 0; j < This->num_contained_ps_consts_i; ++j) {
if (This->changed.pixelShaderConstantsI[i]) { i = This->contained_ps_consts_i[j];
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i, TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantI[i * 4], targetStateBlock->pixelShaderConstantI[i * 4],
targetStateBlock->pixelShaderConstantI[i * 4 + 1], targetStateBlock->pixelShaderConstantI[i * 4 + 1],
@ -470,17 +470,15 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
This->pixelShaderConstantI[i * 4 + 2] = targetStateBlock->pixelShaderConstantI[i * 4 + 2]; This->pixelShaderConstantI[i * 4 + 2] = targetStateBlock->pixelShaderConstantI[i * 4 + 2];
This->pixelShaderConstantI[i * 4 + 3] = targetStateBlock->pixelShaderConstantI[i * 4 + 3]; This->pixelShaderConstantI[i * 4 + 3] = targetStateBlock->pixelShaderConstantI[i * 4 + 3];
} }
}
/* Pixel Shader Boolean Constants */ /* Pixel Shader Boolean Constants */
for (i = 0; i < MAX_CONST_B; ++i) { for (j = 0; j < This->num_contained_ps_consts_b; ++j) {
if (This->changed.pixelShaderConstantsB[i]) { i = This->contained_ps_consts_b[j];
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i, TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE"); targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE");
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i]; This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
} }
}
/* Others + Render & Texture */ /* Others + Render & Texture */
for (i = 0; i < This->num_contained_transform_states; i++) { for (i = 0; i < This->num_contained_transform_states; i++) {
@ -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); IWineD3DDevice_SetPixelShaderConstantF(pDevice, i, This->pixelShaderConstantF + i * 4, 1);
} }
for (i = 0; i < MAX_CONST_I; ++i) { for (i = 0; i < This->num_contained_ps_consts_i; i++) {
if (This->changed.pixelShaderConstantsI[i]) IWineD3DDevice_SetPixelShaderConstantI(pDevice, This->contained_ps_consts_i[i],
IWineD3DDevice_SetPixelShaderConstantI(pDevice, i, This->pixelShaderConstantI + i * 4, 1); This->pixelShaderConstantI + This->contained_ps_consts_i[i] * 4, 1);
} }
for (i = 0; i < MAX_CONST_B; ++i) { for (i = 0; i < This->num_contained_ps_consts_b; i++) {
if (This->changed.pixelShaderConstantsB[i]) IWineD3DDevice_SetPixelShaderConstantB(pDevice, This->contained_ps_consts_b[i],
IWineD3DDevice_SetPixelShaderConstantB(pDevice, i, This->pixelShaderConstantB + i, 1); This->pixelShaderConstantB + This->contained_ps_consts_b[i], 1);
} }
} }

View File

@ -1375,6 +1375,10 @@ struct IWineD3DStateBlockImpl
unsigned int num_contained_vs_consts_i; unsigned int num_contained_vs_consts_i;
DWORD contained_vs_consts_b[MAX_CONST_B]; DWORD contained_vs_consts_b[MAX_CONST_B];
unsigned int num_contained_vs_consts_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( extern void stateblock_savedstates_set(