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

d3d9: Add a separate function for vertex shader initialization.

parent 0a72acc7
...@@ -206,8 +206,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9 ...@@ -206,8 +206,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9
IDirect3DVertexDeclaration9 *pDecl) DECLSPEC_HIDDEN; IDirect3DVertexDeclaration9 *pDecl) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface, extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface,
IDirect3DVertexDeclaration9 **ppDecl) DECLSPEC_HIDDEN; IDirect3DVertexDeclaration9 **ppDecl) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(IDirect3DDevice9Ex *iface,
const DWORD *pFunction, IDirect3DVertexShader9 **ppShader) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *iface, extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *iface,
IDirect3DVertexShader9 *pShader) DECLSPEC_HIDDEN; IDirect3DVertexShader9 *pShader) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *iface, extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *iface,
...@@ -528,6 +526,9 @@ typedef struct IDirect3DVertexShader9Impl { ...@@ -528,6 +526,9 @@ typedef struct IDirect3DVertexShader9Impl {
LPDIRECT3DDEVICE9EX parentDevice; LPDIRECT3DDEVICE9EX parentDevice;
} IDirect3DVertexShader9Impl; } IDirect3DVertexShader9Impl;
HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader,
IDirect3DDevice9Impl *device, const DWORD *byte_code) DECLSPEC_HIDDEN;
#define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256 #define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256
#define D3D9_MAX_SIMULTANEOUS_RENDERTARGETS 4 #define D3D9_MAX_SIMULTANEOUS_RENDERTARGETS 4
......
...@@ -1830,6 +1830,36 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface, DWO ...@@ -1830,6 +1830,36 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface, DWO
return hr; return hr;
} }
static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(IDirect3DDevice9Ex *iface,
const DWORD *byte_code, IDirect3DVertexShader9 **shader)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DVertexShader9Impl *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)
{
ERR("Failed to allocate vertex shader memory.\n");
return E_OUTOFMEMORY;
}
hr = vertexshader_init(object, This, byte_code);
if (FAILED(hr))
{
WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created vertex shader %p.\n", object);
*shader = (IDirect3DVertexShader9 *)object;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) { static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr; HRESULT hr;
......
...@@ -111,43 +111,27 @@ static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl = ...@@ -111,43 +111,27 @@ static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
IDirect3DVertexShader9Impl_GetFunction IDirect3DVertexShader9Impl_GetFunction
}; };
HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
{
HRESULT hr;
/* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */ shader->ref = 1;
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) { shader->lpVtbl = &Direct3DVertexShader9_Vtbl;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
IDirect3DVertexShader9Impl *object;
/* Setup a stub object for now */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->ref = 1;
object->lpVtbl = &Direct3DVertexShader9_Vtbl;
wined3d_mutex_lock(); wined3d_mutex_lock();
hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction, hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code,
NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object); NULL /* output signature */, &shader->wineD3DVertexShader, (IUnknown *)shader);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (FAILED(hr))
if (FAILED(hrc)) { {
WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
/* free up object */ return hr;
FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
HeapFree(GetProcessHeap(), 0, object);
}else{
IDirect3DDevice9Ex_AddRef(iface);
object->parentDevice = iface;
*ppShader = (IDirect3DVertexShader9 *)object;
TRACE("(%p) : Created vertex shader %p\n", This, object);
} }
TRACE("(%p) : returning %p\n", This, *ppShader); shader->parentDevice = (IDirect3DDevice9Ex *)device;
return hrc; IDirect3DDevice9Ex_AddRef(shader->parentDevice);
return D3D_OK;
} }
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader) { HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader) {
......
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