d3d8: Cleanup the vertexshader handling code a bit.
This commit is contained in:
parent
4131135a9f
commit
c0cefb3501
|
@ -1879,75 +1879,78 @@ static IDirect3DVertexDeclaration8Impl *IDirect3DDevice8Impl_FindDecl(IDirect3DD
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
||||||
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
||||||
HRESULT hrc = D3D_OK;
|
IDirect3DVertexShader8Impl *shader;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p) : Relay\n", This);
|
TRACE("(%p) : Relay\n", This);
|
||||||
EnterCriticalSection(&d3d8_cs);
|
|
||||||
if (VS_HIGHESTFIXEDFXF >= pShader) {
|
if (VS_HIGHESTFIXEDFXF >= pShader) {
|
||||||
TRACE("Setting FVF, %#x\n", pShader);
|
TRACE("Setting FVF, %#x\n", pShader);
|
||||||
|
|
||||||
|
EnterCriticalSection(&d3d8_cs);
|
||||||
IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
|
IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
|
||||||
IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration);
|
IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration);
|
||||||
IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
|
IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
|
||||||
} else {
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
IDirect3DVertexShader8Impl *shader;
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
TRACE("Setting shader\n");
|
TRACE("Setting shader\n");
|
||||||
|
|
||||||
|
EnterCriticalSection(&d3d8_cs);
|
||||||
shader = d3d8_get_object(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1));
|
shader = d3d8_get_object(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1));
|
||||||
if (!shader)
|
if (!shader)
|
||||||
{
|
{
|
||||||
WARN("Invalid handle (%#x) passed.\n", pShader);
|
WARN("Invalid handle (%#x) passed.\n", pShader);
|
||||||
hrc = D3DERR_INVALIDCALL;
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
|
||||||
hrc = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
|
|
||||||
((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration);
|
((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration);
|
||||||
if (SUCCEEDED(hrc))
|
if (SUCCEEDED(hr)) hr = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, shader->wineD3DVertexShader);
|
||||||
hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, shader->wineD3DVertexShader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TRACE("(%p) : returning hr(%u)\n", This, hrc);
|
|
||||||
LeaveCriticalSection(&d3d8_cs);
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
|
|
||||||
return hrc;
|
TRACE("Returning hr %#x\n", hr);
|
||||||
|
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
|
static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
|
||||||
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
||||||
IWineD3DVertexDeclaration *wined3d_declaration;
|
IWineD3DVertexDeclaration *wined3d_declaration;
|
||||||
|
IDirect3DVertexDeclaration8 *d3d8_declaration;
|
||||||
HRESULT hrc;
|
HRESULT hrc;
|
||||||
|
|
||||||
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
|
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
|
||||||
EnterCriticalSection(&d3d8_cs);
|
EnterCriticalSection(&d3d8_cs);
|
||||||
|
|
||||||
hrc = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
|
hrc = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
|
||||||
if (SUCCEEDED(hrc))
|
if (FAILED(hrc))
|
||||||
{
|
{
|
||||||
if (wined3d_declaration)
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
|
WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
|
||||||
|
This, hrc, This->WineD3DDevice);
|
||||||
|
return hrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wined3d_declaration)
|
||||||
{
|
{
|
||||||
IDirect3DVertexDeclaration8 *d3d8_declaration;
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
|
*ppShader = 0;
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
hrc = IWineD3DVertexDeclaration_GetParent(wined3d_declaration, (IUnknown **)&d3d8_declaration);
|
hrc = IWineD3DVertexDeclaration_GetParent(wined3d_declaration, (IUnknown **)&d3d8_declaration);
|
||||||
IWineD3DVertexDeclaration_Release(wined3d_declaration);
|
IWineD3DVertexDeclaration_Release(wined3d_declaration);
|
||||||
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
if (SUCCEEDED(hrc))
|
if (SUCCEEDED(hrc))
|
||||||
{
|
{
|
||||||
*ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
|
*ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
|
||||||
IDirect3DVertexDeclaration8_Release(d3d8_declaration);
|
IDirect3DVertexDeclaration8_Release(d3d8_declaration);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*ppShader = 0;
|
|
||||||
hrc = D3D_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
|
|
||||||
This, hrc, This->WineD3DDevice);
|
|
||||||
}
|
|
||||||
TRACE("(%p) : returning %#x\n", This, *ppShader);
|
TRACE("(%p) : returning %#x\n", This, *ppShader);
|
||||||
LeaveCriticalSection(&d3d8_cs);
|
|
||||||
|
|
||||||
return hrc;
|
return hrc;
|
||||||
}
|
}
|
||||||
|
@ -1955,6 +1958,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 ifa
|
||||||
static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
||||||
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
||||||
IDirect3DVertexShader8Impl *shader;
|
IDirect3DVertexShader8Impl *shader;
|
||||||
|
IWineD3DVertexShader *cur = NULL;
|
||||||
|
|
||||||
TRACE("(%p) : pShader %#x\n", This, pShader);
|
TRACE("(%p) : pShader %#x\n", This, pShader);
|
||||||
|
|
||||||
|
@ -1966,21 +1970,22 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE
|
||||||
WARN("Invalid handle (%#x) passed.\n", pShader);
|
WARN("Invalid handle (%#x) passed.\n", pShader);
|
||||||
LeaveCriticalSection(&d3d8_cs);
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
} else {
|
}
|
||||||
IWineD3DVertexShader *cur = NULL;
|
|
||||||
|
|
||||||
IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &cur);
|
IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &cur);
|
||||||
if(cur) {
|
|
||||||
if(cur == shader->wineD3DVertexShader) IDirect3DDevice8_SetVertexShader(iface, 0);
|
if (cur)
|
||||||
|
{
|
||||||
|
if (cur == shader->wineD3DVertexShader) IDirect3DDevice8_SetVertexShader(iface, 0);
|
||||||
IWineD3DVertexShader_Release(cur);
|
IWineD3DVertexShader_Release(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
|
|
||||||
if (IUnknown_Release((IUnknown *)shader))
|
if (IUnknown_Release((IUnknown *)shader))
|
||||||
{
|
{
|
||||||
ERR("Shader %p has references left, this shouldn't happen.\n", shader);
|
ERR("Shader %p has references left, this shouldn't happen.\n", shader);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
LeaveCriticalSection(&d3d8_cs);
|
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
@ -2060,16 +2065,15 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEV
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shader->wineD3DVertexShader)
|
if (!shader->wineD3DVertexShader)
|
||||||
{
|
|
||||||
hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
*pSizeOfData = 0;
|
*pSizeOfData = 0;
|
||||||
hr = D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData);
|
||||||
|
|
||||||
LeaveCriticalSection(&d3d8_cs);
|
LeaveCriticalSection(&d3d8_cs);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue