Commit dca3c6e7 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Keep vertex declaration references in the stateblock.

parent 709aedf5
......@@ -3328,6 +3328,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* if
TRACE("(%p) : pDecl=%p\n", This, pDecl);
if (pDecl) IWineD3DVertexDeclaration_AddRef(pDecl);
if (oldDecl) IWineD3DVertexDeclaration_Release(oldDecl);
This->updateStateBlock->vertexDecl = pDecl;
This->updateStateBlock->changed.vertexDecl = TRUE;
......
......@@ -279,6 +279,8 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
if (!refCount) {
int counter;
if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++)
{
if (This->textures[counter]) IWineD3DBaseTexture_Release(This->textures[counter]);
......@@ -511,6 +513,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
if(This->changed.vertexDecl && 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;
}
......@@ -624,7 +628,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
record_lights(This, targetStateBlock);
} else if(This->blockType == WINED3DSBT_ALL) {
This->vertexDecl = targetStateBlock->vertexDecl;
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);
......@@ -648,6 +651,13 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
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])
......
......@@ -69,7 +69,8 @@ static ULONG WINAPI IWineD3DVertexDeclarationImpl_Release(IWineD3DVertexDeclarat
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
if(iface == This->wineD3DDevice->stateBlock->vertexDecl) {
if (This->wineD3DDevice->stateBlock && iface == This->wineD3DDevice->stateBlock->vertexDecl)
{
/* See comment in PixelShader::Release */
IWineD3DDeviceImpl_MarkStateDirty(This->wineD3DDevice, STATE_VDECL);
}
......
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