d3d8: Add a separate function for pixel shader initialization.
This commit is contained in:
parent
7f1c802b9f
commit
717419da11
|
@ -603,17 +603,6 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
|
||||||
|
|
||||||
#define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256
|
#define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------ */
|
|
||||||
/* IDirect3DPixelShaderImpl */
|
|
||||||
/* ------------------------ */
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* Predeclare the interface implementation structures
|
|
||||||
*/
|
|
||||||
extern const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl DECLSPEC_HIDDEN;
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IDirect3DPixelShader implementation structure
|
* IDirect3DPixelShader implementation structure
|
||||||
*/
|
*/
|
||||||
|
@ -625,6 +614,9 @@ typedef struct IDirect3DPixelShader8Impl {
|
||||||
IWineD3DPixelShader *wineD3DPixelShader;
|
IWineD3DPixelShader *wineD3DPixelShader;
|
||||||
} IDirect3DPixelShader8Impl;
|
} IDirect3DPixelShader8Impl;
|
||||||
|
|
||||||
|
HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
|
||||||
|
const DWORD *byte_code, DWORD shader_handle) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internals functions
|
* Internals functions
|
||||||
*
|
*
|
||||||
|
|
|
@ -2094,15 +2094,20 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, I
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pFunction, DWORD* ppShader) {
|
|
||||||
|
static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *iface,
|
||||||
|
const DWORD *byte_code, DWORD *shader)
|
||||||
|
{
|
||||||
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
||||||
IDirect3DPixelShader8Impl *object;
|
IDirect3DPixelShader8Impl *object;
|
||||||
|
DWORD shader_handle;
|
||||||
DWORD handle;
|
DWORD handle;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
|
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
|
||||||
|
|
||||||
if (NULL == ppShader) {
|
if (!shader)
|
||||||
|
{
|
||||||
TRACE("(%p) Invalid call\n", This);
|
TRACE("(%p) Invalid call\n", This);
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
@ -2110,39 +2115,38 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 i
|
||||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||||
if (!object)
|
if (!object)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate memmory.\n");
|
ERR("Failed to allocate pixel shader memmory.\n");
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
object->ref = 1;
|
|
||||||
object->lpVtbl = &Direct3DPixelShader8_Vtbl;
|
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction,
|
handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_PS);
|
||||||
NULL, &object->wineD3DPixelShader, (IUnknown *)object);
|
wined3d_mutex_unlock();
|
||||||
|
if (handle == D3D8_INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
ERR("Failed to allocate pixel shader handle.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
shader_handle = handle + VS_HIGHESTFIXEDFXF + 1;
|
||||||
|
|
||||||
|
hr = pixelshader_init(object, This, byte_code, shader_handle);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
|
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
|
||||||
|
wined3d_mutex_lock();
|
||||||
|
d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_PS);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
HeapFree(GetProcessHeap(), 0 , object);
|
*shader = 0;
|
||||||
*ppShader = 0;
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_PS);
|
TRACE("Created pixel shader %p (handle %#x).\n", object, shader_handle);
|
||||||
wined3d_mutex_unlock();
|
*shader = shader_handle;
|
||||||
|
|
||||||
if (handle == D3D8_INVALID_HANDLE)
|
return D3D_OK;
|
||||||
{
|
|
||||||
ERR("Failed to allocate shader handle\n");
|
|
||||||
IDirect3DVertexShader8_Release((IUnknown *)object);
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ppShader = object->handle = handle + VS_HIGHESTFIXEDFXF + 1;
|
|
||||||
TRACE("(%p) : returning %p (handle %#x)\n", This, object, *ppShader);
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
|
||||||
|
|
|
@ -65,10 +65,32 @@ static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * if
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl =
|
static const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl =
|
||||||
{
|
{
|
||||||
/* IUnknown */
|
/* IUnknown */
|
||||||
IDirect3DPixelShader8Impl_QueryInterface,
|
IDirect3DPixelShader8Impl_QueryInterface,
|
||||||
IDirect3DPixelShader8Impl_AddRef,
|
IDirect3DPixelShader8Impl_AddRef,
|
||||||
IDirect3DPixelShader8Impl_Release,
|
IDirect3DPixelShader8Impl_Release,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
|
||||||
|
const DWORD *byte_code, DWORD shader_handle)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
shader->ref = 1;
|
||||||
|
shader->lpVtbl = &Direct3DPixelShader8_Vtbl;
|
||||||
|
shader->handle = shader_handle;
|
||||||
|
|
||||||
|
wined3d_mutex_lock();
|
||||||
|
hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code,
|
||||||
|
NULL, &shader->wineD3DPixelShader, (IUnknown *)shader);
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue