wined3d: Simplify IWineD3DStateBlockImpl_Capture().
Consistently use the stateblock's contained states to determine what to capture.
This commit is contained in:
parent
a24d14796a
commit
1f029a30db
|
@ -592,376 +592,280 @@ static void record_lights(IWineD3DStateBlockImpl *This, const IWineD3DStateBlock
|
|||
}
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
|
||||
|
||||
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)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) {
|
||||
if (This->changed.vertexShader && This->vertexShader != targetStateBlock->vertexShader)
|
||||
{
|
||||
TRACE("Updating vertex shader from %p to %p\n", This->vertexShader, targetStateBlock->vertexShader);
|
||||
|
||||
/* Recorded => Only update 'changed' values */
|
||||
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);
|
||||
if (This->vertexShader) IWineD3DVertexShader_Release(This->vertexShader);
|
||||
This->vertexShader = targetStateBlock->vertexShader;
|
||||
}
|
||||
|
||||
if(targetStateBlock->vertexShader) IWineD3DVertexShader_AddRef(targetStateBlock->vertexShader);
|
||||
if(This->vertexShader) IWineD3DVertexShader_Release(This->vertexShader);
|
||||
This->vertexShader = targetStateBlock->vertexShader;
|
||||
}
|
||||
/* Vertex Shader Float Constants */
|
||||
for (i = 0; i < This->num_contained_vs_consts_f; ++i)
|
||||
{
|
||||
unsigned int idx = This->contained_vs_consts_f[i];
|
||||
|
||||
/* 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]);
|
||||
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[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];
|
||||
}
|
||||
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]);
|
||||
/* Vertex Shader Integer Constants */
|
||||
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]);
|
||||
|
||||
/* 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");
|
||||
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];
|
||||
}
|
||||
|
||||
This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
|
||||
}
|
||||
/* Vertex Shader Boolean Constants */
|
||||
for (i = 0; i < This->num_contained_vs_consts_b; ++i)
|
||||
{
|
||||
unsigned int idx = This->contained_vs_consts_b[i];
|
||||
|
||||
/* 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]);
|
||||
TRACE("Setting %p from %p %u to %s.\n",
|
||||
This, targetStateBlock, idx,
|
||||
targetStateBlock->vertexShaderConstantB[idx] ? "TRUE" : "FALSE");
|
||||
|
||||
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];
|
||||
}
|
||||
This->vertexShaderConstantB[idx] = targetStateBlock->vertexShaderConstantB[idx];
|
||||
}
|
||||
|
||||
/* 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]);
|
||||
/* Pixel Shader Float Constants */
|
||||
for (i = 0; i < This->num_contained_ps_consts_f; ++i)
|
||||
{
|
||||
unsigned int idx = This->contained_ps_consts_f[i];
|
||||
|
||||
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];
|
||||
}
|
||||
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]);
|
||||
|
||||
/* 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");
|
||||
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];
|
||||
}
|
||||
|
||||
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
|
||||
}
|
||||
/* Pixel Shader Integer Constants */
|
||||
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]);
|
||||
|
||||
/* 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]];
|
||||
}
|
||||
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];
|
||||
}
|
||||
|
||||
if (This->changed.primitive_type) This->gl_primitive_type = targetStateBlock->gl_primitive_type;
|
||||
/* Pixel Shader Boolean Constants */
|
||||
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");
|
||||
|
||||
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",
|
||||
targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex);
|
||||
if(targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData);
|
||||
if(This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
|
||||
This->pIndexData = targetStateBlock->pIndexData;
|
||||
This->baseVertexIndex = targetStateBlock->baseVertexIndex;
|
||||
This->IndexFmt = targetStateBlock->IndexFmt;
|
||||
}
|
||||
This->pixelShaderConstantB[idx] = targetStateBlock->pixelShaderConstantB[idx];
|
||||
}
|
||||
|
||||
if (This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl
|
||||
&& ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion != 9)
|
||||
{
|
||||
TRACE("Updating vertex declaration from %p to %p\n", This->vertexDecl, targetStateBlock->vertexDecl);
|
||||
/* Others + Render & Texture */
|
||||
for (i = 0; i < This->num_contained_transform_states; ++i)
|
||||
{
|
||||
WINED3DTRANSFORMSTATETYPE transform = This->contained_transform_states[i];
|
||||
|
||||
if (targetStateBlock->vertexDecl) IWineD3DVertexDeclaration_AddRef(targetStateBlock->vertexDecl);
|
||||
if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
|
||||
This->vertexDecl = targetStateBlock->vertexDecl;
|
||||
}
|
||||
TRACE("Updating transform %#x.\n", transform);
|
||||
|
||||
if (This->changed.material && memcmp(&targetStateBlock->material,
|
||||
&This->material,
|
||||
sizeof(WINED3DMATERIAL)) != 0) {
|
||||
TRACE("Updating material\n");
|
||||
This->material = targetStateBlock->material;
|
||||
}
|
||||
This->transforms[transform] = targetStateBlock->transforms[transform];
|
||||
}
|
||||
|
||||
if (This->changed.viewport && memcmp(&targetStateBlock->viewport,
|
||||
&This->viewport,
|
||||
sizeof(WINED3DVIEWPORT)) != 0) {
|
||||
TRACE("Updating viewport\n");
|
||||
This->viewport = targetStateBlock->viewport;
|
||||
}
|
||||
if (This->changed.primitive_type) This->gl_primitive_type = targetStateBlock->gl_primitive_type;
|
||||
|
||||
if(This->changed.scissorRect && memcmp(&targetStateBlock->scissorRect,
|
||||
&This->scissorRect,
|
||||
sizeof(targetStateBlock->scissorRect)))
|
||||
{
|
||||
TRACE("Updating scissor rect\n");
|
||||
targetStateBlock->scissorRect = This->scissorRect;
|
||||
}
|
||||
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",
|
||||
targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex);
|
||||
|
||||
map = This->changed.streamSource;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
if (This->streamStride[i] != targetStateBlock->streamStride[i]
|
||||
|| This->streamSource[i] != targetStateBlock->streamSource[i])
|
||||
{
|
||||
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]);
|
||||
This->streamSource[i] = targetStateBlock->streamSource[i];
|
||||
}
|
||||
}
|
||||
|
||||
map = This->changed.streamFreq;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
if (This->streamFreq[i] != targetStateBlock->streamFreq[i]
|
||||
|| This->streamFlags[i] != targetStateBlock->streamFlags[i])
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
map = This->changed.clipplane;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
if (memcmp(targetStateBlock->clipplane[i], This->clipplane[i], sizeof(*This->clipplane)))
|
||||
{
|
||||
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]];
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
/* Samplers */
|
||||
map = This->changed.textures;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
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,
|
||||
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(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));
|
||||
if (targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData);
|
||||
if (This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
|
||||
This->pIndexData = targetStateBlock->pIndexData;
|
||||
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->IndexFmt = targetStateBlock->IndexFmt;
|
||||
}
|
||||
|
||||
if (This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl
|
||||
&& (This->blockType != WINED3DSBT_RECORDED
|
||||
|| ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion != 9))
|
||||
{
|
||||
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(This->material)))
|
||||
{
|
||||
TRACE("Updating material.\n");
|
||||
|
||||
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;
|
||||
}
|
||||
if (This->changed.viewport
|
||||
&& memcmp(&targetStateBlock->viewport, &This->viewport, sizeof(This->viewport)))
|
||||
{
|
||||
TRACE("Updating viewport.\n");
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
This->viewport = targetStateBlock->viewport;
|
||||
}
|
||||
|
||||
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)
|
||||
if(This->changed.scissorRect
|
||||
&& memcmp(&targetStateBlock->scissorRect, &This->scissorRect, sizeof(This->scissorRect)))
|
||||
{
|
||||
TRACE("Updating scissor rect.\n");
|
||||
|
||||
targetStateBlock->scissorRect = This->scissorRect;
|
||||
}
|
||||
|
||||
map = This->changed.streamSource;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
if (This->streamStride[i] != targetStateBlock->streamStride[i]
|
||||
|| This->streamSource[i] != targetStateBlock->streamSource[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("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]);
|
||||
This->streamSource[i] = targetStateBlock->streamSource[i];
|
||||
}
|
||||
}
|
||||
|
||||
map = This->changed.streamFreq;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
if (This->streamFreq[i] != targetStateBlock->streamFreq[i]
|
||||
|| This->streamFlags[i] != targetStateBlock->streamFlags[i])
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
map = This->changed.clipplane;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
if (memcmp(targetStateBlock->clipplane[i], This->clipplane[i], sizeof(*This->clipplane)))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 (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,
|
||||
targetStateBlock->textureState[stage][state], This->textureState[stage][state]);
|
||||
|
||||
This->textureState[stage][state] = targetStateBlock->textureState[stage][state];
|
||||
}
|
||||
|
||||
/* Samplers */
|
||||
map = This->changed.textures;
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
{
|
||||
if (!(map & 1)) continue;
|
||||
|
||||
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 (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 (targetStateBlock->pixelShader) IWineD3DPixelShader_AddRef(targetStateBlock->pixelShader);
|
||||
if (This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
|
||||
This->pixelShader = targetStateBlock->pixelShader;
|
||||
}
|
||||
|
||||
record_lights(This, targetStateBlock);
|
||||
|
||||
TRACE("(%p) : Updated state block %p ------------------^\n", targetStateBlock, This);
|
||||
|
||||
return WINED3D_OK;
|
||||
|
|
Loading…
Reference in New Issue