SHADERDECL(int) ShaderSetPixelShader(void *pShaderContext, void *pShaderObj) { IWineD3DDeviceImpl *This; IWineD3DPixelShader* pShader; IWineD3DPixelShader* oldShader; SHADER_SET_CURRENT_CONTEXT(pShaderContext); This = g_pCurrentContext->pDeviceContext; pShader = (IWineD3DPixelShader* )pShaderObj; oldShader = This->updateStateBlock->pixelShader; if(oldShader == pShader) { /* Checked here to allow proper stateblock recording */ Log(("App is setting the old shader over, nothing to do\n")); return VINF_SUCCESS; } This->updateStateBlock->pixelShader = pShader; This->updateStateBlock->changed.pixelShader = TRUE; Log(("(%p) : setting pShader(%p)\n", This, pShader)); if(pShader) IWineD3DPixelShader_AddRef(pShader); if(oldShader) IWineD3DPixelShader_Release(oldShader); g_pCurrentContext->fChangedPixelShader = true; g_pCurrentContext->fChangedPixelShaderConstant = true; /* force constant reload. */ return VINF_SUCCESS; }
HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IWineD3DPixelShader *object; HRESULT hrc; TRACE("iface %p, shader %p.\n", iface, ppShader); if (ppShader == NULL) { TRACE("(%p) Invalid call\n", This); return D3DERR_INVALIDCALL; } wined3d_mutex_lock(); hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object); if (SUCCEEDED(hrc)) { if (object) { hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader); IWineD3DPixelShader_Release(object); } else { *ppShader = NULL; } } else { WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice); } wined3d_mutex_unlock(); TRACE("(%p) : returning %p\n", This, *ppShader); return hrc; }
static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * iface) { IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", iface, ref); if (ref == 0) { wined3d_mutex_lock(); IWineD3DPixelShader_Release(This->wineD3DPixelShader); wined3d_mutex_unlock(); } return ref; }
static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_Release(ID3D10PixelShader *iface) { struct d3d10_pixel_shader *This = (struct d3d10_pixel_shader *)iface; ULONG refcount = InterlockedDecrement(&This->refcount); TRACE("%p decreasing refcount to %u\n", This, refcount); if (!refcount) { IWineD3DPixelShader_Release(This->wined3d_shader); } return refcount; }
static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) { IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", iface, ref); if (ref == 0) { IDirect3DDevice9Ex *parentDevice = This->parentDevice; wined3d_mutex_lock(); IWineD3DPixelShader_Release(This->wineD3DPixelShader); wined3d_mutex_unlock(); /* Release the device last, as it may cause the device to be destroyed. */ IDirect3DDevice9Ex_Release(parentDevice); } return ref; }