d3d8: Move texturing code over to wined3d (based on Oliver Stieber's work).

This commit is contained in:
Roderick Colenbrander 2006-02-20 11:11:35 +01:00 committed by Alexandre Julliard
parent 804cd257f6
commit 3da999a1f7
10 changed files with 701 additions and 1558 deletions

View File

@ -1,7 +1,7 @@
/*
* IDirect3DBaseTexture8 implementation
*
* Copyright 2002 Jason Edmeades
* 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
@ -19,33 +19,24 @@
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DBaseTexture8 (Inherited from IUnknown) */
HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface,REFIID riid,LPVOID *ppobj)
{
/* IDirect3DBaseTexture8 IUnknown parts follow: */
HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) : QueryInterface\n", This);
TRACE("(%p) Relay\n" , This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)) {
IDirect3DBaseTexture8Impl_AddRef(iface);
IUnknown_AddRef(iface);
*ppobj = This;
return D3D_OK;
}
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
return E_NOINTERFACE;
}
@ -64,73 +55,95 @@ ULONG WINAPI IDirect3DBaseTexture8Impl_Release(LPDIRECT3DBASETEXTURE8 iface) {
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0)
if (ref == 0) {
IWineD3DBaseTexture_Release(This->wineD3DBaseTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DBaseTexture8 (Inherited from IDirect3DResource8) */
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8** ppDevice) {
/* IDirect3DBaseTexture8 IDirect3DResource8 Interface follow: */
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
/**
* Note Calling this method will increase the internal reference count
* on the IDirect3DDevice8 interface.
*/
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPrivateData(This->wineD3DBaseTexture, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPrivateData(This->wineD3DBaseTexture, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid) {
HRESULT WINAPI IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_FreePrivateData(This->wineD3DBaseTexture, refguid);
}
DWORD WINAPI IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew) {
DWORD WINAPI IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPriority(This->wineD3DBaseTexture, PriorityNew);
}
DWORD WINAPI IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface) {
DWORD WINAPI IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPriority(This->wineD3DBaseTexture);
}
void WINAPI IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface) {
void WINAPI IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
TRACE("(%p) Relay\n" , This);
IWineD3DBaseTexture_PreLoad(This->wineD3DBaseTexture);
return;
}
D3DRESOURCETYPE WINAPI IDirect3DBaseTexture8Impl_GetType(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
/*TRACE("(%p) : returning %d\n", This, This->ResourceType);*/
return This->ResourceType;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetType(This->wineD3DBaseTexture);
}
/* IDirect3DBaseTexture8 */
DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew) {
/* IDirect3DBaseTexture8 Interface follow: */
DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) : returning %d\n", This, This->levels);
return This->levels;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetLOD(This->wineD3DBaseTexture, LODNew);
}
static const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl =
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLOD(This->wineD3DBaseTexture);
}
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLevelCount(This->wineD3DBaseTexture);
}
const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl =
{
IDirect3DBaseTexture8Impl_QueryInterface,
IDirect3DBaseTexture8Impl_AddRef,
@ -143,21 +156,22 @@ static const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl =
IDirect3DBaseTexture8Impl_GetPriority,
IDirect3DBaseTexture8Impl_PreLoad,
IDirect3DBaseTexture8Impl_GetType,
IDirect3DBaseTexture8Impl_SetLOD,
IDirect3DBaseTexture8Impl_GetLOD,
IDirect3DBaseTexture8Impl_GetLevelCount,
IDirect3DBaseTexture8Impl_GetLevelCount
};
BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
return This->Dirty;
return ((IWineD3DBaseTextureImpl*)This->wineD3DBaseTexture)->baseTexture.dirty;
}
BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty) {
BOOL old;
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
old = This->Dirty;
This->Dirty = dirty;
old = ((IWineD3DBaseTextureImpl*)This->wineD3DBaseTexture)->baseTexture.dirty;
((IWineD3DBaseTextureImpl*)This->wineD3DBaseTexture)->baseTexture.dirty = dirty;
return old;
}

View File

