- update wined3d, d3d8, d3d9, ddraw to Wine 1.1.28

svn path=/trunk/; revision=42983
This commit is contained in:
Kamil Hornicek 2009-09-03 09:18:38 +00:00
parent 0b70fb9114
commit 509c6dadc2
77 changed files with 14607 additions and 9630 deletions

View file

@ -57,9 +57,11 @@ static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 ifa
if (ref == 0) {
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D8CB_DestroySurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -73,14 +75,15 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -89,9 +92,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -100,9 +104,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -111,9 +116,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -122,9 +128,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -133,9 +140,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -143,9 +151,9 @@ static void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 ifac
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface) {
@ -153,9 +161,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETE
D3DRESOURCETYPE type;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
type = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return type;
}
@ -165,9 +174,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 ifac
DWORD lod;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
lod = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return lod;
}
@ -176,9 +186,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 ifac
DWORD lod;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
lod = IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return lod;
}
@ -187,9 +198,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTUR
DWORD cnt;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
cnt = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return cnt;
}
@ -201,22 +213,21 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTU
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = NULL; /* DirectX9 only */
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->Size = wined3ddesc.size;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
}
return hr;
}
@ -228,13 +239,14 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBE
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -243,9 +255,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -254,9 +267,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -265,9 +279,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -24,15 +24,6 @@
#include "d3d8_private.h"
#include "wine/debug.h"
static CRITICAL_SECTION_DEBUG d3d8_cs_debug =
{
0, 0, &d3d8_cs,
{ &d3d8_cs_debug.ProcessLocksList,
&d3d8_cs_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": d3d8_cs") }
};
CRITICAL_SECTION d3d8_cs = { &d3d8_cs_debug, -1, 0, 0, 0, 0 };
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
HRESULT WINAPI D3D8GetSWInfo(void) {
@ -48,7 +39,8 @@ IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) {
IDirect3D8Impl* object;
TRACE("SDKVersion = %x\n", SDKVersion);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl));
object->lpVtbl = &Direct3D8_Vtbl;
@ -56,7 +48,8 @@ IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) {
object->WineD3D = WineDirect3DCreate(8, (IUnknown *)object);
TRACE("Created Direct3D object @ %p, WineObj @ %p\n", object, object->WineD3D);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (!object->WineD3D)
{
@ -77,14 +70,14 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
}
/***********************************************************************
* ValidateVertexShader (D3D8.@)
* ValidateVertexShader (D3D8.@)
*
* I've seen reserved1 and reserved2 always passed as 0's
* bool seems always passed as 0 or 1, but other values work as well....
* bool seems always passed as 0 or 1, but other values work as well...
* toto result?
*/
HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, BOOL bool, DWORD* toto)
{
{
HRESULT ret;
FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto);
@ -96,7 +89,7 @@ HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD
switch(*vertexshader) {
case 0xFFFE0101:
case 0xFFFE0100:
case 0xFFFE0100:
ret=S_OK;
break;
default:
@ -108,7 +101,7 @@ HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD
}
/***********************************************************************
* ValidatePixelShader (D3D8.@)
* ValidatePixelShader (D3D8.@)
*
* PARAMS
* toto result?
@ -117,12 +110,12 @@ HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL bo
{
HRESULT ret;
FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto);
if (!pixelshader)
return E_FAIL;
if (reserved1)
return E_FAIL;
return E_FAIL;
switch(*pixelshader) {
case 0xFFFF0100:

View file

@ -97,6 +97,8 @@
_pD3D8Caps->PixelShaderVersion = _pWineCaps->PixelShaderVersion; \
_pD3D8Caps->MaxPixelShaderValue = _pWineCaps->PixelShader1xMaxValue;
void fixup_caps(WINED3DCAPS *pWineCaps);
/* Direct3D8 Interfaces: */
typedef struct IDirect3DBaseTexture8Impl IDirect3DBaseTexture8Impl;
typedef struct IDirect3DVolumeTexture8Impl IDirect3DVolumeTexture8Impl;
@ -120,9 +122,6 @@ typedef struct IDirect3DVertexShaderDeclarationImpl IDirect3DVertexShaderDeclara
/* Advance declaration of structures to satisfy compiler */
typedef struct IDirect3DVertexShader8Impl IDirect3DVertexShader8Impl;
/* Global critical section */
extern CRITICAL_SECTION d3d8_cs;
/* ===========================================================================
The interfaces themselves
=========================================================================== */
@ -166,10 +165,24 @@ extern const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl;
#define D3D8_INITIAL_HANDLE_TABLE_SIZE 64
#define D3D8_INVALID_HANDLE ~0U
enum d3d8_handle_type
{
D3D8_HANDLE_FREE,
D3D8_HANDLE_VS,
D3D8_HANDLE_PS,
D3D8_HANDLE_SB,
};
struct d3d8_handle_entry
{
void *object;
enum d3d8_handle_type type;
};
struct d3d8_handle_table
{
void **entries;
void **free_entries;
struct d3d8_handle_entry *entries;
struct d3d8_handle_entry *free_entries;
UINT table_size;
UINT entry_count;
};
@ -455,7 +468,7 @@ struct IDirect3DVolumeTexture8Impl
/* TODO: Generate a valid GUIDs */
/* {83B073CE-6F30-11d9-C687-00046142C14F} */
DEFINE_GUID(IID_IDirect3DStateBlock8,
DEFINE_GUID(IID_IDirect3DStateBlock8,
0x83b073ce, 0x6f30, 0x11d9, 0xc6, 0x87, 0x0, 0x4, 0x61, 0x42, 0xc1, 0x4f);
DEFINE_GUID(IID_IDirect3DVertexDeclaration8,

File diff suppressed because it is too large Load diff

View file

@ -71,9 +71,11 @@ static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
if (ref == 0) {
TRACE("Releasing wined3d %p\n", This->WineD3D);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3D_Release(This->WineD3D);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
@ -86,9 +88,10 @@ static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface,
HRESULT hr;
TRACE("(%p)->(%p)\n", This, pInitializeFunction);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -97,36 +100,41 @@ static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
HRESULT hr;
TRACE("(%p)\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterCount(This->WineD3D);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface,
UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) {
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface,
UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8 *pIdentifier)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;
TRACE("(%p)->(%d,%08x, %p\n", This, Adapter, Flags, pIdentifier);
EnterCriticalSection(&d3d8_cs);
/* dx8 and dx9 have different structures to be filled in, with incompatible
layouts so pass in pointers to the places to be filled via an internal
structure */
adapter_id.Driver = pIdentifier->Driver;
adapter_id.Description = pIdentifier->Description;
adapter_id.DeviceName = NULL; /* d3d9 only */
adapter_id.DriverVersion = &pIdentifier->DriverVersion;
adapter_id.VendorId = &pIdentifier->VendorId;
adapter_id.DeviceId = &pIdentifier->DeviceId;
adapter_id.SubSysId = &pIdentifier->SubSysId;
adapter_id.Revision = &pIdentifier->Revision;
adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
adapter_id.driver = pIdentifier->Driver;
adapter_id.driver_size = sizeof(pIdentifier->Driver);
adapter_id.description = pIdentifier->Description;
adapter_id.description_size = sizeof(pIdentifier->Description);
adapter_id.device_name = NULL; /* d3d9 only */
adapter_id.device_name_size = 0; /* d3d9 only */
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
pIdentifier->DriverVersion = adapter_id.driver_version;
pIdentifier->VendorId = adapter_id.vendor_id;
pIdentifier->DeviceId = adapter_id.device_id;
pIdentifier->SubSysId = adapter_id.subsystem_id;
pIdentifier->Revision = adapter_id.revision;
memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
pIdentifier->WHQLLevel = adapter_id.whql_level;
return hr;
}
@ -135,9 +143,10 @@ static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Ad
HRESULT hr;
TRACE("(%p)->(%d)\n", This, Adapter);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -146,9 +155,9 @@ static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT A
HRESULT hr;
TRACE("(%p)->(%d, %d, %p)\n", This, Adapter, Mode, pMode);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -160,9 +169,9 @@ static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, U
HRESULT hr;
TRACE("(%p)->(%d,%p)\n", This, Adapter, pMode);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -176,10 +185,11 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 i
HRESULT hr;
TRACE("(%p)->(%d, %d, %d, %d, %s)\n", This, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed ? "true" : "false");
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -191,6 +201,14 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 i
WINED3DRESOURCETYPE WineD3DRType;
TRACE("(%p)->(%d, %d, %d, %08x, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
if(CheckFormat == D3DFMT_R8G8B8)
{
/* See comment in dlls/d3d9/directx.c, IDirect3D9Impl_CheckDeviceFormat for details */
WARN("D3DFMT_R8G8B8 is not available on windows, returning D3DERR_NOTAVAILABLE\n");
return D3DERR_NOTAVAILABLE;
}
switch(RType) {
case D3DRTYPE_VERTEXBUFFER:
case D3DRTYPE_INDEXBUFFER:
@ -202,42 +220,59 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 i
break;
}
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) {
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
HRESULT hr;
TRACE("(%p)-<(%d, %d, %d, %s, %d)\n", This, Adapter, DeviceType, SurfaceFormat, Windowed ? "true" : "false", MultiSampleType);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
HRESULT hr;
TRACE("(%p)-<(%d, %d, %d, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
wined3dformat_from_d3dformat(DepthStencilFormat));
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
void fixup_caps(WINED3DCAPS *caps)
{
/* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
if (caps->PixelShaderVersion > D3DPS_VERSION(1,4)) {
caps->PixelShaderVersion = D3DPS_VERSION(1,4);
}
if (caps->VertexShaderVersion > D3DVS_VERSION(1,1)) {
caps->VertexShaderVersion = D3DVS_VERSION(1,1);
}
caps->MaxVertexShaderConst = min(D3D8_MAX_VERTEX_SHADER_CONSTANTF, caps->MaxVertexShaderConst);
caps->StencilCaps &= ~WINED3DSTENCILCAPS_TWOSIDED;
}
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
HRESULT hrc = D3D_OK;
@ -252,21 +287,15 @@ static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Ada
if(pWineCaps == NULL){
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
}
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
fixup_caps(pWineCaps);
WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
HeapFree(GetProcessHeap(), 0, pWineCaps);
/* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
if(pCaps->PixelShaderVersion > D3DPS_VERSION(1,4)){
pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
}
if(pCaps->VertexShaderVersion > D3DVS_VERSION(1,1)){
pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
}
pCaps->MaxVertexShaderConst = min(D3D8_MAX_VERTEX_SHADER_CONSTANTF, pCaps->MaxVertexShaderConst);
TRACE("(%p) returning %p\n", This, pCaps);
return hrc;
}
@ -276,9 +305,10 @@ static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT
HMONITOR ret;
TRACE("(%p)->(%d)\n", This, Adapter);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -344,14 +374,15 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
*ppReturnedDeviceInterface = (IDirect3DDevice8 *)object;
/* Allocate an associated WineD3DDevice object */
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
(IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -378,7 +409,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
}
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
@ -404,9 +435,11 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
object->decls = HeapAlloc(GetProcessHeap(), 0, object->declArraySize * sizeof(*object->decls));
if(!object->decls) {
ERR("Out of memory\n");
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DDevice_Release(object->WineD3DDevice);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
hr = E_OUTOFMEMORY;

View file

@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -72,14 +73,15 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -88,9 +90,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -99,9 +102,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -110,9 +114,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXB
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -121,9 +126,10 @@ static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -132,9 +138,10 @@ static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -142,9 +149,9 @@ static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 ifac
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
@ -160,9 +167,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -171,9 +179,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -183,9 +192,9 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 i
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Format = d3dformat_from_wined3dformat(This->format);

View file

@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * if
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DPixelShader_Release(This->wineD3DPixelShader);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
return ref;

View file

@ -58,9 +58,10 @@ static ULONG WINAPI IDirect3DStateBlock8Impl_Release(IDirect3DStateBlock8 *iface
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@ -74,16 +75,14 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_GetDevice(IDirect3DStateBlock8 *i
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_GetDevice(This->wineD3DStateBlock, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -94,11 +93,9 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_Capture(IDirect3DStateBlock8 *ifa
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -109,11 +106,9 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_Apply(IDirect3DStateBlock8 *iface
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -76,9 +76,10 @@ static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
if (This->parentDevice) IUnknown_Release(This->parentDevice);
/* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
if (!This->isImplicit) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DSurface_Release(This->wineD3DSurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
}
@ -94,14 +95,15 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface,
HRESULT hr;
TRACE("(%p)->(%p)\n", This, ppDevice);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDevice(This->wineD3DSurface, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -110,9 +112,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -121,9 +124,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -132,9 +136,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -159,22 +164,21 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
memset(&wined3ddesc, 0, sizeof(wined3ddesc));
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->Size = wined3ddesc.size;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
}
return hr;
}
@ -185,7 +189,7 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D
TRACE("(%p) Relay\n", This);
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
if (pRect) {
D3DSURFACE_DESC desc;
IDirect3DSurface8_GetDesc(iface, &desc);
@ -197,13 +201,15 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D
|| (pRect->right > desc.Width)
|| (pRect->bottom > desc.Height)) {
WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n");
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
}
hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -212,9 +218,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface)
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
switch(hr)
{
case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL;

View file

@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface)
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D8CB_DestroyRenderTarget);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (This->parentDevice) IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -71,9 +72,10 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -84,13 +86,14 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE )Type, &mySurface);
if (hrc == D3D_OK && NULL != mySurface) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
IWineD3DSurface_Release(mySurface);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}

View file

@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DTexture_Destroy(This->wineD3DTexture, D3D8CB_DestroySurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -72,14 +73,16 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface,
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetDevice(This->wineD3DTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -88,9 +91,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -99,9 +103,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -110,9 +115,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -121,9 +127,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface,
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -132,9 +139,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface)
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -142,9 +150,9 @@ static void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DTexture_PreLoad(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
@ -152,9 +160,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 i
D3DRESOURCETYPE type;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
type = IWineD3DTexture_GetType(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return type;
}
@ -164,9 +173,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -175,9 +185,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -186,9 +197,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -200,22 +212,21 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 ifac
WINED3DSURFACE_DESC wined3ddesc;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
memset(&wined3ddesc, 0, sizeof(wined3ddesc));
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->Size = wined3ddesc.size;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
}
return hr;
}
@ -226,13 +237,15 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 i
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -241,9 +254,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, U
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -252,9 +266,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -263,9 +278,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 i
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -74,14 +75,15 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DVertexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -90,9 +92,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -101,9 +104,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -112,9 +116,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -123,9 +128,10 @@ static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFE
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -134,9 +140,10 @@ static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFE
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -144,9 +151,9 @@ static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 if
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
@ -162,9 +169,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -173,9 +181,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -185,9 +194,9 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Type = D3DRTYPE_VERTEXBUFFER;

View file

@ -61,9 +61,10 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDecla
TRACE("(%p) : Releasing to %d\n", This, ref_count);
if (!ref_count) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This->elements);
HeapFree(GetProcessHeap(), 0, This);
}

View file

@ -59,9 +59,9 @@ static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *i
IDirect3DVertexDeclaration8_Release(This->vertex_declaration);
if (This->wineD3DVertexShader)
{
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
HeapFree(GetProcessHeap(), 0, This);
}

View file

@ -72,9 +72,10 @@ static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
@ -87,11 +88,12 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, ID
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return D3D_OK;
}
@ -100,9 +102,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -111,9 +114,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -122,9 +126,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 ifa
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -154,21 +159,21 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DV
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Size = wined3ddesc.Size;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
}
return hr;
}
@ -178,9 +183,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DL
HRESULT hr;
TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -189,9 +195,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
HRESULT hr;
TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D8CB_DestroyVolume);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -73,14 +74,15 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXT
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetDevice(This->wineD3DVolumeTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -89,9 +91,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUM
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -100,9 +103,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUM
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -111,9 +115,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -122,9 +127,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXT
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -133,9 +139,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXT
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -143,9 +150,9 @@ static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
@ -153,9 +160,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLU
D3DRESOURCETYPE type;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return type;
}
@ -165,9 +173,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -176,9 +185,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -187,9 +197,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETE
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
@ -197,26 +208,25 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETE
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Size = wined3ddesc.Size;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
}
return hr;
}
@ -228,13 +238,14 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (hrc == D3D_OK && NULL != ppVolumeLevel) {
IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -243,9 +254,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTUR
HRESULT hr;
TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -254,9 +266,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXT
HRESULT hr;
TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
@ -265,9 +278,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -61,10 +61,10 @@ static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 ifa
if (ref == 0) {
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D9CB_DestroySurface);
IDirect3DDevice9Ex_Release(This->parentDevice);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
@ -78,14 +78,15 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -94,9 +95,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -105,9 +107,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -116,9 +119,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -127,9 +131,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -138,9 +143,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -148,9 +154,9 @@ static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 ifac
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
@ -158,9 +164,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETE
D3DRESOURCETYPE ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -170,9 +177,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 ifac
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -181,9 +189,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 ifac
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetLOD(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -192,9 +201,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTUR
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -203,9 +213,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DC
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -214,9 +225,10 @@ static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterTyp
D3DTEXTUREFILTERTYPE ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -224,37 +236,34 @@ static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBE
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
}
/* IDirect3DCubeTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
WINED3DSURFACE_DESC wined3ddesc;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *) &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
}
return hr;
}
@ -266,13 +275,14 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBE
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -281,9 +291,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -292,9 +303,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -303,9 +315,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXT
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -363,10 +376,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9EX ifac
}
object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (hr != D3D_OK){

View file

@ -25,15 +25,6 @@
#include "initguid.h"
#include "d3d9_private.h"
static CRITICAL_SECTION_DEBUG d3d9_cs_debug =
{
0, 0, &d3d9_cs,
{ &d3d9_cs_debug.ProcessLocksList,
&d3d9_cs_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": d3d9_cs") }
};
CRITICAL_SECTION d3d9_cs = { &d3d9_cs_debug, -1, 0, 0, 0, 0 };
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static int D3DPERF_event_level = 0;
@ -47,9 +38,10 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) {
object->lpVtbl = &Direct3D9_Vtbl;
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
object->WineD3D = WineDirect3DCreate(9, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);

View file

@ -3,7 +3,7 @@
*
* Copyright 2002-2003 Jason Edmeades
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -44,7 +44,6 @@
extern HRESULT vdecl_convert_fvf(
DWORD FVF,
D3DVERTEXELEMENT9** ppVertexElements);
extern CRITICAL_SECTION d3d9_cs;
D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format);
WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format);
@ -369,7 +368,6 @@ typedef struct IDirect3DBaseTexture9Impl
/* IDirect3DResource9 fields */
IWineD3DBaseTexture *wineD3DBaseTexture;
} IDirect3DBaseTexture9Impl;
/* --------------------- */

File diff suppressed because it is too large Load diff

View file

@ -69,9 +69,10 @@ static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3D_Release(This->WineD3D);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
@ -84,9 +85,10 @@ static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX ifac
HRESULT hr;
TRACE("(%p)->(%p)\n", This, pInitializeFunction);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -95,9 +97,10 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
HRESULT hr;
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterCount(This->WineD3D);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -106,23 +109,25 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, U
WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;
/* dx8 and dx9 have different structures to be filled in, with incompatible
layouts so pass in pointers to the places to be filled via an internal
structure */
adapter_id.Driver = pIdentifier->Driver;
adapter_id.Description = pIdentifier->Description;
adapter_id.DeviceName = pIdentifier->DeviceName;
adapter_id.DriverVersion = &pIdentifier->DriverVersion;
adapter_id.VendorId = &pIdentifier->VendorId;
adapter_id.DeviceId = &pIdentifier->DeviceId;
adapter_id.SubSysId = &pIdentifier->SubSysId;
adapter_id.Revision = &pIdentifier->Revision;
adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
adapter_id.driver = pIdentifier->Driver;
adapter_id.driver_size = sizeof(pIdentifier->Driver);
adapter_id.description = pIdentifier->Description;
adapter_id.description_size = sizeof(pIdentifier->Description);
adapter_id.device_name = pIdentifier->DeviceName;
adapter_id.device_name_size = sizeof(pIdentifier->DeviceName);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
pIdentifier->DriverVersion = adapter_id.driver_version;
pIdentifier->VendorId = adapter_id.vendor_id;
pIdentifier->DeviceId = adapter_id.device_id;
pIdentifier->SubSysId = adapter_id.subsystem_id;
pIdentifier->Revision = adapter_id.revision;
memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
pIdentifier->WHQLLevel = adapter_id.whql_level;
return hr;
}
@ -136,9 +141,10 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT
return 0;
}
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -151,10 +157,10 @@ static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT
if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5)
return D3DERR_INVALIDCALL;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
Mode, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -165,38 +171,51 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface,
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
HRESULT hr;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9EX iface,
UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
D3DFORMAT BackBufferFormat, BOOL Windowed) {
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
HRESULT hr;
TRACE("(%p)->(%d, %d, %d, %d, %s\n", This, Adapter, CheckType, DisplayFormat,
BackBufferFormat, Windowed ? "true" : "false");
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9EX iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
HRESULT hr;
WINED3DRESOURCETYPE WineD3DRType;
TRACE("%p\n", This);
/* This format is nothing special and it is supported perfectly.
* However, ati and nvidia driver on windows do not mark this format as
* supported (tested with the dxCapsViewer) and pretending to
* support this format uncovers a bug in Battlefield 1942 (fonts are missing)
* So do the same as Windows drivers and pretend not to support it on dx8 and 9
*/
if(CheckFormat == D3DFMT_R8G8B8)
{
WARN("D3DFMT_R8G8B8 is not available on windows, returning D3DERR_NOTAVAILABLE\n");
return D3DERR_NOTAVAILABLE;
}
switch(RType) {
case D3DRTYPE_VERTEXBUFFER:
case D3DRTYPE_INDEXBUFFER:
@ -208,39 +227,43 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9EX iface,
break;
}
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9EX iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType,
DWORD *pQualityLevels)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
HRESULT hr;
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9EX iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
HRESULT hr;
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
wined3dformat_from_d3dformat(DepthStencilFormat));
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -249,10 +272,11 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX i
HRESULT hr;
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -330,9 +354,11 @@ static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Ada
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
}
memset(pCaps, 0, sizeof(*pCaps));
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
HeapFree(GetProcessHeap(), 0, pWineCaps);
@ -350,9 +376,10 @@ static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UIN
HMONITOR ret;
TRACE("%p\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -418,13 +445,14 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
*ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
/* Allocate an associated WineD3DDevice object */
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
(IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -492,7 +520,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
* can be used without further checking
*/
object->convertedDecls = HeapAlloc(GetProcessHeap(), 0, 0);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -73,14 +74,15 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -89,9 +91,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -100,9 +103,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -111,9 +115,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXB
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -122,9 +127,10 @@ static DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -133,9 +139,10 @@ static DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -143,9 +150,9 @@ static void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 ifac
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface) {
@ -161,9 +168,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -172,9 +180,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -184,9 +193,9 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXB
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Format = d3dformat_from_wined3dformat(This->format);
@ -223,14 +232,13 @@ static const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl =
/* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9EX iface,
UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(IDirect3DDevice9Ex *iface, UINT Length, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9 **ppIndexBuffer, HANDLE *pSharedHandle)
{
IDirect3DIndexBuffer9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
@ -243,10 +251,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9EX iface,
object->ref = 1;
object->format = wined3dformat_from_d3dformat(Format);
TRACE("Calling wined3d create index buffer\n");
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK,
(WINED3DPOOL)Pool, &object->wineD3DIndexBuffer, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (hrc != D3D_OK) {
/* free up object */

View file

@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DPixelShader_Release(This->wineD3DPixelShader);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -72,11 +73,12 @@ static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return D3D_OK;
}
@ -86,9 +88,10 @@ static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -127,12 +130,14 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9EX iface,
object->ref = 1;
object->lpVtbl = &Direct3DPixelShader9_Vtbl;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, NULL,
&object->wineD3DPixelShader, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
if (hrc != D3D_OK) {
wined3d_mutex_unlock();
if (hrc != D3D_OK)
{
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
HeapFree(GetProcessHeap(), 0 , object);
@ -152,9 +157,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return D3D_OK;
}
@ -169,7 +175,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
return D3DERR_INVALIDCALL;
}
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
if (SUCCEEDED(hrc))
{
@ -187,7 +193,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
{
WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
@ -196,11 +202,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -210,9 +217,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9EX
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -222,9 +229,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -233,9 +241,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -244,9 +253,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -255,8 +265,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DQuery_Release(This->wineD3DQuery);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -74,7 +75,7 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDir
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetDevice(This->wineD3DQuery, &pDevice);
if(hr != D3D_OK){
*ppDevice = NULL;
@ -82,7 +83,8 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDir
hr = IWineD3DDevice_GetParent(pDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(pDevice);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -91,9 +93,10 @@ static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetType(This->wineD3DQuery);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -102,9 +105,10 @@ static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -113,9 +117,10 @@ static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dw
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -124,9 +129,10 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void*
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -154,9 +160,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQU
if (!ppQuery)
{
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -169,9 +176,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQU
object->lpVtbl = &Direct3DQuery9_Vtbl;
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (FAILED(hr)) {

View file

@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -73,25 +74,27 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_GetDevice(This->wineD3DStateBlock, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -100,9 +103,10 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -125,7 +129,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9EX iface,
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DStateBlock9Impl* object;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
if(Type != D3DSBT_ALL && Type != D3DSBT_PIXELSTATE &&
@ -133,15 +137,16 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9EX iface,
WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n");
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl));
if (NULL == object) return E_OUTOFMEMORY;
object->lpVtbl = &Direct3DStateBlock9_Vtbl;
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown*)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if(hrc != D3D_OK){
FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
HeapFree(GetProcessHeap(), 0, object);
@ -155,37 +160,41 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9EX iface,
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9EX iface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9EX iface, IDirect3DStateBlock9** ppSB) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **ppSB)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DStateBlock *wineD3DStateBlock;
IDirect3DStateBlock9Impl *object;
HRESULT hr;
IWineD3DStateBlock* wineD3DStateBlock;
IDirect3DStateBlock9Impl* object;
TRACE("(%p) Relay\n", This);
TRACE("(%p) Relay\n", This);
/* Tell wineD3D to endstateblock before anything else (in case we run out
* of memory later and cause locking problems)
*/
EnterCriticalSection(&d3d9_cs);
* of memory later and cause locking problems) */
wined3d_mutex_lock();
hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock);
LeaveCriticalSection(&d3d9_cs);
if(hr!= D3D_OK){
wined3d_mutex_unlock();
if (hr!= D3D_OK)
{
WARN("IWineD3DDevice_EndStateBlock returned an error\n");
return hr;
}
}
/* allocate a new IDirectD3DStateBlock */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock9Impl));
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl));
if (!object) return E_OUTOFMEMORY;
object->ref = 1;
object->lpVtbl = &Direct3DStateBlock9_Vtbl;

View file

@ -78,9 +78,10 @@ static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
if (ref == 0) {
if (This->parentDevice) IDirect3DDevice9Ex_Release(This->parentDevice);
if (!This->isImplicit) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DSurface_Release(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
}
@ -96,14 +97,15 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface,
HRESULT hr;
TRACE("(%p)->(%p)\n", This, ppDevice);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDevice(This->wineD3DSurface, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -112,9 +114,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -123,9 +126,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -134,9 +138,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -145,9 +150,10 @@ static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -156,9 +162,10 @@ static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface)
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetPriority(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -166,10 +173,9 @@ static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DSurface_PreLoad(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
return ;
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
@ -177,9 +183,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 i
D3DRESOURCETYPE ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DSurface_GetType(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -205,28 +212,25 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 ifac
static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
WINED3DSURFACE_DESC wined3ddesc;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
}
return hr;
}
@ -236,10 +240,11 @@ static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -248,9 +253,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface)
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
switch(hr)
{
case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL;
@ -263,9 +269,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC*
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -274,9 +281,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
switch(hr) {
case WINEDDERR_NODC: return WINED3DERR_INVALIDCALL;
default: return hr;

View file

@ -62,9 +62,10 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface)
if (ref == 0) {
if (This->parentDevice) IDirect3DDevice9Ex_Release(This->parentDevice);
if (!This->isImplicit) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D9CB_DestroyRenderTarget);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
}
@ -78,9 +79,9 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -90,9 +91,10 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPC
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -103,13 +105,14 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &mySurface);
if (hrc == D3D_OK && NULL != mySurface) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
IWineD3DSurface_Release(mySurface);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
/* Do not touch the **ppBackBuffer pointer otherwise! (see device test) */
return hrc;
}
@ -119,9 +122,10 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAI
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -130,9 +134,9 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -146,13 +150,14 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 ifa
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DSwapChain_GetDevice(This->wineD3DSwapChain, &device);
if (hrc == D3D_OK && NULL != device) {
IWineD3DDevice_GetParent(device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -163,9 +168,9 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWA
TRACE("(%p)->(%p): Relay\n", This, pPresentationParameters);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, &winePresentParameters);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = winePresentParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = winePresentParameters.BackBufferHeight;
@ -240,10 +245,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
localParameters.AutoRestoreDisplayMode = TRUE;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters,
&object->wineD3DSwapChain, (IUnknown*)object, SURFACE_OPENGL);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
@ -280,7 +285,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UI
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain);
if (hrc == D3D_OK && NULL != swapchain) {
IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain);
@ -288,7 +293,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UI
} else {
*pSwapChain = NULL;
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -297,8 +303,9 @@ UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9EX
UINT ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}

View file

@ -59,9 +59,10 @@ static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DTexture_Destroy(This->wineD3DTexture, D3D9CB_DestroySurface);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -75,14 +76,15 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetDevice(This->wineD3DTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -91,9 +93,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -102,9 +105,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -113,9 +117,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -124,9 +129,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface,
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -135,9 +141,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface)
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -145,9 +152,9 @@ static void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DTexture_PreLoad(This->wineD3DTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface) {
@ -155,9 +162,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 i
HRESULT ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetType(This->wineD3DTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -167,9 +175,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -178,9 +187,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface) {
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -189,9 +199,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -200,9 +211,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_SetAutoGenFilterType(This->wineD3DTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -211,9 +223,10 @@ static D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LP
D3DTEXTUREFILTERTYPE ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
ret = (D3DTEXTUREFILTERTYPE) IWineD3DTexture_GetAutoGenFilterType(This->wineD3DTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return ret;
}
@ -221,38 +234,34 @@ static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DTexture_GenerateMipSubLevels(This->wineD3DTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
}
/* IDirect3DTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
HRESULT hr;
WINED3DFORMAT format;
WINED3DSURFACE_DESC wined3ddesc;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt; /* required for d3d8 */
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
}
return hr;
}
@ -263,13 +272,15 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 i
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -278,9 +289,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, U
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -289,9 +301,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -300,9 +313,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -343,7 +357,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9EX iface, U
IDirect3DTexture9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%d), Fmt(%#x), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
/* Allocate the storage for the device */
@ -356,12 +370,14 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9EX iface, U
object->lpVtbl = &Direct3DTexture9_Vtbl;
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DTexture, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
if (FAILED(hrc)) {
wined3d_mutex_unlock();
if (FAILED(hrc))
{
/* free up object */
WARN("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);

View file

@ -58,9 +58,10 @@ static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 i
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -74,14 +75,15 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DVertexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -91,9 +93,9 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEX
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -103,9 +105,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -114,9 +117,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -125,9 +129,10 @@ static DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -136,9 +141,10 @@ static DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -146,10 +152,9 @@ static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 if
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d9_cs);
return ;
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
@ -165,9 +170,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -176,9 +182,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -188,9 +195,9 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Format = D3DFMT_VERTEXDATA;
@ -228,10 +235,9 @@ static const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
/* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9EX iface,
UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface, UINT Size, DWORD Usage,
DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle)
{
IDirect3DVertexBuffer9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
@ -246,11 +252,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9EX iface
object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
object->ref = 1;
object->fvf = FVF;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK,
0 /* fvf for ddraw only */, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (hrc != D3D_OK) {
/* free up object */

View file

@ -87,8 +87,7 @@ HRESULT vdecl_convert_fvf(
/* convert the declaration */
elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(D3DVERTEXELEMENT9));
if (!elements)
return D3DERR_OUTOFVIDEOMEMORY;
if (!elements) return D3DERR_OUTOFVIDEOMEMORY;
elements[size-1] = end_element;
idx = 0;
@ -230,9 +229,11 @@ void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface)
/* Should not happen unless wine has a bug or the application releases references it does not own */
ERR("Destroying vdecl with ref != 0\n");
}
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This->elements);
HeapFree(GetProcessHeap(), 0, This);
}
@ -262,13 +263,14 @@ static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEX
TRACE("(%p) : Relay\n", iface);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice);
if (hr == D3D_OK && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -348,8 +350,9 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9* d3d9_elem
}
/* IDirect3DDevice9 IDirect3DVertexDeclaration9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9EX iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) {
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(IDirect3DDevice9Ex *iface,
const D3DVERTEXELEMENT9 *pVertexElements, IDirect3DVertexDeclaration9 **ppDecl)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DVertexDeclaration9Impl *object = NULL;
WINED3DVERTEXELEMENT* wined3d_elements;
@ -392,10 +395,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
CopyMemory(object->elements, pVertexElements, element_count * sizeof(D3DVERTEXELEMENT9));
object->element_count = element_count;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wineD3DVertexDeclaration,
(IUnknown *)object, wined3d_elements, wined3d_element_count);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
@ -421,9 +424,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9EX i
TRACE("(%p) : Relay\n", iface);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl == NULL ? NULL : pDeclImpl->wineD3DVertexDeclaration);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -439,7 +443,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9EX i
}
*ppDecl = NULL;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest);
if (hr == D3D_OK && NULL != pTest) {
IWineD3DVertexDeclaration_GetParent(pTest, (IUnknown **)ppDecl);
@ -447,7 +452,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9EX i
} else {
*ppDecl = NULL;
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
TRACE("(%p) : returning %p\n", This, *ppDecl);
return hr;
}

View file

@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 i
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -72,7 +73,7 @@ static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADE
HRESULT hr;
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
if (WINED3D_OK == hr && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
@ -80,7 +81,8 @@ static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADE
} else {
*ppDevice = NULL;
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return hr;
}
@ -90,9 +92,10 @@ static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHA
HRESULT hr;
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -125,9 +128,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface
object->ref = 1;
object->lpVtbl = &Direct3DVertexShader9_Vtbl;
EnterCriticalSection(&d3d9_cs);
hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, NULL /* declaration */, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction,
NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object);
wined3d_mutex_unlock();
if (FAILED(hrc)) {
@ -150,9 +155,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, I
HRESULT hrc = D3D_OK;
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
TRACE("(%p) : returning hr(%u)\n", This, hrc);
return hrc;
@ -164,7 +170,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, I
HRESULT hrc = D3D_OK;
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
if (SUCCEEDED(hrc))
{
@ -182,7 +189,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, I
{
WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
}
@ -198,9 +206,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9EX
return D3DERR_INVALIDCALL;
}
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -215,9 +224,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9EX
}
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -226,9 +237,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -237,9 +249,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -248,9 +261,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -259,8 +273,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -72,9 +72,10 @@ static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
@ -89,13 +90,13 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, ID
TRACE("iface %p, ppDevice %p\n", iface, ppDevice);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return D3D_OK;
}
@ -106,11 +107,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 ifac
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -121,11 +122,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 ifac
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -136,11 +137,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 ifa
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -167,29 +168,26 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface,
static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
}
return hr;
}
@ -200,12 +198,12 @@ static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DL
TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -216,11 +214,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}

View file

@ -58,9 +58,10 @@ static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D9CB_DestroyVolume);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@ -75,14 +76,14 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_GetDevice(This->wineD3DVolumeTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -93,11 +94,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -108,11 +109,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -123,11 +124,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLU
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -138,11 +139,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
priority = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return priority;
}
@ -153,11 +154,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
priority = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return priority;
}
@ -167,11 +168,11 @@ static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
@ -180,11 +181,11 @@ static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLU
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return type;
}
@ -196,11 +197,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
lod = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return lod;
}
@ -211,11 +212,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
lod = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return lod;
}
@ -226,11 +227,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETE
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
level_count = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return level_count;
}
@ -241,11 +242,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -256,11 +257,11 @@ static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterT
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
filter_type = (D3DTEXTUREFILTERTYPE)IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return filter_type;
}
@ -270,40 +271,37 @@ static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVO
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
}
/* IDirect3DVolumeTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
WINED3DFORMAT format;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
if (SUCCEEDED(hr))
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
}
return hr;
}
@ -315,7 +313,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (hrc == D3D_OK && NULL != ppVolumeLevel) {
@ -323,7 +321,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUM
IWineD3DVolumeTexture_Release(myVolume);
}
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hrc;
}
@ -334,12 +332,12 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTUR
TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -350,11 +348,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -365,11 +363,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETE
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
return hr;
}
@ -407,11 +405,10 @@ static const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl =
/* IDirect3DDevice9 IDirect3DVolumeTexture9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9EX iface,
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) {
HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format,
D3DPOOL Pool, IDirect3DVolumeTexture9 **ppVolumeTexture, HANDLE *pSharedHandle)
{
IDirect3DVolumeTexture9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
@ -428,13 +425,13 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9EX if
object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
object->ref = 1;
EnterCriticalSection(&d3d9_cs);
wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels,
Usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(Format),
Pool, &object->wineD3DVolumeTexture, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
wined3d_mutex_unlock();
if (hrc != D3D_OK) {

View file

@ -816,7 +816,7 @@ IDirectDrawImpl_GetDisplayMode(IDirectDraw7 *iface,
EnterCriticalSection(&ddraw_cs);
/* This seems sane */
if(!DDSD)
if (!DDSD)
{
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
@ -841,7 +841,7 @@ IDirectDrawImpl_GetDisplayMode(IDirectDraw7 *iface,
DDSD->dwSize = Size;
DDSD->dwFlags |= DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_REFRESHRATE;
DDSD->dwWidth = Mode.Width;
DDSD->dwHeight = Mode.Height;
DDSD->dwHeight = Mode.Height;
DDSD->u2.dwRefreshRate = 60;
DDSD->ddsCaps.dwCaps = 0;
DDSD->u4.ddpfPixelFormat.dwSize = sizeof(DDSD->u4.ddpfPixelFormat);
@ -1101,7 +1101,7 @@ IDirectDrawImpl_FlipToGDISurface(IDirectDraw7 *iface)
* Returns:
* Always returns DD_OK
*
*****************************************************************************/
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawImpl_WaitForVerticalBlank(IDirectDraw7 *iface,
DWORD Flags,
@ -1135,7 +1135,7 @@ IDirectDrawImpl_WaitForVerticalBlank(IDirectDraw7 *iface,
* Returns:
* Always returns DD_OK
*
*****************************************************************************/
*****************************************************************************/
static HRESULT WINAPI IDirectDrawImpl_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
@ -1155,7 +1155,7 @@ static HRESULT WINAPI IDirectDrawImpl_GetScanLine(IDirectDraw7 *iface, DWORD *Sc
&Mode);
/* Fake the line sweeping of the monitor */
/* FIXME: We should synchronize with a source to keep the refresh rate */
/* FIXME: We should synchronize with a source to keep the refresh rate */
*Scanline = This->cur_scanline++;
/* Assume 20 scan lines in the vertical blank */
if (This->cur_scanline >= Mode.Height + 20)
@ -1176,7 +1176,7 @@ static HRESULT WINAPI IDirectDrawImpl_GetScanLine(IDirectDraw7 *iface, DWORD *Sc
* DDERR_NOEXCLUSIVEMODE or DDERR_EXCLUSIVEMODEALREADYSET
* if the state is not correct(See below)
*
*****************************************************************************/
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawImpl_TestCooperativeLevel(IDirectDraw7 *iface)
{
@ -1187,8 +1187,8 @@ IDirectDrawImpl_TestCooperativeLevel(IDirectDraw7 *iface)
EnterCriticalSection(&ddraw_cs);
/* Description from MSDN:
* For fullscreen apps return DDERR_NOEXCLUSIVEMODE if the user switched
* away from the app with e.g. alt-tab. Windowed apps receive
* DDERR_EXCLUSIVEMODEALREADYSET if another application created a
* away from the app with e.g. alt-tab. Windowed apps receive
* DDERR_EXCLUSIVEMODEALREADYSET if another application created a
* DirectDraw object in exclusive mode. DDERR_WRONGMODE is returned,
* when the video mode has changed
*/
@ -1243,7 +1243,7 @@ IDirectDrawImpl_TestCooperativeLevel(IDirectDraw7 *iface)
* DD_OK if the surface was found
* DDERR_NOTFOUND if the GDI surface wasn't found
*
*****************************************************************************/
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawImpl_GetGDISurface(IDirectDraw7 *iface,
IDirectDrawSurface7 **GDISurface)
@ -1311,7 +1311,7 @@ IDirectDrawImpl_GetGDISurface(IDirectDraw7 *iface,
* DD_OK on success
* DDERR_INVALIDPARAMS if the callback wasn't set
*
*****************************************************************************/
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
DWORD Flags,
@ -1664,10 +1664,8 @@ IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
WINED3DSURFACE_DESC Desc;
WINED3DFORMAT Format;
WINED3DRESOURCETYPE Type;
DWORD Usage;
WINED3DPOOL Pool;
UINT Size;
WINED3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
@ -1702,19 +1700,17 @@ IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
IWineD3DSurface_GetClipper(wineD3DSurface, &clipper);
/* Get the surface properties */
Desc.Format = &Format;
Desc.Type = &Type;
Desc.Usage = &Usage;
Desc.Pool = &Pool;
Desc.Size = &Size;
Desc.MultiSampleType = &MultiSampleType;
Desc.MultiSampleQuality = &MultiSampleQuality;
Desc.Width = &Width;
Desc.Height = &Height;
hr = IWineD3DSurface_GetDesc(wineD3DSurface, &Desc);
if(hr != D3D_OK) return hr;
Format = Desc.format;
Usage = Desc.usage;
Pool = Desc.pool;
MultiSampleType = Desc.multisample_type;
MultiSampleQuality = Desc.multisample_quality;
Width = Desc.width;
Height = Desc.height;
if(swapchain) {
/* If there's a swapchain, it owns the IParent interface. Create a new one for the
* new surface
@ -1729,7 +1725,7 @@ IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
/* Create the new surface */
hr = IWineD3DDevice_CreateSurface(This->wineD3DDevice, Width, Height, Format,
TRUE /* Lockable */, FALSE /* Discard */, surfImpl->mipmap_level, &surfImpl->WineD3DSurface,
Type, Usage, Pool, MultiSampleType, MultiSampleQuality, This->ImplType, Parent);
Usage, Pool, MultiSampleType, MultiSampleQuality, This->ImplType, Parent);
if(hr != D3D_OK)
return hr;
@ -1840,9 +1836,8 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
UINT level)
{
HRESULT hr;
UINT Width = 0, Height = 0;
UINT Width, Height;
WINED3DFORMAT Format = WINED3DFMT_UNKNOWN;
WINED3DRESOURCETYPE ResType = WINED3DRTYPE_SURFACE;
DWORD Usage = 0;
WINED3DSURFTYPE ImplType = This->ImplType;
WINED3DSURFACE_DESC Desc;
@ -1850,12 +1845,6 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
IParentImpl *parImpl = NULL;
WINED3DPOOL Pool = WINED3DPOOL_DEFAULT;
/* Dummies for GetDesc */
WINED3DPOOL dummy_d3dpool;
WINED3DMULTISAMPLE_TYPE dummy_mst;
UINT dummy_uint;
DWORD dummy_dword;
if (TRACE_ON(ddraw))
{
TRACE(" (%p) Requesting surface desc :\n", This);
@ -1897,8 +1886,9 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
}
else
{
if((pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE ) &&
(This->ImplType != SURFACE_OPENGL ) && DefaultSurfaceType == SURFACE_UNKNOWN)
if ((pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
&& (This->ImplType != SURFACE_OPENGL)
&& DefaultSurfaceType == SURFACE_UNKNOWN)
{
/* We have to change to OpenGL,
* and re-create all WineD3DSurfaces
@ -2026,8 +2016,8 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
/* Now create the WineD3D Surface */
hr = IWineD3DDevice_CreateSurface(This->wineD3DDevice, pDDSD->dwWidth, pDDSD->dwHeight, Format,
TRUE /* Lockable */, FALSE /* Discard */, level, &(*ppSurf)->WineD3DSurface, ResType, Usage,
Pool, WINED3DMULTISAMPLE_NONE, 0 /* MultiSampleQuality */, ImplType, Parent);
TRUE /* Lockable */, FALSE /* Discard */, level, &(*ppSurf)->WineD3DSurface,
Usage, Pool, WINED3DMULTISAMPLE_NONE, 0 /* MultiSampleQuality */, ImplType, Parent);
if(hr != D3D_OK)
{
@ -2058,16 +2048,6 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
* Don't use the Format choosen above, WineD3D might have
* changed it
*/
Desc.Format = &Format;
Desc.Type = &ResType;
Desc.Usage = &Usage;
Desc.Pool = &dummy_d3dpool;
Desc.Size = &dummy_uint;
Desc.MultiSampleType = &dummy_mst;
Desc.MultiSampleQuality = &dummy_dword;
Desc.Width = &Width;
Desc.Height = &Height;
(*ppSurf)->surface_desc.dwFlags |= DDSD_PIXELFORMAT;
hr = IWineD3DSurface_GetDesc((*ppSurf)->WineD3DSurface, &Desc);
if(hr != D3D_OK)
@ -2077,6 +2057,10 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
return hr;
}
Format = Desc.format;
Width = Desc.width;
Height = Desc.height;
if(Format == WINED3DFMT_UNKNOWN)
{
FIXME("IWineD3DSurface::GetDesc returned WINED3DFMT_UNKNOWN\n");

View file

@ -94,7 +94,7 @@ static inline WORD d3d_fpu_setup(void)
}
/*****************************************************************************
* IUnknown Methods. Common for Version 1, 2, 3 and 7
* IUnknown Methods. Common for Version 1, 2, 3 and 7
*****************************************************************************/
/*****************************************************************************
@ -2558,7 +2558,6 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
BOOL tex_alpha = FALSE;
IWineD3DBaseTexture *tex = NULL;
WINED3DSURFACE_DESC desc;
WINED3DFORMAT fmt;
DDPIXELFORMAT ddfmt;
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
@ -2567,13 +2566,11 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
if(hr == WINED3D_OK && tex)
{
memset(&desc, 0, sizeof(desc));
desc.Format = &fmt;
hr = IWineD3DTexture_GetLevelDesc((IWineD3DTexture*) tex, 0, &desc);
if (SUCCEEDED(hr))
{
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, fmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
@ -2642,7 +2639,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
{
case D3DRENDERSTATE_TEXTUREMAG:
{
WINED3DTEXTUREFILTERTYPE tex_mag = WINED3DTEXF_NONE;
WINED3DTEXTUREFILTERTYPE tex_mag = WINED3DTEXF_POINT;
switch ((D3DTEXTUREFILTER) Value)
{
@ -2666,7 +2663,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
case D3DRENDERSTATE_TEXTUREMIN:
{
WINED3DTEXTUREFILTERTYPE tex_min = WINED3DTEXF_NONE;
WINED3DTEXTUREFILTERTYPE tex_min = WINED3DTEXF_POINT;
WINED3DTEXTUREFILTERTYPE tex_mip = WINED3DTEXF_NONE;
switch ((D3DTEXTUREFILTER) Value)
@ -2678,11 +2675,11 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
tex_min = WINED3DTEXF_LINEAR;
break;
case D3DFILTER_MIPNEAREST:
tex_min = WINED3DTEXF_NONE;
tex_min = WINED3DTEXF_POINT;
tex_mip = WINED3DTEXF_POINT;
break;
case D3DFILTER_MIPLINEAR:
tex_min = WINED3DTEXF_NONE;
tex_min = WINED3DTEXF_POINT;
tex_mip = WINED3DTEXF_LINEAR;
break;
case D3DFILTER_LINEARMIPNEAREST:
@ -2833,7 +2830,6 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
BOOL tex_alpha = FALSE;
IWineD3DBaseTexture *tex = NULL;
WINED3DSURFACE_DESC desc;
WINED3DFORMAT fmt;
DDPIXELFORMAT ddfmt;
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
@ -2843,12 +2839,11 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
if(hr == WINED3D_OK && tex)
{
memset(&desc, 0, sizeof(desc));
desc.Format = &fmt;
hr = IWineD3DTexture_GetLevelDesc((IWineD3DTexture*) tex, 0, &desc);
if (SUCCEEDED(hr))
{
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, fmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
@ -2961,7 +2956,7 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
TRACE("(%p)->(%08x,%08x)\n", This, LightStateType, Value);
if (!LightStateType && (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
if (!LightStateType || (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
{
TRACE("Unexpected Light State Type\n");
return DDERR_INVALIDPARAMS;
@ -3094,7 +3089,7 @@ IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
TRACE("(%p)->(%08x,%p)\n", This, LightStateType, Value);
if (!LightStateType && (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
if (!LightStateType || (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
{
TRACE("Unexpected Light State Type\n");
return DDERR_INVALIDPARAMS;
@ -4507,7 +4502,7 @@ IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, Stage, &Surf);
if( (hr != D3D_OK) || (!Surf) )
if( (hr != D3D_OK) || (!Surf) )
{
*Texture = NULL;
LeaveCriticalSection(&ddraw_cs);
@ -4648,7 +4643,6 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
BOOL tex_alpha = FALSE;
IWineD3DBaseTexture *tex = NULL;
WINED3DSURFACE_DESC desc;
WINED3DFORMAT fmt;
DDPIXELFORMAT ddfmt;
HRESULT result;
@ -4659,12 +4653,11 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
if(result == WINED3D_OK && tex)
{
memset(&desc, 0, sizeof(desc));
desc.Format = &fmt;
result = IWineD3DTexture_GetLevelDesc((IWineD3DTexture*) tex, 0, &desc);
if (SUCCEEDED(result))
{
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, fmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
@ -5309,7 +5302,7 @@ IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface,
TRACE("(%p)->(%p): Relay!\n", This, Mat);
EnterCriticalSection(&ddraw_cs);
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
hr = IWineD3DDevice_GetMaterial(This->wineD3DDevice,
(WINED3DMATERIAL*) Mat);
LeaveCriticalSection(&ddraw_cs);
@ -5944,8 +5937,8 @@ static BOOL is_mip_level_subset(IDirectDrawSurfaceImpl *dest,
static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
IDirectDrawSurfaceImpl *dest,
IDirectDrawSurfaceImpl *src,
POINT *DestPoint,
RECT *SrcRect)
const POINT *DestPoint,
const RECT *SrcRect)
{
IDirectDrawSurfaceImpl *src_level, *dest_level;
IDirectDrawSurface7 *temp;

View file

@ -1324,7 +1324,7 @@ IDirect3DImpl_GetCaps(IWineD3D *WineD3D,
Desc7->dwStencilCaps &= (
D3DSTENCILCAPS_KEEP | D3DSTENCILCAPS_ZERO | D3DSTENCILCAPS_REPLACE |
D3DSTENCILCAPS_INCRSAT | D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INVERT |
D3DSTENCILCAPS_INCR | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_TWOSIDED);
D3DSTENCILCAPS_INCR | D3DSTENCILCAPS_DECR);
/* FVF caps ?*/

View file

@ -227,14 +227,14 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
} else if(lpDevice->Handles[ci->u2.dwArg[0] - 1].type != DDrawHandle_Matrix) {
ERR("Handle %d is not a matrix handle\n", ci->u2.dwArg[0]);
} else {
if(ci->u1.drstRenderStateType == D3DTRANSFORMSTATE_WORLD)
if(ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_WORLD)
lpDevice->world = ci->u2.dwArg[0];
if(ci->u1.drstRenderStateType == D3DTRANSFORMSTATE_VIEW)
if(ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_VIEW)
lpDevice->view = ci->u2.dwArg[0];
if(ci->u1.drstRenderStateType == D3DTRANSFORMSTATE_PROJECTION)
if(ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_PROJECTION)
lpDevice->proj = ci->u2.dwArg[0];
IDirect3DDevice7_SetTransform((IDirect3DDevice7 *)lpDevice,
ci->u1.drstRenderStateType, (LPD3DMATRIX)lpDevice->Handles[ci->u2.dwArg[0] - 1].ptr);
ci->u1.dtstTransformStateType, (LPD3DMATRIX)lpDevice->Handles[ci->u2.dwArg[0] - 1].ptr);
}
instr += size;
}
@ -249,7 +249,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
TRACE("(%08x,%08x)\n", ci->u1.dlstLightStateType, ci->u2.dwArg[0]);
if (!ci->u1.dlstLightStateType && (ci->u1.dlstLightStateType > D3DLIGHTSTATE_COLORVERTEX))
if (!ci->u1.dlstLightStateType || (ci->u1.dlstLightStateType > D3DLIGHTSTATE_COLORVERTEX))
ERR("Unexpected Light State Type\n");
else if (ci->u1.dlstLightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */) {
DWORD matHandle = ci->u2.dwArg[0];
@ -317,7 +317,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
for (i = 0; i < count; i++) {
LPD3DSTATE ci = (LPD3DSTATE) instr;
IDirect3DDevice2_SetRenderState(d3d_device2, ci->u1.drstRenderStateType, ci->u2.dwArg[0]);
instr += size;
@ -369,33 +369,33 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
TRACE("UPDATEEXTENTS ");
TRACE("\n");
}
/* This is where doing Direct3D on top on OpenGL is quite difficult.
This method transforms a set of vertices using the CURRENT state
(lighting, projection, ...) but does not rasterize them.
They will only be put on screen later (with the POINT / LINE and
TRIANGLE op-codes). The problem is that you can have a triangle
with each point having been transformed using another state...
In this implementation, I will emulate only ONE thing : each
vertex can have its own "WORLD" transformation (this is used in the
TWIST.EXE demo of the 5.2 SDK). I suppose that all vertices of the
execute buffer use the same state.
If I find applications that change other states, I will try to do a
more 'fine-tuned' state emulation (but I may become quite tricky if
it changes a light position in the middle of a triangle).
In this case, a 'direct' approach (i.e. without using OpenGL, but
writing our own 3D rasterizer) would be easier. */
/* The current method (with the hypothesis that only the WORLD matrix
will change between two points) is like this :
- I transform 'manually' all the vertices with the current WORLD
matrix and store them in the vertex buffer
- during the rasterization phase, the WORLD matrix will be set to
the Identity matrix */
/* Enough for the moment */
if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) {
unsigned int nb;
@ -439,7 +439,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
src++;
dst++;
}
} else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) {
unsigned int nb;
@ -465,7 +465,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
dst->u6.specular = src->u5.specular;
dst->u7.tu = src->u6.tu;
dst->u8.tv = src->u7.tv;
/* Now, the matrix multiplication */
dst->u1.sx = (src->u1.x * mat._11) + (src->u2.y * mat._21) + (src->u3.z * mat._31) + (1.0 * mat._41);
dst->u2.sy = (src->u1.x * mat._12) + (src->u2.y * mat._22) + (src->u3.z * mat._32) + (1.0 * mat._42);
@ -551,7 +551,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
for (i = 0; i < count; i++) {
LPD3DSTATUS ci = (LPD3DSTATUS) instr;
This->data.dsStatus = *ci;
instr += size;
@ -705,7 +705,7 @@ IDirect3DExecuteBufferImpl_Lock(IDirect3DExecuteBuffer *iface,
dwSize = lpDesc->dwSize;
memset(lpDesc, 0, dwSize);
memcpy(lpDesc, &This->desc, dwSize);
if (TRACE_ON(d3d7)) {
TRACE(" Returning description :\n");
_dump_D3DEXECUTEBUFFERDESC(lpDesc);
@ -756,7 +756,7 @@ IDirect3DExecuteBufferImpl_SetExecuteData(IDirect3DExecuteBuffer *iface,
/* Get the number of vertices in the execute buffer */
nbvert = This->data.dwVertexCount;
/* Prepares the transformed vertex buffer */
HeapFree(GetProcessHeap(), 0, This->vertex_data);
This->vertex_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nbvert * sizeof(D3DTLVERTEX));

View file

@ -179,17 +179,17 @@ IDirect3DLightImpl_SetLight(IDirect3DLight *iface,
if ( (lpLight->dltType == 0) || (lpLight->dltType > D3DLIGHT_PARALLELPOINT) )
return DDERR_INVALIDPARAMS;
if ( lpLight->dltType == D3DLIGHT_PARALLELPOINT )
FIXME("D3DLIGHT_PARALLELPOINT no supported\n");
FIXME("D3DLIGHT_PARALLELPOINT no supported\n");
/* Translate D3DLIGH2 structure to D3DLIGHT7 */
light7->dltType = lpLight->dltType;
light7->dcvDiffuse = lpLight->dcvColor;
if ((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_NO_SPECULAR) != 0)
if ((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_NO_SPECULAR) != 0)
light7->dcvSpecular = lpLight->dcvColor;
else
light7->dcvSpecular = *(const D3DCOLORVALUE*)zero_value;
light7->dcvSpecular = *(const D3DCOLORVALUE*)zero_value;
light7->dcvAmbient = lpLight->dcvColor;
light7->dvPosition = lpLight->dvPosition;
light7->dvDirection = lpLight->dvDirection;
@ -204,7 +204,7 @@ IDirect3DLightImpl_SetLight(IDirect3DLight *iface,
EnterCriticalSection(&ddraw_cs);
memcpy(&This->light, lpLight, lpLight->dwSize);
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
This->update(This);
This->update(This);
}
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
@ -274,7 +274,7 @@ void light_activate(IDirect3DLightImpl* This)
if (!This->active_viewport || !This->active_viewport->active_device)
return;
device = This->active_viewport->active_device;
light_update(This);
/* If was not active, activate it */
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) == 0) {
@ -299,7 +299,7 @@ void light_desactivate(IDirect3DLightImpl* This)
if (!This->active_viewport || !This->active_viewport->active_device)
return;
device = This->active_viewport->active_device;
/* If was not active, activate it */
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, This->dwLightIndex, FALSE);

View file

@ -117,8 +117,7 @@ IParentImpl_AddRef(IParent *iface)
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IParentImpl_Release(IParent *iface)
static ULONG WINAPI IParentImpl_Release(IParent *iface)
{
IParentImpl *This = (IParentImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);

View file

@ -920,9 +920,6 @@ IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This,
IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
}
/* MSDN:
* "This method increments the reference count of the surface being attached."
*/
IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)Surf);
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
@ -1033,7 +1030,7 @@ IDirectDrawSurfaceImpl_AddOverlayDirtyRect(IDirectDrawSurface7 *iface,
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
TRACE("(%p)->(%p)\n",This,Rect);
/* MSDN says it's not implemented. I could forward it to WineD3D,
/* MSDN says it's not implemented. I could forward it to WineD3D,
* then we'd implement it, but I don't think that's a good idea
* (Stefan Dösinger)
*/

View file

@ -349,7 +349,7 @@ PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat,
WINED3DFORMAT
PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat)
{
TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
if(TRACE_ON(ddraw))
{
DDRAW_dump_pixelformat(DDPixelFormat);

View file

@ -84,7 +84,7 @@ void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights) {
vp.dvMinZ = This->viewports.vp1.dvMinZ;
vp.dvMaxZ = This->viewports.vp1.dvMaxZ;
}
/* And also set the viewport */
IDirect3DDevice7_SetViewport((IDirect3DDevice7 *)This->active_device, &vp);
}
@ -657,11 +657,8 @@ IDirect3DViewportImpl_GetBackgroundDepth(IDirect3DViewport3 *iface,
* The return value of IDirect3DDevice7::Clear
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
DWORD dwCount,
D3DRECT *lpRects,
DWORD dwFlags)
static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
DWORD dwCount, D3DRECT *lpRects, DWORD dwFlags)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
DWORD color = 0x00000000;
@ -679,14 +676,15 @@ IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
EnterCriticalSection(&ddraw_cs);
if (dwFlags & D3DCLEAR_TARGET) {
if (This->background == NULL) {
ERR(" Trying to clear the color buffer without background material !\n");
} else {
color =
((int) ((This->background->mat.u.diffuse.u1.r) * 255) << 16) |
((int) ((This->background->mat.u.diffuse.u2.g) * 255) << 8) |
((int) ((This->background->mat.u.diffuse.u3.b) * 255) << 0) |
((int) ((This->background->mat.u.diffuse.u4.a) * 255) << 24);
}
ERR(" Trying to clear the color buffer without background material !\n");
}
else
{
color = ((int)((This->background->mat.u.diffuse.u1.r) * 255) << 16)
| ((int) ((This->background->mat.u.diffuse.u2.g) * 255) << 8)
| ((int) ((This->background->mat.u.diffuse.u3.b) * 255) << 0)
| ((int) ((This->background->mat.u.diffuse.u4.a) * 255) << 24);
}
}
/* Need to temporarily activate viewport to clear it. Previously active one will be restored
@ -729,7 +727,7 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight;
DWORD i = 0;
DWORD map = This->map_lights;
TRACE("(%p)->(%p)\n", This, lpDirect3DLight);
EnterCriticalSection(&ddraw_cs);
@ -755,7 +753,7 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
/* Attach the light to the viewport */
lpDirect3DLightImpl->active_viewport = This;
/* If active, activate the light */
if (This->active_device != NULL) {
lpDirect3DLightImpl->activate(lpDirect3DLightImpl);
@ -785,7 +783,7 @@ IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight;
IDirect3DLightImpl *cur_light, *prev_light = NULL;
TRACE("(%p)->(%p)\n", This, lpDirect3DLight);
EnterCriticalSection(&ddraw_cs);

File diff suppressed because it is too large Load diff

View file

@ -28,6 +28,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
/* GL locking for state handlers is done by the caller. */
/* Some private defines, Constant associations, etc.
* Env bump matrix and per stage constant should be independent,
* a stage that bump maps can't read the per state constant
@ -51,8 +53,7 @@ struct atifs_ffp_desc
struct atifs_private_data
{
struct hash_table_t *fragment_shaders; /* A hashtable to track fragment pipeline replacement shaders */
struct wine_rb_tree fragment_shaders; /* A rb-tree to track fragment pipeline replacement shaders */
};
static const char *debug_dstmod(GLuint mod) {
@ -191,8 +192,9 @@ static const char *debug_mask(GLuint mask) {
}
#define GLINFO_LOCATION (*gl_info)
static void wrap_op1(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod) {
static void wrap_op1(const struct wined3d_gl_info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod)
{
if(dstMask == GL_ALPHA) {
TRACE("glAlphaFragmentOp1ATI(%s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod));
@ -205,9 +207,9 @@ static void wrap_op1(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLui
}
}
static void wrap_op2(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
GLuint arg2, GLuint arg2Rep, GLuint arg2Mod) {
static void wrap_op2(const struct wined3d_gl_info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod)
{
if(dstMask == GL_ALPHA) {
TRACE("glAlphaFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
@ -222,10 +224,10 @@ static void wrap_op2(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLui
}
}
static void wrap_op3(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
GLuint arg2, GLuint arg2Rep, GLuint arg2Mod,
GLuint arg3, GLuint arg3Rep, GLuint arg3Mod) {
static void wrap_op3(const struct wined3d_gl_info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod,
GLuint arg3, GLuint arg3Rep, GLuint arg3Mod)
{
if(dstMask == GL_ALPHA) {
/* Leave some free space to fit "GL_NONE, " in to align most alpha and color op lines */
TRACE("glAlphaFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
@ -249,7 +251,7 @@ static void wrap_op3(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLui
}
}
static GLuint register_for_arg(DWORD arg, const WineD3D_GL_Info *gl_info,
static GLuint register_for_arg(DWORD arg, const struct wined3d_gl_info *gl_info,
unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg)
{
GLenum ret;
@ -377,7 +379,7 @@ static GLuint find_tmpreg(const struct texture_stage_op op[MAX_TEXTURES])
}
}
static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], const WineD3D_GL_Info *gl_info)
static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], const struct wined3d_gl_info *gl_info)
{
GLuint ret = GL_EXTCALL(glGenFragmentShadersATI(1));
unsigned int stage;
@ -422,13 +424,6 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con
GL_EXTCALL(glPassTexCoordATI(GL_REG_0_ATI + stage + 1,
GL_TEXTURE0_ARB + stage + 1,
swizzle));
/* We need GL_REG_5_ATI as a temporary register to swizzle the bump matrix. So we run into
* issues if we're bump mapping on stage 4 or 5
*/
if(stage >= 4) {
FIXME("Bump mapping in stage %d\n", stage);
}
}
/* Pass 2: Generate perturbation calculations */
@ -459,22 +454,24 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con
ATI_FFP_CONST_BUMPMAT(stage), GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
GL_REG_0_ATI + stage + 1, GL_RED, GL_NONE);
/* FIXME: How can I make GL_DOT2_ADD_ATI read the factors from blue and alpha? It defaults to red and green,
* and it is fairly easy to make it read GL_BLUE or BL_ALPHA, but I can't get an R * B + G * A. So we're wasting
* one register and two instructions in this pass for a simple swizzling operation.
* For starters it might be good enough to merge the two movs into one, but even that isn't possible :-(
/* Don't use GL_DOT2_ADD_ATI here because we cannot configure it to read the blue and alpha
* component of the bump matrix. Instead do this with two MADs:
*
* NOTE: GL_BLUE | GL_ALPHA is not possible. It doesn't throw a compilation error, but an OR operation on the
* constants doesn't make sense, considering their values.
* coord.a = tex.r * bump.b + coord.g
* coord.g = tex.g * bump.a + coord.a
*
* The first instruction writes to alpha so it can be coissued with the above DOT2_ADD.
* coord.a is unused. If the perturbed texture is projected, this was already handled
* in the glPassTexCoordATI above.
*/
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_5_ATI, GL_RED_BIT_ATI, GL_NONE,
ATI_FFP_CONST_BUMPMAT(stage), GL_BLUE, GL_NONE);
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_5_ATI, GL_GREEN_BIT_ATI, GL_NONE,
ATI_FFP_CONST_BUMPMAT(stage), GL_ALPHA, GL_NONE);
wrap_op3(gl_info, GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_GREEN_BIT_ATI, GL_NONE,
GL_REG_0_ATI + stage, GL_NONE, argmodextra_y,
GL_REG_5_ATI, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
wrap_op3(gl_info, GL_MAD_ATI, GL_REG_0_ATI + stage + 1, GL_ALPHA, GL_NONE,
GL_REG_0_ATI + stage, GL_RED, argmodextra_y,
ATI_FFP_CONST_BUMPMAT(stage), GL_BLUE, GL_NONE,
GL_REG_0_ATI + stage + 1, GL_GREEN, GL_NONE);
wrap_op3(gl_info, GL_MAD_ATI, GL_REG_0_ATI + stage + 1, GL_GREEN_BIT_ATI, GL_NONE,
GL_REG_0_ATI + stage, GL_GREEN, argmodextra_y,
ATI_FFP_CONST_BUMPMAT(stage), GL_ALPHA, GL_NONE,
GL_REG_0_ATI + stage + 1, GL_ALPHA, GL_NONE);
}
/* Pass 3: Generate sampling instructions for regular textures */
@ -799,7 +796,8 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con
#undef GLINFO_LOCATION
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
IWineD3DDeviceImpl *This = stateblock->wineD3DDevice;
const struct atifs_ffp_desc *desc;
struct ffp_frag_settings settings;
@ -808,7 +806,7 @@ static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, Wi
unsigned int i;
gen_ffp_frag_op(stateblock, &settings, TRUE);
desc = (const struct atifs_ffp_desc *)find_ffp_frag_shader(priv->fragment_shaders, &settings);
desc = (const struct atifs_ffp_desc *)find_ffp_frag_shader(&priv->fragment_shaders, &settings);
if(!desc) {
struct atifs_ffp_desc *new_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_desc));
if (!new_desc)
@ -824,7 +822,7 @@ static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, Wi
memcpy(&new_desc->parent.settings, &settings, sizeof(settings));
new_desc->shader = gen_ati_shader(settings.op, &GLINFO_LOCATION);
add_ffp_frag_shader(priv->fragment_shaders, &new_desc->parent);
add_ffp_frag_shader(&priv->fragment_shaders, &new_desc->parent);
TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
desc = new_desc;
}
@ -845,7 +843,8 @@ static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, Wi
GL_EXTCALL(glBindFragmentShaderATI(desc->shader));
}
static void state_texfactor_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void state_texfactor_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
float col[4];
D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
@ -853,7 +852,8 @@ static void state_texfactor_atifs(DWORD state, IWineD3DStateBlockImpl *statebloc
checkGLcall("glSetFragmentShaderConstantATI(ATI_FFP_CONST_TFACTOR, col)");
}
static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
float mat[2][2];
@ -868,21 +868,23 @@ static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
* shader(it is free). This might potentially reduce precision. However, if the hardware does
* support proper floats it shouldn't, and if it doesn't we can't get anything better anyway
*/
mat[0][0] = (mat[0][0] + 1.0) * 0.5;
mat[1][0] = (mat[1][0] + 1.0) * 0.5;
mat[0][1] = (mat[0][1] + 1.0) * 0.5;
mat[1][1] = (mat[1][1] + 1.0) * 0.5;
mat[0][0] = (mat[0][0] + 1.0f) * 0.5f;
mat[1][0] = (mat[1][0] + 1.0f) * 0.5f;
mat[0][1] = (mat[0][1] + 1.0f) * 0.5f;
mat[1][1] = (mat[1][1] + 1.0f) * 0.5f;
GL_EXTCALL(glSetFragmentShaderConstantATI(ATI_FFP_CONST_BUMPMAT(stage), (float *) mat));
checkGLcall("glSetFragmentShaderConstantATI(ATI_FFP_CONST_BUMPMAT(stage), mat)");
}
static void textransform(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void textransform(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
if(!isStateDirty(context, STATE_PIXELSHADER)) {
set_tex_op_atifs(state, stateblock, context);
}
}
static void atifs_apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void atifs_apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
BOOL use_vshader = use_vs(stateblock);
@ -899,7 +901,7 @@ static void atifs_apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *statebl
* simpler.
*/
if(!isStateDirty(context, device->StateTable[STATE_VSHADER].representative)) {
device->shader_backend->shader_select((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, use_vshader);
device->shader_backend->shader_select(context, FALSE, use_vshader);
if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && use_vshader) {
device->StateTable[STATE_VERTEXSHADERCONSTANT].apply(STATE_VERTEXSHADERCONSTANT, stateblock, context);
@ -910,139 +912,141 @@ static void atifs_apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *statebl
#undef GLINFO_LOCATION
static const struct StateEntryTemplate atifs_fragmentstate_template[] = {
{STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor_atifs }, 0 },
{STATE_RENDER(WINED3DRS_FOGCOLOR), { STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor }, 0 },
{STATE_RENDER(WINED3DRS_FOGDENSITY), { STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity }, 0 },
{STATE_RENDER(WINED3DRS_FOGENABLE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{STATE_RENDER(WINED3DRS_FOGTABLEMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{STATE_RENDER(WINED3DRS_FOGVERTEXMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{STATE_RENDER(WINED3DRS_FOGSTART), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{STATE_RENDER(WINED3DRS_FOGEND), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, 0 },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, 0 },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, 0 },
{ STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, 0 },
{ STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }, 0 },
{ STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }, 0 },
{ STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }, 0 },
{ STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }, 0 },
{ STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }, 0 },
{STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(0, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(1, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(2, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(3, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(4, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(5, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(6, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(7, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_PIXELSHADER, { STATE_PIXELSHADER, atifs_apply_pixelshader }, 0 },
{0 /* Terminate */, { 0, 0 }, 0 },
{STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor_atifs }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGCOLOR), { STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGDENSITY), { STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGENABLE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGTABLEMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGVERTEXMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGSTART), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGEND), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(0, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(1, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(2, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(3, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(4, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(5, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(6, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(7, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, WINED3D_GL_EXT_NONE },
{STATE_PIXELSHADER, { STATE_PIXELSHADER, atifs_apply_pixelshader }, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
/* Context activation is done by the caller. */
static void atifs_enable(IWineD3DDevice *iface, BOOL enable) {
ENTER_GL();
if(enable) {
glEnable(GL_FRAGMENT_SHADER_ATI);
checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
@ -1050,9 +1054,10 @@ static void atifs_enable(IWineD3DDevice *iface, BOOL enable) {
glDisable(GL_FRAGMENT_SHADER_ATI);
checkGLcall("glDisable(GL_FRAGMENT_SHADER_ATI)");
}
LEAVE_GL();
}
static void atifs_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *caps)
static void atifs_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
{
caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE |
WINED3DTEXOPCAPS_SELECTARG1 |
@ -1110,14 +1115,21 @@ static HRESULT atifs_alloc(IWineD3DDevice *iface) {
return E_OUTOFMEMORY;
}
priv = This->fragment_priv;
priv->fragment_shaders = hash_table_create(ffp_frag_program_key_hash, ffp_frag_program_key_compare);
if (wine_rb_init(&priv->fragment_shaders, &wined3d_ffp_frag_program_rb_functions) == -1)
{
ERR("Failed to initialize rbtree.\n");
HeapFree(GetProcessHeap(), 0, This->fragment_priv);
return E_OUTOFMEMORY;
}
return WINED3D_OK;
}
#define GLINFO_LOCATION This->adapter->gl_info
static void atifs_free_ffpshader(void *value, void *device) {
IWineD3DDeviceImpl *This = device;
struct atifs_ffp_desc *entry_ati = value;
/* Context activation is done by the caller. */
static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *context)
{
IWineD3DDeviceImpl *This = context;
struct atifs_ffp_desc *entry_ati = WINE_RB_ENTRY_VALUE(entry, struct atifs_ffp_desc, parent.entry);
ENTER_GL();
GL_EXTCALL(glDeleteFragmentShaderATI(entry_ati->shader));
@ -1126,11 +1138,12 @@ static void atifs_free_ffpshader(void *value, void *device) {
LEAVE_GL();
}
/* Context activation is done by the caller. */
static void atifs_free(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
struct atifs_private_data *priv = This->fragment_priv;
hash_table_destroy(priv->fragment_shaders, atifs_free_ffpshader, This);
wine_rb_destroy(&priv->fragment_shaders, atifs_free_ffpshader, This);
HeapFree(GetProcessHeap(), 0, priv);
This->fragment_priv = NULL;

View file

@ -138,35 +138,41 @@ const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token
}
}
static inline BOOL shader_is_version_token(DWORD token) {
return shader_is_pshader_version(token) ||
shader_is_vshader_version(token);
}
void shader_buffer_init(struct SHADER_BUFFER *buffer)
void shader_buffer_clear(struct wined3d_shader_buffer *buffer)
{
buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
buffer->buffer[0] = '\0';
buffer->bsize = 0;
buffer->lineNo = 0;
buffer->newline = TRUE;
}
void shader_buffer_free(struct SHADER_BUFFER *buffer)
BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer)
{
buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
if (!buffer->buffer)
{
ERR("Failed to allocate shader buffer memory.\n");
return FALSE;
}
shader_buffer_clear(buffer);
return TRUE;
}
void shader_buffer_free(struct wined3d_shader_buffer *buffer)
{
HeapFree(GetProcessHeap(), 0, buffer->buffer);
}
int shader_vaddline(SHADER_BUFFER* buffer, const char *format, va_list args)
int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args)
{
char* base = buffer->buffer + buffer->bsize;
int rc;
rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args);
if (rc < 0 || /* C89 */
rc > SHADER_PGMSIZE - 1 - buffer->bsize) { /* C99 */
if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */)
{
ERR("The buffer allocated for the shader program string "
"is too small at %d bytes.\n", SHADER_PGMSIZE);
buffer->bsize = SHADER_PGMSIZE - 1;
@ -188,7 +194,7 @@ int shader_vaddline(SHADER_BUFFER* buffer, const char *format, va_list args)
return 0;
}
int shader_addline(SHADER_BUFFER* buffer, const char *format, ...)
int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...)
{
int ret;
va_list args;
@ -246,24 +252,23 @@ static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit)
}
static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct shader_reg_maps *reg_maps,
DWORD register_type, UINT register_idx, BOOL has_rel_addr, BOOL pshader)
const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type)
{
switch (register_type)
switch (reg->type)
{
case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
if (pshader) reg_maps->texcoord[register_idx] = 1;
else reg_maps->address[register_idx] = 1;
if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx;
else reg_maps->address |= 1 << reg->idx;
break;
case WINED3DSPR_TEMP:
reg_maps->temporary[register_idx] = 1;
reg_maps->temporary |= 1 << reg->idx;
break;
case WINED3DSPR_INPUT:
if (!pshader) reg_maps->attributes[register_idx] = 1;
else
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
{
if (has_rel_addr)
if (reg->rel_addr)
{
/* If relative addressing is used, we must assume that all registers
* are used. Even if it is a construct like v3[aL], we can't assume
@ -276,84 +281,142 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct sh
}
else
{
((IWineD3DPixelShaderImpl *)This)->input_reg_used[register_idx] = TRUE;
((IWineD3DPixelShaderImpl *)This)->input_reg_used[reg->idx] = TRUE;
}
}
else reg_maps->input_registers |= 1 << reg->idx;
break;
case WINED3DSPR_RASTOUT:
if (register_idx == 1) reg_maps->fog = 1;
if (reg->idx == 1) reg_maps->fog = 1;
break;
case WINED3DSPR_MISCTYPE:
if (pshader && register_idx == 0) reg_maps->vpos = 1;
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
{
if (reg->idx == 0) reg_maps->vpos = 1;
else if (reg->idx == 1) reg_maps->usesfacing = 1;
}
break;
case WINED3DSPR_CONST:
if (has_rel_addr)
if (reg->rel_addr)
{
if (!pshader)
if (shader_type != WINED3D_SHADER_TYPE_PIXEL)
{
if (register_idx <= ((IWineD3DVertexShaderImpl *)This)->min_rel_offset)
((IWineD3DVertexShaderImpl *)This)->min_rel_offset = register_idx;
else if (register_idx >= ((IWineD3DVertexShaderImpl *)This)->max_rel_offset)
((IWineD3DVertexShaderImpl *)This)->max_rel_offset = register_idx;
if (reg->idx < ((IWineD3DVertexShaderImpl *)This)->min_rel_offset)
{
((IWineD3DVertexShaderImpl *)This)->min_rel_offset = reg->idx;
}
if (reg->idx > ((IWineD3DVertexShaderImpl *)This)->max_rel_offset)
{
((IWineD3DVertexShaderImpl *)This)->max_rel_offset = reg->idx;
}
}
reg_maps->usesrelconstF = TRUE;
}
else
{
set_bitmap_bit(reg_maps->constf, register_idx);
set_bitmap_bit(reg_maps->constf, reg->idx);
}
break;
case WINED3DSPR_CONSTINT:
reg_maps->integer_constants |= (1 << register_idx);
reg_maps->integer_constants |= (1 << reg->idx);
break;
case WINED3DSPR_CONSTBOOL:
reg_maps->boolean_constants |= (1 << register_idx);
reg_maps->boolean_constants |= (1 << reg->idx);
break;
case WINED3DSPR_COLOROUT:
reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx);
break;
default:
TRACE("Not recording register of type %#x and idx %u\n", register_type, register_idx);
TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx);
break;
}
}
static unsigned char get_instr_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, int param)
static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
{
switch(instr)
{
case WINED3DSIH_M4x4:
case WINED3DSIH_M3x4:
return param == 1 ? 4 : 1;
return param == 1 ? 3 : 0;
case WINED3DSIH_M4x3:
case WINED3DSIH_M3x3:
return param == 1 ? 3 : 1;
return param == 1 ? 2 : 0;
case WINED3DSIH_M3x2:
return param == 1 ? 2 : 1;
return param == 1 ? 1 : 0;
default:
return 1;
return 0;
}
}
static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage)
{
static const char *semantic_names[] =
{
/* WINED3DDECLUSAGE_POSITION */ "SV_POSITION",
/* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT",
/* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES",
/* WINED3DDECLUSAGE_NORMAL */ "NORMAL",
/* WINED3DDECLUSAGE_PSIZE */ "PSIZE",
/* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD",
/* WINED3DDECLUSAGE_TANGENT */ "TANGENT",
/* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL",
/* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR",
/* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT",
/* WINED3DDECLUSAGE_COLOR */ "COLOR",
/* WINED3DDECLUSAGE_FOG */ "FOG",
/* WINED3DDECLUSAGE_DEPTH */ "DEPTH",
/* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE",
};
if (usage >= sizeof(semantic_names) / sizeof(*semantic_names))
{
FIXME("Unrecognized usage %#x\n", usage);
return "UNRECOGNIZED";
}
return semantic_names[usage];
}
BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage)
{
return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
}
static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e,
const struct wined3d_shader_semantic *s)
{
e->semantic_name = shader_semantic_name_from_usage(s->usage);
e->semantic_idx = s->usage_idx;
e->sysval_semantic = 0;
e->component_type = 0;
e->register_idx = s->reg.reg.idx;
e->mask = s->reg.write_mask;
}
/* Note that this does not count the loop register
* as an address register. */
HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
struct shader_reg_maps *reg_maps, struct wined3d_shader_semantic *semantics_in,
struct wined3d_shader_semantic *semantics_out, const DWORD *byte_code, DWORD constf_size)
struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes,
struct wined3d_shader_signature_element *input_signature,
struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size)
{
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
void *fe_data = This->baseShader.frontend_data;
struct wined3d_shader_version shader_version;
unsigned int cur_loop_depth = 0, max_loop_depth = 0;
const DWORD* pToken = byte_code;
char pshader;
/* There are some minor differences between pixel and vertex shaders */
@ -368,7 +431,6 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
fe->shader_read_header(fe_data, &pToken, &shader_version);
reg_maps->shader_version = shader_version;
pshader = shader_is_pshader_version(shader_version.type);
reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*reg_maps->constf) * ((constf_size + 31) / 32));
@ -410,15 +472,22 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
/* Vshader: mark attributes used
* Pshader: mark 3.0 input registers used, save token */
case WINED3DSPR_INPUT:
if (!pshader) reg_maps->attributes[semantic.reg.reg.idx] = 1;
else reg_maps->packed_input[semantic.reg.reg.idx] = 1;
semantics_in[semantic.reg.reg.idx] = semantic;
reg_maps->input_registers |= 1 << semantic.reg.reg.idx;
if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
{
attributes[semantic.reg.reg.idx].usage = semantic.usage;
attributes[semantic.reg.reg.idx].usage_idx = semantic.usage_idx;
}
else
{
shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic);
}
break;
/* Vshader: mark 3.0 output registers used, save token */
case WINED3DSPR_OUTPUT:
reg_maps->packed_output[semantic.reg.reg.idx] = 1;
semantics_out[semantic.reg.reg.idx] = semantic;
reg_maps->output_registers |= 1 << semantic.reg.reg.idx;
shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic);
if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1;
break;
@ -447,17 +516,17 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
pToken += 4;
/* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
if (shader_version.major == 1 && pshader)
if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
{
float *value = (float *) lconst->value;
if(value[0] < -1.0) value[0] = -1.0;
else if(value[0] > 1.0) value[0] = 1.0;
if(value[1] < -1.0) value[1] = -1.0;
else if(value[1] > 1.0) value[1] = 1.0;
if(value[2] < -1.0) value[2] = -1.0;
else if(value[2] > 1.0) value[2] = 1.0;
if(value[3] < -1.0) value[3] = -1.0;
else if(value[3] > 1.0) value[3] = 1.0;
if (value[0] < -1.0f) value[0] = -1.0f;
else if (value[0] > 1.0f) value[0] = 1.0f;
if (value[1] < -1.0f) value[1] = -1.0f;
else if (value[1] > 1.0f) value[1] = 1.0f;
if (value[2] < -1.0f) value[2] = -1.0f;
else if (value[2] > 1.0f) value[2] = 1.0f;
if (value[3] < -1.0f) value[3] = -1.0f;
else if (value[3] > 1.0f) value[3] = 1.0f;
}
list_add_head(&This->baseShader.constantsF, &lconst->entry);
@ -477,6 +546,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
pToken += 4;
list_add_head(&This->baseShader.constantsI, &lconst->entry);
reg_maps->local_int_consts |= (1 << dst.reg.idx);
}
else if (ins.handler_idx == WINED3DSIH_DEFB)
{
@ -493,6 +563,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
++pToken;
list_add_head(&This->baseShader.constantsB, &lconst->entry);
reg_maps->local_bool_consts |= (1 << dst.reg.idx);
}
/* If there's a loop in the shader */
else if (ins.handler_idx == WINED3DSIH_LOOP
@ -528,12 +599,13 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
struct wined3d_shader_src_param src, rel_addr;
fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
reg_maps->labels[src.reg.idx] = 1;
reg_maps->labels |= 1 << src.reg.idx;
}
/* Set texture, address, temporary registers */
else
{
int i, limit;
BOOL color0_mov = FALSE;
/* This will loop over all the registers and try to
* make a bitmask of the ones we're interested in.
@ -549,22 +621,49 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
shader_record_register_usage(This, reg_maps, &dst_param.reg, shader_version.type);
/* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and
* is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel
* shaders because TECRDOUT isn't used in them, but future register types might cause issues */
if (!pshader && shader_version.major < 3 && dst_param.reg.type == WINED3DSPR_TEXCRDOUT)
if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3
&& dst_param.reg.type == WINED3DSPR_TEXCRDOUT)
{
reg_maps->texcoord_mask[dst_param.reg.type] |= dst_param.write_mask;
reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask;
}
else
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
{
shader_record_register_usage(This, reg_maps, dst_param.reg.type,
dst_param.reg.idx, !!dst_param.reg.rel_addr, pshader);
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)This;
if(dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0)
{
/* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
* COLOROUT 0. If we know this in advance, the ARB shader backend can skip
* the mov and perform the sRGB write correction from the source register.
*
* However, if the mov is only partial, we can't do this, and if the write
* comes from an instruction other than MOV it is hard to do as well. If
* COLOROUT 0 is overwritten partially later, the marker is dropped again. */
ps->color0_mov = FALSE;
if (ins.handler_idx == WINED3DSIH_MOV)
{
/* Used later when the source register is read. */
color0_mov = TRUE;
}
}
/* Also drop the MOV marker if the source register is overwritten prior to the shader
* end
*/
else if(dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg)
{
ps->color0_mov = FALSE;
}
}
/* Declare 1.X samplers implicitly, based on the destination reg. number */
if (shader_version.major == 1
&& pshader /* Filter different instructions with the same enum values in VS */
&& (ins.handler_idx == WINED3DSIH_TEX
|| ins.handler_idx == WINED3DSIH_TEXBEM
|| ins.handler_idx == WINED3DSIH_TEXBEML
@ -587,16 +686,16 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
if (ins.handler_idx == WINED3DSIH_TEXBEM
|| ins.handler_idx == WINED3DSIH_TEXBEML)
{
reg_maps->bumpmat[sampler_code] = TRUE;
reg_maps->bumpmat |= 1 << dst_param.reg.idx;
if (ins.handler_idx == WINED3DSIH_TEXBEML)
{
reg_maps->luminanceparams[sampler_code] = TRUE;
reg_maps->luminanceparams |= 1 << dst_param.reg.idx;
}
}
}
else if (pshader && ins.handler_idx == WINED3DSIH_BEM)
else if (ins.handler_idx == WINED3DSIH_BEM)
{
reg_maps->bumpmat[dst_param.reg.idx] = TRUE;
reg_maps->bumpmat |= 1 << dst_param.reg.idx;
}
}
@ -608,45 +707,77 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
{
reg_maps->usesdsy = 1;
}
else if (ins.handler_idx == WINED3DSIH_DSX)
{
reg_maps->usesdsx = 1;
}
else if(ins.handler_idx == WINED3DSIH_TEXLDD)
{
reg_maps->usestexldd = 1;
}
else if(ins.handler_idx == WINED3DSIH_TEXLDL)
{
reg_maps->usestexldl = 1;
}
else if(ins.handler_idx == WINED3DSIH_MOVA)
{
reg_maps->usesmova = 1;
}
else if(ins.handler_idx == WINED3DSIH_IFC)
{
reg_maps->usesifc = 1;
}
else if(ins.handler_idx == WINED3DSIH_CALL)
{
reg_maps->usescall = 1;
}
limit = ins.src_count + (ins.predicate ? 1 : 0);
for (i = 0; i < limit; ++i)
{
struct wined3d_shader_src_param src_param, src_rel_addr;
unsigned int count;
fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
switch(get_instr_regcount(ins.handler_idx, i))
count = get_instr_extra_regcount(ins.handler_idx, i);
shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type);
while (count)
{
case 4:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx + 3, !!src_param.reg.rel_addr, pshader);
/* drop through */
case 3:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx + 2, !!src_param.reg.rel_addr, pshader);
/* drop through */
case 2:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx + 1, !!src_param.reg.rel_addr, pshader);
/* drop through */
case 1:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx, !!src_param.reg.rel_addr, pshader);
++src_param.reg.idx;
shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type);
--count;
}
if(color0_mov)
{
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This;
if(src_param.reg.type == WINED3DSPR_TEMP &&
src_param.swizzle == WINED3DSP_NOSWIZZLE)
{
ps->color0_mov = TRUE;
ps->color0_reg = src_param.reg.idx;
}
}
}
}
}
reg_maps->loop_depth = max_loop_depth;
This->baseShader.functionLength = ((char *)pToken - (char *)byte_code);
This->baseShader.functionLength = ((const char *)pToken - (const char *)byte_code);
return WINED3D_OK;
}
unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max)
{
DWORD map = 1 << max;
map |= map - 1;
map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
return wined3d_log2i(map);
}
static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic,
const struct wined3d_shader_version *shader_version)
{
@ -665,7 +796,7 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti
else
{
/* Pixel shaders 3.0 don't have usage semantics */
if (shader_is_pshader_version(shader_version->type) && shader_version->major < 3)
if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL)
return;
else
TRACE("_");
@ -721,15 +852,14 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti
}
}
static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx,
enum wined3d_immconst_type immconst_type, const DWORD *immconst_data,
const struct wined3d_shader_src_param *rel_addr, const struct wined3d_shader_version *shader_version)
static void shader_dump_register(const struct wined3d_shader_register *reg,
const struct wined3d_shader_version *shader_version)
{
static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
static const char * const misctype_reg_names[] = {"vPos", "vFace"};
UINT offset = register_idx;
UINT offset = reg->idx;
switch (register_type)
switch (reg->type)
{
case WINED3DSPR_TEMP:
TRACE("r");
@ -744,15 +874,15 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type
case WINED3DSPR_CONST3:
case WINED3DSPR_CONST4:
TRACE("c");
offset = shader_get_float_offset(register_type, register_idx);
offset = shader_get_float_offset(reg->type, reg->idx);
break;
case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
TRACE("%c", shader_is_pshader_version(shader_version->type) ? 't' : 'a');
TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a');
break;
case WINED3DSPR_RASTOUT:
TRACE("%s", rastout_reg_names[register_idx]);
TRACE("%s", rastout_reg_names[reg->idx]);
break;
case WINED3DSPR_COLOROUT:
@ -795,8 +925,8 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type
break;
case WINED3DSPR_MISCTYPE:
if (register_idx > 1) FIXME("Unhandled misctype register %d\n", register_idx);
else TRACE("%s", misctype_reg_names[register_idx]);
if (reg->idx > 1) FIXME("Unhandled misctype register %d\n", reg->idx);
else TRACE("%s", misctype_reg_names[reg->idx]);
break;
case WINED3DSPR_PREDICATE:
@ -807,42 +937,59 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type
TRACE("l");
break;
case WINED3DSPR_CONSTBUFFER:
TRACE("cb");
break;
default:
TRACE("unhandled_rtype(%#x)", register_type);
TRACE("unhandled_rtype(%#x)", reg->type);
break;
}
if (register_type == WINED3DSPR_IMMCONST)
if (reg->type == WINED3DSPR_IMMCONST)
{
TRACE("(");
switch (immconst_type)
switch (reg->immconst_type)
{
case WINED3D_IMMCONST_FLOAT:
TRACE("%.8e", *(float *)immconst_data);
TRACE("%.8e", *(const float *)reg->immconst_data);
break;
case WINED3D_IMMCONST_FLOAT4:
TRACE("%.8e, %.8e, %.8e, %.8e",
*(float *)&immconst_data[0], *(float *)&immconst_data[1],
*(float *)&immconst_data[2], *(float *)&immconst_data[3]);
*(const float *)&reg->immconst_data[0], *(const float *)&reg->immconst_data[1],
*(const float *)&reg->immconst_data[2], *(const float *)&reg->immconst_data[3]);
break;
default:
TRACE("<unhandled immconst_type %#x>", immconst_type);
TRACE("<unhandled immconst_type %#x>", reg->immconst_type);
break;
}
TRACE(")");
}
else if (register_type != WINED3DSPR_RASTOUT && register_type != WINED3DSPR_MISCTYPE)
else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE)
{
if (rel_addr)
if (reg->array_idx != ~0U)
{
TRACE("[");
shader_dump_src_param(rel_addr, shader_version);
TRACE(" + ");
TRACE("%u[%u", offset, reg->array_idx);
if (reg->rel_addr)
{
TRACE(" + ");
shader_dump_src_param(reg->rel_addr, shader_version);
}
TRACE("]");
}
else
{
if (reg->rel_addr)
{
TRACE("[");
shader_dump_src_param(reg->rel_addr, shader_version);
TRACE(" + ");
}
TRACE("%u", offset);
if (reg->rel_addr) TRACE("]");
}
TRACE("%u", offset);
if (rel_addr) TRACE("]");
}
}
@ -851,7 +998,7 @@ void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
{
DWORD write_mask = param->write_mask;
shader_dump_register(param->reg.type, param->reg.idx, 0, NULL, param->reg.rel_addr, shader_version);
shader_dump_register(&param->reg, shader_version);
if (write_mask != WINED3DSP_WRITEMASK_ALL)
{
@ -885,8 +1032,7 @@ void shader_dump_src_param(const struct wined3d_shader_src_param *param,
if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
TRACE("abs(");
shader_dump_register(param->reg.type, param->reg.idx, param->reg.immconst_type,
param->reg.immconst_data, param->reg.rel_addr, shader_version);
shader_dump_register(&param->reg, shader_version);
if (src_modifier)
{
@ -935,12 +1081,11 @@ void shader_dump_src_param(const struct wined3d_shader_src_param *param,
/* Shared code in order to generate the bulk of the shader string.
* NOTE: A description of how to parse tokens can be found on msdn */
void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
const shader_reg_maps *reg_maps, const DWORD *pFunction)
void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx)
{
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
const struct wined3d_shader_frontend *fe = This->baseShader.frontend;
void *fe_data = This->baseShader.frontend_data;
struct wined3d_shader_src_param src_rel_addr[4];
@ -951,13 +1096,13 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
struct wined3d_shader_instruction ins;
struct wined3d_shader_context ctx;
const DWORD *pToken = pFunction;
SHADER_HANDLER hw_fct;
DWORD i;
/* Initialize current parsing state */
ctx.shader = iface;
ctx.reg_maps = reg_maps;
ctx.buffer = buffer;
ctx.backend_data = backend_ctx;
ins.ctx = &ctx;
ins.dst = &dst_param;
@ -992,24 +1137,12 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
|| ins.handler_idx == WINED3DSIH_DEF
|| ins.handler_idx == WINED3DSIH_DEFI
|| ins.handler_idx == WINED3DSIH_DEFB
|| ins.handler_idx == WINED3DSIH_PHASE
|| ins.handler_idx == WINED3DSIH_RET)
|| ins.handler_idx == WINED3DSIH_PHASE)
{
pToken += param_size;
continue;
}
/* Select handler */
hw_fct = handler_table[ins.handler_idx];
/* Unhandled opcode */
if (!hw_fct)
{
FIXME("Backend can't handle opcode %#x\n", ins.handler_idx);
pToken += param_size;
continue;
}
/* Destination token */
if (ins.dst_count) fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
@ -1023,10 +1156,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
}
/* Call appropriate function for output target */
hw_fct(&ins);
/* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
device->shader_backend->shader_add_instruction_modifiers(&ins);
device->shader_backend->shader_handle_instruction(&ins);
}
}
@ -1059,14 +1189,34 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data,
{
struct wined3d_shader_version shader_version;
const DWORD* pToken = pFunction;
const char *type_prefix;
DWORD i;
TRACE("Parsing %p\n", pFunction);
fe->shader_read_header(fe_data, &pToken, &shader_version);
TRACE("%s_%u_%u\n", shader_is_pshader_version(shader_version.type) ? "ps": "vs",
shader_version.major, shader_version.minor);
switch (shader_version.type)
{
case WINED3D_SHADER_TYPE_VERTEX:
type_prefix = "vs";
break;
case WINED3D_SHADER_TYPE_GEOMETRY:
type_prefix = "gs";
break;
case WINED3D_SHADER_TYPE_PIXEL:
type_prefix = "ps";
break;
default:
FIXME("Unhandled shader type %#x.\n", shader_version.type);
type_prefix = "unknown";
break;
}
TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor);
while (!fe->shader_is_end(fe_data, &pToken))
{
@ -1224,39 +1374,27 @@ void shader_cleanup(IWineD3DBaseShader *iface)
}
}
static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0};
static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {}
static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {}
static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {}
static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {}
static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {}
static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
static void shader_none_destroy(IWineD3DBaseShader *iface) {}
static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
static void shader_none_free(IWineD3DDevice *iface) {}
static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
static GLuint shader_none_generate_pshader(IWineD3DPixelShader *iface,
SHADER_BUFFER *buffer, const struct ps_compile_args *args)
{
FIXME("NONE shader backend asked to generate a pixel shader\n");
return 0;
}
static GLuint shader_none_generate_vshader(IWineD3DVertexShader *iface,
SHADER_BUFFER *buffer, const struct vs_compile_args *args)
{
FIXME("NONE shader backend asked to generate a vertex shader\n");
return 0;
}
static void shader_none_add_instruction_modifiers(const struct wined3d_shader_instruction *ins) {}
#define GLINFO_LOCATION (*gl_info)
static void shader_none_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps)
static void shader_none_get_caps(WINED3DDEVTYPE devtype,
const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
{
/* Set the shader caps to 0 for the none shader backend */
pCaps->VertexShaderVersion = 0;
pCaps->PixelShaderVersion = 0;
pCaps->PixelShader1xMaxValue = 0.0;
pCaps->PixelShader1xMaxValue = 0.0f;
}
#undef GLINFO_LOCATION
static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
@ -1279,7 +1417,7 @@ static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
}
const shader_backend_t none_shader_backend = {
shader_none_instruction_handler_table,
shader_none_handle_instruction,
shader_none_select,
shader_none_select_depth_blt,
shader_none_deselect_depth_blt,
@ -1291,9 +1429,6 @@ const shader_backend_t none_shader_backend = {
shader_none_alloc,
shader_none_free,
shader_none_dirty_const,
shader_none_generate_pshader,
shader_none_generate_vshader,
shader_none_get_caps,
shader_none_color_fixup_supported,
shader_none_add_instruction_modifiers,
};

View file

@ -27,32 +27,44 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
void basetexture_init(struct IWineD3DBaseTextureClass *texture, UINT levels, DWORD usage)
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
WINED3DPOOL pool, IUnknown *parent)
{
texture->levels = levels;
texture->filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
texture->LOD = 0;
texture->dirty = TRUE;
texture->srgbDirty = TRUE;
texture->is_srgb = FALSE;
texture->pow2Matrix_identity = TRUE;
HRESULT hr;
hr = resource_init((IWineD3DResource *)texture, resource_type, device, size, usage, format_desc, pool, parent);
if (FAILED(hr))
{
WARN("Failed to initialize resource, returning %#x\n", hr);
return hr;
}
texture->baseTexture.levels = levels;
texture->baseTexture.filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
texture->baseTexture.LOD = 0;
texture->baseTexture.dirty = TRUE;
texture->baseTexture.srgbDirty = TRUE;
texture->baseTexture.is_srgb = FALSE;
texture->baseTexture.pow2Matrix_identity = TRUE;
if (texture->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
{
texture->baseTexture.minMipLookup = minMipLookup;
texture->baseTexture.magLookup = magLookup;
}
else
{
texture->baseTexture.minMipLookup = minMipLookup_noFilter;
texture->baseTexture.magLookup = magLookup_noFilter;
}
return WINED3D_OK;
}
void basetexture_cleanup(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
TRACE("(%p) : textureName(%d)\n", This, This->baseTexture.textureName);
if (This->baseTexture.textureName != 0) {
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
TRACE("(%p) : Deleting texture %d\n", This, This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.srgbTextureName);
LEAVE_GL();
}
basetexture_unload(iface);
resource_cleanup((IWineD3DResource *)iface);
}
@ -62,11 +74,17 @@ void basetexture_unload(IWineD3DBaseTexture *iface)
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
if(This->baseTexture.textureName) {
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
glDeleteTextures(1, &This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.srgbTextureName);
This->baseTexture.textureName = 0;
LEAVE_GL();
}
if(This->baseTexture.srgbTextureName) {
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
glDeleteTextures(1, &This->baseTexture.srgbTextureName);
This->baseTexture.srgbTextureName = 0;
LEAVE_GL();
}
@ -74,33 +92,41 @@ void basetexture_unload(IWineD3DBaseTexture *iface)
This->baseTexture.srgbDirty = TRUE;
}
/* There is no OpenGL equivalent of setLOD, getLOD. All they do anyway is prioritize texture loading
* so just pretend that they work unless something really needs a failure. */
DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
DWORD old = This->baseTexture.LOD;
/* The d3d9:texture test shows that SetLOD is ignored on non-managed
* textures. The call always returns 0, and GetLOD always returns 0
*/
if (This->resource.pool != WINED3DPOOL_MANAGED) {
return WINED3DERR_INVALIDCALL;
TRACE("Ignoring SetLOD on %s texture, returning 0\n", debug_d3dpool(This->resource.pool));
return 0;
}
if(LODNew >= This->baseTexture.levels)
LODNew = This->baseTexture.levels - 1;
This->baseTexture.LOD = LODNew;
TRACE("(%p) : set bogus LOD to %d\n", This, This->baseTexture.LOD);
if(This->baseTexture.LOD != LODNew) {
This->baseTexture.LOD = LODNew;
return This->baseTexture.LOD;
This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
This->baseTexture.srgbstates[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
if(This->baseTexture.bindCount) {
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(This->baseTexture.sampler));
}
}
TRACE("(%p) : set LOD to %d\n", This, This->baseTexture.LOD);
return old;
}
DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
if (This->resource.pool != WINED3DPOOL_MANAGED) {
return WINED3DERR_INVALIDCALL;
}
TRACE("(%p) : returning %d\n", This, This->baseTexture.LOD);
return This->baseTexture.LOD;
@ -128,7 +154,7 @@ HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DT
* Or should we delay the applying until the texture is used for drawing? For now, apply
* immediately.
*/
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
glBindTexture(textureDimensions, This->baseTexture.textureName);
checkGLcall("glBindTexture");
@ -158,12 +184,11 @@ HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DT
WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
return WINED3DTEXF_NONE;
}
return This->baseTexture.filterType;
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
return This->baseTexture.filterType;
}
void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface)
@ -190,6 +215,7 @@ BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
return This->baseTexture.dirty || This->baseTexture.srgbDirty;
}
/* Context activation is done by the caller. */
HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
@ -234,7 +260,7 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
states[WINED3DTEXSTA_MAXANISOTROPY] = 0;
states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
states[WINED3DTEXSTA_SRGBTEXTURE] = 0;
states[WINED3DTEXSTA_ELEMENTINDEX] = 0;
states[WINED3DTEXSTA_DMAPOFFSET] = 0;
@ -288,6 +314,7 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
return hr;
}
/* GL locking is done by the caller */
static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type,
BOOL cond_np2) {
GLint wrapParm;
@ -313,6 +340,7 @@ static inline void apply_wrap(const GLint textureDimensions, const DWORD state,
}
}
/* GL locking is done by the caller (state handler) */
void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1])
@ -321,6 +349,9 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
DWORD state, *states;
GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
BOOL cond_np2 = IWineD3DBaseTexture_IsCondNP2(iface);
DWORD aniso;
TRACE("iface %p, textureStates %p, samplerStates %p\n", iface, textureStates, samplerStates);
if(This->baseTexture.is_srgb) {
states = This->baseTexture.srgbstates;
@ -328,7 +359,7 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
states = This->baseTexture.states;
}
/* ApplyStateChanges relies on the correct texture being bound and loaded. */
/* This function relies on the correct texture being bound and loaded. */
if(samplerStates[WINED3DSAMP_ADDRESSU] != states[WINED3DTEXSTA_ADDRESSU]) {
state = samplerStates[WINED3DSAMP_ADDRESSU];
@ -364,17 +395,14 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
state = samplerStates[WINED3DSAMP_MAGFILTER];
if (state > WINED3DTEXF_ANISOTROPIC) {
FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
} else {
glValue = This->baseTexture.magLookup[state - WINED3DTEXF_NONE];
TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
/* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state &&
!cond_np2) {
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
}
states[WINED3DTEXSTA_MAGFILTER] = state;
}
glValue = wined3d_gl_mag_filter(This->baseTexture.magLookup,
min(max(state, WINED3DTEXF_POINT), WINED3DTEXF_LINEAR));
TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
states[WINED3DTEXSTA_MAGFILTER] = state;
}
if((samplerStates[WINED3DSAMP_MINFILTER] != states[WINED3DTEXSTA_MINFILTER] ||
@ -386,17 +414,17 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
if (states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC ||
states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_LINEAR)
if (states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
|| states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
{
FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
states[WINED3DTEXSTA_MINFILTER],
states[WINED3DTEXSTA_MIPFILTER]);
}
glValue = This->baseTexture.minMipLookup
[min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
.mip[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
glValue = wined3d_gl_min_mip_filter(This->baseTexture.minMipLookup,
min(max(samplerStates[WINED3DSAMP_MINFILTER], WINED3DTEXF_POINT), WINED3DTEXF_LINEAR),
min(max(samplerStates[WINED3DSAMP_MIPFILTER], WINED3DTEXF_NONE), WINED3DTEXF_LINEAR));
TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
samplerStates[WINED3DSAMP_MINFILTER],
@ -406,23 +434,46 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
if(!cond_np2) {
if(states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
glValue = 0;
glValue = This->baseTexture.LOD;
} else if(states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
glValue = This->baseTexture.levels - 1;
} else if(states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD) {
/* baseTexture.LOD is already clamped in the setter */
glValue = This->baseTexture.LOD;
} else {
glValue = states[WINED3DTEXSTA_MAXMIPLEVEL];
}
/* Note that D3DSAMP_MAXMIPLEVEL specifies the biggest mipmap(default 0), while
* GL_TEXTURE_MAX_LEVEL specifies the smallest mimap used(default 1000).
* So D3DSAMP_MAXMIPLEVEL is the same as GL_TEXTURE_BASE_LEVEL.
*/
glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
}
}
if(samplerStates[WINED3DSAMP_MAXANISOTROPY] != states[WINED3DTEXSTA_MAXANISOTROPY]) {
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && !cond_np2) {
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
} else {
WARN("Unsupported in local OpenGL implementation: glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT\n");
if ((states[WINED3DSAMP_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
&& states[WINED3DSAMP_MINFILTER] != WINED3DTEXF_ANISOTROPIC
&& states[WINED3DSAMP_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
|| cond_np2)
{
aniso = 1;
}
else
{
aniso = samplerStates[WINED3DSAMP_MAXANISOTROPY];
}
if (states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
{
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC))
{
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
checkGLcall("glTexParameteri(GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso)");
}
states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY];
else
{
WARN("Anisotropic filtering not supported.\n");
}
states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
}
}

View file

@ -34,16 +34,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define VB_MAXDECLCHANGES 100 /* After that number we stop converting */
#define VB_RESETDECLCHANGE 1000 /* Reset the changecount after that number of draws */
/* Context activation is done by the caller. */
static void buffer_create_buffer_object(struct wined3d_buffer *This)
{
GLenum error, gl_usage;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
TRACE("Creating an OpenGL vertex buffer object for IWineD3DVertexBuffer %p Usage(%s)\n",
This, debug_d3dusage(This->resource.usage));
/* Make sure that a context is there. Needed in a multithreaded environment. Otherwise this call is a nop */
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
/* Make sure that the gl error is cleared. Do not use checkGLcall
@ -200,17 +198,20 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
return ret;
}
static BOOL buffer_check_attribute(struct wined3d_buffer *This,
const struct wined3d_stream_info_element *attrib, const BOOL check_d3dcolor, const BOOL is_ffp_position,
const BOOL is_ffp_color, DWORD *stride_this_run, BOOL *float16_used)
static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct wined3d_stream_info *si,
UINT attrib_idx, const BOOL check_d3dcolor, const BOOL is_ffp_position, const BOOL is_ffp_color,
DWORD *stride_this_run, BOOL *float16_used)
{
const struct wined3d_stream_info_element *attrib = &si->elements[attrib_idx];
BOOL ret = FALSE;
WINED3DFORMAT format;
/* Ignore attributes that do not have our vbo. After that check we can be sure that the attribute is
* there, on nonexistent attribs the vbo is 0.
*/
if (attrib->buffer_object != This->buffer_object) return FALSE;
if (!(si->use_map & (1 << attrib_idx))
|| attrib->buffer_object != This->buffer_object)
return FALSE;
format = attrib->format_desc->format;
/* Look for newly appeared conversion */
@ -257,7 +258,7 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This,
{
WINED3DFORMAT format;
if (strided->elements[i].buffer_object != This->buffer_object) continue;
if (!(strided->use_map & (1 << i)) || strided->elements[i].buffer_object != This->buffer_object) continue;
format = strided->elements[i].format_desc->format;
if (format == WINED3DFMT_R16G16_FLOAT)
@ -308,6 +309,7 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This,
static BOOL buffer_find_decl(struct wined3d_buffer *This)
{
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
const struct wined3d_stream_info *si = &device->strided_streams;
UINT stride_this_run = 0;
BOOL float16_used = FALSE;
BOOL ret = FALSE;
@ -395,8 +397,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
}
for (i = 0; i < MAX_ATTRIBS; ++i)
{
ret = buffer_check_attribute(This, &device->strided_streams.elements[i],
FALSE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, si, i, FALSE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
}
/* Recalculate the conversion shift map if the declaration has changed,
@ -405,7 +406,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
if (ret && (float16_used || This->conversion_map))
{
HeapFree(GetProcessHeap(), 0, This->conversion_shift);
This->conversion_shift = find_conversion_shift(This, &device->strided_streams, This->stride);
This->conversion_shift = find_conversion_shift(This, si, This->stride);
}
}
else
@ -415,29 +416,29 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
* the attributes that our current fixed function pipeline implementation cares for.
*/
BOOL support_d3dcolor = GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA);
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_POSITION],
ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION,
TRUE, TRUE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_NORMAL],
ret = buffer_check_attribute(This, si, WINED3D_FFP_NORMAL,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_DIFFUSE],
ret = buffer_check_attribute(This, si, WINED3D_FFP_DIFFUSE,
!support_d3dcolor, FALSE, TRUE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_SPECULAR],
ret = buffer_check_attribute(This, si, WINED3D_FFP_SPECULAR,
!support_d3dcolor, FALSE, TRUE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD0],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD0,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD1],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD1,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD2],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD2,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD3],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD3,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD4],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD4,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD5],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD5,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD6],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD6,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD7],
ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD7,
TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
if (float16_used) FIXME("Float16 conversion used with fixed function vertex processing\n");
@ -457,6 +458,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
return ret;
}
/* Context activation is done by the caller. */
static void buffer_check_buffer_object_size(struct wined3d_buffer *This)
{
UINT size = This->conversion_stride ?
@ -506,29 +508,18 @@ static inline void fixup_d3dcolor(DWORD *dst_color)
static inline void fixup_transformed_pos(float *p)
{
float x, y, z, w;
/* rhw conversion like in drawStridedSlow */
if (p[3] == 1.0 || ((p[3] < eps) && (p[3] > -eps)))
/* rhw conversion like in position_float4(). */
if (p[3] != 1.0f && p[3] != 0.0f)
{
x = p[0];
y = p[1];
z = p[2];
w = 1.0;
float w = 1.0f / p[3];
p[0] *= w;
p[1] *= w;
p[2] *= w;
p[3] = w;
}
else
{
w = 1.0 / p[3];
x = p[0] * w;
y = p[1] * w;
z = p[2] * w;
}
p[0] = x;
p[1] = y;
p[2] = z;
p[3] = w;
}
/* Context activation is done by the caller. */
const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object)
{
struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
@ -588,7 +579,8 @@ static ULONG STDMETHODCALLTYPE buffer_AddRef(IWineD3DBuffer *iface)
return refcount;
}
const BYTE *buffer_get_sysmem(struct wined3d_buffer *This)
/* Context activation is done by the caller. */
BYTE *buffer_get_sysmem(struct wined3d_buffer *This)
{
/* AllocatedMemory exists if the buffer is double buffered or has no buffer object at all */
if(This->resource.allocatedMemory) return This->resource.allocatedMemory;
@ -614,7 +606,7 @@ static void STDMETHODCALLTYPE buffer_UnLoad(IWineD3DBuffer *iface)
{
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
/* Download the buffer, but don't permanently enable double buffering */
if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER))
@ -701,6 +693,8 @@ static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
TRACE("iface %p\n", iface);
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
if (!This->buffer_object)
{
/* TODO: Make converting independent from VBOs */
@ -736,7 +730,7 @@ static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
if (This->conversion_count > VB_MAXDECLCHANGES)
{
FIXME("Too many declaration changes, stopping converting\n");
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
GL_EXTCALL(glDeleteBuffersARB(1, &This->buffer_object));
checkGLcall("glDeleteBuffersARB");
@ -809,7 +803,7 @@ static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
if (!device->isInDraw)
{
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
}
ENTER_GL();
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
@ -959,7 +953,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset,
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_INDEXBUFFER);
}
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB));
@ -985,6 +979,16 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
TRACE("(%p)\n", This);
/* In the case that the number of Unmap calls > the
* number of Map calls, d3d returns always D3D_OK.
* This is also needed to prevent Map from returning garbage on
* the next call (this will happen if the lock_count is < 0). */
if(This->lock_count == 0)
{
TRACE("Unmap called without a previous Map call!\n");
return WINED3D_OK;
}
if (InterlockedDecrement(&This->lock_count))
{
/* Delay loading the buffer until everything is unlocked */
@ -1001,7 +1005,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_INDEXBUFFER);
}
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));

File diff suppressed because it is too large Load diff

View file

@ -25,11 +25,241 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
#define GLINFO_LOCATION (*gl_info)
static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource Preload method. */
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
unsigned int i, j;
BOOL srgb_mode;
BOOL *dirty;
switch (srgb)
{
case SRGB_RGB:
srgb_mode = FALSE;
break;
case SRGB_BOTH:
cubetexture_internal_preload(iface, SRGB_RGB);
/* Fallthrough */
case SRGB_SRGB:
srgb_mode = TRUE;
break;
default:
srgb_mode = This->baseTexture.is_srgb;
break;
}
dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
TRACE("(%p) : About to load texture: dirtified(%u).\n", This, *dirty);
/* We only have to activate a context for gl when we're not drawing.
* In most cases PreLoad will be called during draw and a context was
* activated at the beginning of drawPrimitive. */
if (!device->isInDraw)
{
/* No danger of recursive calls, ActivateContext sets isInDraw to true
* when loading offscreen render targets into their texture. */
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
}
if (This->resource.format_desc->format == WINED3DFMT_P8
|| This->resource.format_desc->format == WINED3DFMT_A8P8)
{
for (i = 0; i < This->baseTexture.levels; ++i)
{
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j)
{
if (palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[j][i]))
{
TRACE("Reloading surface because the d3d8/9 palette was changed.\n");
/* TODO: This is not necessarily needed with hw palettized texture support. */
IWineD3DSurface_LoadLocation(This->surfaces[j][i], SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change,
* this kills performance though :( */
IWineD3DSurface_ModifyLocation(This->surfaces[j][i], SFLAG_INTEXTURE, FALSE);
}
}
}
}
/* If the texture is marked dirty or the srgb sampler setting has changed
* since the last load then reload the surfaces. */
if (*dirty)
{
for (i = 0; i < This->baseTexture.levels; ++i)
{
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j)
{
IWineD3DSurface_LoadTexture(This->surfaces[j][i], srgb_mode);
}
}
}
else
{
TRACE("(%p) Texture not dirty, nothing to do.\n" , iface);
}
/* No longer dirty. */
*dirty = FALSE;
}
static void cubetexture_cleanup(IWineD3DCubeTextureImpl *This, D3DCB_DESTROYSURFACEFN surface_destroy_cb)
{
unsigned int i, j;
TRACE("(%p) : Cleaning up.\n", This);
for (i = 0; i < This->baseTexture.levels; ++i)
{
for (j = 0; j < 6; ++j)
{
IWineD3DSurface *surface = This->surfaces[j][i];
if (surface)
{
/* Clean out the texture name we gave to the surface so that the
* surface doesn't try and release it. */
surface_set_texture_name(surface, 0, TRUE);
surface_set_texture_name(surface, 0, FALSE);
surface_set_texture_target(surface, 0);
IWineD3DSurface_SetContainer(surface, NULL);
surface_destroy_cb(surface);
}
}
}
basetexture_cleanup((IWineD3DBaseTexture *)This);
}
HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
UINT pow2_edge_length;
unsigned int i, j;
UINT tmp_w;
HRESULT hr;
/* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
if (WINED3DFMT_UNKNOWN >= format)
{
WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
return WINED3DERR_INVALIDCALL;
}
if (!GL_SUPPORT(ARB_TEXTURE_CUBE_MAP) && pool != WINED3DPOOL_SCRATCH)
{
WARN("(%p) : Tried to create not supported cube texture.\n", texture);
return WINED3DERR_INVALIDCALL;
}
/* Calculate levels for mip mapping */
if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
{
WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (levels > 1)
{
WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
levels = 1;
}
else if (!levels)
{
levels = wined3d_log2i(edge_length) + 1;
TRACE("Calculated levels = %u.\n", levels);
}
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
WINED3DRTYPE_CUBETEXTURE, device, 0, usage, format_desc, pool, parent);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x\n", hr);
return hr;
}
/* Find the nearest pow2 match. */
pow2_edge_length = 1;
while (pow2_edge_length < edge_length) pow2_edge_length <<= 1;
if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || (edge_length == pow2_edge_length))
{
/* Precalculated scaling for 'faked' non power of two texture coords. */
texture->baseTexture.pow2Matrix[0] = 1.0f;
texture->baseTexture.pow2Matrix[5] = 1.0f;
texture->baseTexture.pow2Matrix[10] = 1.0f;
texture->baseTexture.pow2Matrix[15] = 1.0f;
}
else
{
/* Precalculated scaling for 'faked' non power of two texture coords. */
texture->baseTexture.pow2Matrix[0] = ((float)edge_length) / ((float)pow2_edge_length);
texture->baseTexture.pow2Matrix[5] = ((float)edge_length) / ((float)pow2_edge_length);
texture->baseTexture.pow2Matrix[10] = ((float)edge_length) / ((float)pow2_edge_length);
texture->baseTexture.pow2Matrix[15] = 1.0f;
texture->baseTexture.pow2Matrix_identity = FALSE;
}
/* Generate all the surfaces. */
tmp_w = edge_length;
for (i = 0; i < texture->baseTexture.levels; ++i)
{
/* Create the 6 faces. */
for (j = 0; j < 6; ++j)
{
static const GLenum cube_targets[6] =
{
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
};
hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
format, usage, pool, i /* Level */, j, &texture->surfaces[j][i]);
if (FAILED(hr))
{
FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
texture->surfaces[j][i] = NULL;
cubetexture_cleanup(texture, D3DCB_DefaultDestroySurface);
return hr;
}
IWineD3DSurface_SetContainer(texture->surfaces[j][i], (IWineD3DBase *)texture);
TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[j][i]);
surface_set_texture_target(texture->surfaces[j][i], cube_targets[j]);
}
tmp_w = max(1, tmp_w >> 1);
}
texture->baseTexture.internal_preload = cubetexture_internal_preload;
return WINED3D_OK;
}
#undef GLINFO_LOCATION
/* *******************************************
IWineD3DCubeTexture IUnknown parts follow
******************************************* */
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static HRESULT WINAPI IWineD3DCubeTextureImpl_QueryInterface(IWineD3DCubeTexture *iface, REFIID riid, LPVOID *ppobj)
{
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
@ -91,65 +321,6 @@ static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *ifa
return resource_get_priority((IWineD3DResource *)iface);
}
void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb) {
/* Override the IWineD3DResource Preload method */
unsigned int i,j;
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL srgb_mode;
BOOL *dirty;
switch(srgb) {
case SRGB_RGB: srgb_mode = FALSE; break;
case SRGB_BOTH: cubetexture_internal_preload(iface, SRGB_RGB);
case SRGB_SRGB: srgb_mode = TRUE; break;
/* DONTKNOW, and shut up the compiler */
default: srgb_mode = This->baseTexture.is_srgb; break;
}
dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, *dirty);
/* We only have to activate a context for gl when we're not drawing. In most cases PreLoad will be called during draw
* and a context was activated at the beginning of drawPrimitive
*/
if(!device->isInDraw) {
/* No danger of recursive calls, ActivateContext sets isInDraw to true when loading
* offscreen render targets into their texture
*/
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
}
if (This->resource.format_desc->format == WINED3DFMT_P8 || This->resource.format_desc->format == WINED3DFMT_A8P8)
{
for (i = 0; i < This->baseTexture.levels; i++) {
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
if(palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[j][i])) {
TRACE("Reloading surface because the d3d8/9 palette was changed\n");
/* TODO: This is not necessarily needed with hw palettized texture support */
IWineD3DSurface_LoadLocation(This->surfaces[j][i], SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
IWineD3DSurface_ModifyLocation(This->surfaces[j][i], SFLAG_INTEXTURE, FALSE);
}
}
}
}
/* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */
if (*dirty) {
for (i = 0; i < This->baseTexture.levels; i++) {
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
IWineD3DSurface_LoadTexture(This->surfaces[j][i], srgb_mode);
}
}
} else {
TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
}
/* No longer dirty */
*dirty = FALSE;
return;
}
static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
cubetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
@ -219,6 +390,7 @@ static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface)
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
/* Context activation is done by the caller. */
static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface, BOOL srgb) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
BOOL set_gl_texture_desc;
@ -257,36 +429,13 @@ static BOOL WINAPI IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture *iface)
return FALSE;
}
static void WINAPI IWineD3DCubeTextureImpl_ApplyStateChanges(IWineD3DCubeTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
TRACE("(%p) : relay to BaseTexture\n", iface);
basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
}
/* *******************************************
IWineD3DCubeTexture IWineD3DCubeTexture parts follow
******************************************* */
static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroySurface) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
unsigned int i,j;
TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) {
for (j = 0; j < 6; j++) {
if (This->surfaces[j][i] != NULL) {
IWineD3DSurface *surface = This->surfaces[j][i];
/* Clean out the texture name we gave to the surface so that the surface doesn't try and release it */
surface_set_texture_name(surface, 0, TRUE);
surface_set_texture_name(surface, 0, FALSE);
surface_set_texture_target(surface, 0);
/* Cleanup the container */
IWineD3DSurface_SetContainer(This->surfaces[j][i], 0);
D3DCB_DestroySurface(This->surfaces[j][i]);
}
}
}
basetexture_cleanup((IWineD3DBaseTexture *)iface);
cubetexture_cleanup(This, D3DCB_DestroySurface);
/* finally delete the object */
HeapFree(GetProcessHeap(), 0, This);
}
@ -399,7 +548,6 @@ const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
IWineD3DCubeTextureImpl_BindTexture,
IWineD3DCubeTextureImpl_GetTextureDimensions,
IWineD3DCubeTextureImpl_IsCondNP2,
IWineD3DCubeTextureImpl_ApplyStateChanges,
/* IWineD3DCubeTexture */
IWineD3DCubeTextureImpl_Destroy,
IWineD3DCubeTextureImpl_GetLevelDesc,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
#include <stdio.h>
#include <math.h>
/* GL locking is done by the caller */
static void drawStridedFast(IWineD3DDevice *iface, GLenum primitive_type,
UINT min_vertex_idx, UINT max_vertex_idx, UINT count, UINT idx_size,
const void *idx_data, UINT start_idx)
@ -68,8 +69,10 @@ static void drawStridedFast(IWineD3DDevice *iface, GLenum primitive_type,
* Slower GL version which extracts info about each vertex in turn
*/
static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_info *si, UINT NumVertexes,
GLenum glPrimType, const void *idxData, UINT idxSize, UINT minIndex, UINT startIdx)
/* GL locking is done by the caller */
static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context *context,
const struct wined3d_stream_info *si, UINT NumVertexes, GLenum glPrimType,
const void *idxData, UINT idxSize, UINT minIndex, UINT startIdx)
{
unsigned int textureNo = 0;
const WORD *pIdxBufS = NULL;
@ -84,6 +87,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
const BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
const struct wined3d_stream_info_element *element;
UINT num_untracked_materials;
DWORD tex_mask = 0;
TRACE("Using slow vertex array code\n");
@ -109,22 +113,38 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
VTRACE(("glBegin(%x)\n", glPrimType));
glBegin(glPrimType);
element = &si->elements[WINED3D_FFP_POSITION];
if (element->data) position = element->data + streamOffset[element->stream_idx];
if (si->use_map & (1 << WINED3D_FFP_POSITION))
{
element = &si->elements[WINED3D_FFP_POSITION];
position = element->data + streamOffset[element->stream_idx];
}
element = &si->elements[WINED3D_FFP_NORMAL];
if (element->data) normal = element->data + streamOffset[element->stream_idx];
else glNormal3f(0, 0, 0);
if (si->use_map & (1 << WINED3D_FFP_NORMAL))
{
element = &si->elements[WINED3D_FFP_NORMAL];
normal = element->data + streamOffset[element->stream_idx];
}
else
{
glNormal3f(0, 0, 0);
}
element = &si->elements[WINED3D_FFP_DIFFUSE];
if (element->data) diffuse = element->data + streamOffset[element->stream_idx];
else glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (This->activeContext->num_untracked_materials && element->format_desc->format != WINED3DFMT_A8R8G8B8)
if (si->use_map & (1 << WINED3D_FFP_DIFFUSE))
{
element = &si->elements[WINED3D_FFP_DIFFUSE];
diffuse = element->data + streamOffset[element->stream_idx];
}
else
{
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
num_untracked_materials = context->num_untracked_materials;
if (num_untracked_materials && element->format_desc->format != WINED3DFMT_A8R8G8B8)
FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->format_desc->format));
element = &si->elements[WINED3D_FFP_SPECULAR];
if (element->data)
if (si->use_map & (1 << WINED3D_FFP_SPECULAR))
{
element = &si->elements[WINED3D_FFP_SPECULAR];
specular = element->data + streamOffset[element->stream_idx];
/* special case where the fog density is stored in the specular alpha channel */
@ -159,7 +179,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
for (textureNo = 0; textureNo < texture_stages; ++textureNo)
{
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
int texture_idx = This->texUnitMap[textureNo];
DWORD texture_idx = This->texUnitMap[textureNo];
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0)
{
@ -169,7 +189,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;
if (texture_idx == -1) continue;
if (texture_idx == WINED3D_UNMAPPED_STAGE) continue;
if (coordIdx > 7)
{
@ -182,9 +202,9 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
continue;
}
element = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
if (element->data)
if (si->use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx)))
{
element = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
texCoords[coordIdx] = element->data + streamOffset[element->stream_idx];
tex_mask |= (1 << textureNo);
}
@ -227,7 +247,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
{
int coord_idx;
const void *ptr;
int texture_idx;
DWORD texture_idx;
if (!(tmp_tex_mask & 1)) continue;
@ -244,18 +264,20 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
const void *ptrToCoords = diffuse + SkipnStrides * si->elements[WINED3D_FFP_DIFFUSE].stride;
diffuse_funcs[si->elements[WINED3D_FFP_DIFFUSE].format_desc->emit_idx](ptrToCoords);
if(This->activeContext->num_untracked_materials) {
if (num_untracked_materials)
{
DWORD diffuseColor = ((const DWORD *)ptrToCoords)[0];
unsigned char i;
float color[4];
color[0] = D3DCOLOR_B_R(diffuseColor) / 255.0;
color[1] = D3DCOLOR_B_G(diffuseColor) / 255.0;
color[2] = D3DCOLOR_B_B(diffuseColor) / 255.0;
color[3] = D3DCOLOR_B_A(diffuseColor) / 255.0;
color[0] = D3DCOLOR_B_R(diffuseColor) / 255.0f;
color[1] = D3DCOLOR_B_G(diffuseColor) / 255.0f;
color[2] = D3DCOLOR_B_B(diffuseColor) / 255.0f;
color[3] = D3DCOLOR_B_A(diffuseColor) / 255.0f;
for(i = 0; i < This->activeContext->num_untracked_materials; i++) {
glMaterialfv(GL_FRONT_AND_BACK, This->activeContext->untracked_materials[i], color);
for (i = 0; i < num_untracked_materials; ++i)
{
glMaterialfv(GL_FRONT_AND_BACK, context->untracked_materials[i], color);
}
}
}
@ -295,6 +317,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
checkGLcall("glEnd and previous calls");
}
/* GL locking is done by the caller */
static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format, const UINT index, const void *ptr)
{
switch(format)
@ -397,6 +420,7 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format
}
}
/* GL locking is done by the caller */
static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream_info *si, UINT numberOfVertices,
GLenum glPrimitiveType, const void *idxData, UINT idxSize, UINT minIndex, UINT startIdx)
{
@ -442,8 +466,9 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream
}
}
for(i = MAX_ATTRIBS - 1; i >= 0; i--) {
if(!si->elements[i].data) continue;
for (i = MAX_ATTRIBS - 1; i >= 0; i--)
{
if (!(si->use_map & (1 << i))) continue;
ptr = si->elements[i].data +
si->elements[i].stride * SkipnStrides +
@ -457,6 +482,7 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream
glEnd();
}
/* GL locking is done by the caller */
static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wined3d_stream_info *si,
UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, UINT idxSize, UINT minIndex,
UINT startIdx)
@ -496,6 +522,8 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wine
for (i = 0; i < sizeof(si->elements) / sizeof(*si->elements); ++i)
{
if (!(si->use_map & (1 << i))) continue;
if (stateblock->streamFlags[si->elements[i].stream_idx] & WINED3DSTREAMSOURCE_INSTANCEDATA)
{
instancedData[numInstancedAttribs] = i;
@ -532,7 +560,11 @@ static inline void remove_vbos(IWineD3DDeviceImpl *This, struct wined3d_stream_i
for (i = 0; i < (sizeof(s->elements) / sizeof(*s->elements)); ++i)
{
struct wined3d_stream_info_element *e = &s->elements[i];
struct wined3d_stream_info_element *e;
if (!(s->use_map & (1 << i))) continue;
e = &s->elements[i];
if (e->buffer_object)
{
struct wined3d_buffer *vb = (struct wined3d_buffer *)This->stateBlock->streamSource[e->stream_idx];
@ -549,30 +581,42 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DSurfaceImpl *target;
struct wined3d_context *context;
unsigned int i;
if (!index_count) return;
/* Invalidate the back buffer memory so LockRect will read it the next time */
for(i = 0; i < GL_LIMITS(buffers); i++) {
target = (IWineD3DSurfaceImpl *) This->render_targets[i];
if (target) {
IWineD3DSurface_LoadLocation((IWineD3DSurface *) target, SFLAG_INDRAWABLE, NULL);
IWineD3DSurface_ModifyLocation((IWineD3DSurface *) target, SFLAG_INDRAWABLE, TRUE);
if (This->stateBlock->renderState[WINED3DRS_COLORWRITEENABLE])
{
/* Invalidate the back buffer memory so LockRect will read it the next time */
for (i = 0; i < GL_LIMITS(buffers); ++i)
{
target = (IWineD3DSurfaceImpl *)This->render_targets[i];
if (target)
{
IWineD3DSurface_LoadLocation((IWineD3DSurface *)target, SFLAG_INDRAWABLE, NULL);
IWineD3DSurface_ModifyLocation((IWineD3DSurface *)target, SFLAG_INDRAWABLE, TRUE);
}
}
}
/* Signals other modules that a drawing is in progress and the stateblock finalized */
This->isInDraw = TRUE;
ActivateContext(This, This->render_targets[0], CTXUSAGE_DRAWPRIM);
context = ActivateContext(This, This->render_targets[0], CTXUSAGE_DRAWPRIM);
if (This->stencilBufferTarget) {
/* Note that this depends on the ActivateContext call above to set
* This->render_offscreen properly */
DWORD location = This->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
surface_load_ds_location(This->stencilBufferTarget, location);
surface_modify_ds_location(This->stencilBufferTarget, location);
* This->render_offscreen properly. We don't currently take the
* Z-compare function into account, but we could skip loading the
* depthstencil for D3DCMP_NEVER and D3DCMP_ALWAYS as well. Also note
* that we never copy the stencil data.*/
DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
if (This->stateBlock->renderState[WINED3DRS_ZWRITEENABLE]
|| This->stateBlock->renderState[WINED3DRS_ZENABLE])
surface_load_ds_location(This->stencilBufferTarget, context, location);
if (This->stateBlock->renderState[WINED3DRS_ZWRITEENABLE])
surface_modify_ds_location(This->stencilBufferTarget, location);
}
/* Ok, we will be updating the screen from here onwards so grab the lock */
@ -587,7 +631,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice
if (!use_vs(This->stateBlock))
{
if (!This->strided_streams.position_transformed && This->activeContext->num_untracked_materials
if (!This->strided_streams.position_transformed && context->num_untracked_materials
&& This->stateBlock->renderState[WINED3DRS_LIGHTING])
{
static BOOL warned;
@ -599,7 +643,8 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice
}
emulation = TRUE;
}
else if(This->activeContext->fog_coord && This->stateBlock->renderState[WINED3DRS_FOGENABLE]) {
else if (context->fog_coord && This->stateBlock->renderState[WINED3DRS_FOGENABLE])
{
/* Either write a pipeline replacement shader or convert the specular alpha from unsigned byte
* to a float in the vertex buffer
*/
@ -633,7 +678,8 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice
}
drawStridedSlowVs(iface, stream_info, index_count, glPrimType, idxData, idxSize, minIndex, StartIdx);
} else {
drawStridedSlow(iface, stream_info, index_count, glPrimType, idxData, idxSize, minIndex, StartIdx);
drawStridedSlow(iface, context, stream_info, index_count,
glPrimType, idxData, idxSize, minIndex, StartIdx);
}
} else if(This->instancedDraw) {
/* Instancing emulation with mixing immediate mode and arrays */
@ -653,7 +699,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice
#ifdef SHOW_FRAME_MAKEUP
{
static long int primCounter = 0;
/* NOTE: set primCounter to the value reported by drawprim
/* NOTE: set primCounter to the value reported by drawprim
before you want to to write frame makeup to /tmp */
if (primCounter >= 0) {
WINED3DLOCKED_RECT r;
@ -695,7 +741,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice
static void normalize_normal(float *n) {
float length = n[0] * n[0] + n[1] * n[1] + n[2] * n[2];
if(length == 0.0) return;
if (length == 0.0f) return;
length = sqrt(length);
n[0] = n[0] / length;
n[1] = n[1] / length;
@ -727,7 +773,7 @@ static void normalize_normal(float *n) {
HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
struct WineD3DRectPatch *patch) {
unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size;
float max_x = 0.0, max_y = 0.0, max_z = 0.0, neg_z = 0.0;
float max_x = 0.0f, max_y = 0.0f, max_z = 0.0f, neg_z = 0.0f;
struct wined3d_stream_info stream_info;
struct wined3d_stream_info_element *e;
const BYTE *data;
@ -736,6 +782,11 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
GLenum feedback_type;
GLfloat *feedbuffer;
/* Simply activate the context for blitting. This disables all the things we don't want and
* takes care of dirtifying. Dirtifying is preferred over pushing / popping, since drawing the
* patch (as opposed to normal draws) will most likely need different changes anyway. */
ActivateContext(This, NULL, CTXUSAGE_BLIT);
/* First, locate the position data. This is provided in a vertex buffer in the stateblock.
* Beware of vbos
*/
@ -786,19 +837,14 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
patch->has_normals = TRUE;
patch->has_texcoords = FALSE;
/* Simply activate the context for blitting. This disables all the things we don't want and
* takes care of dirtifying. Dirtifying is preferred over pushing / popping, since drawing the
* patch (as opposed to normal draws) will most likely need different changes anyway
*/
ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_BLIT);
ENTER_GL();
glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
glLoadIdentity();
checkGLcall("glLoadIndentity()");
glScalef(1 / (max_x) , 1 / (max_y), max_z == 0 ? 1 : 1 / ( 2 * max_z));
glTranslatef(0, 0, 0.5);
glScalef(1.0f / (max_x), 1.0f / (max_y), max_z == 0.0f ? 1.0f : 1.0f / (2.0f * max_z));
glTranslatef(0.0f, 0.0f, 0.5f);
checkGLcall("glScalef");
glViewport(-max_x, -max_y, 2 * (max_x), 2 * (max_y));
checkGLcall("glViewport");
@ -810,11 +856,11 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_FILLMODE));
if(patch->has_normals) {
static const GLfloat black[] = {0, 0, 0, 0};
static const GLfloat red[] = {1, 0, 0, 0};
static const GLfloat green[] = {0, 1, 0, 0};
static const GLfloat blue[] = {0, 0, 1, 0};
static const GLfloat white[] = {1, 1, 1, 1};
static const GLfloat black[] = {0.0f, 0.0f, 0.0f, 0.0f};
static const GLfloat red[] = {1.0f, 0.0f, 0.0f, 0.0f};
static const GLfloat green[] = {0.0f, 1.0f, 0.0f, 0.0f};
static const GLfloat blue[] = {0.0f, 0.0f, 1.0f, 0.0f};
static const GLfloat white[] = {1.0f, 1.0f, 1.0f, 1.0f};
glEnable(GL_LIGHTING);
checkGLcall("glEnable(GL_LIGHTING)");
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black);
@ -833,21 +879,21 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
glLightfv(GL_LIGHT0, GL_AMBIENT, black);
glLightfv(GL_LIGHT0, GL_POSITION, red);
glEnable(GL_LIGHT0);
checkGLcall("Setting up light 1\n");
checkGLcall("Setting up light 1");
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(1));
glLightfv(GL_LIGHT1, GL_DIFFUSE, green);
glLightfv(GL_LIGHT1, GL_SPECULAR, black);
glLightfv(GL_LIGHT1, GL_AMBIENT, black);
glLightfv(GL_LIGHT1, GL_POSITION, green);
glEnable(GL_LIGHT1);
checkGLcall("Setting up light 2\n");
checkGLcall("Setting up light 2");
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(2));
glLightfv(GL_LIGHT2, GL_DIFFUSE, blue);
glLightfv(GL_LIGHT2, GL_SPECULAR, black);
glLightfv(GL_LIGHT2, GL_AMBIENT, black);
glLightfv(GL_LIGHT2, GL_POSITION, blue);
glEnable(GL_LIGHT2);
checkGLcall("Setting up light 3\n");
checkGLcall("Setting up light 3");
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_MATERIAL);
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORVERTEX));
@ -855,7 +901,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, white);
checkGLcall("Setting up materials\n");
checkGLcall("Setting up materials");
}
/* Enable the needed maps.
@ -895,18 +941,18 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
feedbuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer_size * sizeof(float) * 8);
glMap2f(GL_MAP2_VERTEX_3,
0, 1, vtxStride / sizeof(float), info->Width,
0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
0.0f, 1.0f, vtxStride / sizeof(float), info->Width,
0.0f, 1.0f, info->Stride * vtxStride / sizeof(float), info->Height,
(const GLfloat *)data);
checkGLcall("glMap2f");
if(patch->has_texcoords) {
glMap2f(GL_MAP2_TEXTURE_COORD_4,
0, 1, vtxStride / sizeof(float), info->Width,
0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
0.0f, 1.0f, vtxStride / sizeof(float), info->Width,
0.0f, 1.0f, info->Stride * vtxStride / sizeof(float), info->Height,
(const GLfloat *)data);
checkGLcall("glMap2f");
}
glMapGrid2f(ceilf(patch->numSegs[0]), 0.0, 1.0, ceilf(patch->numSegs[1]), 0.0, 1.0);
glMapGrid2f(ceilf(patch->numSegs[0]), 0.0f, 1.0f, ceilf(patch->numSegs[1]), 0.0f, 1.0f);
checkGLcall("glMapGrid2f");
glFeedbackBuffer(buffer_size * 2, feedback_type, feedbuffer);
@ -914,19 +960,17 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
glRenderMode(GL_FEEDBACK);
glEvalMesh2(GL_FILL, 0, ceilf(patch->numSegs[0]), 0, ceilf(patch->numSegs[1]));
checkGLcall("glEvalMesh2\n");
checkGLcall("glEvalMesh2");
i = glRenderMode(GL_RENDER);
if(i == -1) {
LEAVE_GL();
ERR("Feedback failed. Expected %d elements back\n", buffer_size);
Sleep(10000);
HeapFree(GetProcessHeap(), 0, feedbuffer);
return WINED3DERR_DRIVERINTERNALERROR;
} else if(i != buffer_size) {
LEAVE_GL();
ERR("Unexpected amount of elements returned. Expected %d, got %d\n", buffer_size, i);
Sleep(10000);
HeapFree(GetProcessHeap(), 0, feedbuffer);
return WINED3DERR_DRIVERINTERNALERROR;
} else {
@ -950,7 +994,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
*/
patch->mem[i + 0] = feedbuffer[j + out_vertex_size * 2 + 2]; /* x, triangle 2 */
patch->mem[i + 1] = feedbuffer[j + out_vertex_size * 2 + 3]; /* y, triangle 2 */
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 2 + 4] - 0.5) * 4 * max_z; /* z, triangle 3 */
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 2 + 4] - 0.5f) * 4.0f * max_z; /* z, triangle 3 */
if(patch->has_normals) {
patch->mem[i + 3] = feedbuffer[j + out_vertex_size * 2 + 5];
patch->mem[i + 4] = feedbuffer[j + out_vertex_size * 2 + 6];
@ -960,7 +1004,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
patch->mem[i + 0] = feedbuffer[j + out_vertex_size * 1 + 2]; /* x, triangle 2 */
patch->mem[i + 1] = feedbuffer[j + out_vertex_size * 1 + 3]; /* y, triangle 2 */
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 1 + 4] - 0.5) * 4 * max_z; /* z, triangle 2 */
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 1 + 4] - 0.5f) * 4.0f * max_z; /* z, triangle 2 */
if(patch->has_normals) {
patch->mem[i + 3] = feedbuffer[j + out_vertex_size * 1 + 5];
patch->mem[i + 4] = feedbuffer[j + out_vertex_size * 1 + 6];
@ -970,7 +1014,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
patch->mem[i + 0] = feedbuffer[j + out_vertex_size * 0 + 2]; /* x, triangle 1 */
patch->mem[i + 1] = feedbuffer[j + out_vertex_size * 0 + 3]; /* y, triangle 1 */
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 0 + 4] - 0.5) * 4 * max_z; /* z, triangle 1 */
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 0 + 4] - 0.5f) * 4.0f * max_z; /* z, triangle 1 */
if(patch->has_normals) {
patch->mem[i + 3] = feedbuffer[j + out_vertex_size * 0 + 5];
patch->mem[i + 4] = feedbuffer[j + out_vertex_size * 0 + 6];
@ -981,18 +1025,18 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
if(patch->has_normals) {
/* Now do the same with reverse light directions */
static const GLfloat x[] = {-1, 0, 0, 0};
static const GLfloat y[] = { 0, -1, 0, 0};
static const GLfloat z[] = { 0, 0, -1, 0};
static const GLfloat x[] = {-1.0f, 0.0f, 0.0f, 0.0f};
static const GLfloat y[] = { 0.0f, -1.0f, 0.0f, 0.0f};
static const GLfloat z[] = { 0.0f, 0.0f, -1.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_POSITION, x);
glLightfv(GL_LIGHT1, GL_POSITION, y);
glLightfv(GL_LIGHT2, GL_POSITION, z);
checkGLcall("Setting up reverse light directions\n");
checkGLcall("Setting up reverse light directions");
glRenderMode(GL_FEEDBACK);
checkGLcall("glRenderMode(GL_FEEDBACK)");
glEvalMesh2(GL_FILL, 0, ceilf(patch->numSegs[0]), 0, ceilf(patch->numSegs[1]));
checkGLcall("glEvalMesh2\n");
checkGLcall("glEvalMesh2");
i = glRenderMode(GL_RENDER);
checkGLcall("glRenderMode(GL_RENDER)");
@ -1006,29 +1050,29 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
ERR("Unexpected polygon: %f corners\n", feedbuffer[j + 1]);
continue;
}
if(patch->mem[i + 3] == 0.0)
if(patch->mem[i + 3] == 0.0f)
patch->mem[i + 3] = -feedbuffer[j + out_vertex_size * 2 + 5];
if(patch->mem[i + 4] == 0.0)
if(patch->mem[i + 4] == 0.0f)
patch->mem[i + 4] = -feedbuffer[j + out_vertex_size * 2 + 6];
if(patch->mem[i + 5] == 0.0)
if(patch->mem[i + 5] == 0.0f)
patch->mem[i + 5] = -feedbuffer[j + out_vertex_size * 2 + 7];
normalize_normal(patch->mem + i + 3);
i += d3d_out_vertex_size;
if(patch->mem[i + 3] == 0.0)
if(patch->mem[i + 3] == 0.0f)
patch->mem[i + 3] = -feedbuffer[j + out_vertex_size * 1 + 5];
if(patch->mem[i + 4] == 0.0)
if(patch->mem[i + 4] == 0.0f)
patch->mem[i + 4] = -feedbuffer[j + out_vertex_size * 1 + 6];
if(patch->mem[i + 5] == 0.0)
if(patch->mem[i + 5] == 0.0f)
patch->mem[i + 5] = -feedbuffer[j + out_vertex_size * 1 + 7];
normalize_normal(patch->mem + i + 3);
i += d3d_out_vertex_size;
if(patch->mem[i + 3] == 0.0)
if(patch->mem[i + 3] == 0.0f)
patch->mem[i + 3] = -feedbuffer[j + out_vertex_size * 0 + 5];
if(patch->mem[i + 4] == 0.0)
if(patch->mem[i + 4] == 0.0f)
patch->mem[i + 4] = -feedbuffer[j + out_vertex_size * 0 + 6];
if(patch->mem[i + 5] == 0.0)
if(patch->mem[i + 5] == 0.0f)
patch->mem[i + 5] = -feedbuffer[j + out_vertex_size * 0 + 7];
normalize_normal(patch->mem + i + 3);
i += d3d_out_vertex_size;

View file

@ -133,7 +133,7 @@ static void WINE_GLAPI wine_glGetIntegerv(GLenum pname, GLint* params) {
static void (WINE_GLAPI *old_multitex_glGetFloatv) (GLenum pname, GLfloat* params) = NULL;
static void WINE_GLAPI wine_glGetFloatv(GLenum pname, GLfloat* params) {
if(pname == GL_ACTIVE_TEXTURE) *params = 0.0;
if (pname == GL_ACTIVE_TEXTURE) *params = 0.0f;
else old_multitex_glGetFloatv(pname, params);
}
@ -147,7 +147,7 @@ static void WINE_GLAPI wine_glGetDoublev(GLenum pname, GLdouble* params) {
static void (WINE_GLAPI *old_fogcoord_glEnable) (GLenum cap) = NULL;
static void WINE_GLAPI wine_glEnable(GLenum cap) {
if(cap == GL_FOG) {
WineD3DContext *ctx = getActiveContext();
struct wined3d_context *ctx = context_get_current();
ctx->fog_enabled = 1;
if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
}
@ -157,7 +157,7 @@ static void WINE_GLAPI wine_glEnable(GLenum cap) {
static void (WINE_GLAPI *old_fogcoord_glDisable) (GLenum cap) = NULL;
static void WINE_GLAPI wine_glDisable(GLenum cap) {
if(cap == GL_FOG) {
WineD3DContext *ctx = getActiveContext();
struct wined3d_context *ctx = context_get_current();
ctx->fog_enabled = 0;
if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
}
@ -166,8 +166,9 @@ static void WINE_GLAPI wine_glDisable(GLenum cap) {
static void (WINE_GLAPI *old_fogcoord_glFogi) (GLenum pname, GLint param) = NULL;
static void WINE_GLAPI wine_glFogi(GLenum pname, GLint param) {
struct wined3d_context *ctx = context_get_current();
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = param;
if(param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
@ -177,9 +178,9 @@ static void WINE_GLAPI wine_glFogi(GLenum pname, GLint param) {
}
} else {
if(pname == GL_FOG_START) {
getActiveContext()->fogstart = param;
ctx->fogstart = param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = param;
ctx->fogend = param;
}
old_fogcoord_glFogi(pname, param);
}
@ -187,8 +188,8 @@ static void WINE_GLAPI wine_glFogi(GLenum pname, GLint param) {
static void (WINE_GLAPI *old_fogcoord_glFogiv) (GLenum pname, const GLint *param) = NULL;
static void WINE_GLAPI wine_glFogiv(GLenum pname, const GLint *param) {
struct wined3d_context *ctx = context_get_current();
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = *param;
if(*param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
@ -198,9 +199,9 @@ static void WINE_GLAPI wine_glFogiv(GLenum pname, const GLint *param) {
}
} else {
if(pname == GL_FOG_START) {
getActiveContext()->fogstart = *param;
ctx->fogstart = *param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = *param;
ctx->fogend = *param;
}
old_fogcoord_glFogiv(pname, param);
}
@ -208,8 +209,8 @@ static void WINE_GLAPI wine_glFogiv(GLenum pname, const GLint *param) {
static void (WINE_GLAPI *old_fogcoord_glFogf) (GLenum pname, GLfloat param) = NULL;
static void WINE_GLAPI wine_glFogf(GLenum pname, GLfloat param) {
struct wined3d_context *ctx = context_get_current();
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = (GLint) param;
if(param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
@ -219,9 +220,9 @@ static void WINE_GLAPI wine_glFogf(GLenum pname, GLfloat param) {
}
} else {
if(pname == GL_FOG_START) {
getActiveContext()->fogstart = param;
ctx->fogstart = param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = param;
ctx->fogend = param;
}
old_fogcoord_glFogf(pname, param);
}
@ -229,8 +230,8 @@ static void WINE_GLAPI wine_glFogf(GLenum pname, GLfloat param) {
static void (WINE_GLAPI *old_fogcoord_glFogfv) (GLenum pname, const GLfloat *param) = NULL;
static void WINE_GLAPI wine_glFogfv(GLenum pname, const GLfloat *param) {
struct wined3d_context *ctx = context_get_current();
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = (GLint) *param;
if(*param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
@ -240,15 +241,14 @@ static void WINE_GLAPI wine_glFogfv(GLenum pname, const GLfloat *param) {
}
} else {
if(pname == GL_FOG_COLOR) {
WineD3DContext *ctx = getActiveContext();
ctx->fogcolor[0] = param[0];
ctx->fogcolor[1] = param[1];
ctx->fogcolor[2] = param[2];
ctx->fogcolor[3] = param[3];
} else if(pname == GL_FOG_START) {
getActiveContext()->fogstart = *param;
ctx->fogstart = *param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = *param;
ctx->fogend = *param;
}
old_fogcoord_glFogfv(pname, param);
}
@ -269,15 +269,15 @@ static void (WINE_GLAPI *old_fogcoord_glFogCoordfvEXT) (const GLfloat *f) = NULL
static void (WINE_GLAPI *old_fogcoord_glFogCoorddvEXT) (const GLdouble *f) = NULL;
static void WINE_GLAPI wine_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
WineD3DContext *ctx = getActiveContext();
struct wined3d_context *ctx = context_get_current();
if(ctx->gl_fog_source == GL_FOG_COORDINATE_EXT && ctx->fog_enabled) {
GLfloat c[4] = {ctx->color[0], ctx->color[1], ctx->color[2], ctx->color[3]};
GLfloat i;
i = (ctx->fogend - ctx->fog_coord_value) / (ctx->fogend - ctx->fogstart);
c[0] = i * c[0] + (1.0 - i) * ctx->fogcolor[0];
c[1] = i * c[1] + (1.0 - i) * ctx->fogcolor[1];
c[2] = i * c[2] + (1.0 - i) * ctx->fogcolor[2];
c[0] = i * c[0] + (1.0f - i) * ctx->fogcolor[0];
c[1] = i * c[1] + (1.0f - i) * ctx->fogcolor[1];
c[2] = i * c[2] + (1.0f - i) * ctx->fogcolor[2];
old_fogcoord_glColor4f(c[0], c[1], c[2], c[3]);
old_fogcoord_glVertex4f(x, y, z, w);
@ -291,15 +291,15 @@ static void WINE_GLAPI wine_glVertex4fv(const GLfloat *pos) {
}
static void WINE_GLAPI wine_glVertex3f(GLfloat x, GLfloat y, GLfloat z) {
wine_glVertex4f(x, y, z, 1.0);
wine_glVertex4f(x, y, z, 1.0f);
}
static void WINE_GLAPI wine_glVertex3fv(const GLfloat *pos) {
wine_glVertex4f(pos[0], pos[1], pos[2], 1.0);
wine_glVertex4f(pos[0], pos[1], pos[2], 1.0f);
}
static void wine_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
WineD3DContext *ctx = getActiveContext();
static void WINE_GLAPI wine_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
struct wined3d_context *ctx = context_get_current();
ctx->color[0] = r;
ctx->color[1] = g;
ctx->color[2] = b;
@ -307,43 +307,44 @@ static void wine_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
old_fogcoord_glColor4f(r, g, b, a);
}
static void wine_glColor4fv(const GLfloat *c) {
static void WINE_GLAPI wine_glColor4fv(const GLfloat *c) {
wine_glColor4f(c[0], c[1], c[2], c[3]);
}
static void wine_glColor3f(GLfloat r, GLfloat g, GLfloat b) {
wine_glColor4f(r, g, b, 1.0);
static void WINE_GLAPI wine_glColor3f(GLfloat r, GLfloat g, GLfloat b) {
wine_glColor4f(r, g, b, 1.0f);
}
static void wine_glColor3fv(const GLfloat *c) {
wine_glColor4f(c[0], c[1], c[2], 1.0);
static void WINE_GLAPI wine_glColor3fv(const GLfloat *c) {
wine_glColor4f(c[0], c[1], c[2], 1.0f);
}
static void wine_glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
wine_glColor4f(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
static void WINE_GLAPI wine_glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
wine_glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
}
/* In D3D the fog coord is a UBYTE, so there's no problem with using the single
* precision function
*/
static void wine_glFogCoordfEXT(GLfloat f) {
WineD3DContext *ctx = getActiveContext();
static void WINE_GLAPI wine_glFogCoordfEXT(GLfloat f) {
struct wined3d_context *ctx = context_get_current();
ctx->fog_coord_value = f;
}
static void wine_glFogCoorddEXT(GLdouble f) {
static void WINE_GLAPI wine_glFogCoorddEXT(GLdouble f) {
wine_glFogCoordfEXT(f);
}
static void wine_glFogCoordfvEXT(const GLfloat *f) {
static void WINE_GLAPI wine_glFogCoordfvEXT(const GLfloat *f) {
wine_glFogCoordfEXT(*f);
}
static void wine_glFogCoorddvEXT(const GLdouble *f) {
static void WINE_GLAPI wine_glFogCoorddvEXT(const GLdouble *f) {
wine_glFogCoordfEXT(*f);
}
/* End GL_EXT_fog_coord emulation */
#define GLINFO_LOCATION (*gl_info)
void add_gl_compat_wrappers(WineD3D_GL_Info *gl_info) {
void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info)
{
if(!GL_SUPPORT(ARB_MULTITEXTURE)) {
TRACE("Applying GL_ARB_multitexture emulation hooks\n");
gl_info->glActiveTextureARB = wine_glActiveTextureARB;

File diff suppressed because it is too large Load diff

View file

@ -29,7 +29,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
/* GL locking for state handlers is done by the caller. */
static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
BOOL bumpmap = FALSE;
if(stage > 0 && (stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE ||
@ -445,12 +449,12 @@ void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEX
stage, is_alpha, debug_d3dtop(op), op, arg1, arg2, arg3, texture_idx);
}
checkGLcall("set_tex_op_nvrc()\n");
checkGLcall("set_tex_op_nvrc()");
}
static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map & (1 << stage);
@ -542,7 +546,8 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
}
}
static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
DWORD sampler = state - STATE_SAMPLER(0);
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler];
@ -557,7 +562,8 @@ static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
nvts_activate_dimensions(sampler, stateblock, context);
}
static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage + 1];
float mat[2][2];
@ -584,7 +590,8 @@ static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, Win
}
}
static void nvrc_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void nvrc_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
float col[4];
D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
@ -592,9 +599,12 @@ static void nvrc_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
#undef GLINFO_LOCATION
#define GLINFO_LOCATION (*gl_info)
/* Context activation is done by the caller. */
static void nvrc_enable(IWineD3DDevice *iface, BOOL enable) { }
/* Context activation is done by the caller. */
static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
ENTER_GL();
if(enable) {
glEnable(GL_TEXTURE_SHADER_NV);
checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)");
@ -602,9 +612,11 @@ static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
glDisable(GL_TEXTURE_SHADER_NV);
checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)");
}
LEAVE_GL();
}
static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps)
static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype,
const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
{
pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
WINED3DTEXOPCAPS_ADDSIGNED |
@ -659,6 +671,7 @@ static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info
}
static HRESULT nvrc_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
/* Context activation is done by the caller. */
static void nvrc_fragment_free(IWineD3DDevice *iface) {}
/* Two fixed function pipeline implementations using GL_NV_register_combiners and
@ -687,137 +700,137 @@ static BOOL nvts_color_fixup_supported(struct color_fixup_desc fixup)
}
static const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_PIXELSHADER, { STATE_PIXELSHADER, apply_pixelshader }, 0 },
{ STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), { STATE_PIXELSHADER, apply_pixelshader }, 0 },
{ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), nvrc_texfactor }, 0 },
{ STATE_RENDER(WINED3DRS_FOGCOLOR), { STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor }, 0 },
{ STATE_RENDER(WINED3DRS_FOGDENSITY), { STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity }, 0 },
{ STATE_RENDER(WINED3DRS_FOGENABLE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{ STATE_RENDER(WINED3DRS_FOGTABLEMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{ STATE_RENDER(WINED3DRS_FOGVERTEXMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{ STATE_RENDER(WINED3DRS_FOGSTART), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{ STATE_RENDER(WINED3DRS_FOGEND), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop }, WINED3D_GL_EXT_NONE },
{ STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), nvrc_colorop }, WINED3D_GL_EXT_NONE },
{ STATE_PIXELSHADER, { STATE_PIXELSHADER, apply_pixelshader }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), { STATE_PIXELSHADER, apply_pixelshader }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), nvrc_texfactor }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_FOGCOLOR), { STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_FOGDENSITY), { STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_FOGENABLE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_FOGTABLEMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_FOGVERTEXMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_FOGSTART), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_FOGEND), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, 0 },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, 0 },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(2), { STATE_SAMPLER(2), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, 0 },
{ STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(3), { STATE_SAMPLER(3), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }, 0 },
{ STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(4), { STATE_SAMPLER(4), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }, 0 },
{ STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(5), { STATE_SAMPLER(5), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }, 0 },
{ STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(6), { STATE_SAMPLER(6), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }, 0 },
{ STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(7), { STATE_SAMPLER(7), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }, 0 },
{0 /* Terminate */, { 0, 0 }, 0 },
{ STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }, WINED3D_GL_EXT_NONE },
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
const struct fragment_pipeline nvts_fragment_pipeline = {

View file

@ -22,7 +22,6 @@
#include "winerror.h"
#include "wine/debug.h"
#include <assert.h>
#include <string.h>
#include "wined3d_private.h"
@ -78,7 +77,9 @@ DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags) {
case WINEDDPCAPS_2BIT: return 4;
case WINEDDPCAPS_4BIT: return 16;
case WINEDDPCAPS_8BIT: return 256;
default: assert(0); return 256;
default:
FIXME("Unhandled size bits %#x.\n", dwFlags & SIZE_BITS);
return 256;
}
}

View file

@ -178,6 +178,10 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This)
This->baseShader.limits.label = 16;
break;
case WINED3D_SHADER_VERSION(4,0):
FIXME("Using 3.0 limits for 4.0 shader\n");
/* Fall through */
case WINED3D_SHADER_VERSION(3,0):
This->baseShader.limits.temporary = 32;
This->baseShader.limits.constant_float = 224;
@ -238,8 +242,9 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
list_init(&This->baseShader.constantsI);
/* Second pass: figure out which registers are used, what the semantics are, etc.. */
hr = shader_get_registers_used((IWineD3DBaseShader *)This, fe, reg_maps, This->semantics_in, NULL, pFunction,
GL_LIMITS(pshader_constantsF));
hr = shader_get_registers_used((IWineD3DBaseShader *)This, fe,
reg_maps, NULL, This->input_signature, NULL,
pFunction, GL_LIMITS(pshader_constantsF));
if (FAILED(hr)) return hr;
pshader_set_limits(This);
@ -294,7 +299,7 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
return WINED3D_OK;
}
static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures)
void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures)
{
WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = reg_maps->sampler_type;
unsigned int i;
@ -338,29 +343,6 @@ static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD
}
}
static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps_compile_args *args)
{
CONST DWORD *function = This->baseShader.function;
GLuint retval;
SHADER_BUFFER buffer;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
TRACE("(%p) : function %p\n", This, function);
pixelshader_update_samplers(&This->baseShader.reg_maps,
((IWineD3DDeviceImpl *)This->baseShader.device)->stateBlock->textures);
/* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This);
This->cur_args = args;
shader_buffer_init(&buffer);
retval = device->shader_backend->shader_generate_pshader((IWineD3DPixelShader *)This, &buffer, args);
shader_buffer_free(&buffer);
This->cur_args = NULL;
return retval;
}
const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
{
/*** IUnknown methods ***/
@ -439,44 +421,3 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp
}
}
}
GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args)
{
UINT i;
DWORD new_size;
struct ps_compiled_shader *new_array;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap or a binary search
* (cache coherency etc)
*/
for(i = 0; i < shader->num_gl_shaders; i++) {
if(memcmp(&shader->gl_shaders[i].args, args, sizeof(*args)) == 0) {
return shader->gl_shaders[i].prgId;
}
}
TRACE("No matching GL shader found, compiling a new shader\n");
if(shader->shader_array_size == shader->num_gl_shaders) {
if (shader->num_gl_shaders)
{
new_size = shader->shader_array_size + max(1, shader->shader_array_size / 2);
new_array = HeapReAlloc(GetProcessHeap(), 0, shader->gl_shaders,
new_size * sizeof(*shader->gl_shaders));
} else {
new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader->gl_shaders));
new_size = 1;
}
if(!new_array) {
ERR("Out of memory\n");
return 0;
}
shader->gl_shaders = new_array;
shader->shader_array_size = new_size;
}
shader->gl_shaders[shader->num_gl_shaders].args = *args;
shader->gl_shaders[shader->num_gl_shaders].prgId = pixelshader_compile(shader, args);
return shader->gl_shaders[shader->num_gl_shaders++].prgId;
}

View file

@ -62,38 +62,22 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
ENTER_GL();
/* Queries are specific to the GL context that created them. Not
* deleting the query will obviously leak it, but that's still better
* than potentially deleting a different query with the same id in this
* context, and (still) leaking the actual query. */
if(This->type == WINED3DQUERYTYPE_EVENT) {
if (((WineQueryEventData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext
|| This->wineD3DDevice->activeContext->tid != GetCurrentThreadId())
{
FIXME("Query was created in a different context, skipping deletion\n");
}
else if(GL_SUPPORT(APPLE_FENCE))
{
GL_EXTCALL(glDeleteFencesAPPLE(1, &((WineQueryEventData *)(This->extendedData))->fenceId));
checkGLcall("glDeleteFencesAPPLE");
} else if(GL_SUPPORT(NV_FENCE)) {
GL_EXTCALL(glDeleteFencesNV(1, &((WineQueryEventData *)(This->extendedData))->fenceId));
checkGLcall("glDeleteFencesNV");
}
} else if(This->type == WINED3DQUERYTYPE_OCCLUSION && GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
if (((WineQueryOcclusionData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext
|| This->wineD3DDevice->activeContext->tid != GetCurrentThreadId())
{
FIXME("Query was created in a different context, skipping deletion\n");
}
else
{
GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId));
checkGLcall("glDeleteQueriesARB");
}
if (This->type == WINED3DQUERYTYPE_EVENT)
{
struct wined3d_event_query *query = This->extendedData;
if (query->context) context_free_event_query(query);
}
else if (This->type == WINED3DQUERYTYPE_OCCLUSION)
{
struct wined3d_occlusion_query *query = This->extendedData;
if (query->context) context_free_occlusion_query(query);
}
LEAVE_GL();
HeapFree(GetProcessHeap(), 0, This->extendedData);
HeapFree(GetProcessHeap(), 0, This);
@ -286,7 +270,7 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
GLuint queryId = ((WineQueryOcclusionData *)This->extendedData)->queryId;
struct wined3d_occlusion_query *query = This->extendedData;
DWORD* data = pData;
GLuint available;
GLuint samples;
@ -294,6 +278,8 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
if (!query->context) This->state = QUERY_CREATED;
if (This->state == QUERY_CREATED)
{
/* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */
@ -316,26 +302,27 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
return S_OK;
}
if (((WineQueryOcclusionData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext
|| This->wineD3DDevice->activeContext->tid != GetCurrentThreadId())
if (query->context->tid != GetCurrentThreadId())
{
FIXME("%p Wrong context, returning 1.\n", This);
FIXME("%p Wrong thread, returning 1.\n", This);
*data = 1;
return S_OK;
}
ActivateContext(This->wineD3DDevice, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)\n");
GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)");
TRACE("(%p) : available %d.\n", This, available);
if (available)
{
if (data)
{
GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_ARB, &samples));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)\n");
GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_ARB, &samples));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)");
TRACE("(%p) : Returning %d samples.\n", This, samples);
*data = samples;
}
@ -353,32 +340,52 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
struct wined3d_event_query *query = This->extendedData;
BOOL* data = pData;
WineD3DContext *ctx;
TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
ctx = ((WineQueryEventData *)This->extendedData)->ctx;
if(pData == NULL || dwSize == 0) {
return S_OK;
} if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
/* See comment in IWineD3DQuery::Issue, event query codeblock */
FIXME("Query context not active, reporting GPU idle\n");
if (!pData || !dwSize) return S_OK;
if (!query->context)
{
ERR("Query not started, returning TRUE.\n");
*data = TRUE;
} else if(GL_SUPPORT(APPLE_FENCE)) {
ENTER_GL();
*data = GL_EXTCALL(glTestFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
return S_OK;
}
if (query->context->tid != GetCurrentThreadId())
{
/* See comment in IWineD3DQuery::Issue, event query codeblock */
FIXME("Wrong thread, reporting GPU idle.\n");
*data = TRUE;
return S_OK;
}
ActivateContext(This->wineD3DDevice, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
if (GL_SUPPORT(APPLE_FENCE))
{
*data = GL_EXTCALL(glTestFenceAPPLE(query->id));
checkGLcall("glTestFenceAPPLE");
LEAVE_GL();
} else if(GL_SUPPORT(NV_FENCE)) {
ENTER_GL();
*data = GL_EXTCALL(glTestFenceNV(((WineQueryEventData *)This->extendedData)->fenceId));
}
else if (GL_SUPPORT(NV_FENCE))
{
*data = GL_EXTCALL(glTestFenceNV(query->id));
checkGLcall("glTestFenceNV");
LEAVE_GL();
} else {
}
else
{
WARN("(%p): reporting GPU idle\n", This);
*data = TRUE;
}
LEAVE_GL();
return S_OK;
}
@ -455,29 +462,47 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
TRACE("(%p) : dwIssueFlags %#x, type D3DQUERY_EVENT\n", This, dwIssueFlags);
if (dwIssueFlags & WINED3DISSUE_END) {
WineD3DContext *ctx = ((WineQueryEventData *)This->extendedData)->ctx;
if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
/* GL fences can be used only from the context that created them,
* so if a different context is active, don't bother setting the query. The penalty
* of a context switch is most likely higher than the gain of a correct query result
*
* If the query is used from a different thread, don't bother creating a multithread
* context - there's no point in doing that as the query would be unusable anyway
*/
WARN("Query context not active\n");
} else if(GL_SUPPORT(APPLE_FENCE)) {
ENTER_GL();
GL_EXTCALL(glSetFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
checkGLcall("glSetFenceAPPLE");
LEAVE_GL();
} else if (GL_SUPPORT(NV_FENCE)) {
ENTER_GL();
GL_EXTCALL(glSetFenceNV(((WineQueryEventData *)This->extendedData)->fenceId, GL_ALL_COMPLETED_NV));
checkGLcall("glSetFenceNV");
LEAVE_GL();
if (dwIssueFlags & WINED3DISSUE_END)
{
struct wined3d_event_query *query = This->extendedData;
struct wined3d_context *context;
if (query->context)
{
if (query->context->tid != GetCurrentThreadId())
{
context_free_event_query(query);
context = ActivateContext(This->wineD3DDevice, NULL, CTXUSAGE_RESOURCELOAD);
context_alloc_event_query(context, query);
}
else
{
ActivateContext(This->wineD3DDevice, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
}
}
} else if(dwIssueFlags & WINED3DISSUE_BEGIN) {
else
{
context = ActivateContext(This->wineD3DDevice, NULL, CTXUSAGE_RESOURCELOAD);
context_alloc_event_query(context, query);
}
ENTER_GL();
if (GL_SUPPORT(APPLE_FENCE))
{
GL_EXTCALL(glSetFenceAPPLE(query->id));
checkGLcall("glSetFenceAPPLE");
}
else if (GL_SUPPORT(NV_FENCE))
{
GL_EXTCALL(glSetFenceNV(query->id, GL_ALL_COMPLETED_NV));
checkGLcall("glSetFenceNV");
}
LEAVE_GL();
}
else if(dwIssueFlags & WINED3DISSUE_BEGIN)
{
/* Started implicitly at device creation */
ERR("Event query issued with START flag - what to do?\n");
}
@ -494,35 +519,68 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD
static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
WineD3DContext *ctx = ((WineQueryOcclusionData *)This->extendedData)->ctx;
if (GL_SUPPORT(ARB_OCCLUSION_QUERY))
{
struct wined3d_occlusion_query *query = This->extendedData;
struct wined3d_context *context;
/* This is allowed according to msdn and our tests. Reset the query and restart */
if (dwIssueFlags & WINED3DISSUE_BEGIN)
{
if (This->state == QUERY_BUILDING)
{
if (query->context->tid != GetCurrentThreadId())
{
FIXME("Wrong thread, can't restart query.\n");
context_free_occlusion_query(query);
context = ActivateContext(This->wineD3DDevice, NULL, CTXUSAGE_RESOURCELOAD);
context_alloc_occlusion_query(context, query);
}
else
{
ActivateContext(This->wineD3DDevice, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
checkGLcall("glEndQuery()");
LEAVE_GL();
}
}
else
{
if (query->context) context_free_occlusion_query(query);
context = ActivateContext(This->wineD3DDevice, NULL, CTXUSAGE_RESOURCELOAD);
context_alloc_occlusion_query(context, query);
}
if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
FIXME("Not the owning context, can't start query\n");
} else {
ENTER_GL();
/* This is allowed according to msdn and our tests. Reset the query and restart */
if (dwIssueFlags & WINED3DISSUE_BEGIN) {
if(This->state == QUERY_BUILDING) {
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
checkGLcall("glEndQuery()");
}
GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, ((WineQueryOcclusionData *)This->extendedData)->queryId));
checkGLcall("glBeginQuery()");
}
if (dwIssueFlags & WINED3DISSUE_END) {
/* Msdn says _END on a non-building occlusion query returns an error, but
* our tests show that it returns OK. But OpenGL doesn't like it, so avoid
* generating an error
*/
if(This->state == QUERY_BUILDING) {
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
checkGLcall("glEndQuery()");
}
}
GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query->id));
checkGLcall("glBeginQuery()");
LEAVE_GL();
}
if (dwIssueFlags & WINED3DISSUE_END) {
/* Msdn says _END on a non-building occlusion query returns an error, but
* our tests show that it returns OK. But OpenGL doesn't like it, so avoid
* generating an error
*/
if (This->state == QUERY_BUILDING)
{
if (query->context->tid != GetCurrentThreadId())
{
FIXME("Wrong thread, can't end query.\n");
}
else
{
ActivateContext(This->wineD3DDevice, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
checkGLcall("glEndQuery()");
LEAVE_GL();
}
}
}
} else {
FIXME("(%p) : Occlusion queries not supported\n", This);
}

View file

@ -26,10 +26,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
HRESULT resource_init(struct IWineD3DResourceClass *resource, WINED3DRESOURCETYPE resource_type,
HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
WINED3DPOOL pool, IUnknown *parent)
{
struct IWineD3DResourceClass *resource = &((IWineD3DResourceImpl *)iface)->resource;
resource->wineD3DDevice = device;
resource->parent = parent;
resource->resourceType = resource_type;
@ -68,6 +70,8 @@ HRESULT resource_init(struct IWineD3DResourceClass *resource, WINED3DRESOURCETYP
WineD3DAdapterChangeGLRam(device, size);
}
device_resource_add(device, iface);
return WINED3D_OK;
}
@ -96,10 +100,7 @@ void resource_cleanup(IWineD3DResource *iface)
This->resource.allocatedMemory = 0;
This->resource.heapMemory = 0;
if (This->resource.wineD3DDevice != NULL) {
IWineD3DDevice_ResourceReleased((IWineD3DDevice *)This->resource.wineD3DDevice, iface);
}/* NOTE: this is not really an error for system memory resources */
return;
if (This->resource.wineD3DDevice) device_resource_released(This->resource.wineD3DDevice, iface);
}
HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice** ppDevice)

View file

@ -349,6 +349,7 @@ static void shader_parse_src_param(DWORD param, const struct wined3d_shader_src_
src->reg.type = ((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT)
| ((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2);
src->reg.idx = param & WINED3DSP_REGNUM_MASK;
src->reg.array_idx = ~0U;
src->swizzle = (param & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
src->modifiers = (param & WINED3DSP_SRCMOD_MASK) >> WINED3DSP_SRCMOD_SHIFT;
src->reg.rel_addr = rel_addr;
@ -360,6 +361,7 @@ static void shader_parse_dst_param(DWORD param, const struct wined3d_shader_src_
dst->reg.type = ((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT)
| ((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2);
dst->reg.idx = param & WINED3DSP_REGNUM_MASK;
dst->reg.array_idx = ~0U;
dst->write_mask = (param & WINED3D_SM1_WRITEMASK_MASK) >> WINED3D_SM1_WRITEMASK_SHIFT;
dst->modifiers = (param & WINED3DSP_DSTMOD_MASK) >> WINED3DSP_DSTMOD_SHIFT;
dst->shift = (param & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;

View file

@ -28,6 +28,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define WINED3D_SM4_OPCODE_MASK 0xff
#define WINED3D_SM4_REGISTER_ORDER_SHIFT 20
#define WINED3D_SM4_REGISTER_ORDER_MASK (0x3 << WINED3D_SM4_REGISTER_ORDER_SHIFT)
#define WINED3D_SM4_REGISTER_TYPE_SHIFT 12
#define WINED3D_SM4_REGISTER_TYPE_MASK (0xf << WINED3D_SM4_REGISTER_TYPE_SHIFT)
@ -46,19 +49,26 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
enum wined3d_sm4_opcode
{
WINED3D_SM4_OP_ADD = 0x00,
WINED3D_SM4_OP_DP3 = 0x10,
WINED3D_SM4_OP_DP4 = 0x11,
WINED3D_SM4_OP_EXP = 0x19,
WINED3D_SM4_OP_LOG = 0x2f,
WINED3D_SM4_OP_MIN = 0x33,
WINED3D_SM4_OP_MAX = 0x34,
WINED3D_SM4_OP_MOV = 0x36,
WINED3D_SM4_OP_MUL = 0x38,
WINED3D_SM4_OP_RET = 0x3e,
WINED3D_SM4_OP_RSQ = 0x44,
WINED3D_SM4_OP_SINCOS = 0x4d,
};
enum wined3d_sm4_register_type
{
WINED3D_SM4_RT_TEMP = 0x0,
WINED3D_SM4_RT_INPUT = 0x1,
WINED3D_SM4_RT_OUTPUT = 0x2,
WINED3D_SM4_RT_IMMCONST = 0x4,
WINED3D_SM4_RT_TEMP = 0x0,
WINED3D_SM4_RT_INPUT = 0x1,
WINED3D_SM4_RT_OUTPUT = 0x2,
WINED3D_SM4_RT_IMMCONST = 0x4,
WINED3D_SM4_RT_CONSTBUFFER = 0x8,
};
enum wined3d_sm4_immconst_type
@ -92,20 +102,30 @@ struct sysval_map
static const struct wined3d_sm4_opcode_info opcode_table[] =
{
{WINED3D_SM4_OP_ADD, WINED3DSIH_ADD, 1, 2},
{WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, 1, 2},
{WINED3D_SM4_OP_DP4, WINED3DSIH_DP4, 1, 2},
{WINED3D_SM4_OP_EXP, WINED3DSIH_EXP, 1, 1},
{WINED3D_SM4_OP_LOG, WINED3DSIH_LOG, 1, 1},
{WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, 1, 2},
{WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, 1, 2},
{WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, 1, 1},
{WINED3D_SM4_OP_MUL, WINED3DSIH_MUL, 1, 2},
{WINED3D_SM4_OP_RET, WINED3DSIH_RET, 0, 0},
{WINED3D_SM4_OP_RSQ, WINED3DSIH_RSQ, 1, 1},
{WINED3D_SM4_OP_SINCOS, WINED3DSIH_SINCOS, 1, 2},
};
static const WINED3DSHADER_PARAM_REGISTER_TYPE register_type_table[] =
{
/* WINED3D_SM4_RT_TEMP */ WINED3DSPR_TEMP,
/* WINED3D_SM4_RT_INPUT */ WINED3DSPR_INPUT,
/* WINED3D_SM4_RT_OUTPUT */ WINED3DSPR_OUTPUT,
/* UNKNOWN */ 0,
/* WINED3D_SM4_RT_IMMCONST */ WINED3DSPR_IMMCONST,
/* WINED3D_SM4_RT_TEMP */ WINED3DSPR_TEMP,
/* WINED3D_SM4_RT_INPUT */ WINED3DSPR_INPUT,
/* WINED3D_SM4_RT_OUTPUT */ WINED3DSPR_OUTPUT,
/* UNKNOWN */ 0,
/* WINED3D_SM4_RT_IMMCONST */ WINED3DSPR_IMMCONST,
/* UNKNOWN */ 0,
/* UNKNOWN */ 0,
/* UNKNOWN */ 0,
/* WINED3D_SM4_RT_CONSTBUFFER */ WINED3DSPR_CONSTBUFFER,
};
static const struct sysval_map sysval_map[] =
@ -265,6 +285,7 @@ static void shader_sm4_read_src_param(void *data, const DWORD **ptr, struct wine
struct wined3d_sm4_data *priv = data;
DWORD token = *(*ptr)++;
enum wined3d_sm4_register_type register_type;
DWORD order;
register_type = (token & WINED3D_SM4_REGISTER_TYPE_MASK) >> WINED3D_SM4_REGISTER_TYPE_SHIFT;
if (register_type >= sizeof(register_type_table) / sizeof(*register_type_table))
@ -277,6 +298,16 @@ static void shader_sm4_read_src_param(void *data, const DWORD **ptr, struct wine
src_param->reg.type = register_type_table[register_type];
}
order = (token & WINED3D_SM4_REGISTER_ORDER_MASK) >> WINED3D_SM4_REGISTER_ORDER_SHIFT;
if (order < 1) src_param->reg.idx = ~0U;
else src_param->reg.idx = *(*ptr)++;
if (order < 2) src_param->reg.array_idx = ~0U;
else src_param->reg.array_idx = *(*ptr)++;
if (order > 2) FIXME("Unhandled order %u.\n", order);
if (register_type == WINED3D_SM4_RT_IMMCONST)
{
enum wined3d_sm4_immconst_type immconst_type =
@ -304,7 +335,6 @@ static void shader_sm4_read_src_param(void *data, const DWORD **ptr, struct wine
}
else
{
src_param->reg.idx = *(*ptr)++;
src_param->swizzle = (token & WINED3D_SM4_SWIZZLE_MASK) >> WINED3D_SM4_SWIZZLE_SHIFT;
}
@ -319,8 +349,8 @@ static void shader_sm4_read_dst_param(void *data, const DWORD **ptr, struct wine
{
struct wined3d_sm4_data *priv = data;
DWORD token = *(*ptr)++;
UINT register_idx = *(*ptr)++;
enum wined3d_sm4_register_type register_type;
DWORD order;
register_type = (token & WINED3D_SM4_REGISTER_TYPE_MASK) >> WINED3D_SM4_REGISTER_TYPE_SHIFT;
if (register_type >= sizeof(register_type_table) / sizeof(*register_type_table))
@ -333,7 +363,16 @@ static void shader_sm4_read_dst_param(void *data, const DWORD **ptr, struct wine
dst_param->reg.type = register_type_table[register_type];
}
dst_param->reg.idx = register_idx;
order = (token & WINED3D_SM4_REGISTER_ORDER_MASK) >> WINED3D_SM4_REGISTER_ORDER_SHIFT;
if (order < 1) dst_param->reg.idx = ~0U;
else dst_param->reg.idx = *(*ptr)++;
if (order < 2) dst_param->reg.array_idx = ~0U;
else dst_param->reg.array_idx = *(*ptr)++;
if (order > 2) FIXME("Unhandled order %u.\n", order);
dst_param->write_mask = (token & WINED3D_SM4_WRITEMASK_MASK) >> WINED3D_SM4_WRITEMASK_SHIFT;
dst_param->modifiers = 0;
dst_param->shift = 0;

File diff suppressed because it is too large Load diff

View file

@ -31,11 +31,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
* Stateblock helper functions follow
**************************************/
/** Allocates the correct amount of space for pixel and vertex shader constants,
/* Allocates the correct amount of space for pixel and vertex shader constants,
* along with their set/changed flags on the given stateblock object
*/
HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) {
HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object)
{
IWineD3DStateBlockImpl *This = object;
/* Allocate space for floating point constants */
@ -113,11 +113,8 @@ static inline void stateblock_set_bits(DWORD *map, UINT map_size)
}
/** Set all members of a stateblock savedstate to the given value */
void stateblock_savedstates_set(
IWineD3DStateBlock* iface,
SAVEDSTATES* states,
BOOL value) {
void stateblock_savedstates_set(IWineD3DStateBlock *iface, SAVEDSTATES *states, BOOL value)
{
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
unsigned bsize = sizeof(BOOL);
@ -228,7 +225,7 @@ void stateblock_copy(
memcpy(Dest->vertexShaderConstantI, This->vertexShaderConstantI, sizeof(INT) * MAX_CONST_I * 4);
memcpy(Dest->pixelShaderConstantB, This->pixelShaderConstantB, sizeof(BOOL) * MAX_CONST_B);
memcpy(Dest->pixelShaderConstantI, This->pixelShaderConstantI, sizeof(INT) * MAX_CONST_I * 4);
memcpy(Dest->streamStride, This->streamStride, sizeof(UINT) * MAX_STREAMS);
memcpy(Dest->streamOffset, This->streamOffset, sizeof(UINT) * MAX_STREAMS);
memcpy(Dest->streamSource, This->streamSource, sizeof(IWineD3DBuffer *) * MAX_STREAMS);
@ -357,7 +354,7 @@ static inline void record_lights(IWineD3DStateBlockImpl *This, IWineD3DStateBloc
LIST_FOR_EACH(e, &This->lightMap[i]) {
BOOL updated = FALSE;
PLIGHTINFOEL *src = LIST_ENTRY(e, PLIGHTINFOEL, entry), *realLight;
if(!src->changed || !src->enabledChanged) continue;
if (!src->changed && !src->enabledChanged) continue;
/* Look up the light in the destination */
LIST_FOR_EACH(f, &targetStateBlock->lightMap[i]) {
@ -1087,9 +1084,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
unsigned int i;
IWineD3DSwapChain *swapchain;
IWineD3DSurface *backbuffer;
WINED3DSURFACE_DESC desc = {0};
UINT width, height;
RECT scissorrect;
HRESULT hr;
/* Note this may have a large overhead but it should only be executed
@ -1292,28 +1286,27 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
This->textures[i] = NULL;
}
/* Set the default scissor rect values */
desc.Width = &width;
desc.Height = &height;
/* check the return values, because the GetBackBuffer call isn't valid for ddraw */
hr = IWineD3DDevice_GetSwapChain(device, 0, &swapchain);
if( hr == WINED3D_OK && swapchain != NULL) {
WINED3DVIEWPORT vp;
hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
if( hr == WINED3D_OK && backbuffer != NULL) {
if (SUCCEEDED(hr) && backbuffer)
{
WINED3DSURFACE_DESC desc;
RECT scissorrect;
IWineD3DSurface_GetDesc(backbuffer, &desc);
IWineD3DSurface_Release(backbuffer);
/* Set the default scissor rect values */
scissorrect.left = 0;
scissorrect.right = width;
scissorrect.right = desc.width;
scissorrect.top = 0;
scissorrect.bottom = height;
scissorrect.bottom = desc.height;
hr = IWineD3DDevice_SetScissorRect(device, &scissorrect);
if( hr != WINED3D_OK ) {
ERR("This should never happen, expect rendering issues!\n");
}
if (FAILED(hr)) ERR("This should never happen, expect rendering issues!\n");
}
/* Set the default viewport */

File diff suppressed because it is too large Load diff

View file

@ -30,8 +30,6 @@
#include "wine/port.h"
#include "wined3d_private.h"
#include <assert.h>
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
/* See also float_16_to_32() in wined3d_private.h */
@ -43,26 +41,26 @@ static inline unsigned short float_32_to_16(const float *in)
unsigned short ret;
/* Deal with special numbers */
if(*in == 0.0) return 0x0000;
if (*in == 0.0f) return 0x0000;
if(isnan(*in)) return 0x7C01;
if(isinf(*in)) return (*in < 0.0 ? 0xFC00 : 0x7c00);
if (isinf(*in)) return (*in < 0.0f ? 0xFC00 : 0x7c00);
if(tmp < pow(2, 10)) {
do
{
tmp = tmp * 2.0;
tmp = tmp * 2.0f;
exp--;
}while(tmp < pow(2, 10));
} else if(tmp >= pow(2, 11)) {
do
{
tmp /= 2.0;
tmp /= 2.0f;
exp++;
}while(tmp >= pow(2, 11));
}
mantissa = (unsigned int) tmp;
if(tmp - mantissa >= 0.5) mantissa++; /* round to nearest, away from zero */
if(tmp - mantissa >= 0.5f) mantissa++; /* round to nearest, away from zero */
exp += 10; /* Normalize the mantissa */
exp += 15; /* Exponent is encoded with excess 15 */
@ -80,7 +78,7 @@ static inline unsigned short float_32_to_16(const float *in)
ret = (exp << 10) | (mantissa & 0x3ff);
}
ret |= ((*in < 0.0 ? 1 : 0) << 15); /* Add the sign */
ret |= ((*in < 0.0f ? 1 : 0) << 15); /* Add the sign */
return ret;
}
@ -181,15 +179,17 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSU
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : copying into %p\n", This, pDesc);
if(pDesc->Format != NULL) *(pDesc->Format) = This->resource.format_desc->format;
if(pDesc->Type != NULL) *(pDesc->Type) = This->resource.resourceType;
if(pDesc->Usage != NULL) *(pDesc->Usage) = This->resource.usage;
if(pDesc->Pool != NULL) *(pDesc->Pool) = This->resource.pool;
if(pDesc->Size != NULL) *(pDesc->Size) = This->resource.size; /* dx8 only */
if(pDesc->MultiSampleType != NULL) *(pDesc->MultiSampleType) = This->currentDesc.MultiSampleType;
if(pDesc->MultiSampleQuality != NULL) *(pDesc->MultiSampleQuality) = This->currentDesc.MultiSampleQuality;
if(pDesc->Width != NULL) *(pDesc->Width) = This->currentDesc.Width;
if(pDesc->Height != NULL) *(pDesc->Height) = This->currentDesc.Height;
pDesc->format = This->resource.format_desc->format;
pDesc->resource_type = This->resource.resourceType;
pDesc->usage = This->resource.usage;
pDesc->pool = This->resource.pool;
pDesc->size = This->resource.size; /* dx8 only */
pDesc->multisample_type = This->currentDesc.MultiSampleType;
pDesc->multisample_quality = This->currentDesc.MultiSampleQuality;
pDesc->width = This->currentDesc.Width;
pDesc->height = This->currentDesc.Height;
return WINED3D_OK;
}
@ -332,19 +332,19 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD
DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
WINED3DFORMAT format = This->resource.format_desc->format;
const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
DWORD ret;
TRACE("(%p)\n", This);
/* DXTn formats don't have exact pitches as they are to the new row of blocks,
where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt2/3/4/5)
ie pitch = (width/4) * bytes per block */
if (format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
ret = ((This->currentDesc.Width + 3) >> 2) << 3;
else if (format == WINED3DFMT_DXT2 || format == WINED3DFMT_DXT3 ||
format == WINED3DFMT_DXT4 || format == WINED3DFMT_DXT5) /* DXT2/3/4/5 is 16 bytes per block */
ret = ((This->currentDesc.Width + 3) >> 2) << 4;
else {
if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
{
/* Since compressed formats are block based, pitch means the amount of
* bytes to the next row of block rather than the next row of pixels. */
UINT row_block_count = (This->currentDesc.Width + format_desc->block_width - 1) / format_desc->block_width;
ret = row_block_count * format_desc->block_byte_count;
}
else
{
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
ret = This->resource.format_desc->byte_count * This->currentDesc.Width; /* Bytes / row */
ret = (ret + alignment - 1) & ~(alignment - 1);
@ -519,20 +519,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3D
}
TRACE("(%p) : Setting texture format to (%d,%s)\n", This, format, debug_d3dformat(format));
if (format == WINED3DFMT_UNKNOWN) {
This->resource.size = 0;
} else if (format == WINED3DFMT_DXT1) {
/* DXT1 is half byte per pixel */
This->resource.size = ((max(This->pow2Width, 4) * format_desc->byte_count) * max(This->pow2Height, 4)) >> 1;
} else if (format == WINED3DFMT_DXT2 || format == WINED3DFMT_DXT3 ||
format == WINED3DFMT_DXT4 || format == WINED3DFMT_DXT5) {
This->resource.size = ((max(This->pow2Width, 4) * format_desc->byte_count) * max(This->pow2Height, 4));
} else {
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
This->resource.size = ((This->pow2Width * format_desc->byte_count) + alignment - 1) & ~(alignment - 1);
This->resource.size *= This->pow2Height;
}
This->resource.size = surface_calculate_size(format_desc, This->resource.wineD3DDevice->surface_alignment,
This->pow2Width, This->pow2Height);
This->Flags |= (WINED3DFMT_D16_LOCKABLE == format) ? SFLAG_LOCKABLE : 0;
@ -735,6 +724,25 @@ static void convert_r5g6b5_x8r8g8b8(const BYTE *src, BYTE *dst,
}
}
static void convert_a8r8g8b8_x8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
unsigned int x, y;
TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
for (y = 0; y < h; ++y)
{
const DWORD *src_line = (const DWORD *)(src + y * pitch_in);
DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
for (x = 0; x < w; ++x)
{
dst_line[x] = 0xff000000 | (src_line[x] & 0xffffff);
}
}
}
struct d3dfmt_convertor_desc {
WINED3DFORMAT from, to;
void (*convert)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
@ -744,6 +752,7 @@ static const struct d3dfmt_convertor_desc convertors[] =
{
{WINED3DFMT_R32_FLOAT, WINED3DFMT_R16_FLOAT, convert_r32_float_r16_float},
{WINED3DFMT_R5G6B5, WINED3DFMT_X8R8G8B8, convert_r5g6b5_x8r8g8b8},
{WINED3DFMT_A8R8G8B8, WINED3DFMT_X8R8G8B8, convert_a8r8g8b8_x8r8g8b8},
};
static inline const struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to)
@ -781,10 +790,9 @@ static IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source,
return NULL;
}
IWineD3DDevice_CreateSurface((IWineD3DDevice *)source->resource.wineD3DDevice,
source->currentDesc.Width, source->currentDesc.Height, to_fmt, TRUE /* lockable */,
TRUE /* discard */, 0 /* level */, &ret, WINED3DRTYPE_SURFACE, 0 /* usage */,
WINED3DPOOL_SCRATCH, WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */,
IWineD3DDevice_CreateSurface((IWineD3DDevice *)source->resource.wineD3DDevice, source->currentDesc.Width,
source->currentDesc.Height, to_fmt, TRUE /* lockable */, TRUE /* discard */, 0 /* level */, &ret,
0 /* usage */, WINED3DPOOL_SCRATCH, WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */,
0 /* MultiSampleQuality */, IWineD3DSurface_GetImplType((IWineD3DSurface *) source), NULL /* parent */);
if(!ret) {
ERR("Failed to create a destination surface for conversion\n");
@ -1127,8 +1135,6 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
dstwidth = xdst.right - xdst.left;
width = (xdst.right - xdst.left) * bpp;
assert(width <= dlock.Pitch);
if (DestRect && Src != This)
dbuf = dlock.pBits;
else
@ -1629,7 +1635,6 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
slock.Pitch = dlock.Pitch;
/* Since slock was originally copied from this surface's description, we can just reuse it */
assert(This->resource.allocatedMemory != NULL);
sbuf = This->resource.allocatedMemory + lock_src.top * pitch + lock_src.left * bpp;
dbuf = This->resource.allocatedMemory + lock_dst.top * pitch + lock_dst.left * bpp;
sEntry = Src->resource.format_desc;
@ -1650,63 +1655,39 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
dEntry = This->resource.format_desc;
}
/* Handle first the FOURCC surfaces... */
if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_FOURCC)
/* Handle compressed surfaces first... */
if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_COMPRESSED)
{
UINT block_width;
UINT block_height;
UINT block_byte_size;
UINT row_block_count;
TRACE("Fourcc -> Fourcc copy\n");
TRACE("compressed -> compressed copy\n");
if (trans)
FIXME("trans arg not supported when a FOURCC surface is involved\n");
FIXME("trans arg not supported when a compressed surface is involved\n");
if (dstx || dsty)
FIXME("offset for destination surface is not supported\n");
if (Src->resource.format_desc->format != This->resource.format_desc->format)
{
FIXME("FOURCC->FOURCC copy only supported for the same type of surface\n");
FIXME("compressed -> compressed copy only supported for the same type of surface\n");
ret = WINED3DERR_WRONGTEXTUREFORMAT;
goto error;
}
if (This->resource.format_desc->format == WINED3DFMT_DXT1)
row_block_count = (w + dEntry->block_width - 1) / dEntry->block_width;
for (y = 0; y < h; y += dEntry->block_height)
{
block_width = 4;
block_height = 4;
block_byte_size = 8;
}
else if (This->resource.format_desc->format == WINED3DFMT_DXT2
|| This->resource.format_desc->format == WINED3DFMT_DXT3
|| This->resource.format_desc->format == WINED3DFMT_DXT4
|| This->resource.format_desc->format == WINED3DFMT_DXT5)
{
block_width = 4;
block_height = 4;
block_byte_size = 16;
}
else
{
FIXME("Unsupported FourCC format %s.\n", debug_d3dformat(This->resource.format_desc->format));
block_width = 1;
block_height = 1;
block_byte_size = This->resource.format_desc->byte_count;
}
for (y = 0; y < h; y += block_height)
{
memcpy(dbuf, sbuf, (w / block_width) * block_byte_size);
memcpy(dbuf, sbuf, row_block_count * dEntry->block_byte_count);
dbuf += dlock.Pitch;
sbuf += slock.Pitch;
}
goto error;
}
if ((sEntry->Flags & WINED3DFMT_FLAG_FOURCC) && !(dEntry->Flags & WINED3DFMT_FLAG_FOURCC))
if ((sEntry->Flags & WINED3DFMT_FLAG_COMPRESSED) && !(dEntry->Flags & WINED3DFMT_FLAG_COMPRESSED))
{
/* TODO: Use the libtxc_dxtn.so shared library to do
* software decompression
*/
ERR("DXTC decompression not supported by now\n");
ERR("Software decompression not supported.\n");
goto error;
}
@ -1844,32 +1825,24 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DL
}
else
{
const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
TRACE("Lock Rect (%p) = l %d, t %d, r %d, b %d\n",
pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
/* DXTn textures are based on compressed blocks of 4x4 pixels, each
* 16 bytes large (8 bytes in case of DXT1). Because of that Pitch has
* slightly different meaning compared to regular textures. For DXTn
* textures Pitch is the size of a row of blocks, 4 high and "width"
* long. The x offset is calculated differently as well, since moving 4
* pixels to the right actually moves an entire 4x4 block to right, ie
* 16 bytes (8 in case of DXT1). */
if (This->resource.format_desc->format == WINED3DFMT_DXT1)
if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
{
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + (pRect->left * 2);
}
else if (This->resource.format_desc->format == WINED3DFMT_DXT2
|| This->resource.format_desc->format == WINED3DFMT_DXT3
|| This->resource.format_desc->format == WINED3DFMT_DXT4
|| This->resource.format_desc->format == WINED3DFMT_DXT5)
{
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + (pRect->left * 4);
/* Compressed textures are block based, so calculate the offset of
* the block that contains the top-left pixel of the locked rectangle. */
pLockedRect->pBits = This->resource.allocatedMemory
+ ((pRect->top / format_desc->block_height) * pLockedRect->Pitch)
+ ((pRect->left / format_desc->block_width) * format_desc->block_byte_count);
}
else
{
pLockedRect->pBits = This->resource.allocatedMemory +
(pLockedRect->Pitch * pRect->top) +
(pRect->left * This->resource.format_desc->byte_count);
(pRect->left * format_desc->byte_count);
}
This->lockedRect.left = pRect->left;
This->lockedRect.top = pRect->top;

View file

@ -29,12 +29,34 @@
#include "wine/port.h"
#include "wined3d_private.h"
#include <assert.h>
#include <stdio.h>
/* Use the d3d_surface debug channel to have one channel for all surfaces */
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
void surface_gdi_cleanup(IWineD3DSurfaceImpl *This)
{
TRACE("(%p) : Cleaning up.\n", This);
if (This->Flags & SFLAG_DIBSECTION)
{
/* Release the DC. */
SelectObject(This->hDC, This->dib.holdbitmap);
DeleteDC(This->hDC);
/* Release the DIB section. */
DeleteObject(This->dib.DIBsection);
This->dib.bitmap_data = NULL;
This->resource.allocatedMemory = NULL;
}
if (This->Flags & SFLAG_USERPTR) IWineD3DSurface_SetMem((IWineD3DSurface *)This, NULL);
if (This->overlay_dest) list_remove(&This->overlay_entry);
HeapFree(GetProcessHeap(), 0, This->palette9);
resource_cleanup((IWineD3DResource *)This);
}
/*****************************************************************************
* IWineD3DSurface::Release, GDI version
*
@ -46,32 +68,15 @@ static ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
if (ref == 0) {
TRACE("(%p) : cleaning up\n", This);
if(This->Flags & SFLAG_DIBSECTION) {
/* Release the DC */
SelectObject(This->hDC, This->dib.holdbitmap);
DeleteDC(This->hDC);
/* Release the DIB section */
DeleteObject(This->dib.DIBsection);
This->dib.bitmap_data = NULL;
This->resource.allocatedMemory = NULL;
}
if(This->Flags & SFLAG_USERPTR) IWineD3DSurface_SetMem(iface, NULL);
if (!ref)
{
surface_gdi_cleanup(This);
HeapFree(GetProcessHeap(), 0, This->palette9);
resource_cleanup((IWineD3DResource *)iface);
if(This->overlay_dest) {
list_remove(&This->overlay_entry);
}
TRACE("(%p) Released\n", This);
TRACE("(%p) Released.\n", This);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
@ -178,7 +183,8 @@ IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface)
char buffer[4096];
++gen;
if ((gen % 10) == 0) {
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, This->glDescription.target, This->glDescription.level, gen);
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm",
This, This->texture_target, This->texture_level, gen);
IWineD3DSurfaceImpl_SaveSnapshot(iface, buffer);
}
/*
@ -194,7 +200,10 @@ IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface)
/* Tell the swapchain to update the screen */
if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
{
x11_copy_to_screen(swapchain, &This->lockedRect);
if(iface == swapchain->frontBuffer)
{
x11_copy_to_screen(swapchain, &This->lockedRect);
}
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
}
@ -485,7 +494,10 @@ static HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface)
/* Tell the swapchain to update the screen */
if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain)))
{
x11_copy_to_screen(swapchain, NULL);
if(iface == swapchain->frontBuffer)
{
x11_copy_to_screen(swapchain, NULL);
}
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
}
@ -536,12 +548,6 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
return WINED3D_OK;
}
static void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
FIXME("(%p) : Should not be called on a GDI surface\n", This);
*glDescription = NULL;
}
static HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
@ -671,7 +677,6 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
IWineD3DBaseSurfaceImpl_BindTexture,
IWineGDISurfaceImpl_SaveSnapshot,
IWineD3DBaseSurfaceImpl_SetContainer,
IWineGDISurfaceImpl_GetGlDesc,
IWineD3DBaseSurfaceImpl_GetData,
IWineD3DBaseSurfaceImpl_SetFormat,
IWineGDISurfaceImpl_PrivateSetup,

View file

@ -45,26 +45,36 @@ static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
IWineD3DSwapChain_SetGammaRamp(iface, 0, &This->orig_gamma);
/* release the ref to the front and back buffer parents */
if(This->frontBuffer) {
/* Release the swapchain's draw buffers. Make sure This->backBuffer[0] is
* the last buffer to be destroyed, FindContext() depends on that. */
if (This->frontBuffer)
{
IWineD3DSurface_SetContainer(This->frontBuffer, 0);
if(D3DCB_DestroyRenderTarget(This->frontBuffer) > 0) {
FIXME("(%p) Something's still holding the front buffer\n",This);
if (D3DCB_DestroyRenderTarget(This->frontBuffer))
{
FIXME("(%p) Something's still holding the front buffer (%p).\n",
This, This->frontBuffer);
}
This->frontBuffer = NULL;
}
if(This->backBuffer) {
UINT i;
for(i = 0; i < This->presentParms.BackBufferCount; i++) {
if (This->backBuffer)
{
UINT i = This->presentParms.BackBufferCount;
while (i--)
{
IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
FIXME("(%p) Something's still holding the back buffer\n",This);
}
if (D3DCB_DestroyRenderTarget(This->backBuffer[i]))
FIXME("(%p) Something's still holding back buffer %u (%p).\n",
This, i, This->backBuffer[i]);
}
HeapFree(GetProcessHeap(), 0, This->backBuffer);
This->backBuffer = NULL;
}
for(i = 0; i < This->num_contexts; i++) {
for (i = 0; i < This->num_contexts; ++i)
{
DestroyContext(This->wineD3DDevice, This->context[i]);
}
/* Restore the screen resolution if we rendered in fullscreen
@ -111,9 +121,9 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
cursor.resource.pool = WINED3DPOOL_SCRATCH;
cursor.resource.format_desc = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &This->wineD3DDevice->adapter->gl_info);
cursor.resource.resourceType = WINED3DRTYPE_SURFACE;
cursor.glDescription.textureName = This->wineD3DDevice->cursorTexture;
cursor.glDescription.target = GL_TEXTURE_2D;
cursor.glDescription.level = 0;
cursor.texture_name = This->wineD3DDevice->cursorTexture;
cursor.texture_target = GL_TEXTURE_2D;
cursor.texture_level = 0;
cursor.currentDesc.Width = This->wineD3DDevice->cursorWidth;
cursor.currentDesc.Height = This->wineD3DDevice->cursorHeight;
cursor.glRect.left = 0;
@ -131,7 +141,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
if (This->presentParms.Windowed) {
MapWindowPoints(NULL, This->win_handle, (LPPOINT)&destRect, 2);
}
IWineD3DSurface_Blt(This->backBuffer[0], &destRect, (IWineD3DSurface *) &cursor, NULL, WINEDDBLT_KEYSRC, NULL, WINED3DTEXF_NONE);
IWineD3DSurface_Blt(This->backBuffer[0], &destRect, (IWineD3DSurface *)&cursor,
NULL, WINEDDBLT_KEYSRC, NULL, WINED3DTEXF_POINT);
}
if(This->wineD3DDevice->logo_surface) {
/* Blit the logo into the upper left corner of the drawable */
@ -223,7 +234,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
TRACE("Clearing the color buffer with cyan color\n");
IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL,
WINED3DCLEAR_TARGET, 0xff00ffff, 1.0, 0);
WINED3DCLEAR_TARGET, 0xff00ffff, 1.0f, 0);
}
if(((IWineD3DSurfaceImpl *) This->frontBuffer)->Flags & SFLAG_INSYSMEM ||
@ -371,10 +382,11 @@ const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
IWineD3DBaseSwapChainImpl_GetGammaRamp
};
WineD3DContext *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *iface) {
WineD3DContext *ctx;
struct wined3d_context *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *iface)
{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
WineD3DContext **newArray;
struct wined3d_context **newArray;
struct wined3d_context *ctx;
TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
@ -401,10 +413,11 @@ WineD3DContext *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *
return ctx;
}
void get_drawable_size_swapchain(IWineD3DSurfaceImpl *This, UINT *width, UINT *height) {
void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->current_rt;
/* The drawable size of an onscreen drawable is the surface size.
* (Actually: The window size, but the surface is created in window size)
*/
*width = This->currentDesc.Width;
*height = This->currentDesc.Height;
* (Actually: The window size, but the surface is created in window size) */
*width = surface->currentDesc.Width;
*height = surface->currentDesc.Height;
}

View file

@ -25,11 +25,271 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
#define GLINFO_LOCATION (*gl_info)
static void texture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource PreLoad method. */
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
unsigned int i;
BOOL srgb_mode;
BOOL *dirty;
TRACE("(%p) : About to load texture.\n", This);
switch (srgb)
{
case SRGB_RGB:
srgb_mode = FALSE;
break;
case SRGB_BOTH:
texture_internal_preload(iface, SRGB_RGB);
/* Fallthrough */
case SRGB_SRGB:
srgb_mode = TRUE;
break;
default:
srgb_mode = This->baseTexture.is_srgb;
break;
}
dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
if (!device->isInDraw)
{
/* ActivateContext sets isInDraw to TRUE when loading a pbuffer into a texture,
* thus no danger of recursive calls. */
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
}
if (This->resource.format_desc->format == WINED3DFMT_P8
|| This->resource.format_desc->format == WINED3DFMT_A8P8)
{
for (i = 0; i < This->baseTexture.levels; ++i)
{
if (palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[i]))
{
TRACE("Reloading surface because the d3d8/9 palette was changed.\n");
/* TODO: This is not necessarily needed with hw palettized texture support. */
IWineD3DSurface_LoadLocation(This->surfaces[i], SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
IWineD3DSurface_ModifyLocation(This->surfaces[i], SFLAG_INTEXTURE, FALSE);
}
}
}
/* If the texture is marked dirty or the srgb sampler setting has changed
* since the last load then reload the surfaces. */
if (*dirty)
{
for (i = 0; i < This->baseTexture.levels; ++i)
{
IWineD3DSurface_LoadTexture(This->surfaces[i], srgb_mode);
}
}
else
{
TRACE("(%p) Texture not dirty, nothing to do.\n", iface);
}
/* No longer dirty. */
*dirty = FALSE;
}
static void texture_cleanup(IWineD3DTextureImpl *This, D3DCB_DESTROYSURFACEFN surface_destroy_cb)
{
unsigned int i;
TRACE("(%p) : Cleaning up\n", This);
for (i = 0; i < This->baseTexture.levels; ++i)
{
if (This->surfaces[i])
{
/* Clean out the texture name we gave to the surface so that the
* surface doesn't try and release it */
surface_set_texture_name(This->surfaces[i], 0, TRUE);
surface_set_texture_name(This->surfaces[i], 0, FALSE);
surface_set_texture_target(This->surfaces[i], 0);
IWineD3DSurface_SetContainer(This->surfaces[i], 0);
surface_destroy_cb(This->surfaces[i]);
}
}
TRACE("(%p) : Cleaning up base texture\n", This);
basetexture_cleanup((IWineD3DBaseTexture *)This);
}
HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
UINT pow2_width, pow2_height;
UINT tmp_w, tmp_h;
unsigned int i;
HRESULT hr;
/* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
if (WINED3DFMT_UNKNOWN >= format)
{
WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
return WINED3DERR_INVALIDCALL;
}
/* Non-power2 support. */
if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO))
{
pow2_width = width;
pow2_height = height;
}
else
{
/* Find the nearest pow2 match. */
pow2_width = pow2_height = 1;
while (pow2_width < width) pow2_width <<= 1;
while (pow2_height < height) pow2_height <<= 1;
if (pow2_width != width || pow2_height != height)
{
if (levels > 1)
{
WARN("Attempted to create a mipmapped np2 texture without unconditional np2 support.\n");
return WINED3DERR_INVALIDCALL;
}
levels = 1;
}
}
/* Calculate levels for mip mapping. */
if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
{
WARN("No mipmap generation support, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (levels > 1)
{
WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
levels = 1;
}
else if (!levels)
{
levels = wined3d_log2i(max(width, height)) + 1;
TRACE("Calculated levels = %u.\n", levels);
}
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
WINED3DRTYPE_TEXTURE, device, 0, usage, format_desc, pool, parent);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x.\n", hr);
return hr;
}
/* Precalculated scaling for 'faked' non power of two texture coords.
* Second also don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
* is used in combination with texture uploads (RTL_READTEX). The reason is that EXT_PALETTED_TEXTURE
* doesn't work in combination with ARB_TEXTURE_RECTANGLE. */
if (GL_SUPPORT(WINE_NORMALIZED_TEXRECT) && (width != pow2_width || height != pow2_height))
{
texture->baseTexture.pow2Matrix[0] = 1.0f;
texture->baseTexture.pow2Matrix[5] = 1.0f;
texture->baseTexture.pow2Matrix[10] = 1.0f;
texture->baseTexture.pow2Matrix[15] = 1.0f;
texture->target = GL_TEXTURE_2D;
texture->cond_np2 = TRUE;
texture->baseTexture.minMipLookup = minMipLookup_noFilter;
}
else if (GL_SUPPORT(ARB_TEXTURE_RECTANGLE) && (width != pow2_width || height != pow2_height)
&& !((format_desc->format == WINED3DFMT_P8) && GL_SUPPORT(EXT_PALETTED_TEXTURE)
&& (wined3d_settings.rendertargetlock_mode == RTL_READTEX)))
{
if ((width != 1) || (height != 1)) texture->baseTexture.pow2Matrix_identity = FALSE;
texture->baseTexture.pow2Matrix[0] = (float)width;
texture->baseTexture.pow2Matrix[5] = (float)height;
texture->baseTexture.pow2Matrix[10] = 1.0f;
texture->baseTexture.pow2Matrix[15] = 1.0f;
texture->target = GL_TEXTURE_RECTANGLE_ARB;
texture->cond_np2 = TRUE;
if(texture->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
{
texture->baseTexture.minMipLookup = minMipLookup_noMip;
}
else
{
texture->baseTexture.minMipLookup = minMipLookup_noFilter;
}
}
else
{
if ((width != pow2_width) || (height != pow2_height))
{
texture->baseTexture.pow2Matrix_identity = FALSE;
texture->baseTexture.pow2Matrix[0] = (((float)width) / ((float)pow2_width));
texture->baseTexture.pow2Matrix[5] = (((float)height) / ((float)pow2_height));
}
else
{
texture->baseTexture.pow2Matrix[0] = 1.0f;
texture->baseTexture.pow2Matrix[5] = 1.0f;
}
texture->baseTexture.pow2Matrix[10] = 1.0f;
texture->baseTexture.pow2Matrix[15] = 1.0f;
texture->target = GL_TEXTURE_2D;
texture->cond_np2 = FALSE;
}
TRACE("xf(%f) yf(%f)\n", texture->baseTexture.pow2Matrix[0], texture->baseTexture.pow2Matrix[5]);
/* Generate all the surfaces. */
tmp_w = width;
tmp_h = height;
for (i = 0; i < texture->baseTexture.levels; ++i)
{
/* Use the callback to create the texture surface. */
hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h, format_desc->format,
usage, pool, i, WINED3DCUBEMAP_FACE_POSITIVE_X, &texture->surfaces[i]);
if (FAILED(hr) || ((IWineD3DSurfaceImpl *)texture->surfaces[i])->Flags & SFLAG_OVERSIZE)
{
FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
texture->surfaces[i] = NULL;
texture_cleanup(texture, D3DCB_DefaultDestroySurface);
return hr;
}
IWineD3DSurface_SetContainer(texture->surfaces[i], (IWineD3DBase *)texture);
TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[i]);
surface_set_texture_target(texture->surfaces[i], texture->target);
/* Calculate the next mipmap level. */
tmp_w = max(1, tmp_w >> 1);
tmp_h = max(1, tmp_h >> 1);
}
texture->baseTexture.internal_preload = texture_internal_preload;
return WINED3D_OK;
}
#undef GLINFO_LOCATION
/* *******************************************
IWineD3DTexture IUnknown parts follow
******************************************* */
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID riid, LPVOID *ppobj)
{
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
@ -92,61 +352,6 @@ static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) {
return resource_get_priority((IWineD3DResource *)iface);
}
void texture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb) {
/* Override the IWineD3DResource PreLoad method */
unsigned int i;
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL srgb_mode;
BOOL *dirty;
TRACE("(%p) : About to load texture\n", This);
switch(srgb) {
case SRGB_RGB: srgb_mode = FALSE; break;
case SRGB_BOTH: texture_internal_preload(iface, SRGB_RGB);
case SRGB_SRGB: srgb_mode = TRUE; break;
/* DONTKNOW, and shut up the compiler */
default: srgb_mode = This->baseTexture.is_srgb; break;
}
dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
if(!device->isInDraw) {
/* ActivateContext sets isInDraw to TRUE when loading a pbuffer into a texture, thus no danger of
* recursive calls
*/
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
}
if (This->resource.format_desc->format == WINED3DFMT_P8
|| This->resource.format_desc->format == WINED3DFMT_A8P8)
{
for (i = 0; i < This->baseTexture.levels; i++) {
if(palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[i])) {
TRACE("Reloading surface because the d3d8/9 palette was changed\n");
/* TODO: This is not necessarily needed with hw palettized texture support */
IWineD3DSurface_LoadLocation(This->surfaces[i], SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
IWineD3DSurface_ModifyLocation(This->surfaces[i], SFLAG_INTEXTURE, FALSE);
}
}
}
/* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */
if (*dirty) {
for (i = 0; i < This->baseTexture.levels; i++) {
IWineD3DSurface_LoadTexture(This->surfaces[i], srgb_mode);
}
} else {
TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
}
/* No longer dirty */
*dirty = FALSE;
return ;
}
static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
texture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
@ -213,6 +418,7 @@ static BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) {
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
/* Context activation is done by the caller. */
static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface, BOOL srgb) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
BOOL set_gl_texture_desc;
@ -271,33 +477,13 @@ static BOOL WINAPI IWineD3DTextureImpl_IsCondNP2(IWineD3DTexture *iface) {
return This->cond_np2;
}
static void WINAPI IWineD3DTextureImpl_ApplyStateChanges(IWineD3DTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
TRACE("(%p) : relay to BaseTexture\n", iface);
basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
}
/* *******************************************
IWineD3DTexture IWineD3DTexture parts follow
******************************************* */
static void WINAPI IWineD3DTextureImpl_Destroy(IWineD3DTexture *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroySurface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
unsigned int i;
TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) {
if (This->surfaces[i] != NULL) {
/* Clean out the texture name we gave to the surface so that the surface doesn't try and release it */
surface_set_texture_name(This->surfaces[i], 0, TRUE);
surface_set_texture_name(This->surfaces[i], 0, FALSE);
surface_set_texture_target(This->surfaces[i], 0);
IWineD3DSurface_SetContainer(This->surfaces[i], 0);
D3DCB_DestroySurface(This->surfaces[i]);
}
}
TRACE("(%p) : cleaning up base texture\n", This);
basetexture_cleanup((IWineD3DBaseTexture *)iface);
texture_cleanup(This, D3DCB_DestroySurface);
/* free the object */
HeapFree(GetProcessHeap(), 0, This);
}
@ -401,7 +587,6 @@ const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
IWineD3DTextureImpl_BindTexture,
IWineD3DTextureImpl_GetTextureDimensions,
IWineD3DTextureImpl_IsCondNP2,
IWineD3DTextureImpl_ApplyStateChanges,
/* IWineD3DTexture */
IWineD3DTextureImpl_Destroy,
IWineD3DTextureImpl_GetLevelDesc,

File diff suppressed because it is too large Load diff

View file

@ -71,6 +71,10 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This)
This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF));
break;
case WINED3D_SHADER_VERSION(4,0):
FIXME("Using 3.0 limits for 4.0 shader\n");
/* Fall through */
case WINED3D_SHADER_VERSION(3,0):
This->baseShader.limits.temporary = 32;
This->baseShader.limits.constant_bool = 32;
@ -101,26 +105,6 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This)
}
}
/* This is an internal function,
* used to create fake semantics for shaders
* that don't have them - d3d8 shaders where the declaration
* stores the register for each input
*/
static void vshader_set_input(
IWineD3DVertexShaderImpl* This,
unsigned int regnum,
BYTE usage, BYTE usage_idx) {
This->semantics_in[regnum].usage = usage;
This->semantics_in[regnum].usage_idx = usage_idx;
This->semantics_in[regnum].reg.reg.type = WINED3DSPR_INPUT;
This->semantics_in[regnum].reg.reg.idx = regnum;
This->semantics_in[regnum].reg.write_mask = WINED3DSP_WRITEMASK_ALL;
This->semantics_in[regnum].reg.modifiers = 0;
This->semantics_in[regnum].reg.shift = 0;
This->semantics_in[regnum].reg.reg.rel_addr = NULL;
}
static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2) {
if (usage_idx1 != usage_idx2) return FALSE;
if (usage1 == usage2) return TRUE;
@ -130,19 +114,18 @@ static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_id
return FALSE;
}
BOOL vshader_get_input(
IWineD3DVertexShader* iface,
BYTE usage_req, BYTE usage_idx_req,
unsigned int* regnum) {
BOOL vshader_get_input(IWineD3DVertexShader* iface, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum)
{
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
WORD map = This->baseShader.reg_maps.input_registers;
unsigned int i;
IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface;
int i;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
for (i = 0; i < MAX_ATTRIBS; i++) {
if (!This->baseShader.reg_maps.attributes[i]) continue;
if (match_usage(This->semantics_in[i].usage,
This->semantics_in[i].usage_idx, usage_req, usage_idx_req))
if (match_usage(This->attributes[i].usage,
This->attributes[i].usage_idx, usage_req, usage_idx_req))
{
*regnum = i;
return TRUE;
@ -203,7 +186,7 @@ static ULONG WINAPI IWineD3DVertexShaderImpl_Release(IWineD3DVertexShader *iface
static HRESULT WINAPI IWineD3DVertexShaderImpl_GetParent(IWineD3DVertexShader *iface, IUnknown** parent){
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
*parent = This->parent;
IUnknown_AddRef(*parent);
TRACE("(%p) : returning %p\n", This, *parent);
@ -249,6 +232,7 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
IWineD3DVertexShaderImpl *This =(IWineD3DVertexShaderImpl *)iface;
IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device;
const struct wined3d_shader_frontend *fe;
unsigned int i;
HRESULT hr;
shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
@ -280,16 +264,26 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
This->min_rel_offset = GL_LIMITS(vshader_constantsF);
This->max_rel_offset = 0;
hr = shader_get_registers_used((IWineD3DBaseShader*) This, fe,
reg_maps, This->semantics_in, This->semantics_out, pFunction,
GL_LIMITS(vshader_constantsF));
reg_maps, This->attributes, NULL, This->output_signature,
pFunction, GL_LIMITS(vshader_constantsF));
if (hr != WINED3D_OK) return hr;
if (output_signature)
{
for (i = 0; i < output_signature->element_count; ++i)
{
struct wined3d_shader_signature_element *e = &output_signature->elements[i];
reg_maps->output_registers |= 1 << e->register_idx;
This->output_signature[e->register_idx] = *e;
}
}
vshader_set_limits(This);
if(deviceImpl->vs_selected_mode == SHADER_ARB &&
(GLINFO_LOCATION).arb_vs_offset_limit &&
This->min_rel_offset <= This->max_rel_offset) {
if (deviceImpl->vs_selected_mode == SHADER_ARB
&& ((GLINFO_LOCATION).quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT)
&& This->min_rel_offset <= This->max_rel_offset)
{
if(This->max_rel_offset - This->min_rel_offset > 127) {
FIXME("The difference between the minimum and maximum relative offset is > 127\n");
FIXME("Which this OpenGL implementation does not support. Try using GLSL\n");
@ -312,19 +306,6 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
return WINED3D_OK;
}
/* Preload semantics for d3d8 shaders */
static void WINAPI IWineD3DVertexShaderImpl_FakeSemantics(IWineD3DVertexShader *iface, IWineD3DVertexDeclaration *vertex_declaration) {
IWineD3DVertexShaderImpl *This =(IWineD3DVertexShaderImpl *)iface;
IWineD3DVertexDeclarationImpl* vdecl = (IWineD3DVertexDeclarationImpl*)vertex_declaration;
unsigned int i;
for (i = 0; i < vdecl->element_count; ++i)
{
const struct wined3d_vertex_declaration_element *e = &vdecl->elements[i];
vshader_set_input(This, e->output_slot, e->usage, e->usage_idx);
}
}
/* Set local constants for d3d8 shaders */
static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertexShader *iface,
UINT start_idx, const float *src_data, UINT count) {
@ -351,22 +332,6 @@ static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertex
return WINED3D_OK;
}
static GLuint vertexshader_compile(IWineD3DVertexShaderImpl *This, const struct vs_compile_args *args) {
IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device;
SHADER_BUFFER buffer;
GLuint ret;
/* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This);
shader_buffer_init(&buffer);
This->cur_args = args;
ret = deviceImpl->shader_backend->shader_generate_vshader((IWineD3DVertexShader *)This, &buffer, args);
This->cur_args = NULL;
shader_buffer_free(&buffer);
return ret;
}
const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
{
/*** IUnknown methods ***/
@ -380,7 +345,6 @@ const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
/*** IWineD3DVertexShader methods ***/
IWineD3DVertexShaderImpl_GetDevice,
IWineD3DVertexShaderImpl_GetFunction,
IWineD3DVertexShaderImpl_FakeSemantics,
IWIneD3DVertexShaderImpl_SetLocalConstantsF
};
@ -388,52 +352,3 @@ void find_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockIm
args->fog_src = stateblock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE ? VS_FOG_COORD : VS_FOG_Z;
args->swizzle_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.swizzle_map;
}
static inline BOOL vs_args_equal(const struct vs_compile_args *stored, const struct vs_compile_args *new,
const DWORD use_map) {
if((stored->swizzle_map & use_map) != new->swizzle_map) return FALSE;
return stored->fog_src == new->fog_src;
}
GLuint find_gl_vshader(IWineD3DVertexShaderImpl *shader, const struct vs_compile_args *args)
{
UINT i;
DWORD new_size = shader->shader_array_size;
struct vs_compiled_shader *new_array;
DWORD use_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.use_map;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap or a binary search
* (cache coherency etc)
*/
for(i = 0; i < shader->num_gl_shaders; i++) {
if(vs_args_equal(&shader->gl_shaders[i].args, args, use_map)) {
return shader->gl_shaders[i].prgId;
}
}
TRACE("No matching GL shader found, compiling a new shader\n");
if(shader->shader_array_size == shader->num_gl_shaders) {
if (shader->num_gl_shaders)
{
new_size = shader->shader_array_size + max(1, shader->shader_array_size / 2);
new_array = HeapReAlloc(GetProcessHeap(), 0, shader->gl_shaders,
new_size * sizeof(*shader->gl_shaders));
} else {
new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader->gl_shaders));
new_size = 1;
}
if(!new_array) {
ERR("Out of memory\n");
return 0;
}
shader->gl_shaders = new_array;
shader->shader_array_size = new_size;
}
shader->gl_shaders[shader->num_gl_shaders].args = *args;
shader->gl_shaders[shader->num_gl_shaders].prgId = vertexshader_compile(shader, args);
return shader->gl_shaders[shader->num_gl_shaders++].prgId;
}

View file

@ -26,10 +26,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* Context activation is done by the caller. */
static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
IWineD3DVolumeTexture *texture;
int active_sampler;
DWORD active_sampler;
/* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
* Read the unit back instead of switching to 0, this avoids messing around with the state manager's
@ -52,7 +53,8 @@ static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
active_sampler = 0;
}
if (active_sampler != -1) {
if (active_sampler != WINED3D_UNMAPPED_STAGE)
{
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));
}
@ -196,14 +198,15 @@ static HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DV
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : copying into %p\n", This, pDesc);
*(pDesc->Format) = This->resource.format_desc->format;
*(pDesc->Type) = This->resource.resourceType;
*(pDesc->Usage) = This->resource.usage;
*(pDesc->Pool) = This->resource.pool;
*(pDesc->Size) = This->resource.size; /* dx8 only */
*(pDesc->Width) = This->currentDesc.Width;
*(pDesc->Height) = This->currentDesc.Height;
*(pDesc->Depth) = This->currentDesc.Depth;
pDesc->Format = This->resource.format_desc->format;
pDesc->Type = This->resource.resourceType;
pDesc->Usage = This->resource.usage;
pDesc->Pool = This->resource.pool;
pDesc->Size = This->resource.size; /* dx8 only */
pDesc->Width = This->currentDesc.Width;
pDesc->Height = This->currentDesc.Height;
pDesc->Depth = This->currentDesc.Depth;
return WINED3D_OK;
}
@ -300,6 +303,7 @@ static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWi
return WINED3D_OK;
}
/* Context activation is done by the caller. */
static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
const struct GlPixelFormatDesc *glDesc = This->resource.format_desc;

View file

@ -24,11 +24,177 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
#define GLINFO_LOCATION (*gl_info)
static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource Preload method. */
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
BOOL srgb_mode = This->baseTexture.is_srgb;
BOOL srgb_was_toggled = FALSE;
unsigned int i;
TRACE("(%p) : About to load texture.\n", This);
if (!device->isInDraw)
{
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
}
else if (GL_SUPPORT(EXT_TEXTURE_SRGB) && This->baseTexture.bindCount > 0)
{
srgb_mode = device->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE];
srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode;
This->baseTexture.is_srgb = srgb_mode;
}
/* If the texture is marked dirty or the srgb sampler setting has changed
* since the last load then reload the volumes. */
if (This->baseTexture.dirty)
{
for (i = 0; i < This->baseTexture.levels; ++i)
{
IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
}
}
else if (srgb_was_toggled)
{
for (i = 0; i < This->baseTexture.levels; ++i)
{
volume_add_dirty_box(This->volumes[i], NULL);
IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
}
}
else
{
TRACE("(%p) Texture not dirty, nothing to do.\n", iface);
}
/* No longer dirty */
This->baseTexture.dirty = FALSE;
}
static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This, D3DCB_DESTROYVOLUMEFN volume_destroy_cb)
{
unsigned int i;
TRACE("(%p) : Cleaning up.\n", This);
for (i = 0; i < This->baseTexture.levels; ++i)
{
IWineD3DVolume *volume = This->volumes[i];
if (volume)
{
/* Cleanup the container. */
IWineD3DVolume_SetContainer(volume, NULL);
volume_destroy_cb(volume);
}
}
basetexture_cleanup((IWineD3DBaseTexture *)This);
}
HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height, UINT depth, UINT levels,
IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
UINT tmp_w, tmp_h, tmp_d;
unsigned int i;
HRESULT hr;
/* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
if (WINED3DFMT_UNKNOWN >= format)
{
WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
return WINED3DERR_INVALIDCALL;
}
if (!GL_SUPPORT(EXT_TEXTURE3D))
{
WARN("(%p) : Texture cannot be created - no volume texture support.\n", texture);
return WINED3DERR_INVALIDCALL;
}
/* Calculate levels for mip mapping. */
if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
{
WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (levels > 1)
{
WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
levels = 1;
}
else if (!levels)
{
levels = wined3d_log2i(max(max(width, height), depth)) + 1;
TRACE("Calculated levels = %u.\n", levels);
}
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
WINED3DRTYPE_VOLUMETEXTURE, device, 0, usage, format_desc, pool, parent);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x.\n", hr);
return hr;
}
/* Is NP2 support for volumes needed? */
texture->baseTexture.pow2Matrix[0] = 1.0f;
texture->baseTexture.pow2Matrix[5] = 1.0f;
texture->baseTexture.pow2Matrix[10] = 1.0f;
texture->baseTexture.pow2Matrix[15] = 1.0f;
/* Generate all the surfaces. */
tmp_w = width;
tmp_h = height;
tmp_d = depth;
for (i = 0; i < texture->baseTexture.levels; ++i)
{
/* Create the volume. */
hr = IWineD3DDeviceParent_CreateVolume(device->device_parent, parent,
tmp_w, tmp_h, tmp_d, format, pool, usage, &texture->volumes[i]);
if (FAILED(hr))
{
ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
texture->volumes[i] = NULL;
volumetexture_cleanup(texture, D3DCB_DefaultDestroyVolume);
return hr;
}
/* Set its container to this texture. */
IWineD3DVolume_SetContainer(texture->volumes[i], (IWineD3DBase *)texture);
/* Calculate the next mipmap level. */
tmp_w = max(1, tmp_w >> 1);
tmp_h = max(1, tmp_h >> 1);
tmp_d = max(1, tmp_d >> 1);
}
texture->baseTexture.internal_preload = volumetexture_internal_preload;
return WINED3D_OK;
}
#undef GLINFO_LOCATION
/* *******************************************
IWineD3DTexture IUnknown parts follow
******************************************* */
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static HRESULT WINAPI IWineD3DVolumeTextureImpl_QueryInterface(IWineD3DVolumeTexture *iface, REFIID riid, LPVOID *ppobj)
{
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
@ -90,43 +256,6 @@ static DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture
return resource_get_priority((IWineD3DResource *)iface);
}
void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb) {
/* Overrider the IWineD3DResource Preload method */
unsigned int i;
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL srgb_mode = This->baseTexture.is_srgb;
BOOL srgb_was_toggled = FALSE;
TRACE("(%p) : About to load texture\n", This);
if(!device->isInDraw) {
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
} else if (GL_SUPPORT(EXT_TEXTURE_SRGB) && This->baseTexture.bindCount > 0) {
srgb_mode = device->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE];
srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode;
This->baseTexture.is_srgb = srgb_mode;
}
/* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */
if (This->baseTexture.dirty) {
for (i = 0; i < This->baseTexture.levels; i++)
IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
} else if (srgb_was_toggled) {
for (i = 0; i < This->baseTexture.levels; i++) {
volume_add_dirty_box(This->volumes[i], NULL);
IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
}
} else {
TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
}
/* No longer dirty */
This->baseTexture.dirty = FALSE;
return ;
}
static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
volumetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
@ -191,6 +320,7 @@ static BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *ifa
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
/* Context activation is done by the caller. */
static HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface, BOOL srgb) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
BOOL dummy;
@ -211,30 +341,14 @@ static BOOL WINAPI IWineD3DVolumeTextureImpl_IsCondNP2(IWineD3DVolumeTexture *if
return FALSE;
}
static void WINAPI IWineD3DVolumeTextureImpl_ApplyStateChanges(IWineD3DVolumeTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : nothing to do, passing to base texture\n", This);
basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
}
/* *******************************************
IWineD3DVolumeTexture IWineD3DVolumeTexture parts follow
******************************************* */
static void WINAPI IWineD3DVolumeTextureImpl_Destroy(IWineD3DVolumeTexture *iface, D3DCB_DESTROYVOLUMEFN D3DCB_DestroyVolume) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
unsigned int i;
TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) {
if (This->volumes[i] != NULL) {
/* Cleanup the container */
IWineD3DVolume_SetContainer(This->volumes[i], 0);
D3DCB_DestroyVolume(This->volumes[i]);
}
}
basetexture_cleanup((IWineD3DBaseTexture *)iface);
volumetexture_cleanup(This, D3DCB_DestroyVolume);
HeapFree(GetProcessHeap(), 0, This);
}
@ -330,7 +444,6 @@ const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =
IWineD3DVolumeTextureImpl_BindTexture,
IWineD3DVolumeTextureImpl_GetTextureDimensions,
IWineD3DVolumeTextureImpl_IsCondNP2,
IWineD3DVolumeTextureImpl_ApplyStateChanges,
/* volume texture */
IWineD3DVolumeTextureImpl_Destroy,
IWineD3DVolumeTextureImpl_GetLevelDesc,

View file

@ -1,2 +1,4 @@
@ stdcall WineDirect3DCreate(long ptr)
@ stdcall WineDirect3DCreateClipper(ptr)
@ stdcall wined3d_mutex_lock()
@ stdcall wined3d_mutex_unlock()

View file

@ -1141,10 +1141,13 @@ void (WINE_GLAPI *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
void (WINE_GLAPI *glPointParameterfv) (GLenum pname, const GLfloat *params);
/* glFinish and glFlush are always loaded from opengl32.dll, thus they always have
* __stdcall calling convention
* __stdcall calling convention.
*
* They are wgl functions and must not be called inside the gl lock, give them a
* name that makes this clear
*/
void (__stdcall *glFinish) ();
void (__stdcall *glFlush) ();
void (__stdcall *wglFinish) ();
void (__stdcall *wglFlush) ();
/* WGL functions */
HGLRC (WINAPI *pwglCreateContext)(HDC);
@ -1517,6 +1520,20 @@ BOOL (WINAPI *pwglShareLists)(HGLRC,HGLRC);
#endif
typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
/* GL_ARB_depth_buffer_float */
#ifndef GL_ARB_depth_buffer_float
#define GL_ARB_depth_buffer_float 1
#define GL_DEPTH_COMPONENT32F 0x8cac
#define GL_DEPTH32F_STENCIL8 0x8cad
#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8dad
#endif
/* GL_ARB_depth_clamp */
#ifndef GL_ARB_depth_clamp
#define GL_ARB_depth_clamp 1
#define GL_DEPTH_CLAMP 0x864f
#endif
/* GL_ARB_depth_texture */
#ifndef GL_ARB_depth_texture
#define GL_ARB_depth_texture 1
@ -1897,6 +1914,15 @@ typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint sr
#endif
typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
/* GL_EXT_packed_depth_stencil */
#ifndef GL_EXT_packed_depth_stencil
#define GL_EXT_packed_depth_stencil 1
#define GL_DEPTH_STENCIL_EXT 0x84f9
#define GL_UNSIGNED_INT_24_8_EXT 0x84fa
#define GL_DEPTH24_STENCIL8_EXT 0x88f0
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88f1
#endif
/* GL_EXT_secondary_color */
#ifndef GL_EXT_secondary_color
#define GL_EXT_secondary_color 1
@ -1935,6 +1961,17 @@ typedef void (WINE_GLAPI * PGLFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum inte
#endif
typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
/* GL_EXT_provoking_vertex */
#ifndef GL_EXT_provoking_vertex
#define GL_EXT_provoking_vertex 1
#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8e4d
#define GL_LAST_VERTEX_CONVENTION_EXT 0x8e4e
#define GL_PROVOKING_VERTEX_EXT 0x8e4f
#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTIONS_EXT 0x8e4c
#endif
typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode);
/* GL_EXT_texture3D */
#ifndef GL_EXT_texture3D
#define GL_EXT_texture3D 1
@ -3080,6 +3117,13 @@ typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI) (GLuint dst, const
#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
#endif
/* GL_NV_vertex_program2_option */
#ifndef GL_NV_vertex_program2_option
#define GL_NV_vertex_program2_option
#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
#endif
/* GL_VERSION_2_0 */
#ifndef GL_VERSION_2_0
#define GL_VERSION_2_0 1
@ -3302,6 +3346,18 @@ typedef enum _GL_Cards {
CARD_ATI_RADEON_HD2600 = 0x9581,
CARD_ATI_RADEON_HD2900 = 0x9400,
CARD_ATI_RADEON_HD3200 = 0x9620,
CARD_ATI_RADEON_HD4350 = 0x954f,
CARD_ATI_RADEON_HD4550 = 0x9540,
CARD_ATI_RADEON_HD4600 = 0x9495,
CARD_ATI_RADEON_HD4650 = 0x9498,
CARD_ATI_RADEON_HD4670 = 0x9490,
CARD_ATI_RADEON_HD4700 = 0x944e,
CARD_ATI_RADEON_HD4770 = 0x94b3,
CARD_ATI_RADEON_HD4800 = 0x944c, /* picked one value between 9440,944c,9442,9460 */
CARD_ATI_RADEON_HD4830 = 0x944c,
CARD_ATI_RADEON_HD4850 = 0x9442,
CARD_ATI_RADEON_HD4870 = 0x9440,
CARD_ATI_RADEON_HD4890 = 0x9460,
CARD_NVIDIA_RIVA_128 = 0x0018,
CARD_NVIDIA_RIVA_TNT = 0x0020,
@ -3342,39 +3398,21 @@ typedef enum _GL_Cards {
CARD_INTEL_I915G = 0x2582,
CARD_INTEL_I915GM = 0x2592,
CARD_INTEL_I945GM = 0x27a2, /* Same as GMA 950?? */
CARD_INTEL_X3100 = 0x2a02, /* found in macs. Same as GMA 965? */
} GL_Cards;
#define WINE_DEFAULT_VIDMEM 64*1024*1024
typedef enum _GL_VSVersion {
VS_VERSION_NOT_SUPPORTED = 0x0,
VS_VERSION_10 = 0x10,
VS_VERSION_11 = 0x11,
VS_VERSION_20 = 0x20,
VS_VERSION_30 = 0x30,
/*Force 32-bits*/
VS_VERSION_FORCE_DWORD = 0x7FFFFFFF
} GL_VSVersion;
typedef enum _GL_PSVersion {
PS_VERSION_NOT_SUPPORTED = 0x0,
PS_VERSION_10 = 0x10,
PS_VERSION_11 = 0x11,
PS_VERSION_12 = 0x12,
PS_VERSION_13 = 0x13,
PS_VERSION_14 = 0x14,
PS_VERSION_20 = 0x20,
PS_VERSION_30 = 0x30,
/*Force 32-bits*/
PS_VERSION_FORCE_DWORD = 0x7FFFFFFF
} GL_PSVersion;
#define MAKEDWORD_VERSION(maj, min) ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF)
/* OpenGL Supported Extensions (ARB and EXT) */
typedef enum _GL_SupportedExt {
WINED3D_GL_EXT_NONE,
/* ARB */
ARB_COLOR_BUFFER_FLOAT,
ARB_DEPTH_BUFFER_FLOAT,
ARB_DEPTH_CLAMP,
ARB_DEPTH_TEXTURE,
ARB_DRAW_BUFFERS,
ARB_FRAGMENT_PROGRAM,
ARB_FRAGMENT_SHADER,
@ -3414,9 +3452,11 @@ typedef enum _GL_SupportedExt {
EXT_FRAMEBUFFER_OBJECT,
EXT_FRAMEBUFFER_BLIT,
EXT_FRAMEBUFFER_MULTISAMPLE,
EXT_PACKED_DEPTH_STENCIL,
EXT_PALETTED_TEXTURE,
EXT_PIXEL_BUFFER_OBJECT,
EXT_POINT_PARAMETERS,
EXT_PROVOKING_VERTEX,
EXT_SECONDARY_COLOR,
EXT_STENCIL_TWO_SIDE,
EXT_STENCIL_WRAP,
@ -3449,7 +3489,9 @@ typedef enum _GL_SupportedExt {
NV_VERTEX_PROGRAM,
NV_VERTEX_PROGRAM1_1,
NV_VERTEX_PROGRAM2,
NV_VERTEX_PROGRAM2_OPTION,
NV_VERTEX_PROGRAM3,
NV_FRAGMENT_PROGRAM_OPTION,
NV_FENCE,
NV_DEPTH_CLAMP,
NV_LIGHT_MAX_EXPONENT,
@ -3478,7 +3520,7 @@ typedef enum _GL_SupportedExt {
WGL_ARB_PIXEL_FORMAT,
WGL_WINE_PIXEL_FORMAT_PASSTHROUGH,
OPENGL_SUPPORTED_EXT_END
WINED3D_GL_EXT_COUNT,
} GL_SupportedExt;
@ -3591,6 +3633,8 @@ typedef enum _GL_SupportedExt {
/* GL_EXT_point_parameters */ \
USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, glPointParameterfEXT, EXT_POINT_PARAMETERS, NULL )\
USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, glPointParameterfvEXT, EXT_POINT_PARAMETERS, NULL )\
/* GL_EXT_provoking_vertex */ \
USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC, glProvokingVertexEXT, EXT_PROVOKING_VERTEX, NULL)\
/* GL_EXT_secondary_color */ \
USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, glSecondaryColor3ubEXT, EXT_SECONDARY_COLOR, NULL )\
USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBVEXTPROC, glSecondaryColor3ubvEXT, EXT_SECONDARY_COLOR, NULL )\
@ -3906,77 +3950,61 @@ typedef BOOL (WINAPI * WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFor
****************************************************/
#define USE_GL_FUNC(type, pfn, ext, replace) type pfn;
typedef struct _WineD3D_GL_Info {
DWORD glx_version;
DWORD gl_version;
struct wined3d_gl_info
{
GL_Vendors gl_vendor;
GL_Cards gl_card;
UINT vidmem;
DWORD driver_version;
DWORD driver_version_hipart;
const char *driver_description;
GL_Vendors gl_vendor;
GL_Cards gl_card;
UINT vidmem;
DWORD driver_version;
DWORD driver_version_hipart;
CHAR driver_description[255];
CHAR gl_renderer[255];
/**
* CAPS Constants
*/
UINT max_buffers;
UINT max_lights;
UINT max_textures;
UINT max_texture_stages;
UINT max_fragment_samplers;
UINT max_vertex_samplers;
UINT max_combined_samplers;
UINT max_sampler_stages;
UINT max_clipplanes;
UINT max_texture_size;
UINT max_texture3d_size;
float max_pointsize, max_pointsizemin;
UINT max_point_sprite_units;
UINT max_blends;
UINT max_anisotropy;
UINT max_glsl_varyings;
float max_shininess;
UINT max_buffers;
UINT max_lights;
UINT max_textures;
UINT max_texture_stages;
UINT max_fragment_samplers;
UINT max_vertex_samplers;
UINT max_combined_samplers;
UINT max_sampler_stages;
UINT max_clipplanes;
UINT max_texture_size;
UINT max_texture3d_size;
float max_pointsize, max_pointsizemin;
UINT max_point_sprite_units;
UINT max_blends;
UINT max_anisotropy;
UINT max_glsl_varyings;
float max_shininess;
unsigned max_vshader_constantsF;
unsigned max_pshader_constantsF;
unsigned int max_vshader_constantsF;
unsigned int max_pshader_constantsF;
unsigned vs_arb_constantsF;
unsigned vs_arb_max_instructions;
unsigned vs_arb_max_temps;
unsigned ps_arb_constantsF;
unsigned ps_arb_max_instructions;
unsigned ps_arb_max_temps;
unsigned vs_glsl_constantsF;
unsigned ps_glsl_constantsF;
unsigned int vs_arb_constantsF;
unsigned int vs_arb_max_instructions;
unsigned int vs_arb_max_temps;
unsigned int ps_arb_constantsF;
unsigned int ps_arb_max_local_constants;
unsigned int ps_arb_max_instructions;
unsigned int ps_arb_max_temps;
unsigned int vs_glsl_constantsF;
unsigned int ps_glsl_constantsF;
GL_PSVersion ps_arb_version;
GL_PSVersion ps_nv_version;
DWORD reserved_glsl_constants;
GL_VSVersion vs_arb_version;
GL_VSVersion vs_nv_version;
GL_VSVersion vs_ati_version;
DWORD quirks;
BOOL arb_vs_offset_limit;
BOOL set_texcoord_w;
DWORD reserved_glsl_constants;
BOOL supported[WINED3D_GL_EXT_COUNT];
BOOL supported[OPENGL_SUPPORTED_EXT_END + 1];
/* GL function pointers */
GL_EXT_FUNCS_GEN
/* WGL function pointers */
WGL_EXT_FUNCS_GEN
/** OpenGL EXT and ARB functions ptr */
GL_EXT_FUNCS_GEN
/** OpenGL WGL functions ptr */
WGL_EXT_FUNCS_GEN
struct GlPixelFormatDesc *gl_formats;
} WineD3D_GL_Info;
#undef USE_GL_FUNC
struct driver_quirk {
BOOL (*match)(const WineD3D_GL_Info *gl_info);
void (*apply)(WineD3D_GL_Info *gl_info);
const char *description;
struct GlPixelFormatDesc *gl_formats;
};
#undef USE_GL_FUNC
#endif /* __WINE_WINED3D_GL */

View file

@ -32,17 +32,25 @@ int num_lock = 0;
void (*CDECL wine_tsx11_lock_ptr)(void) = NULL;
void (*CDECL wine_tsx11_unlock_ptr)(void) = NULL;
CRITICAL_SECTION wined3d_cs;
static CRITICAL_SECTION_DEBUG wined3d_cs_debug =
{
0, 0, &wined3d_cs,
{&wined3d_cs_debug.ProcessLocksList,
&wined3d_cs_debug.ProcessLocksList},
0, 0, {(DWORD_PTR)(__FILE__ ": wined3d_cs")}
};
CRITICAL_SECTION wined3d_cs = {&wined3d_cs_debug, -1, 0, 0, 0, 0};
/* When updating default value here, make sure to update winecfg as well,
* where appropriate. */
wined3d_settings_t wined3d_settings =
wined3d_settings_t wined3d_settings =
{
VS_HW, /* Hardware by default */
PS_HW, /* Hardware by default */
VBO_HW, /* Hardware by default */
TRUE, /* Use of GLSL enabled by default */
ORM_BACKBUFFER, /* Use the backbuffer to do offscreen rendering */
RTL_AUTO, /* Automatically determine best locking method */
ORM_FBO, /* Use FBOs to do offscreen rendering */
RTL_READTEX, /* Default render target locking method */
PCI_VENDOR_NONE,/* PCI Vendor ID */
PCI_DEVICE_NONE,/* PCI Device ID */
0, /* The default of memory is set in FillGLCaps */
@ -97,6 +105,7 @@ static void CDECL wined3d_do_nothing(void)
static BOOL wined3d_init(HINSTANCE hInstDLL)
{
DWORD wined3d_context_tls_idx;
HMODULE mod;
char buffer[MAX_PATH+10];
DWORD size = sizeof(buffer);
@ -105,6 +114,15 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
DWORD len, tmpvalue;
WNDCLASSA wc;
wined3d_context_tls_idx = TlsAlloc();
if (wined3d_context_tls_idx == TLS_OUT_OF_INDEXES)
{
DWORD err = GetLastError();
ERR("Failed to allocate context TLS index, err %#x.\n", err);
return FALSE;
}
context_set_tls_idx(wined3d_context_tls_idx);
/* We need our own window class for a fake window which we use to retrieve GL capabilities */
/* We might need CS_OWNDC in the future if we notice strange things on Windows.
* Various articles/posts about OpenGL problems on Windows recommend this. */
@ -117,11 +135,16 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "WineD3D_OpenGL";
wc.lpszClassName = WINED3D_OPENGL_WINDOW_CLASS_NAME;
if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
if (!RegisterClassA(&wc))
{
ERR("Failed to register window class 'WineD3D_OpenGL'!\n");
if (!TlsFree(wined3d_context_tls_idx))
{
DWORD err = GetLastError();
ERR("Failed to free context TLS index, err %#x.\n", err);
}
return FALSE;
}
@ -181,19 +204,6 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
wined3d_settings.ps_mode = PS_NONE;
}
}
if ( !get_config_key( hkey, appkey, "VertexBufferMode", buffer, size) )
{
if (!strcmp(buffer,"none"))
{
TRACE("Disable Vertex Buffer Hardware support\n");
wined3d_settings.vbo_mode = VBO_NONE;
}
else if (!strcmp(buffer,"hardware"))
{
TRACE("Allow Vertex Buffer Hardware support\n");
wined3d_settings.vbo_mode = VBO_HW;
}
}
if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) )
{
if (!strcmp(buffer,"disabled"))
@ -237,16 +247,6 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
TRACE("Using glReadPixels for render target reading and textures for writing\n");
wined3d_settings.rendertargetlock_mode = RTL_READTEX;
}
else if (!strcmp(buffer,"texdraw"))
{
TRACE("Using textures for render target reading and glDrawPixels for writing\n");
wined3d_settings.rendertargetlock_mode = RTL_TEXDRAW;
}
else if (!strcmp(buffer,"textex"))
{
TRACE("Reading render targets via textures and writing via textures\n");
wined3d_settings.rendertargetlock_mode = RTL_TEXTEX;
}
}
if ( !get_config_key_dword( hkey, appkey, "VideoPciDeviceID", &tmpvalue) )
{
@ -309,8 +309,6 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
TRACE("Allow HW vertex shaders\n");
if (wined3d_settings.ps_mode == PS_NONE)
TRACE("Disable pixel shaders\n");
if (wined3d_settings.vbo_mode == VBO_NONE)
TRACE("Disable Vertex Buffer Hardware support\n");
if (wined3d_settings.glslRequested)
TRACE("If supported by your system, GL Shading Language will be used\n");
@ -320,13 +318,32 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
return TRUE;
}
static BOOL wined3d_destroy(void)
static BOOL wined3d_destroy(HINSTANCE hInstDLL)
{
DWORD wined3d_context_tls_idx = context_get_tls_idx();
if (!TlsFree(wined3d_context_tls_idx))
{
DWORD err = GetLastError();
ERR("Failed to free context TLS index, err %#x.\n", err);
}
HeapFree(GetProcessHeap(), 0, wined3d_settings.logo);
UnregisterClassA(WINED3D_OPENGL_WINDOW_CLASS_NAME, hInstDLL);
return TRUE;
}
void WINAPI wined3d_mutex_lock(void)
{
EnterCriticalSection(&wined3d_cs);
}
void WINAPI wined3d_mutex_unlock(void)
{
LeaveCriticalSection(&wined3d_cs);
}
/* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
@ -338,7 +355,16 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
return wined3d_init(hInstDLL);
case DLL_PROCESS_DETACH:
return wined3d_destroy();
return wined3d_destroy(hInstDLL);
case DLL_THREAD_DETACH:
{
if (!context_set_current(NULL))
{
ERR("Failed to clear current context.\n");
}
return TRUE;
}
default:
return TRUE;

File diff suppressed because it is too large Load diff

View file

@ -1691,16 +1691,19 @@ typedef struct _WINED3DTRIPATCH_INFO
typedef struct _WINED3DADAPTER_IDENTIFIER
{
char *Driver;
char *Description;
char *DeviceName;
LARGE_INTEGER *DriverVersion;
DWORD *VendorId;
DWORD *DeviceId;
DWORD *SubSysId;
DWORD *Revision;
GUID *DeviceIdentifier;
DWORD *WHQLLevel;
char *driver;
UINT driver_size;
char *description;
UINT description_size;
char *device_name;
UINT device_name_size;
LARGE_INTEGER driver_version;
DWORD vendor_id;
DWORD device_id;
DWORD subsystem_id;
DWORD revision;
GUID device_identifier;
DWORD whql_level;
} WINED3DADAPTER_IDENTIFIER;
typedef struct _WINED3DPRESENT_PARAMETERS
@ -1724,27 +1727,27 @@ typedef struct _WINED3DPRESENT_PARAMETERS
typedef struct _WINED3DSURFACE_DESC
{
WINED3DFORMAT *Format;
WINED3DRESOURCETYPE *Type;
DWORD *Usage;
WINED3DPOOL *Pool;
UINT *Size;
WINED3DMULTISAMPLE_TYPE *MultiSampleType;
DWORD *MultiSampleQuality;
UINT *Width;
UINT *Height;
WINED3DFORMAT format;
WINED3DRESOURCETYPE resource_type;
DWORD usage;
WINED3DPOOL pool;
UINT size;
WINED3DMULTISAMPLE_TYPE multisample_type;
DWORD multisample_quality;
UINT width;
UINT height;
} WINED3DSURFACE_DESC;
typedef struct _WINED3DVOLUME_DESC
{
WINED3DFORMAT *Format;
WINED3DRESOURCETYPE *Type;
DWORD *Usage;
WINED3DPOOL *Pool;
UINT *Size;
UINT *Width;
UINT *Height;
UINT *Depth;
WINED3DFORMAT Format;
WINED3DRESOURCETYPE Type;
DWORD Usage;
WINED3DPOOL Pool;
UINT Size;
UINT Width;
UINT Height;
UINT Depth;
} WINED3DVOLUME_DESC;
typedef struct _WINED3DCLIPSTATUS
@ -1883,13 +1886,6 @@ typedef struct _WINED3DBUFFER_DESC
UINT Size;
} WINED3DBUFFER_DESC;
typedef struct glDescriptor
{
UINT textureName, srgbTextureName;
int level;
int /*GLenum*/ target;
} glDescriptor;
typedef struct WineDirect3DStridedData
{
WINED3DFORMAT format; /* Format of the data */
@ -2529,9 +2525,6 @@ interface IWineD3DSurface : IWineD3DResource
HRESULT SetContainer(
[in] IWineD3DBase *container
);
void GetGlDesc(
[out] glDescriptor **desc
);
const void *GetData(
);
HRESULT SetFormat(
@ -2616,10 +2609,6 @@ interface IWineD3DBaseTexture : IWineD3DResource
);
BOOL IsCondNP2(
);
void ApplyStateChanges(
const DWORD texture_states[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]
);
}
[
@ -2872,9 +2861,6 @@ interface IWineD3DVertexShader : IWineD3DBaseShader
[out] void *data,
[in, out] UINT *data_size
);
void FakeSemantics(
[in] IWineD3DVertexDeclaration *vertex_declaration
);
HRESULT SetLocalConstantsF(
[in] UINT start_idx,
[in] const float *src_data,
@ -2939,7 +2925,6 @@ interface IWineD3DDevice : IWineD3DBase
[in] BOOL discard,
[in] UINT level,
[out] IWineD3DSurface **surface,
[in] WINED3DRESOURCETYPE resource_type,
[in] DWORD usage,
[in] WINED3DPOOL pool,
[in] WINED3DMULTISAMPLE_TYPE multisample_type,
@ -3015,8 +3000,8 @@ interface IWineD3DDevice : IWineD3DBase
[in] DWORD fvf
);
HRESULT CreateVertexShader(
[in] IWineD3DVertexDeclaration *declaration,
[in] const DWORD *function,
[in] const struct wined3d_shader_signature *output_signature,
[out] IWineD3DVertexShader **shader,
[in] IUnknown *parent
);
@ -3475,9 +3460,6 @@ interface IWineD3DDevice : IWineD3DBase
[in] UINT swapchain_idx,
[in] IWineD3DSurface *dst_surface
);
void ResourceReleased(
[in] IWineD3DResource *resource
);
HRESULT EnumResources(
[in] D3DCB_ENUMRESOURCES callback,
[in] void *data
@ -3486,3 +3468,5 @@ interface IWineD3DDevice : IWineD3DBase
IWineD3D *WineDirect3DCreate(UINT dxVersion, IUnknown *parent);
IWineD3DClipper *WineDirect3DCreateClipper(IUnknown *parent);
void wined3d_mutex_lock(void);
void wined3d_mutex_unlock(void);