wined3d: Simplify IWineD3DStateBlockImpl_Capture().

Consistently use the stateblock's contained states to determine what to
capture.
This commit is contained in:
Henri Verbeet 2009-10-14 10:55:18 +02:00 committed by Alexandre Julliard
parent a24d14796a
commit 1f029a30db
1 changed files with 237 additions and 333 deletions

View File

@ -592,20 +592,17 @@ static void record_lights(IWineD3DStateBlockImpl *This, const IWineD3DStateBlock
}
}
static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
{
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
IWineD3DStateBlockImpl *targetStateBlock = This->wineD3DDevice->stateBlock;
unsigned int i, j;
unsigned int i;
DWORD map;
TRACE("(%p) : Updating state block %p ------------------v\n", targetStateBlock, This);
/* If not recorded, then update can just recapture */
if (This->blockType == WINED3DSBT_RECORDED) {
/* Recorded => Only update 'changed' values */
if (This->changed.vertexShader && This->vertexShader != targetStateBlock->vertexShader) {
if (This->changed.vertexShader && This->vertexShader != targetStateBlock->vertexShader)
{
TRACE("Updating vertex shader from %p to %p\n", This->vertexShader, targetStateBlock->vertexShader);
if (targetStateBlock->vertexShader) IWineD3DVertexShader_AddRef(targetStateBlock->vertexShader);
@ -614,97 +611,118 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
}
/* Vertex Shader Float Constants */
for (j = 0; j < This->num_contained_vs_consts_f; ++j) {
i = This->contained_vs_consts_f[j];
TRACE("Setting %p from %p %u to {%f, %f, %f, %f}\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantF[i * 4],
targetStateBlock->vertexShaderConstantF[i * 4 + 1],
targetStateBlock->vertexShaderConstantF[i * 4 + 2],
targetStateBlock->vertexShaderConstantF[i * 4 + 3]);
for (i = 0; i < This->num_contained_vs_consts_f; ++i)
{
unsigned int idx = This->contained_vs_consts_f[i];
This->vertexShaderConstantF[i * 4] = targetStateBlock->vertexShaderConstantF[i * 4];
This->vertexShaderConstantF[i * 4 + 1] = targetStateBlock->vertexShaderConstantF[i * 4 + 1];
This->vertexShaderConstantF[i * 4 + 2] = targetStateBlock->vertexShaderConstantF[i * 4 + 2];
This->vertexShaderConstantF[i * 4 + 3] = targetStateBlock->vertexShaderConstantF[i * 4 + 3];
TRACE("Setting %p from %p %u to {%.8e, %.8e, %.8e, %.8e}.\n",
This, targetStateBlock, idx,
targetStateBlock->vertexShaderConstantF[idx * 4 + 0],
targetStateBlock->vertexShaderConstantF[idx * 4 + 1],
targetStateBlock->vertexShaderConstantF[idx * 4 + 2],
targetStateBlock->vertexShaderConstantF[idx * 4 + 3]);
This->vertexShaderConstantF[idx * 4 + 0] = targetStateBlock->vertexShaderConstantF[idx * 4 + 0];
This->vertexShaderConstantF[idx * 4 + 1] = targetStateBlock->vertexShaderConstantF[idx * 4 + 1];
This->vertexShaderConstantF[idx * 4 + 2] = targetStateBlock->vertexShaderConstantF[idx * 4 + 2];
This->vertexShaderConstantF[idx * 4 + 3] = targetStateBlock->vertexShaderConstantF[idx * 4 + 3];
}
/* Vertex Shader Integer Constants */
for (j = 0; j < This->num_contained_vs_consts_i; ++j) {
i = This->contained_vs_consts_i[j];
TRACE("Setting %p from %p %u 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]);
for (i = 0; i < This->num_contained_vs_consts_i; ++i)
{
unsigned int idx = This->contained_vs_consts_i[i];
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];
TRACE("Setting %p from %p %u to {%d, %d, %d, %d}.\n",
This, targetStateBlock, idx,
targetStateBlock->vertexShaderConstantI[idx * 4 + 0],
targetStateBlock->vertexShaderConstantI[idx * 4 + 1],
targetStateBlock->vertexShaderConstantI[idx * 4 + 2],
targetStateBlock->vertexShaderConstantI[idx * 4 + 3]);
This->vertexShaderConstantI[idx * 4 + 0] = targetStateBlock->vertexShaderConstantI[idx * 4 + 0];
This->vertexShaderConstantI[idx * 4 + 1] = targetStateBlock->vertexShaderConstantI[idx * 4 + 1];
This->vertexShaderConstantI[idx * 4 + 2] = targetStateBlock->vertexShaderConstantI[idx * 4 + 2];
This->vertexShaderConstantI[idx * 4 + 3] = targetStateBlock->vertexShaderConstantI[idx * 4 + 3];
}
/* Vertex Shader Boolean Constants */
for (j = 0; j < This->num_contained_vs_consts_b; ++j) {
i = This->contained_vs_consts_b[j];
TRACE("Setting %p from %p %u to %s\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantB[i] ? "TRUE" : "FALSE");
for (i = 0; i < This->num_contained_vs_consts_b; ++i)
{
unsigned int idx = This->contained_vs_consts_b[i];
This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
TRACE("Setting %p from %p %u to %s.\n",
This, targetStateBlock, idx,
targetStateBlock->vertexShaderConstantB[idx] ? "TRUE" : "FALSE");
This->vertexShaderConstantB[idx] = targetStateBlock->vertexShaderConstantB[idx];
}
/* Pixel Shader Float Constants */
for (j = 0; j < This->num_contained_ps_consts_f; ++j) {
i = This->contained_ps_consts_f[j];
TRACE("Setting %p from %p %u to {%f, %f, %f, %f}\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantF[i * 4],
targetStateBlock->pixelShaderConstantF[i * 4 + 1],
targetStateBlock->pixelShaderConstantF[i * 4 + 2],
targetStateBlock->pixelShaderConstantF[i * 4 + 3]);
for (i = 0; i < This->num_contained_ps_consts_f; ++i)
{
unsigned int idx = This->contained_ps_consts_f[i];
This->pixelShaderConstantF[i * 4] = targetStateBlock->pixelShaderConstantF[i * 4];
This->pixelShaderConstantF[i * 4 + 1] = targetStateBlock->pixelShaderConstantF[i * 4 + 1];
This->pixelShaderConstantF[i * 4 + 2] = targetStateBlock->pixelShaderConstantF[i * 4 + 2];
This->pixelShaderConstantF[i * 4 + 3] = targetStateBlock->pixelShaderConstantF[i * 4 + 3];
TRACE("Setting %p from %p %u to {%.8e, %.8e, %.8e, %.8e}.\n",
This, targetStateBlock, idx,
targetStateBlock->pixelShaderConstantF[idx * 4 + 0],
targetStateBlock->pixelShaderConstantF[idx * 4 + 1],
targetStateBlock->pixelShaderConstantF[idx * 4 + 2],
targetStateBlock->pixelShaderConstantF[idx * 4 + 3]);
This->pixelShaderConstantF[idx * 4 + 0] = targetStateBlock->pixelShaderConstantF[idx * 4 + 0];
This->pixelShaderConstantF[idx * 4 + 1] = targetStateBlock->pixelShaderConstantF[idx * 4 + 1];
This->pixelShaderConstantF[idx * 4 + 2] = targetStateBlock->pixelShaderConstantF[idx * 4 + 2];
This->pixelShaderConstantF[idx * 4 + 3] = targetStateBlock->pixelShaderConstantF[idx * 4 + 3];
}
/* Pixel Shader Integer Constants */
for (j = 0; j < This->num_contained_ps_consts_i; ++j) {
i = This->contained_ps_consts_i[j];
TRACE("Setting %p from %p %u 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]);
for (i = 0; i < This->num_contained_ps_consts_i; ++i)
{
unsigned int idx = This->contained_ps_consts_i[i];
TRACE("Setting %p from %p %u to {%d, %d, %d, %d}.\n",
This, targetStateBlock, idx,
targetStateBlock->pixelShaderConstantI[idx * 4 + 0],
targetStateBlock->pixelShaderConstantI[idx * 4 + 1],
targetStateBlock->pixelShaderConstantI[idx * 4 + 2],
targetStateBlock->pixelShaderConstantI[idx * 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];
This->pixelShaderConstantI[idx * 4 + 0] = targetStateBlock->pixelShaderConstantI[idx * 4 + 0];
This->pixelShaderConstantI[idx * 4 + 1] = targetStateBlock->pixelShaderConstantI[idx * 4 + 1];
This->pixelShaderConstantI[idx * 4 + 2] = targetStateBlock->pixelShaderConstantI[idx * 4 + 2];
This->pixelShaderConstantI[idx * 4 + 3] = targetStateBlock->pixelShaderConstantI[idx * 4 + 3];
}
/* Pixel Shader Boolean Constants */
for (j = 0; j < This->num_contained_ps_consts_b; ++j) {
i = This->contained_ps_consts_b[j];
TRACE("Setting %p from %p %u to %s\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantB[i] ? "TRUE" : "FALSE");
for (i = 0; i < This->num_contained_ps_consts_b; ++i)
{
unsigned int idx = This->contained_ps_consts_b[i];
TRACE("Setting %p from %p %u to %s.\n", This, targetStateBlock, idx,
targetStateBlock->pixelShaderConstantB[idx] ? "TRUE" : "FALSE");
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
This->pixelShaderConstantB[idx] = targetStateBlock->pixelShaderConstantB[idx];
}
/* Others + Render & Texture */
for (i = 0; i < This->num_contained_transform_states; i++) {
TRACE("Updating transform %u\n", i);
This->transforms[This->contained_transform_states[i]] =
targetStateBlock->transforms[This->contained_transform_states[i]];
for (i = 0; i < This->num_contained_transform_states; ++i)
{
WINED3DTRANSFORMSTATETYPE transform = This->contained_transform_states[i];
TRACE("Updating transform %#x.\n", transform);
This->transforms[transform] = targetStateBlock->transforms[transform];
}
if (This->changed.primitive_type) This->gl_primitive_type = targetStateBlock->gl_primitive_type;
if (This->changed.indices && ((This->pIndexData != targetStateBlock->pIndexData)
if (This->changed.indices
&& ((This->pIndexData != targetStateBlock->pIndexData)
|| (This->baseVertexIndex != targetStateBlock->baseVertexIndex)
|| (This->IndexFmt != targetStateBlock->IndexFmt))) {
TRACE("Updating pIndexData to %p, baseVertexIndex to %d\n",
|| (This->IndexFmt != targetStateBlock->IndexFmt)))
{
TRACE("Updating pIndexData to %p, baseVertexIndex to %d.\n",
targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex);
if (targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData);
if (This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
This->pIndexData = targetStateBlock->pIndexData;
@ -713,34 +731,37 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
}
if (This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl
&& ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion != 9)
&& (This->blockType != WINED3DSBT_RECORDED
|| ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion != 9))
{
TRACE("Updating vertex declaration from %p to %p\n", This->vertexDecl, targetStateBlock->vertexDecl);
TRACE("Updating vertex declaration from %p to %p.\n", This->vertexDecl, targetStateBlock->vertexDecl);
if (targetStateBlock->vertexDecl) IWineD3DVertexDeclaration_AddRef(targetStateBlock->vertexDecl);
if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
This->vertexDecl = targetStateBlock->vertexDecl;
}
if (This->changed.material && memcmp(&targetStateBlock->material,
&This->material,
sizeof(WINED3DMATERIAL)) != 0) {
TRACE("Updating material\n");
if (This->changed.material
&& memcmp(&targetStateBlock->material, &This->material, sizeof(This->material)))
{
TRACE("Updating material.\n");
This->material = targetStateBlock->material;
}
if (This->changed.viewport && memcmp(&targetStateBlock->viewport,
&This->viewport,
sizeof(WINED3DVIEWPORT)) != 0) {
TRACE("Updating viewport\n");
if (This->changed.viewport
&& memcmp(&targetStateBlock->viewport, &This->viewport, sizeof(This->viewport)))
{
TRACE("Updating viewport.\n");
This->viewport = targetStateBlock->viewport;
}
if(This->changed.scissorRect && memcmp(&targetStateBlock->scissorRect,
&This->scissorRect,
sizeof(targetStateBlock->scissorRect)))
if(This->changed.scissorRect
&& memcmp(&targetStateBlock->scissorRect, &This->scissorRect, sizeof(This->scissorRect)))
{
TRACE("Updating scissor rect\n");
TRACE("Updating scissor rect.\n");
targetStateBlock->scissorRect = This->scissorRect;
}
@ -752,8 +773,9 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
if (This->streamStride[i] != targetStateBlock->streamStride[i]
|| This->streamSource[i] != targetStateBlock->streamSource[i])
{
TRACE("Updating stream source %u to %p, stride to %u\n",
TRACE("Updating stream source %u to %p, stride to %u.\n",
i, targetStateBlock->streamSource[i], targetStateBlock->streamStride[i]);
This->streamStride[i] = targetStateBlock->streamStride[i];
if (targetStateBlock->streamSource[i]) IWineD3DBuffer_AddRef(targetStateBlock->streamSource[i]);
if (This->streamSource[i]) IWineD3DBuffer_Release(This->streamSource[i]);
@ -769,8 +791,9 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
if (This->streamFreq[i] != targetStateBlock->streamFreq[i]
|| This->streamFlags[i] != targetStateBlock->streamFlags[i])
{
TRACE("Updating stream frequency %u to %u flags to %#x\n",
TRACE("Updating stream frequency %u to %u flags to %#x.\n",
i, targetStateBlock->streamFreq[i], targetStateBlock->streamFlags[i]);
This->streamFreq[i] = targetStateBlock->streamFreq[i];
This->streamFlags[i] = targetStateBlock->streamFlags[i];
}
@ -783,25 +806,30 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
if (memcmp(targetStateBlock->clipplane[i], This->clipplane[i], sizeof(*This->clipplane)))
{
TRACE("Updating clipplane %u\n", i);
TRACE("Updating clipplane %u.\n", i);
memcpy(This->clipplane[i], targetStateBlock->clipplane[i], sizeof(*This->clipplane));
}
}
/* Render */
for (i = 0; i < This->num_contained_render_states; i++) {
TRACE("Updating renderState %u to %u\n", This->contained_render_states[i],
targetStateBlock->renderState[This->contained_render_states[i]]);
This->renderState[This->contained_render_states[i]] = targetStateBlock->renderState[This->contained_render_states[i]];
for (i = 0; i < This->num_contained_render_states; ++i)
{
WINED3DRENDERSTATETYPE rs = This->contained_render_states[i];
TRACE("Updating renderState %#x to %u.\n", rs, targetStateBlock->renderState[rs]);
This->renderState[rs] = targetStateBlock->renderState[rs];
}
/* Texture states */
for (j = 0; j < This->num_contained_tss_states; j++) {
DWORD stage = This->contained_tss_states[j].stage;
DWORD state = This->contained_tss_states[j].state;
for (i = 0; i < This->num_contained_tss_states; ++i)
{
DWORD stage = This->contained_tss_states[i].stage;
DWORD state = This->contained_tss_states[i].state;
TRACE("Updating texturestage state %u, %u to %u (was %u)\n", stage, state,
TRACE("Updating texturestage state %u, %u to %u (was %u).\n", stage, state,
targetStateBlock->textureState[stage][state], This->textureState[stage][state]);
This->textureState[stage][state] = targetStateBlock->textureState[stage][state];
}
@ -811,156 +839,32 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
{
if (!(map & 1)) continue;
TRACE("Updating texture %u to %p (was %p)\n", i, targetStateBlock->textures[i], This->textures[i]);
TRACE("Updating texture %u to %p (was %p).\n", i, targetStateBlock->textures[i], This->textures[i]);
if (targetStateBlock->textures[i]) IWineD3DBaseTexture_AddRef(targetStateBlock->textures[i]);
if (This->textures[i]) IWineD3DBaseTexture_Release(This->textures[i]);
This->textures[i] = targetStateBlock->textures[i];
}
for (j = 0; j < This->num_contained_sampler_states; j++) {
DWORD stage = This->contained_sampler_states[j].stage;
DWORD state = This->contained_sampler_states[j].state;
TRACE("Updating sampler state %u, %u to %u (was %u)\n", stage, state,
for (i = 0; i < This->num_contained_sampler_states; ++i)
{
DWORD stage = This->contained_sampler_states[i].stage;
DWORD state = This->contained_sampler_states[i].state;
TRACE("Updating sampler state %u, %u to %u (was %u).\n", stage, state,
targetStateBlock->samplerState[stage][state], This->samplerState[stage][state]);
This->samplerState[stage][state] = targetStateBlock->samplerState[stage][state];
}
if(This->changed.pixelShader && This->pixelShader != targetStateBlock->pixelShader) {
if (This->changed.pixelShader && This->pixelShader != targetStateBlock->pixelShader)
{
if (targetStateBlock->pixelShader) IWineD3DPixelShader_AddRef(targetStateBlock->pixelShader);
if (This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
This->pixelShader = targetStateBlock->pixelShader;
}
record_lights(This, targetStateBlock);
} else if(This->blockType == WINED3DSBT_ALL) {
memcpy(This->vertexShaderConstantB, targetStateBlock->vertexShaderConstantB, sizeof(This->vertexShaderConstantI));
memcpy(This->vertexShaderConstantI, targetStateBlock->vertexShaderConstantI, sizeof(This->vertexShaderConstantF));
memcpy(This->vertexShaderConstantF, targetStateBlock->vertexShaderConstantF, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4);
This->gl_primitive_type = targetStateBlock->gl_primitive_type;
memcpy(This->streamStride, targetStateBlock->streamStride, sizeof(This->streamStride));
memcpy(This->streamOffset, targetStateBlock->streamOffset, sizeof(This->streamOffset));
memcpy(This->streamFreq, targetStateBlock->streamFreq, sizeof(This->streamFreq));
memcpy(This->streamFlags, targetStateBlock->streamFlags, sizeof(This->streamFlags));
This->baseVertexIndex = targetStateBlock->baseVertexIndex;
memcpy(This->transforms, targetStateBlock->transforms, sizeof(This->transforms));
record_lights(This, targetStateBlock);
memcpy(This->clipplane, targetStateBlock->clipplane, sizeof(This->clipplane));
This->clip_status = targetStateBlock->clip_status;
This->viewport = targetStateBlock->viewport;
This->material = targetStateBlock->material;
memcpy(This->pixelShaderConstantB, targetStateBlock->pixelShaderConstantB, sizeof(This->pixelShaderConstantI));
memcpy(This->pixelShaderConstantI, targetStateBlock->pixelShaderConstantI, sizeof(This->pixelShaderConstantF));
memcpy(This->pixelShaderConstantF, targetStateBlock->pixelShaderConstantF, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4);
memcpy(This->renderState, targetStateBlock->renderState, sizeof(This->renderState));
memcpy(This->textureState, targetStateBlock->textureState, sizeof(This->textureState));
memcpy(This->samplerState, targetStateBlock->samplerState, sizeof(This->samplerState));
This->scissorRect = targetStateBlock->scissorRect;
if (This->vertexDecl != targetStateBlock->vertexDecl)
{
if (targetStateBlock->vertexDecl) IWineD3DVertexDeclaration_AddRef(targetStateBlock->vertexDecl);
if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
This->vertexDecl = targetStateBlock->vertexDecl;
}
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
if (targetStateBlock->textures[i] != This->textures[i])
{
if (targetStateBlock->textures[i]) IWineD3DBaseTexture_AddRef(targetStateBlock->textures[i]);
if (This->textures[i]) IWineD3DBaseTexture_Release(This->textures[i]);
This->textures[i] = targetStateBlock->textures[i];
}
}
if(targetStateBlock->pIndexData != This->pIndexData ||
targetStateBlock->IndexFmt != This->IndexFmt) {
if (targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData);
if (This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
This->pIndexData = targetStateBlock->pIndexData;
This->IndexFmt = targetStateBlock->IndexFmt;
}
for(i = 0; i < MAX_STREAMS; i++) {
if(targetStateBlock->streamSource[i] != This->streamSource[i]) {
if(targetStateBlock->streamSource[i]) IWineD3DBuffer_AddRef(targetStateBlock->streamSource[i]);
if(This->streamSource[i]) IWineD3DBuffer_Release(This->streamSource[i]);
This->streamSource[i] = targetStateBlock->streamSource[i];
}
}
if(This->vertexShader != targetStateBlock->vertexShader) {
if(targetStateBlock->vertexShader) IWineD3DVertexShader_AddRef(targetStateBlock->vertexShader);
if(This->vertexShader) IWineD3DVertexShader_Release(This->vertexShader);
This->vertexShader = targetStateBlock->vertexShader;
}
if(This->pixelShader != targetStateBlock->pixelShader) {
if(targetStateBlock->pixelShader) IWineD3DPixelShader_AddRef(targetStateBlock->pixelShader);
if(This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
This->pixelShader = targetStateBlock->pixelShader;
}
} else if(This->blockType == WINED3DSBT_VERTEXSTATE) {
memcpy(This->vertexShaderConstantB, targetStateBlock->vertexShaderConstantB, sizeof(This->vertexShaderConstantI));
memcpy(This->vertexShaderConstantI, targetStateBlock->vertexShaderConstantI, sizeof(This->vertexShaderConstantF));
memcpy(This->vertexShaderConstantF, targetStateBlock->vertexShaderConstantF, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4);
record_lights(This, targetStateBlock);
for (i = 0; i < sizeof(vertex_states_render) / sizeof(*vertex_states_render); ++i)
{
This->renderState[vertex_states_render[i]] = targetStateBlock->renderState[vertex_states_render[i]];
}
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) {
for (i = 0; i < sizeof(vertex_states_sampler) / sizeof(*vertex_states_sampler); ++i)
{
This->samplerState[j][vertex_states_sampler[i]] = targetStateBlock->samplerState[j][vertex_states_sampler[i]];
}
}
for (j = 0; j < MAX_TEXTURES; j++) {
for (i = 0; i < sizeof(vertex_states_render) / sizeof(*vertex_states_render); ++i)
{
This->textureState[j][vertex_states_render[i]] = targetStateBlock->textureState[j][vertex_states_render[i]];
}
}
for(i = 0; i < MAX_STREAMS; i++) {
if(targetStateBlock->streamSource[i] != This->streamSource[i]) {
if (targetStateBlock->streamSource[i]) IWineD3DBuffer_AddRef(targetStateBlock->streamSource[i]);
if (This->streamSource[i]) IWineD3DBuffer_Release(This->streamSource[i]);
This->streamSource[i] = targetStateBlock->streamSource[i];
}
}
if (This->vertexDecl != targetStateBlock->vertexDecl)
{
if (targetStateBlock->vertexDecl) IWineD3DVertexDeclaration_AddRef(targetStateBlock->vertexDecl);
if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
This->vertexDecl = targetStateBlock->vertexDecl;
}
if(This->vertexShader != targetStateBlock->vertexShader) {
if(targetStateBlock->vertexShader) IWineD3DVertexShader_AddRef(targetStateBlock->vertexShader);
if(This->vertexShader) IWineD3DVertexShader_Release(This->vertexShader);
This->vertexShader = targetStateBlock->vertexShader;
}
} else if(This->blockType == WINED3DSBT_PIXELSTATE) {
memcpy(This->pixelShaderConstantB, targetStateBlock->pixelShaderConstantB, sizeof(This->pixelShaderConstantI));
memcpy(This->pixelShaderConstantI, targetStateBlock->pixelShaderConstantI, sizeof(This->pixelShaderConstantF));
memcpy(This->pixelShaderConstantF, targetStateBlock->pixelShaderConstantF, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4);
for (i = 0; i < sizeof(pixel_states_render) / sizeof(*pixel_states_render); ++i)
{
This->renderState[pixel_states_render[i]] = targetStateBlock->renderState[pixel_states_render[i]];
}
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) {
for (i = 0; i < sizeof(pixel_states_sampler) / sizeof(*pixel_states_sampler); ++i)
{
This->samplerState[j][pixel_states_sampler[i]] = targetStateBlock->samplerState[j][pixel_states_sampler[i]];
}
}
for (j = 0; j < MAX_TEXTURES; j++) {
for (i = 0; i < sizeof(pixel_states_render) / sizeof(*pixel_states_render); ++i)
{
This->textureState[j][pixel_states_render[i]] = targetStateBlock->textureState[j][pixel_states_render[i]];
}
}
if(This->pixelShader != targetStateBlock->pixelShader) {
if(targetStateBlock->pixelShader) IWineD3DPixelShader_AddRef(targetStateBlock->pixelShader);
if(This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
This->pixelShader = targetStateBlock->pixelShader;
}
}
TRACE("(%p) : Updated state block %p ------------------^\n", targetStateBlock, This);