@ -1,7 +1,7 @@
/*
* IDirect3DCubeTexture8 implementation
*
* Copyright 2002 Jason Edmeades
* 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
@ -19,34 +19,23 @@
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DCubeTexture8 IUnknown parts follow: */
HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface,REFIID riid,LPVOID *ppobj)
{
HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) : QueryInterface\n", This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DCubeTexture8)) {
IDirect3DCubeTexture8Impl_AddRef(iface);
IUnknown_AddRef(iface);
*ppobj = This;
return D3D_OK;
}
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
return E_NOINTERFACE;
}
@ -62,228 +51,148 @@ ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface) {
ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
unsigned int i, j;
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0) {
for (i = 0; i < This->levels; i++) {
for (j = 0; j < 6; j++) {
if (This->surfaces[j][i] != NULL) {
TRACE("(%p) : Releasing surface %p\n", This, This->surfaces[j][i]);
IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) This->surfaces[j][i]);
}
}
}
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
IWineD3DCubeTexture_Release(This->wineD3DCubeTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DCubeTexture8 (Inherited from IDirect3DResource8) */
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8** ppDevice) {
/* IDirect3DCubeTexture8 IDirect3DResource8 Interface follow: */
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
/**
* Note Calling this method will increase the internal reference count
* on the IDirect3DDevice8 interface.
*/
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n" , This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static const GLenum cube_targets[6] = {
#if defined(GL_VERSION_1_3)
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
#else
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
#endif
};
void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface) {
unsigned int i, j;
HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->Dirty);
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
}
ENTER_GL();
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
}
for (i = 0; i < This->levels; i++) {
if (i == 0 && D3D8_SURFACE(This->surfaces[0][0])->textureName != 0 && This->Dirty == FALSE) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#if defined(GL_VERSION_1_3)
glBindTexture(GL_TEXTURE_CUBE_MAP, D3D8_SURFACE(This->surfaces[0][0])->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, D3D8_SURFACE(This->surfaces[0][0])->textureName);
#endif
checkGLcall("glBindTexture");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][0], i, D3D8_SURFACE(This->surfaces[0][0])->textureName);
/* No need to walk through all mip-map levels, since already all assigned */
i = This->levels;
} else {
if (i == 0) {
if (D3D8_SURFACE(This->surfaces[0][0])->textureName == 0) {
glGenTextures(1, &(D3D8_SURFACE(This->surfaces[0][0]))->textureName);
checkGLcall("glGenTextures");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, D3D8_SURFACE(This->surfaces[0][0])->textureName);
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
}
#if defined(GL_VERSION_1_3)
glBindTexture(GL_TEXTURE_CUBE_MAP, D3D8_SURFACE(This->surfaces[0][0])->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, D3D8_SURFACE(This->surfaces[0][0])->textureName);
#endif
checkGLcall("glBindTexture");
DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
}
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);
#if defined(GL_VERSION_1_3)
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
#else
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
#endif
checkGLcall("glTexParameteri(GL_TEXTURE_CUBE, GL_TEXTURE_MAX_LEVEL, This->levels - 1)");
}
for (j = 0; j < 6; j++) {
IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[j][i], cube_targets[j], i);
#if 0
static int gen = 0;
char buffer[4096];
snprintf(buffer, sizeof(buffer), "/tmp/cube%d_face%d_level%d_%d.png", This->surfaces[0][0]->textureName, j, i, ++gen);
IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This->surfaces[j][i], buffer);
#endif
}
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
}
}
DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
}
LEAVE_GL();
return ;
void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
}
D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) : returning %d\n", This, This->ResourceType);
return This->ResourceType;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
}
/* IDirect3DCubeTexture8 (Inherited from IDirect3DBaseTexture8) */
DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew) {
/* IDirect3DCubeTexture8 IDirect3DBaseTexture8 Interface follow: */
DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
}
DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface) {
DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) : returning %d\n", This, This->levels);
return This->levels;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This);
}
/* IDirect3DCubeTexture8 */
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
if (Level < This->levels) {
TRACE("(%p) level (%d)\n", This, Level);
return IDirect3DSurface8Impl_GetDesc((LPDIRECT3DSURFACE8) This->surfaces[0][Level], pDesc);
}
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8** ppCubeMapSurface) {
/* IDirect3DCubeTexture8 Interface follow: */
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
if (Level < This->levels) {
*ppCubeMapSurface = (LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level];
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppCubeMapSurface);
TRACE("(%p) -> faceType(%d) level(%d) returning surface@%p\n", This, FaceType, Level, This->surfaces[FaceType][Level]);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
}
return D3D_OK;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
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 = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.MultiSampleType = &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = NULL; /* DirectX9 only */
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
HRESULT hr;
HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8 **ppCubeMapSurface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
if (Level < This->levels) {
/**
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
TRACE("(%p) -> faceType(%d) level(%d) returning memory@%p success(%lu)\n", This, FaceType, Level, pLockedRect->pBits, hr);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, FaceType, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
}
return hr;
return hrc;
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
HRESULT hr;
HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
if (Level < This->levels) {
hr = IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level]);
TRACE("(%p) -> faceType(%d) level(%d) success(%lu)\n", This, FaceType, Level, hr);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
}
return hr;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, FaceType, Level, pLockedRect, pRect, Flags);
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
This->Dirty = TRUE;
TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
return IWineD3DSurface_AddDirtyRect( (IWineD3DSurface*)(This->surfaces[FaceType][0])->wineD3DSurface, pDirtyRect);
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, FaceType, Level);
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT *pDirtyRect) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, FaceType, pDirtyRect);
}
const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
{
/* IUnknown */
IDirect3DCubeTexture8Impl_QueryInterface,
IDirect3DCubeTexture8Impl_AddRef,
IDirect3DCubeTexture8Impl_Release,
/* IDirect3DResource8 */
IDirect3DCubeTexture8Impl_GetDevice,
IDirect3DCubeTexture8Impl_SetPrivateData,
IDirect3DCubeTexture8Impl_GetPrivateData,
@ -292,9 +201,11 @@ const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
IDirect3DCubeTexture8Impl_GetPriority,
IDirect3DCubeTexture8Impl_PreLoad,
IDirect3DCubeTexture8Impl_GetType,
/* IDirect3DBaseTexture8 */
IDirect3DCubeTexture8Impl_SetLOD,
IDirect3DCubeTexture8Impl_GetLOD,
IDirect3DCubeTexture8Impl_GetLevelCount,
/* IDirect3DCubeTexture8 */
IDirect3DCubeTexture8Impl_GetLevelDesc,
IDirect3DCubeTexture8Impl_GetCubeMapSurface,
IDirect3DCubeTexture8Impl_LockRect,

View File

@ -17,6 +17,7 @@
*/
#include "config.h"
#include "initguid.h"
#include <stdarg.h>

View File

@ -600,23 +600,10 @@ struct IDirect3DVolume8Impl
{
/* IUnknown fields */
const IDirect3DVolume8Vtbl *lpVtbl;
LONG ref;
LONG ref;
/* IDirect3DVolume8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
IUnknown *Container;
D3DVOLUME_DESC myDesc;
BYTE *allocatedMemory;
UINT textureName;
UINT bytesPerPixel;
BOOL lockable;
BOOL locked;
D3DBOX lockedBox;
D3DBOX dirtyBox;
BOOL Dirty;
IWineD3DVolume *wineD3DVolume;
};
/* IUnknown: */
@ -848,9 +835,6 @@ extern DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOU
extern void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface);
extern D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface);
/* internal Interfaces */
extern D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface);
/* ---------------------- */
/* IDirect3DVertexBuffer8 */
@ -958,6 +942,31 @@ extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBU
extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc);
/*****************************************************************************
* IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
*/
typedef struct IWineD3DBaseTextureClass
{
UINT levels;
BOOL dirty;
D3DFORMAT format;
DWORD usage;
UINT textureName;
UINT LOD;
D3DTEXTUREFILTERTYPE filterType;
DWORD states[13];
} IWineD3DBaseTextureClass;
typedef struct IWineD3DBaseTextureImpl
{
/* IUnknown & WineD3DResource Information */
const IWineD3DBaseTextureVtbl *lpVtbl;
IWineD3DResourceClass resource;
IWineD3DBaseTextureClass baseTexture;
} IWineD3DBaseTextureImpl;
/* --------------------- */
/* IDirect3DBaseTexture8 */
/* --------------------- */
@ -972,17 +981,7 @@ struct IDirect3DBaseTexture8Impl
LONG ref;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/*
*BOOL isManaged;
*DWORD lod;
*/
IWineD3DBaseTexture *wineD3DBaseTexture;
};
/* IUnknown: */
@ -1029,19 +1028,7 @@ struct IDirect3DCubeTexture8Impl
LONG ref;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DCubeTexture8 fields */
UINT edgeLength;
DWORD usage;
IDirect3DSurface8Impl *surfaces[6][MAX_LEVELS];
IWineD3DCubeTexture *wineD3DCubeTexture;
};
/* IUnknown: */
@ -1071,6 +1058,25 @@ extern HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBET
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect);
/*****************************************************************************
* IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
*/
typedef struct IWineD3DTextureImpl
{
/* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
const IWineD3DTextureVtbl *lpVtbl;
IWineD3DResourceClass resource;
IWineD3DBaseTextureClass baseTexture;
/* IWineD3DTexture */
IWineD3DSurface *surfaces[MAX_LEVELS];
UINT width;
UINT height;
float pow2scalingFactorX;
float pow2scalingFactorY;
} IWineD3DTextureImpl;
/* ----------------- */
/* IDirect3DTexture8 */
@ -1091,20 +1097,7 @@ struct IDirect3DTexture8Impl
LONG ref;
/* IDirect3DResourc8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DTexture8 fields */
UINT width;
UINT height;
DWORD usage;
IDirect3DSurface8Impl *surfaces[MAX_LEVELS];
IWineD3DTexture *wineD3DTexture;
};
/* IUnknown: */
@ -1154,21 +1147,7 @@ struct IDirect3DVolumeTexture8Impl
LONG ref;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DVolumeTexture8 fields */
UINT width;
UINT height;
UINT depth;
DWORD usage;
IDirect3DVolume8Impl *volumes[MAX_LEVELS];
IWineD3DVolumeTexture *wineD3DVolumeTexture;
};
/* IUnknown: */
@ -1445,6 +1424,16 @@ extern HRESULT WINAPI IDirect3DDeviceImpl_CreatePixelShader(IDirect3DDevice8Impl
*
* to see how not defined it here
*/
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, D3DPOOL Pool, UINT Level,
IWineD3DSurface **ppSurface, HANDLE *pSharedHandle);
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) ;
void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
void setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage, DWORD Flags);
void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);

View File

@ -654,214 +654,111 @@ void WINAPI IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DG
return;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8** ppTexture) {
D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8 **ppTexture) {
IDirect3DTexture8Impl *object;
unsigned int i;
UINT tmpW;
UINT tmpH;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hrc = D3D_OK;
TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%ld), Fmt(%u), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
/* Allocate the storage for the device */
TRACE("(%p) : W(%d) H(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, debug_d3dformat(Format), Pool);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture8Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
/* *ppTexture = NULL; */
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DTexture8_Vtbl;
object->Device = This;
object->ResourceType = D3DRTYPE_TEXTURE;
object->ref = 1;
object->width = Width;
object->height = Height;
object->levels = Levels;
object->usage = Usage;
object->format = Format;
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage,
(WINED3DFORMAT)Format, Pool, &object->wineD3DTexture, NULL, (IUnknown *)object, D3D8CB_CreateSurface);
/* Calculate levels for mip mapping */
if (Levels == 0) {
object->levels++;
tmpW = Width;
tmpH = Height;
while (tmpW > 1 && tmpH > 1) {
tmpW = max(1, tmpW / 2);
tmpH = max(1, tmpH / 2);
object->levels++;
}
TRACE("Calculated levels = %d\n", object->levels);
}
if (FAILED(hrc)) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
/* *ppTexture = NULL; */
} else {
*ppTexture = (LPDIRECT3DTEXTURE8) object;
}
/* Generate all the surfaces */
tmpW = Width;
tmpH = Height;
for (i = 0; i < object->levels; i++)
{
IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpH, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[i]);
D3D8_SURFACE(object->surfaces[i])->container = (IUnknown*) object;
D3D8_SURFACE(object->surfaces[i])->resource.usage = Usage;
D3D8_SURFACE(object->surfaces[i])->resource.pool = Pool;
/**
* As written in msdn in IDirect3DTexture8::LockRect
* Textures created in D3DPOOL_DEFAULT are not lockable.
*/
if (D3DPOOL_DEFAULT == Pool) {
D3D8_SURFACE(object->surfaces[i])->lockable = FALSE;
}
TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[i], D3D8_SURFACE(object->surfaces[i])->resource.allocatedMemory);
tmpW = max(1, tmpW / 2);
tmpH = max(1, tmpH / 2);
}
*ppTexture = (LPDIRECT3DTEXTURE8) object;
TRACE("(%p) : Created texture %p\n", This, object);
return D3D_OK;
TRACE("(%p) Created Texture %p, %p\n",This,object,object->wineD3DTexture);
return hrc;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface,
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture) {
IDirect3DVolumeTexture8Impl *object;
unsigned int i;
UINT tmpW;
UINT tmpH;
UINT tmpD;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hrc = D3D_OK;
/* Allocate the storage for it */
TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, Width, Height, Depth, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
TRACE("(%p) Relay\n", This);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl));
if (NULL == object) {
FIXME("(%p) allocation of memory failed\n", This);
*ppVolumeTexture = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
object->ResourceType = D3DRTYPE_VOLUMETEXTURE;
object->Device = This;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage,
(WINED3DFORMAT)Format, Pool, &object->wineD3DVolumeTexture, NULL,
(IUnknown *)object, D3D8CB_CreateVolume);
object->width = Width;
object->height = Height;
object->depth = Depth;
object->levels = Levels;
object->usage = Usage;
object->format = Format;
if (hrc != D3D_OK) {
/* Calculate levels for mip mapping */
if (Levels == 0) {
object->levels++;
tmpW = Width;
tmpH = Height;
tmpD = Depth;
while (tmpW > 1 && tmpH > 1 && tmpD > 1) {
tmpW = max(1, tmpW / 2);
tmpH = max(1, tmpH / 2);
tmpD = max(1, tmpD / 2);
object->levels++;
}
TRACE("Calculated levels = %d\n", object->levels);
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
*ppVolumeTexture = NULL;
} else {
*ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE8) object;
}
/* Generate all the surfaces */
tmpW = Width;
tmpH = Height;
tmpD = Depth;
for (i = 0; i < object->levels; i++)
{
IDirect3DVolume8Impl* volume;
/* Create the volume - No entry point for this seperately?? */
volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume8Impl));
object->volumes[i] = (IDirect3DVolume8Impl *) volume;
volume->lpVtbl = &Direct3DVolume8_Vtbl;
volume->Device = This;
volume->ResourceType = D3DRTYPE_VOLUME;
volume->Container = (IUnknown*) object;
volume->ref = 1;
volume->myDesc.Width = Width;
volume->myDesc.Height = Height;
volume->myDesc.Depth = Depth;
volume->myDesc.Format = Format;
volume->myDesc.Type = D3DRTYPE_VOLUME;
volume->myDesc.Pool = Pool;
volume->myDesc.Usage = Usage;
volume->bytesPerPixel = D3DFmtGetBpp(This, Format);
/* Note: Volume textures cannot be dxtn, hence no need to check here */
volume->myDesc.Size = (Width * volume->bytesPerPixel) * Height * Depth;
volume->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->myDesc.Size);
volume->lockable = TRUE;
volume->locked = FALSE;
memset(&volume->lockedBox, 0, sizeof(D3DBOX));
volume->Dirty = FALSE;
IDirect3DVolume8Impl_CleanDirtyBox((LPDIRECT3DVOLUME8) volume);
TRACE("(%p) : Volume at w(%d) h(%d) d(%d) fmt(%u,%s) surf@%p, surfmem@%p, %d bytes\n",
This, Width, Height, Depth, Format, debug_d3dformat(Format),
volume, volume->allocatedMemory, volume->myDesc.Size);
tmpW = max(1, tmpW / 2);
tmpH = max(1, tmpH / 2);
tmpD = max(1, tmpD / 2);
}
*ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE8) object;
TRACE("(%p) : Created volume texture %p\n", This, object);
return D3D_OK;
TRACE("(%p) returning %p\n", This , *ppVolumeTexture);
return hrc;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture) {
IDirect3DCubeTexture8Impl *object;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
unsigned int i,j;
UINT tmpW;
HRESULT hr = D3D_OK;
TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%ld) fmt(%u), Pool(%d)\n" , This, EdgeLength, Levels, Usage, Format, Pool);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) {
FIXME("(%p) allocation of CubeTexture failed\n", This);
*ppCubeTexture = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
/* Allocate the storage for it */
TRACE("(%p) : Len(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, EdgeLength, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture8Impl));
object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
object->ref = 1;
object->Device = This;
object->ResourceType = D3DRTYPE_CUBETEXTURE;
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
(WINED3DFORMAT)Format, Pool, &object->wineD3DCubeTexture, NULL, (IUnknown*)object,
D3D8CB_CreateSurface);
object->edgeLength = EdgeLength;
object->levels = Levels;
object->usage = Usage;
object->format = Format;
if (hr != D3D_OK){
/* Calculate levels for mip mapping */
if (Levels == 0) {
object->levels++;
tmpW = EdgeLength;
while (tmpW > 1) {
tmpW = max(1, tmpW / 2);
object->levels++;
}
TRACE("Calculated levels = %d\n", object->levels);
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
*ppCubeTexture = NULL;
} else {
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
}
/* Generate all the surfaces */
tmpW = EdgeLength;
for (i = 0; i < object->levels; i++) {
/* Create the 6 faces */
for (j = 0; j < 6; j++) {
IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpW, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[j][i]);
D3D8_SURFACE(object->surfaces[j][i])->container = (IUnknown*) object;
D3D8_SURFACE(object->surfaces[j][i])->resource.usage = Usage;
D3D8_SURFACE(object->surfaces[j][i])->resource.pool = Pool;
/**
* As written in msdn in IDirect3DCubeTexture8::LockRect
* Textures created in D3DPOOL_DEFAULT are not lockable.
*/
if (D3DPOOL_DEFAULT == Pool) {
D3D8_SURFACE(object->surfaces[j][i])->lockable = FALSE;
}
TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[j][i], D3D8_SURFACE(object->surfaces[j][i])->resource.allocatedMemory);
}
tmpW = max(1, tmpW / 2);
}
TRACE("(%p) : Iface@%p\n", This, object);
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
return D3D_OK;
TRACE("(%p) returning %p\n",This, *ppCubeTexture);
return hr;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) {
IDirect3DVertexBuffer8Impl *object;
@ -989,80 +886,10 @@ HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect
}
HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture) {
IDirect3DBaseTexture8Impl* src = (IDirect3DBaseTexture8Impl*) pSourceTexture;
IDirect3DBaseTexture8Impl* dst = (IDirect3DBaseTexture8Impl*) pDestinationTexture;
D3DRESOURCETYPE srcType;
D3DRESOURCETYPE dstType;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
TRACE("(%p) : first try\n", This);
TRACE("(%p) Relay\n" , This);
srcType = IDirect3DBaseTexture8Impl_GetType(pSourceTexture);
dstType = IDirect3DBaseTexture8Impl_GetType(pDestinationTexture);
if (srcType != dstType) {
return D3DERR_INVALIDCALL;
}
if (D3DPOOL_SYSTEMMEM != IDirect3DResource8Impl_GetPool((LPDIRECT3DRESOURCE8) src)) {
return D3DERR_INVALIDCALL;
}
if (D3DPOOL_DEFAULT != IDirect3DResource8Impl_GetPool((LPDIRECT3DRESOURCE8) dst)) {
return D3DERR_INVALIDCALL;
}
if (IDirect3DBaseTexture8Impl_IsDirty(pSourceTexture)) {
/** Only copy Dirty textures */
DWORD srcLevelCnt = IDirect3DBaseTexture8Impl_GetLevelCount(pSourceTexture);
DWORD dstLevelCnt = IDirect3DBaseTexture8Impl_GetLevelCount(pDestinationTexture);
DWORD skipLevels = (dstLevelCnt < srcLevelCnt) ? srcLevelCnt - dstLevelCnt : 0;
UINT i, j;
for (i = skipLevels; i < srcLevelCnt; ++i) {
HRESULT hr;
switch (srcType) {
case D3DRTYPE_TEXTURE:
{
IDirect3DSurface8* srcSur = NULL;
IDirect3DSurface8* dstSur = NULL;
hr = IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) src, i, &srcSur);
hr = IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) dst, i - skipLevels, &dstSur);
/* Fixme: Work out how to just do the dirty regions (src or dst dirty region, and what
about dst with less levels than the source?) */
IDirect3DDevice8Impl_CopyRects(iface, srcSur, NULL, 0, dstSur, NULL);
IDirect3DSurface8Impl_Release(srcSur);
IDirect3DSurface8Impl_Release(dstSur);
}
break;
case D3DRTYPE_VOLUMETEXTURE:
{
FIXME("D3DRTYPE_VOLUMETEXTURE reload currently not implemented\n");
}
break;
case D3DRTYPE_CUBETEXTURE:
{
IDirect3DSurface8* srcSur = NULL;
IDirect3DSurface8* dstSur = NULL;
for (j = 0; j < 5; ++j) {
hr = IDirect3DCubeTexture8Impl_GetCubeMapSurface((LPDIRECT3DCUBETEXTURE8) src, j, i, &srcSur);
hr = IDirect3DCubeTexture8Impl_GetCubeMapSurface((LPDIRECT3DCUBETEXTURE8) dst, j, i - skipLevels, &dstSur);
IDirect3DDevice8Impl_CopyRects(iface, srcSur, NULL, 0, dstSur, NULL);
IDirect3DSurface8Impl_Release(srcSur);
IDirect3DSurface8Impl_Release(dstSur);
}
}
break;
default:
break;
}
}
IDirect3DBaseTexture8Impl_SetDirty(pSourceTexture, FALSE);
}
return D3D_OK;
return IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture8Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture8Impl *)pDestinationTexture)->wineD3DBaseTexture);
}
HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface) {
HRESULT hr;
@ -3189,7 +3016,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD
/* Now setup the texture appropraitly */
textureType = IDirect3DBaseTexture8Impl_GetType(pTexture);
if (textureType == D3DRTYPE_TEXTURE) {
if (oldTxt == pTexture && IDirect3DBaseTexture8Impl_IsDirty(pTexture)) {
TRACE("Skipping setting texture as old == new\n");
@ -4670,3 +4496,26 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
return ret;
}
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, D3DPOOL Pool, UINT Level,
IWineD3DSurface **ppSurface, HANDLE *pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface8Impl *d3dSurface = NULL;
BOOL Lockable = TRUE;
if((D3DPOOL_DEFAULT == Pool && D3DUSAGE_DYNAMIC != Usage))
Lockable = FALSE;
TRACE("relay\n");
res = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)device, Width, Height, (D3DFORMAT)Format, Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface8 **)&d3dSurface, D3DRTYPE_SURFACE, Usage, Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
if (res == D3D_OK) {
*ppSurface = d3dSurface->wineD3DSurface;
} else {
FIXME("(%p) IDirect3DDevice8_CreateSurface failed\n", device);
}
return res;
}

View File

@ -108,30 +108,6 @@ D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface)
return This->ResourceType;
}
D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
switch (This->ResourceType) {
case D3DRTYPE_SURFACE:
return D3D8_SURFACE(((IDirect3DSurface8Impl*) This))->resource.pool;
case D3DRTYPE_TEXTURE:
return D3D8_SURFACE(((IDirect3DTexture8Impl*) This)->surfaces[0])->resource.pool;
case D3DRTYPE_VOLUME:
return ((IDirect3DVolume8Impl*) This)->myDesc.Pool;
case D3DRTYPE_VOLUMETEXTURE:
return ((IDirect3DVolumeTexture8Impl*) This)->volumes[0]->myDesc.Pool;
case D3DRTYPE_CUBETEXTURE:
return D3D8_SURFACE(((IDirect3DCubeTexture8Impl*) This)->surfaces[0][0])->resource.pool;
case D3DRTYPE_VERTEXBUFFER:
return ((IDirect3DVertexBuffer8Impl*) This)->currentDesc.Pool;
case D3DRTYPE_INDEXBUFFER:
return ((IDirect3DIndexBuffer8Impl*) This)->currentDesc.Pool;
default:
FIXME("(%p) Unrecognized type(%d,%s)\n", This, This->ResourceType, debug_d3dressourcetype(This->ResourceType));
return D3DPOOL_DEFAULT;
}
}
const IDirect3DResource8Vtbl Direct3DResource8_Vtbl =
{
IDirect3DResource8Impl_QueryInterface,

View File

@ -42,7 +42,6 @@ HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface, RE
ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
InterlockedIncrement(&D3D8_SURFACE(This)->resource.ref);
TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
@ -59,9 +58,6 @@ ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
IWineD3DSurface_Release(This->wineD3DSurface);
HeapFree(GetProcessHeap(), 0, This);
}
else
InterlockedDecrement(&D3D8_SURFACE(This)->resource.ref);
return ref;
}
@ -93,16 +89,45 @@ HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface, R
HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void **ppContainer) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
HRESULT res;
res = IUnknown_QueryInterface(D3D8_SURFACE(This)->container, riid, ppContainer);
if (E_NOINTERFACE == res) {
/**
* If the surface is created using CreateImageSurface, CreateRenderTarget,
* or CreateDepthStencilSurface, the surface is considered stand alone. In this case,
* GetContainer will return the Direct3D device used to create the surface.
*/
res = IUnknown_QueryInterface(D3D8_SURFACE(This)->container, &IID_IDirect3DDevice8, ppContainer);
IUnknown *IWineContainer = NULL;
TRACE("(%p) Relay\n", This);
/* The container returned from IWineD3DSurface_GetContainer is either an IWineD3DDevice,
one of the subclasses of IWineD3DBaseTexture or an IWineD3DSwapChain */
/* Get the IUnknown container. */
res = IWineD3DSurface_GetContainer(This->wineD3DSurface, &IID_IUnknown, (void **)&IWineContainer);
if (res == D3D_OK && IWineContainer != NULL) {
/* Now find out what kind of container it is (so that we can get its parent)*/
IUnknown *IUnknownParent = NULL;
IUnknown *myContainer = NULL;
if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DDevice, (void **)&myContainer)) {
IWineD3DDevice_GetParent((IWineD3DDevice *)IWineContainer, &IUnknownParent);
IUnknown_Release(myContainer);
} else
if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DBaseTexture, (void **)&myContainer)) {
IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture *)IWineContainer, &IUnknownParent);
IUnknown_Release(myContainer);
} else
if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DSwapChain, (void **)&myContainer)) {
IWineD3DSwapChain_GetParent((IWineD3DSwapChain *)IWineContainer, &IUnknownParent);
IUnknown_Release(myContainer);
} else {
FIXME("Container is of unknown interface\n");
}
/* Tidy up.. */
IUnknown_Release((IWineD3DDevice *)IWineContainer);
/* Now, query the interface of the parent for the riid */
if (IUnknownParent != NULL) {
res = IUnknown_QueryInterface(IUnknownParent, riid, ppContainer);
/* Tidy up.. */
IUnknown_Release(IUnknownParent);
}
}
TRACE("(%p) : returning %p\n", This, *ppContainer);
TRACE("(%p) : returning %p\n", This, *ppContainer);
return res;
}
@ -126,341 +151,17 @@ HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFAC
return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
}
#define D3D8_SURFACE_GET_DEVICE(a) ((IDirect3DDevice8Impl*)((IDirect3DTexture8Impl*)(D3D8_SURFACE(a)->container))->Device)
HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
HRESULT hr;
HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
/* fixme: should we really lock as such? */
if (D3D8_SURFACE(This)->inTexture && D3D8_SURFACE(This)->inPBuffer) {
FIXME("Warning: Surface is in texture memory or pbuffer\n");
D3D8_SURFACE(This)->inTexture = 0;
D3D8_SURFACE(This)->inPBuffer = 0;
}
if (FALSE == D3D8_SURFACE(This)->lockable) {
/* Note: UpdateTextures calls CopyRects which calls this routine to populate the
texture regions, and since the destination is an unlockable region we need
to tolerate this */
TRACE("Warning: trying to lock unlockable surf@%p\n", This);
/*return D3DERR_INVALIDCALL; */
}
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget || This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer || D3D8_SURFACE_GET_DEVICE(This)->depthStencilBuffer) {
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer) {
TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, D3D8_SURFACE(This)->resource.allocatedMemory);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer) {
TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, D3D8_SURFACE(This)->resource.allocatedMemory);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget) {
TRACE("(%p, renderTarget) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, D3D8_SURFACE(This)->resource.allocatedMemory);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->depthStencilBuffer) {
TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, D3D8_SURFACE(This)->resource.allocatedMemory);
}
} else {
TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, D3D8_SURFACE(This)->resource.allocatedMemory);
}
/* 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 (D3D8_SURFACE(This)->resource.format == D3DFMT_DXT1) /* DXT1 is 8 bytes per block */
pLockedRect->Pitch = (D3D8_SURFACE(This)->currentDesc.Width/4) * 8;
else if (D3D8_SURFACE(This)->resource.format == D3DFMT_DXT2 || D3D8_SURFACE(This)->resource.format == D3DFMT_DXT3 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT4 || D3D8_SURFACE(This)->resource.format == D3DFMT_DXT5) /* DXT2/3/4/5 is 16 bytes per block */
pLockedRect->Pitch = (D3D8_SURFACE(This)->currentDesc.Width/4) * 16;
else
pLockedRect->Pitch = D3D8_SURFACE(This)->bytesPerPixel * D3D8_SURFACE(This)->currentDesc.Width; /* Bytes / row */
if (NULL == pRect) {
pLockedRect->pBits = D3D8_SURFACE(This)->resource.allocatedMemory;
D3D8_SURFACE(This)->lockedRect.left = 0;
D3D8_SURFACE(This)->lockedRect.top = 0;
D3D8_SURFACE(This)->lockedRect.right = D3D8_SURFACE(This)->currentDesc.Width;
D3D8_SURFACE(This)->lockedRect.bottom = D3D8_SURFACE(This)->currentDesc.Height;
TRACE("Locked Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", &D3D8_SURFACE(This)->lockedRect, D3D8_SURFACE(This)->lockedRect.left, D3D8_SURFACE(This)->lockedRect.top, D3D8_SURFACE(This)->lockedRect.right, D3D8_SURFACE(This)->lockedRect.bottom);
} else {
TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
if (D3D8_SURFACE(This)->resource.format == D3DFMT_DXT1) { /* DXT1 is half byte per pixel */
pLockedRect->pBits = D3D8_SURFACE(This)->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + ((pRect->left * D3D8_SURFACE(This)->bytesPerPixel/2));
} else {
pLockedRect->pBits = D3D8_SURFACE(This)->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * D3D8_SURFACE(This)->bytesPerPixel);
}
D3D8_SURFACE(This)->lockedRect.left = pRect->left;
D3D8_SURFACE(This)->lockedRect.top = pRect->top;
D3D8_SURFACE(This)->lockedRect.right = pRect->right;
D3D8_SURFACE(This)->lockedRect.bottom = pRect->bottom;
}
if (0 == D3D8_SURFACE(This)->resource.usage) { /* classic surface */
/* Nothing to do ;) */
} else if (D3DUSAGE_RENDERTARGET & D3D8_SURFACE(This)->resource.usage && !(Flags&D3DLOCK_DISCARD)) { /* render surfaces */
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget || This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer) {
GLint prev_store;
GLint prev_read;
ENTER_GL();
/**
* for render->surface copy begin to begin of allocatedMemory
* unlock can be more easy
*/
pLockedRect->pBits = D3D8_SURFACE(This)->resource.allocatedMemory;
glFlush();
vcheckGLcall("glFlush");
glGetIntegerv(GL_READ_BUFFER, &prev_read);
vcheckGLcall("glIntegerv");
glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
vcheckGLcall("glIntegerv");
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer) {
glReadBuffer(GL_BACK);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget) {
glReadBuffer(GL_FRONT);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->depthStencilBuffer) {
ERR("Stencil Buffer lock unsupported for now\n");
}
vcheckGLcall("glReadBuffer");
{
long j;
GLenum format = D3DFmt2GLFmt(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format);
GLenum type = D3DFmt2GLType(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format);
for (j = D3D8_SURFACE(This)->lockedRect.top; j < D3D8_SURFACE(This)->lockedRect.bottom - D3D8_SURFACE(This)->lockedRect.top; ++j) {
glReadPixels(D3D8_SURFACE(This)->lockedRect.left,
D3D8_SURFACE(This)->lockedRect.bottom - j - 1,
D3D8_SURFACE(This)->lockedRect.right - D3D8_SURFACE(This)->lockedRect.left,
1,
format,
type,
(char *)pLockedRect->pBits + (pLockedRect->Pitch * (j-D3D8_SURFACE(This)->lockedRect.top)));
vcheckGLcall("glReadPixels");
}
}
glReadBuffer(prev_read);
vcheckGLcall("glReadBuffer");
LEAVE_GL();
} else {
FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This, D3D8_SURFACE(This)->resource.usage);
}
} else if (D3DUSAGE_DEPTHSTENCIL & D3D8_SURFACE(This)->resource.usage) { /* stencil surfaces */
FIXME("TODO stencil depth surface locking surf@%p usage(%lu)\n", This, D3D8_SURFACE(This)->resource.usage);
} else {
FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This, D3D8_SURFACE(This)->resource.usage);
}
if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
/* Don't dirtify */
} else {
/**
* Dirtify on lock
* as seen in msdn docs
*/
IWineD3DSurface_AddDirtyRect(This->wineD3DSurface, &D3D8_SURFACE(This)->lockedRect);
/** Dirtify Container if needed */
if (NULL != D3D8_SURFACE(This)->container) {
IDirect3DBaseTexture8* cont = NULL;
hr = IUnknown_QueryInterface(D3D8_SURFACE(This)->container, &IID_IDirect3DBaseTexture8, (void**) &cont);
if (SUCCEEDED(hr) && NULL != cont) {
IDirect3DBaseTexture8Impl_SetDirty(cont, TRUE);
IDirect3DBaseTexture8_Release(cont);
cont = NULL;
}
}
}
TRACE("returning memory@%p, pitch(%d) dirtyfied(%d)\n", pLockedRect->pBits, pLockedRect->Pitch, D3D8_SURFACE(This)->Dirty);
D3D8_SURFACE(This)->locked = TRUE;
return D3D_OK;
TRACE("(%p) Relay\n", This);
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %ld\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
return IWineD3DSurface_LockRect(This->wineD3DSurface, pLockedRect, pRect, Flags);
}
HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
GLint skipBytes = 0;
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
if (FALSE == D3D8_SURFACE(This)->locked) {
ERR("trying to Unlock an unlocked surf@%p\n", This);
return D3DERR_INVALIDCALL;
}
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer || D3D8_SURFACE_GET_DEVICE(This)->depthStencilBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget) {
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer) {
TRACE("(%p, backBuffer) : dirtyfied(%d)\n", This, D3D8_SURFACE(This)->Dirty);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer) {
TRACE("(%p, frontBuffer) : dirtyfied(%d)\n", This, D3D8_SURFACE(This)->Dirty);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->depthStencilBuffer) {
TRACE("(%p, stencilBuffer) : dirtyfied(%d)\n", This, D3D8_SURFACE(This)->Dirty);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget) {
TRACE("(%p, renderTarget) : dirtyfied(%d)\n", This, D3D8_SURFACE(This)->Dirty);
}
} else {
TRACE("(%p) : dirtyfied(%d)\n", This, D3D8_SURFACE(This)->Dirty);
}
if (FALSE == D3D8_SURFACE(This)->Dirty) {
TRACE("(%p) : Not Dirtified so nothing to do, return now\n", This);
goto unlock_end;
}
if (0 == D3D8_SURFACE(This)->resource.usage) { /* classic surface */
/**
* nothing to do
* waiting to reload the surface via IDirect3DDevice8::UpdateTexture
*/
} else if (D3DUSAGE_RENDERTARGET & D3D8_SURFACE(This)->resource.usage) { /* render surfaces */
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget) {
GLint prev_store;
GLint prev_draw;
GLint prev_rasterpos[4];
ENTER_GL();
glFlush();
vcheckGLcall("glFlush");
glGetIntegerv(GL_DRAW_BUFFER, &prev_draw);
vcheckGLcall("glIntegerv");
glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
vcheckGLcall("glIntegerv");
glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]);
vcheckGLcall("glIntegerv");
glPixelZoom(1.0, -1.0);
vcheckGLcall("glPixelZoom");
/* glDrawPixels transforms the raster position as though it was a vertex -
we want to draw at screen position 0,0 - Set up ortho (rhw) mode as
per drawprim (and leave set - it will sort itself out due to last_was_rhw */
if (!D3D8_SURFACE_GET_DEVICE(This)->last_was_rhw) {
double X, Y, height, width, minZ, maxZ;
D3D8_SURFACE_GET_DEVICE(This)->last_was_rhw = TRUE;
/* Transformed already into viewport coordinates, so we do not need transform
matrices. Reset all matrices to identity and leave the default matrix in world
mode. */
glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode");
glLoadIdentity();
checkGLcall("glLoadIdentity");
glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode");
glLoadIdentity();
checkGLcall("glLoadIdentity");
/* Set up the viewport to be full viewport */
X = D3D8_SURFACE_GET_DEVICE(This)->StateBlock->viewport.X;
Y = D3D8_SURFACE_GET_DEVICE(This)->StateBlock->viewport.Y;
height = D3D8_SURFACE_GET_DEVICE(This)->StateBlock->viewport.Height;
width = D3D8_SURFACE_GET_DEVICE(This)->StateBlock->viewport.Width;
minZ = D3D8_SURFACE_GET_DEVICE(This)->StateBlock->viewport.MinZ;
maxZ = D3D8_SURFACE_GET_DEVICE(This)->StateBlock->viewport.MaxZ;
TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
checkGLcall("glOrtho");
/* Window Coord 0 is the middle of the first pixel, so translate by half
a pixel (See comment above glTranslate below) */
glTranslatef(0.5, 0.5, 0);
checkGLcall("glTranslatef(0.5, 0.5, 0)");
}
if (This == D3D8_SURFACE_GET_DEVICE(This)->backBuffer) {
glDrawBuffer(GL_BACK);
} else if (This == D3D8_SURFACE_GET_DEVICE(This)->frontBuffer || This == D3D8_SURFACE_GET_DEVICE(This)->renderTarget) {
glDrawBuffer(GL_FRONT);
}
vcheckGLcall("glDrawBuffer");
/* If not fullscreen, we need to skip a number of bytes to find the next row of data */
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes);
glPixelStorei(GL_UNPACK_ROW_LENGTH, D3D8_SURFACE(This)->currentDesc.Width);
/* And back buffers are not blended */
glDisable(GL_BLEND);
glRasterPos3i(D3D8_SURFACE(This)->lockedRect.left, D3D8_SURFACE(This)->lockedRect.top, 1);
vcheckGLcall("glRasterPos2f");
switch (D3D8_SURFACE(This)->resource.format) {
case D3DFMT_R5G6B5:
{
glDrawPixels(D3D8_SURFACE(This)->lockedRect.right - D3D8_SURFACE(This)->lockedRect.left, (D3D8_SURFACE(This)->lockedRect.bottom - D3D8_SURFACE(This)->lockedRect.top)-1,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, D3D8_SURFACE(This)->resource.allocatedMemory);
vcheckGLcall("glDrawPixels");
}
break;
case D3DFMT_R8G8B8:
{
glDrawPixels(D3D8_SURFACE(This)->lockedRect.right - D3D8_SURFACE(This)->lockedRect.left, (D3D8_SURFACE(This)->lockedRect.bottom - D3D8_SURFACE(This)->lockedRect.top)-1,
GL_RGB, GL_UNSIGNED_BYTE, D3D8_SURFACE(This)->resource.allocatedMemory);
vcheckGLcall("glDrawPixels");
}
break;
case D3DFMT_A8R8G8B8:
{
glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
vcheckGLcall("glPixelStorei");
glDrawPixels(D3D8_SURFACE(This)->lockedRect.right - D3D8_SURFACE(This)->lockedRect.left, (D3D8_SURFACE(This)->lockedRect.bottom - D3D8_SURFACE(This)->lockedRect.top)-1,
GL_BGRA, GL_UNSIGNED_BYTE, D3D8_SURFACE(This)->resource.allocatedMemory);
vcheckGLcall("glDrawPixels");
glPixelStorei(GL_PACK_SWAP_BYTES, prev_store);
vcheckGLcall("glPixelStorei");
}
break;
default:
FIXME("Unsupported Format %u in locking func\n", D3D8_SURFACE(This)->resource.format);
}
glPixelZoom(1.0,1.0);
vcheckGLcall("glPixelZoom");
glDrawBuffer(prev_draw);
vcheckGLcall("glDrawBuffer");
glRasterPos3iv(&prev_rasterpos[0]);
vcheckGLcall("glRasterPos3iv");
/* Reset to previous pack row length / blending state */
glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes);
if (D3D8_SURFACE_GET_DEVICE(This)->StateBlock->renderstate[D3DRS_ALPHABLENDENABLE]) glEnable(GL_BLEND);
LEAVE_GL();
/** restore clean dirty state */
IWineD3DSurface_CleanDirtyRect(This->wineD3DSurface);
} else {
FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, D3D8_SURFACE(This)->resource.usage);
}
} else if (D3DUSAGE_DEPTHSTENCIL & D3D8_SURFACE(This)->resource.usage) { /* stencil surfaces */
if (This == D3D8_SURFACE_GET_DEVICE(This)->depthStencilBuffer) {
FIXME("TODO stencil depth surface unlocking surf@%p usage(%lu)\n", This, D3D8_SURFACE(This)->resource.usage);
} else {
FIXME("unsupported unlocking to StencilDepth surface surf@%p usage(%lu)\n", This, D3D8_SURFACE(This)->resource.usage);
}
} else {
FIXME("unsupported unlocking to surface surf@%p usage(%lu)\n", This, D3D8_SURFACE(This)->resource.usage);
}
unlock_end:
D3D8_SURFACE(This)->locked = FALSE;
memset(&D3D8_SURFACE(This)->lockedRect, 0, sizeof(RECT));
return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
}
const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =
@ -480,169 +181,3 @@ const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =
IDirect3DSurface8Impl_LockRect,
IDirect3DSurface8Impl_UnlockRect
};
HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, UINT gl_target, UINT gl_level) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
if (D3D8_SURFACE(This)->inTexture)
return D3D_OK;
if (D3D8_SURFACE(This)->inPBuffer) {
ENTER_GL();
if (gl_level != 0)
FIXME("Surface in texture is only supported for level 0\n");
else if (D3D8_SURFACE(This)->resource.format == D3DFMT_P8 || D3D8_SURFACE(This)->resource.format == D3DFMT_A8P8 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT1 || D3D8_SURFACE(This)->resource.format == D3DFMT_DXT2 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT3 || D3D8_SURFACE(This)->resource.format == D3DFMT_DXT4 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT5)
FIXME("Format %d not supported\n", D3D8_SURFACE(This)->resource.format);
else {
glCopyTexImage2D(gl_target,
0,
D3DFmt2GLIntFmt(D3D8_SURFACE_GET_DEVICE(This),
D3D8_SURFACE(This)->resource.format),
0,
0,/*This->surfaces[j][i]->myDesc.Height-1,*/
D3D8_SURFACE(This)->currentDesc.Width,
D3D8_SURFACE(This)->currentDesc.Height,
0);
TRACE("Updating target %d\n", gl_target);
D3D8_SURFACE(This)->inTexture = TRUE;
}
LEAVE_GL();
return D3D_OK;
}
if ((D3D8_SURFACE(This)->resource.format == D3DFMT_P8 || D3D8_SURFACE(This)->resource.format == D3DFMT_A8P8) &&
!GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, D3D8_SURFACE_GET_DEVICE(This))) {
/**
* wanted a paletted texture and not really support it in HW
* so software emulation code begin
*/
UINT i;
PALETTEENTRY* pal = D3D8_SURFACE_GET_DEVICE(This)->palettes[D3D8_SURFACE_GET_DEVICE(This)->currentPalette];
VOID* surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, D3D8_SURFACE(This)->currentDesc.Width * D3D8_SURFACE(This)->currentDesc.Height * sizeof(DWORD));
BYTE* dst = surface;
BYTE* src = (BYTE*) D3D8_SURFACE(This)->resource.allocatedMemory;
for (i = 0; i < D3D8_SURFACE(This)->currentDesc.Width * D3D8_SURFACE(This)->currentDesc.Height; i++) {
BYTE color = *src++;
*dst++ = pal[color].peRed;
*dst++ = pal[color].peGreen;
*dst++ = pal[color].peBlue;
if (D3D8_SURFACE(This)->resource.format == D3DFMT_A8P8)
*dst++ = pal[color].peFlags;
else
*dst++ = 0xFF;
}
ENTER_GL();
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
gl_level,
GL_RGBA,
D3D8_SURFACE(This)->currentDesc.Width,
D3D8_SURFACE(This)->currentDesc.Height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
surface);
glTexImage2D(gl_target,
gl_level,
GL_RGBA,
D3D8_SURFACE(This)->currentDesc.Width,
D3D8_SURFACE(This)->currentDesc.Height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
surface);
checkGLcall("glTexImage2D");
HeapFree(GetProcessHeap(), 0, surface);
LEAVE_GL();
return D3D_OK;
}
if (D3D8_SURFACE(This)->resource.format == D3DFMT_DXT1 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT2 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT3 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT4 ||
D3D8_SURFACE(This)->resource.format == D3DFMT_DXT5) {
if (GL_SUPPORT_DEV(EXT_TEXTURE_COMPRESSION_S3TC, D3D8_SURFACE_GET_DEVICE(This))) {
TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
gl_target,
gl_level,
D3DFmt2GLIntFmt(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3D8_SURFACE(This)->currentDesc.Width,
D3D8_SURFACE(This)->currentDesc.Height,
0,
D3D8_SURFACE(This)->resource.size,
D3D8_SURFACE(This)->resource.allocatedMemory);
ENTER_GL();
GL_EXTCALL_DEV(glCompressedTexImage2DARB, D3D8_SURFACE_GET_DEVICE(This))(gl_target,
gl_level,
D3DFmt2GLIntFmt(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3D8_SURFACE(This)->currentDesc.Width,
D3D8_SURFACE(This)->currentDesc.Height,
0,
D3D8_SURFACE(This)->resource.size,
D3D8_SURFACE(This)->resource.allocatedMemory);
checkGLcall("glCommpressedTexTexImage2D");
LEAVE_GL();
} else {
FIXME("Using DXT1/3/5 without advertized support\n");
}
} else {
TRACE("Calling glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
gl_level,
debug_d3dformat(D3D8_SURFACE(This)->resource.format),
D3DFmt2GLIntFmt(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3D8_SURFACE(This)->currentDesc.Width,
D3D8_SURFACE(This)->currentDesc.Height,
0,
D3DFmt2GLFmt(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3DFmt2GLType(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3D8_SURFACE(This)->resource.allocatedMemory);
ENTER_GL();
glTexImage2D(gl_target,
gl_level,
D3DFmt2GLIntFmt(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3D8_SURFACE(This)->currentDesc.Width,
D3D8_SURFACE(This)->currentDesc.Height,
0,
D3DFmt2GLFmt(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3DFmt2GLType(D3D8_SURFACE_GET_DEVICE(This), D3D8_SURFACE(This)->resource.format),
D3D8_SURFACE(This)->resource.allocatedMemory);
checkGLcall("glTexImage2D");
LEAVE_GL();
#if 0
{
static unsigned int gen = 0;
char buffer[4096];
++gen;
if ((gen % 10) == 0) {
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, gl_target, gl_level, gen);
IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This, buffer);
}
/*
* debugging crash code
if (gen == 250) {
void** test = NULL;
*test = 0;
}
*/
}
#endif
}
return D3D_OK;
}

View File

@ -1,7 +1,7 @@
/*
* IDirect3DTexture8 implementation
*
* Copyright 2002 Jason Edmeades
* 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
@ -19,29 +19,23 @@
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
#define D3D8_TEXTURE(a) ((IWineD3DTextureImpl*)(a->wineD3DTexture))
#define D3D8_TEXTURE_GET_SURFACE(a) ((IWineD3DSurfaceImpl*)(D3D8_TEXTURE(a)->surfaces[i]))
#define D3D8_BASETEXTURE(a) (((IWineD3DTextureImpl*)(a->wineD3DTexture))->baseTexture)
/* IDirect3DTexture8 IUnknown parts follow: */
HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj)
{
HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) : QueryInterface for %s\n", This, debugstr_guid(riid));
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DTexture8)) {
IDirect3DTexture8Impl_AddRef(iface);
IUnknown_AddRef(iface);
*ppobj = This;
return D3D_OK;
}
@ -62,56 +56,53 @@ ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
unsigned int i;
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0) {
for (i = 0; i < This->levels; i++) {
if (This->surfaces[i] != NULL) {
TRACE("(%p) : Releasing surface %p\n", This, This->surfaces[i]);
IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) This->surfaces[i]);
}
}
IWineD3DTexture_Release(This->wineD3DTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8** ppDevice) {
HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
/**
* Note Calling this method will increase the internal reference count
* on the IDirect3DDevice8 interface.
*/
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
TRACE("(%p) Relay\n", This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
}
DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
}
DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetPriority(This->wineD3DTexture);
}
void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
unsigned int i;
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
@ -119,127 +110,131 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
ENTER_GL();
for (i = 0; i < This->levels; i++) {
if (i == 0 && D3D8_SURFACE(This->surfaces[i])->textureName != 0 && This->Dirty == FALSE) {
glBindTexture(GL_TEXTURE_2D, D3D8_SURFACE(This->surfaces[i])->textureName);
for (i = 0; i < D3D8_BASETEXTURE(This).levels; i++) {
if (i == 0 && D3D8_TEXTURE_GET_SURFACE(This)->textureName != 0 && D3D8_BASETEXTURE(This).dirty == FALSE) {
glBindTexture(GL_TEXTURE_2D, D3D8_TEXTURE_GET_SURFACE(This)->textureName);
checkGLcall("glBindTexture");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, D3D8_SURFACE(This->surfaces[i])->textureName);
TRACE("Texture %p (level %d) given name %d\n", D3D8_TEXTURE_GET_SURFACE(This), i, D3D8_TEXTURE_GET_SURFACE(This)->textureName);
/* No need to walk through all mip-map levels, since already all assigned */
i = This->levels;
i = D3D8_BASETEXTURE(This).levels;
} else {
if (i == 0) {
if (D3D8_SURFACE(This->surfaces[i])->textureName == 0) {
glGenTextures(1, &(D3D8_SURFACE(This->surfaces[i]))->textureName);
if (D3D8_TEXTURE_GET_SURFACE(This)->textureName == 0) {
glGenTextures(1, &(D3D8_TEXTURE_GET_SURFACE(This)->textureName));
checkGLcall("glGenTextures");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, D3D8_SURFACE(This->surfaces[i])->textureName);
TRACE("Texture %p (level %d) given name %d\n", D3D8_TEXTURE_GET_SURFACE(This), i, D3D8_TEXTURE_GET_SURFACE(This)->textureName);
}
glBindTexture(GL_TEXTURE_2D, D3D8_SURFACE(This->surfaces[i])->textureName);
glBindTexture(GL_TEXTURE_2D, D3D8_TEXTURE_GET_SURFACE(This)->textureName);
checkGLcall("glBindTexture");
}
IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i);
IWineD3DSurface_LoadTexture((IWineD3DSurface*)D3D8_TEXTURE_GET_SURFACE(This));
/* IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) D3D8_TEXTURE_GET_SURFACE(This), GL_TEXTURE_2D, i); */
}
}
/* No longer dirty */
This->Dirty = FALSE;
D3D8_BASETEXTURE(This).dirty = FALSE;
/* Always need to reset the number of mipmap levels when rebinding as it is
a property of the active texture unit, and another texture may have set it
to a different value */
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", D3D8_BASETEXTURE(This).levels - 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, D3D8_BASETEXTURE(This).levels - 1);
checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)");
LEAVE_GL();
return ;
}
D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) : is %d\n", This, This->ResourceType);
return This->ResourceType;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetType(This->wineD3DTexture);
}
/* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) : returning %d\n", This, This->levels);
return This->levels;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
}
/* IDirect3DTexture8 */
HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
if (Level < This->levels) {
TRACE("(%p) Level (%d)\n", This, Level);
return IDirect3DSurface8Impl_GetDesc((LPDIRECT3DSURFACE8) This->surfaces[Level], pDesc);
}
FIXME("Levels seems too high?!!\n");
return D3DERR_INVALIDCALL;
}
HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8** ppSurfaceLevel) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
*ppSurfaceLevel = (LPDIRECT3DSURFACE8)This->surfaces[Level];
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->surfaces[Level]);
TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
return D3D_OK;
}
HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) {
HRESULT hr;
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Level (%d)\n", This, Level);
if (Level < This->levels) {
/**
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[Level], pLockedRect, pRect, Flags);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
return D3DERR_INVALIDCALL;
}
return hr;
}
HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
HRESULT hr;
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Level (%d)\n", This, Level);
if (Level < This->levels) {
hr = IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[Level]);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
return D3DERR_INVALIDCALL;
}
return hr;
}
HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
This->Dirty = TRUE;
TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
return IWineD3DSurface_AddDirtyRect( (IWineD3DSurface*)(This->surfaces[0])->wineD3DSurface, pDirtyRect);
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetLOD(This->wineD3DTexture);
}
DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
}
/* IDirect3DTexture8 Interface follow: */
HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
memset(&wined3ddesc, 0, sizeof(wined3ddesc));
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool;
wined3ddesc.Size = &tmpInt; /* required for d3d8 */
wined3ddesc.MultiSampleType = &pDesc->MultiSampleType;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
}
HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8 **ppSurfaceLevel) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
}
return hrc;
}
HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_LockRect(This->wineD3DTexture, Level, pLockedRect, pRect, Flags);
}
HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
}
HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT *pDirtyRect) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
}
const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl =
{
/* IUnknown */
IDirect3DTexture8Impl_QueryInterface,
IDirect3DTexture8Impl_AddRef,
IDirect3DTexture8Impl_Release,
/* IDirect3DResource8 */
IDirect3DTexture8Impl_GetDevice,
IDirect3DTexture8Impl_SetPrivateData,
IDirect3DTexture8Impl_GetPrivateData,
@ -248,13 +243,14 @@ const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl =
IDirect3DTexture8Impl_GetPriority,
IDirect3DTexture8Impl_PreLoad,
IDirect3DTexture8Impl_GetType,
/* IDirect3dBaseTexture8 */
IDirect3DTexture8Impl_SetLOD,
IDirect3DTexture8Impl_GetLOD,
IDirect3DTexture8Impl_GetLevelCount,
/* IDirect3DTexture8 */
IDirect3DTexture8Impl_GetLevelDesc,
IDirect3DTexture8Impl_GetSurfaceLevel,
IDirect3DTexture8Impl_LockRect,
IDirect3DTexture8Impl_UnlockRect,
IDirect3DTexture8Impl_AddDirtyRect
};

