d3d9: Add a separate function for pixel shader initialization.

This commit is contained in:
Henri Verbeet 2009-09-23 18:42:11 +02:00 committed by Alexandre Julliard
parent dde50a4748
commit 7f1c802b9f
3 changed files with 47 additions and 38 deletions

View File

@ -222,8 +222,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(IDirect3DDev
UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
UINT StartRegister, BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex *iface,
const DWORD *pFunction, IDirect3DPixelShader9 **ppShader) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *iface,
IDirect3DPixelShader9 *pShader) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *iface,
@ -551,6 +549,9 @@ typedef struct IDirect3DPixelShader9Impl {
LPDIRECT3DDEVICE9EX parentDevice;
} IDirect3DPixelShader9Impl;
HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader,
IDirect3DDevice9Impl *device, const DWORD *byte_code) DECLSPEC_HIDDEN;
/* --------------- */
/* IDirect3DQuery9 */
/* --------------- */

View File

@ -1967,6 +1967,36 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX ifac
return rc;
}
static HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex *iface,
const DWORD *byte_code, IDirect3DPixelShader9 **shader)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DPixelShader9Impl *object;
HRESULT hr;
TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
FIXME("Failed to allocate pixel shader memory.\n");
return E_OUTOFMEMORY;
}
hr = pixelshader_init(object, This, byte_code);
if (FAILED(hr))
{
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created pixel shader %p.\n", object);
*shader = (IDirect3DPixelShader9 *)object;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;

View File

@ -107,49 +107,27 @@ static const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl =
IDirect3DPixelShader9Impl_GetFunction
};
HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
{
HRESULT hr;
/* IDirect3DDevice9 IDirect3DPixelShader9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DPixelShader9Impl *object;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
if (ppShader == NULL) {
TRACE("(%p) Invalid call\n", This);
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return E_OUTOFMEMORY;
}
object->ref = 1;
object->lpVtbl = &Direct3DPixelShader9_Vtbl;
shader->ref = 1;
shader->lpVtbl = &Direct3DPixelShader9_Vtbl;
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, NULL,
&object->wineD3DPixelShader, (IUnknown *)object);
hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code,
NULL, &shader->wineD3DPixelShader, (IUnknown *)shader);
wined3d_mutex_unlock();
if (hrc != D3D_OK)
if (FAILED(hr))
{
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
HeapFree(GetProcessHeap(), 0 , object);
} else {
IDirect3DDevice9Ex_AddRef(iface);
object->parentDevice = iface;
*ppShader = (IDirect3DPixelShader9*) object;
TRACE("(%p) : Created pixel shader %p\n", This, object);
WARN("Failed to created wined3d pixel shader, hr %#x.\n", hr);
return hr;
}
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
shader->parentDevice = (IDirect3DDevice9Ex *)device;
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader) {