d3d9: Add a separate function for vertex shader initialization.
This commit is contained in:
parent
0a72acc7f4
commit
cdb741274a
|
@ -206,8 +206,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9
|
|||
IDirect3DVertexDeclaration9 *pDecl) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface,
|
||||
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,
|
||||
IDirect3DVertexShader9 *pShader) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *iface,
|
||||
|
@ -528,6 +526,9 @@ typedef struct IDirect3DVertexShader9Impl {
|
|||
LPDIRECT3DDEVICE9EX parentDevice;
|
||||
} IDirect3DVertexShader9Impl;
|
||||
|
||||
HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader,
|
||||
IDirect3DDevice9Impl *device, const DWORD *byte_code) DECLSPEC_HIDDEN;
|
||||
|
||||
#define D3D9_MAX_VERTEX_SHADER_CONSTANTF 256
|
||||
#define D3D9_MAX_SIMULTANEOUS_RENDERTARGETS 4
|
||||
|
||||
|
|
|
@ -1830,6 +1830,36 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface, DWO
|
|||
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) {
|
||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||
HRESULT hr;
|
||||
|
|
|
@ -111,43 +111,27 @@ static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
|
|||
IDirect3DVertexShader9Impl_GetFunction
|
||||
};
|
||||
|
||||
HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
/* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
|
||||
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;
|
||||
shader->ref = 1;
|
||||
shader->lpVtbl = &Direct3DVertexShader9_Vtbl;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction,
|
||||
NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object);
|
||||
hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code,
|
||||
NULL /* output signature */, &shader->wineD3DVertexShader, (IUnknown *)shader);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
if (FAILED(hrc)) {
|
||||
|
||||
/* free up object */
|
||||
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);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create wined3d vertex 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_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader) {
|
||||
|
|
Loading…
Reference in New Issue