View File

@ -1,8 +1,7 @@
/*
* IDirect3DVolume8 implementation
*
* Copyright 2002-2003 Jason Edmeades
* Raphael Junqueira
* 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
@ -20,35 +19,22 @@
*/
#include "config.h"
#include <stdarg.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVolume IUnknown parts follow: */
HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID* ppobj) {
/* IDirect3DVolume8 IUnknown parts follow: */
HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
IDirect3DVolume8Impl_AddRef(iface);
IUnknown_AddRef(iface);
*ppobj = This;
return D3D_OK;
}
WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
return E_NOINTERFACE;
}
@ -68,135 +54,97 @@ ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DVolume_Release(This->wineD3DVolume);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVolume8: */
HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8** ppDevice) {
/* IDirect3DVolume8 Interface follow: */
HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
/* Note Calling this method will increase the internal reference count
on the IDirect3DDevice8 interface. */
IDirect3DDevice8Impl_AddRef(*ppDevice);
IWineD3DDevice *myDevice = NULL;
IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
}
HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void** ppContainer) {
HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->Container);
*ppContainer = This->Container;
IUnknown_AddRef(This->Container);
return D3D_OK;
}
HRESULT res;
IUnknown *IWineContainer = NULL;
HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC* pDesc) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) : copying into %p\n", This, pDesc);
memcpy(pDesc, &This->myDesc, sizeof(D3DVOLUME_DESC));
return D3D_OK;
}
TRACE("(%p) Relay\n", This);
res = IWineD3DVolume_GetContainer(This->wineD3DVolume, riid, (void **)&IWineContainer);
HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
FIXME("(%p) : pBox=%p stub\n", This, pBox);
/* fixme: should we really lock as such? */
TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->allocatedMemory);
pLockedVolume->RowPitch = This->bytesPerPixel * This->myDesc.Width; /* Bytes / row */
pLockedVolume->SlicePitch = This->bytesPerPixel * This->myDesc.Width * This->myDesc.Height; /* Bytes / slice */
if (!pBox) {
TRACE("No box supplied - all is ok\n");
pLockedVolume->pBits = This->allocatedMemory;
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->myDesc.Width;
This->lockedBox.Bottom = This->myDesc.Height;
This->lockedBox.Back = This->myDesc.Depth;
} else {
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
pLockedVolume->pBits = This->allocatedMemory +
(pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
(pLockedVolume->RowPitch * pBox->Top) +
(pBox->Left * This->bytesPerPixel);
This->lockedBox.Left = pBox->Left;
This->lockedBox.Top = pBox->Top;
This->lockedBox.Front = pBox->Front;
This->lockedBox.Right = pBox->Right;
This->lockedBox.Bottom = pBox->Bottom;
This->lockedBox.Back = pBox->Back;
}
if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
/* Don't dirtify */
} else {
/**
* Dirtify on lock
* as seen in msdn docs
*/
IDirect3DVolume8Impl_AddDirtyBox(iface, &This->lockedBox);
/** Dirtify Container if needed */
if (NULL != This->Container) {
IDirect3DVolumeTexture8* cont = (IDirect3DVolumeTexture8*) This->Container;
D3DRESOURCETYPE containerType = IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) cont);
if (containerType == D3DRTYPE_VOLUMETEXTURE) {
IDirect3DBaseTexture8Impl* pTexture = (IDirect3DBaseTexture8Impl*) cont;
pTexture->Dirty = TRUE;
} else {
FIXME("Set dirty on container type %d\n", containerType);
}
}
/* If this works, the only valid container is a child of resource (volumetexture) */
if (res == D3D_OK && NULL != ppContainer) {
IWineD3DResource_GetParent((IWineD3DResource *)IWineContainer, (IUnknown **)ppContainer);
IWineD3DResource_Release((IWineD3DResource *)IWineContainer);
}
This->locked = TRUE;
TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
return D3D_OK;
return res;
}
HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
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 = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
}
HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) relay %p %p %p %ld\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
return IWineD3DVolume_LockBox(This->wineD3DVolume, pLockedVolume, pBox, Flags);
}
HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
if (FALSE == This->locked) {
ERR("trying to lock unlocked volume@%p\n", This);
return D3DERR_INVALIDCALL;
}
TRACE("(%p) : unlocking volume\n", This);
This->locked = FALSE;
memset(&This->lockedBox, 0, sizeof(RECT));
return D3D_OK;
TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
return IWineD3DVolume_UnlockBox(This->wineD3DVolume);
}
const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
{
/* IUnknown */
IDirect3DVolume8Impl_QueryInterface,
IDirect3DVolume8Impl_AddRef,
IDirect3DVolume8Impl_Release,
/* IDirect3DVolume8 */
IDirect3DVolume8Impl_GetDevice,
IDirect3DVolume8Impl_SetPrivateData,
IDirect3DVolume8Impl_GetPrivateData,
@ -208,39 +156,35 @@ const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
};
HRESULT WINAPI IDirect3DVolume8Impl_CleanDirtyBox(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
This->Dirty = FALSE;
This->lockedBox.Left = This->myDesc.Width;
This->lockedBox.Top = This->myDesc.Height;
This->lockedBox.Front = This->myDesc.Depth;
This->lockedBox.Right = 0;
This->lockedBox.Bottom = 0;
This->lockedBox.Back = 0;
return D3D_OK;
}
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) {
IDirect3DVolume8Impl *object;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)pDevice;
HRESULT hrc = D3D_OK;
/**
* Raphael:
* very stupid way to handle multiple dirty box but it works :)
*/
HRESULT WINAPI IDirect3DVolume8Impl_AddDirtyBox(LPDIRECT3DVOLUME8 iface, CONST D3DBOX* pDirtyBox) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
This->Dirty = TRUE;
if (NULL != pDirtyBox) {
This->lockedBox.Left = min(This->lockedBox.Left, pDirtyBox->Left);
This->lockedBox.Top = min(This->lockedBox.Top, pDirtyBox->Top);
This->lockedBox.Front = min(This->lockedBox.Front, pDirtyBox->Front);
This->lockedBox.Right = max(This->lockedBox.Right, pDirtyBox->Right);
This->lockedBox.Bottom = max(This->lockedBox.Bottom, pDirtyBox->Bottom);
This->lockedBox.Back = max(This->lockedBox.Back, pDirtyBox->Back);
} else {
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->myDesc.Width;
This->lockedBox.Bottom = This->myDesc.Height;
This->lockedBox.Back = This->myDesc.Depth;
}
return D3D_OK;
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume8Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppVolume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolume8_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format,
Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
*ppVolume = NULL;
} else {
*ppVolume = (IWineD3DVolume *)object->wineD3DVolume;
}
TRACE("(%p) Created volume %p\n", This, *ppVolume);
return hrc;
}

