2003-07-01 03:09:17 +02:00
|
|
|
/*
|
|
|
|
* IDirect3DVertexShader9 implementation
|
|
|
|
*
|
|
|
|
* Copyright 2002-2003 Jason Edmeades
|
|
|
|
* Raphael Junqueira
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-01 03:09:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "d3d9_private.h"
|
|
|
|
|
2005-08-18 13:45:17 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
|
2003-07-01 03:09:17 +02:00
|
|
|
|
|
|
|
/* IDirect3DVertexShader9 IUnknown parts follow: */
|
2006-06-10 11:51:05 +02:00
|
|
|
static HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
|
2003-07-01 03:09:17 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) {
|
2008-11-02 23:49:40 +01:00
|
|
|
IDirect3DVertexShader9_AddRef(iface);
|
2003-07-01 03:09:17 +02:00
|
|
|
*ppobj = This;
|
2006-06-07 15:13:29 +02:00
|
|
|
return S_OK;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
2006-06-07 15:13:29 +02:00
|
|
|
*ppobj = NULL;
|
2003-07-01 03:09:17 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:51:05 +02:00
|
|
|
static ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
|
2005-01-24 12:31:45 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-10 19:23:22 +02:00
|
|
|
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
|
|
|
return ref;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:51:05 +02:00
|
|
|
static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
|
2005-01-24 12:31:45 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-10 19:23:22 +02:00
|
|
|
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
2003-07-01 03:09:17 +02:00
|
|
|
|
|
|
|
if (ref == 0) {
|
2007-06-14 21:49:18 +02:00
|
|
|
EnterCriticalSection(&d3d9_cs);
|
2005-08-18 13:45:17 +02:00
|
|
|
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
|
2007-06-14 21:49:18 +02:00
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
2008-11-02 23:49:40 +01:00
|
|
|
IDirect3DDevice9Ex_Release(This->parentDevice);
|
2003-07-01 03:09:17 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDirect3DVertexShader9 Interface follow: */
|
2006-06-10 11:51:05 +02:00
|
|
|
static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
|
2005-08-18 13:45:17 +02:00
|
|
|
IWineD3DDevice *myDevice = NULL;
|
2008-10-03 13:55:51 +02:00
|
|
|
HRESULT hr;
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
|
|
|
|
2007-06-14 21:49:18 +02:00
|
|
|
EnterCriticalSection(&d3d9_cs);
|
2008-09-30 14:54:50 +02:00
|
|
|
hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
|
2008-10-03 13:55:51 +02:00
|
|
|
if (WINED3D_OK == hr && myDevice != NULL) {
|
2005-08-18 13:45:17 +02:00
|
|
|
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
|
|
|
|
IWineD3DDevice_Release(myDevice);
|
|
|
|
} else {
|
|
|
|
*ppDevice = NULL;
|
|
|
|
}
|
2007-06-14 21:49:18 +02:00
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
2006-10-13 02:19:42 +02:00
|
|
|
TRACE("(%p) returning (%p)\n", This, *ppDevice);
|
2005-08-18 13:45:17 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:51:05 +02:00
|
|
|
static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
|
2007-06-14 21:49:18 +02:00
|
|
|
HRESULT hr;
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&d3d9_cs);
|
|
|
|
hr = IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
|
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-10 11:51:05 +02:00
|
|
|
static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
|
2003-07-01 03:09:17 +02:00
|
|
|
{
|
2005-08-18 13:45:17 +02:00
|
|
|
/* IUnknown */
|
2003-07-01 03:09:17 +02:00
|
|
|
IDirect3DVertexShader9Impl_QueryInterface,
|
|
|
|
IDirect3DVertexShader9Impl_AddRef,
|
2005-08-23 11:34:57 +02:00
|
|
|
IDirect3DVertexShader9Impl_Release,
|
|
|
|
/* IDirect3DVertexShader9 */
|
2003-07-01 03:09:17 +02:00
|
|
|
IDirect3DVertexShader9Impl_GetDevice,
|
|
|
|
IDirect3DVertexShader9Impl_GetFunction
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2005-08-18 13:45:17 +02:00
|
|
|
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) {
|
2005-11-14 12:21:46 +01:00
|
|
|
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
|
2005-08-18 13:45:17 +02:00
|
|
|
return D3DERR_OUTOFVIDEOMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
object->ref = 1;
|
|
|
|
object->lpVtbl = &Direct3DVertexShader9_Vtbl;
|
2007-06-14 21:49:18 +02:00
|
|
|
EnterCriticalSection(&d3d9_cs);
|
2009-05-26 09:15:12 +02:00
|
|
|
hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, NULL /* declaration */, pFunction,
|
|
|
|
NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object);
|
2007-06-14 21:49:18 +02:00
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
2005-08-18 13:45:17 +02:00
|
|
|
|
|
|
|
if (FAILED(hrc)) {
|
2005-11-14 12:21:46 +01:00
|
|
|
|
2005-08-18 13:45:17 +02:00
|
|
|
/* free up object */
|
|
|
|
FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
}else{
|
2008-11-02 23:49:40 +01:00
|
|
|
IDirect3DDevice9Ex_AddRef(iface);
|
2006-04-12 06:09:27 +02:00
|
|
|
object->parentDevice = iface;
|
2005-08-18 13:45:17 +02:00
|
|
|
*ppShader = (IDirect3DVertexShader9 *)object;
|
2005-11-14 12:21:46 +01:00
|
|
|
TRACE("(%p) : Created vertex shader %p\n", This, object);
|
2005-08-18 13:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p) : returning %p\n", This, *ppShader);
|
|
|
|
return hrc;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2005-08-18 13:45:17 +02:00
|
|
|
HRESULT hrc = D3D_OK;
|
|
|
|
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
EnterCriticalSection(&d3d9_cs);
|
2005-08-18 13:45:17 +02:00
|
|
|
hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
|
2007-06-14 21:49:18 +02:00
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
2005-08-18 13:45:17 +02:00
|
|
|
|
2006-10-10 19:23:22 +02:00
|
|
|
TRACE("(%p) : returning hr(%u)\n", This, hrc);
|
2005-08-18 13:45:17 +02:00
|
|
|
return hrc;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9** ppShader) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2005-08-18 13:45:17 +02:00
|
|
|
IWineD3DVertexShader *pShader;
|
|
|
|
HRESULT hrc = D3D_OK;
|
|
|
|
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
|
2007-06-14 21:49:18 +02:00
|
|
|
EnterCriticalSection(&d3d9_cs);
|
2005-08-18 13:45:17 +02:00
|
|
|
hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
|
2008-12-29 16:31:22 +01:00
|
|
|
if (SUCCEEDED(hrc))
|
|
|
|
{
|
|
|
|
if (pShader)
|
|
|
|
{
|
|
|
|
hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
|
|
|
|
IWineD3DVertexShader_Release(pShader);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppShader = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-10 19:23:22 +02:00
|
|
|
WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
|
2005-08-18 13:45:17 +02:00
|
|
|
}
|
2007-06-14 21:49:18 +02:00
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : returning %p\n", This, *ppShader);
|
|
|
|
return hrc;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
|
2005-08-18 13:45:17 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2007-06-14 21:49:18 +02:00
|
|
|
HRESULT hr;
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
|
2009-04-25 15:02:42 +02:00
|
|
|
if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
|
|
|
|
WARN("Trying to access %u constants, but d3d9 only supports %u\n",
|
|
|
|
Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2007-06-14 21:49:18 +02:00
|
|
|
EnterCriticalSection(&d3d9_cs);
|
|
|
|
hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
|
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
|
2005-08-18 13:45:17 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2007-06-14 21:49:18 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2009-04-25 15:02:42 +02:00
|
|
|
if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
|
|
|
|
WARN("Trying to access %u constants, but d3d9 only supports %u\n",
|
|
|
|
Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
EnterCriticalSection(&d3d9_cs);
|
|
|
|
hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
|
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
|
2005-08-18 13:45:17 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2007-06-14 21:49:18 +02:00
|
|
|
HRESULT hr;
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&d3d9_cs);
|
|
|
|
hr = IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
|
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
|
2005-08-18 13:45:17 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2007-06-14 21:49:18 +02:00
|
|
|
HRESULT hr;
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&d3d9_cs);
|
|
|
|
hr = IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
|
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
|
2005-08-18 13:45:17 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2007-06-14 21:49:18 +02:00
|
|
|
HRESULT hr;
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&d3d9_cs);
|
|
|
|
hr = IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
|
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2008-02-28 21:25:35 +01:00
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2007-06-14 21:49:18 +02:00
|
|
|
HRESULT hr;
|
2005-08-18 13:45:17 +02:00
|
|
|
TRACE("(%p) : Relay\n", This);
|
2007-06-14 21:49:18 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&d3d9_cs);
|
|
|
|
hr = IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
|
|
|
|
LeaveCriticalSection(&d3d9_cs);
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|