View File

@ -1,7 +1,7 @@
/*
* IDirect3DVolumeTexture8 implementation
*
* Copyright 2002 Jason Edmeades
* 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
@ -19,35 +19,24 @@
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVolumeTexture8 IUnknown parts follow: */
HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface,REFIID riid,LPVOID *ppobj)
{
HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) : QueryInterface\n", This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
IDirect3DVolumeTexture8Impl_AddRef(iface);
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return D3D_OK;
}
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
return E_NOINTERFACE;
}
@ -63,209 +52,146 @@ ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface)
ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
UINT i;
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0) {
for (i = 0; i < This->levels; i++) {
if (This->volumes[i] != NULL) {
TRACE("(%p) : Releasing volume %p\n", This, This->volumes[i]);
IDirect3DVolume8Impl_Release((LPDIRECT3DVOLUME8) This->volumes[i]);
}
}
IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8** ppDevice) {
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
/**
* Note Calling this method will increase the internal reference count
* on the IDirect3DDevice8 interface.
*/
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
TRACE("(%p) Relay\n", This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
FIXME("(%p) : stub returning 0\n", This);
return 0;
}
DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
FIXME("(%p) : stub returning 0\n", This);
return 0;
}
void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
unsigned int i;
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) : About to load texture\n", This);
ENTER_GL();
for (i = 0; i < This->levels; i++) {
if (i == 0 && This->volumes[i]->textureName != 0 && This->Dirty == FALSE) {
glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
checkGLcall("glBindTexture");
TRACE("Texture %p (level %d) given name %d\n", This->volumes[i], i, This->volumes[i]->textureName);
/* No need to walk through all mip-map levels, since already all assigned */
i = This->levels;
} else {
if (i == 0) {
if (This->volumes[i]->textureName == 0) {
glGenTextures(1, &This->volumes[i]->textureName);
checkGLcall("glGenTextures");
TRACE("Texture %p (level %d) given name %d\n", This->volumes[i], i, This->volumes[i]->textureName);
}
glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
checkGLcall("glBindTexture");
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
checkGLcall("glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1)");
}
TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_3D,
i,
D3DFmt2GLIntFmt(This->Device, This->format),
This->volumes[i]->myDesc.Width,
This->volumes[i]->myDesc.Height,
This->volumes[i]->myDesc.Depth,
0,
D3DFmt2GLFmt(This->Device, This->format),
D3DFmt2GLType(This->Device, This->format),
This->volumes[i]->allocatedMemory);
glTexImage3D(GL_TEXTURE_3D,
i,
D3DFmt2GLIntFmt(This->Device, This->format),
This->volumes[i]->myDesc.Width,
This->volumes[i]->myDesc.Height,
This->volumes[i]->myDesc.Depth,
0,
D3DFmt2GLFmt(This->Device, This->format),
D3DFmt2GLType(This->Device, This->format),
This->volumes[i]->allocatedMemory);
checkGLcall("glTexImage3D");
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
}
}
LEAVE_GL();
return ;
HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
}
DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
}
DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
}
void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
}
D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) : returning %d\n", This, This->ResourceType);
return This->ResourceType;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
}
/* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
FIXME("(%p) : stub returning 0\n", This);
return 0;
}
DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
FIXME("(%p) : stub returning 0\n", This);
return 0;
}
DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) : returning %d\n", This, This->levels);
return This->levels;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
}
/* IDirect3DVolumeTexture8 */
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DVOLUME_DESC *pDesc) {
DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
if (Level < This->levels) {
TRACE("(%p) Level (%d)\n", This, Level);
return IDirect3DVolume8Impl_GetDesc((LPDIRECT3DVOLUME8) This->volumes[Level], pDesc);
} else {
FIXME("(%p) Level (%d)\n", This, Level);
}
return D3D_OK;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8** ppVolumeLevel) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
if (Level < This->levels) {
*ppVolumeLevel = (LPDIRECT3DVOLUME8)This->volumes[Level];
IDirect3DVolume8Impl_AddRef((LPDIRECT3DVOLUME8) *ppVolumeLevel);
TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel);
} else {
FIXME("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
HRESULT hr;
DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
if (Level < This->levels) {
/**
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DVolume8Impl_LockBox((LPDIRECT3DVOLUME8) This->volumes[Level], pLockedVolume, pBox, Flags);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
}
/* IDirect3DVolumeTexture8 Interface follow: */
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
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 = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DVolume *myVolume = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (hrc == D3D_OK && NULL != ppVolumeLevel) {
IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
}
return hr;
return hrc;
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
HRESULT hr;
HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
if (Level < This->levels) {
hr = IDirect3DVolume8Impl_UnlockBox((LPDIRECT3DVOLUME8) This->volumes[Level]);
TRACE("(%p) -> level(%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
}
return hr;
TRACE("(%p) Relay %p %p %p %ld\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
return IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, pLockedVolume, pBox, Flags);
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox) {
HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
This->Dirty = TRUE;
TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
return IDirect3DVolume8Impl_AddDirtyBox((LPDIRECT3DVOLUME8) This->volumes[0], pDirtyBox);
TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
return IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, pDirtyBox);
}
const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
{
/* IUnknown */
IDirect3DVolumeTexture8Impl_QueryInterface,
IDirect3DVolumeTexture8Impl_AddRef,
IDirect3DVolumeTexture8Impl_Release,
/* IDirect3DResource8 */
IDirect3DVolumeTexture8Impl_GetDevice,
IDirect3DVolumeTexture8Impl_SetPrivateData,
IDirect3DVolumeTexture8Impl_GetPrivateData,
@ -274,9 +200,11 @@ const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
IDirect3DVolumeTexture8Impl_GetPriority,
IDirect3DVolumeTexture8Impl_PreLoad,
IDirect3DVolumeTexture8Impl_GetType,
/* IDirect3DBaseTexture8 */
IDirect3DVolumeTexture8Impl_SetLOD,
IDirect3DVolumeTexture8Impl_GetLOD,
IDirect3DVolumeTexture8Impl_GetLevelCount,
/* IDirect3DVolumeTexture8 */
IDirect3DVolumeTexture8Impl_GetLevelDesc,
IDirect3DVolumeTexture8Impl_GetVolumeLevel,
IDirect3DVolumeTexture8Impl_LockBox,