Commit 4e4fc936 authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

d3d8: Move d3d8 surface over to wined3d (based on the work of Oliver Stieber).

parent bc2b9e3f
......@@ -143,27 +143,27 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
ENTER_GL();
for (i = 0; i < This->levels; i++) {
if (i == 0 && This->surfaces[0][0]->textureName != 0 && This->Dirty == FALSE) {
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, This->surfaces[0][0]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP, D3D8_SURFACE(This->surfaces[0][0])->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][0]->textureName);
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, This->surfaces[0][0]->textureName);
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 (This->surfaces[0][0]->textureName == 0) {
glGenTextures(1, &This->surfaces[0][0]->textureName);
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, This->surfaces[0][0]->textureName);
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, D3D8_SURFACE(This->surfaces[0][0])->textureName);
}
#if defined(GL_VERSION_1_3)
glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][0]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP, D3D8_SURFACE(This->surfaces[0][0])->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][0]->textureName);
#endif
......@@ -275,7 +275,7 @@ HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXT
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
This->Dirty = TRUE;
TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
return IDirect3DSurface8Impl_AddDirtyRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][0], pDirtyRect);
return IWineD3DSurface_AddDirtyRect( (IWineD3DSurface*)(This->surfaces[FaceType][0])->wineD3DSurface, pDirtyRect);
}
......
......@@ -64,8 +64,13 @@ extern int num_lock;
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8.h"
#include "wine/wined3d_interface.h"
......@@ -674,6 +679,92 @@ extern ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface
extern HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
extern HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer);
/* Below follow the definitions of some WineD3D structures which are needed during the D3D8->WineD3D transition. */
typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
typedef struct PrivateData
{
struct PrivateData* next;
GUID tag;
DWORD flags; /* DDSPD_* */
DWORD uniqueness_value;
union
{
LPVOID data;
LPUNKNOWN object;
} ptr;
DWORD size;
} PrivateData;
typedef struct IWineD3DResourceClass
{
/* IUnknown fields */
LONG ref; /* Note: Ref counting not required */
/* WineD3DResource Information */
IUnknown *parent;
D3DRESOURCETYPE resourceType;
void *wineD3DDevice;
D3DPOOL pool;
UINT size;
DWORD usage;
WINED3DFORMAT format;
BYTE *allocatedMemory;
PrivateData *privateData;
} IWineD3DResourceClass;
typedef struct _WINED3DSURFACET_DESC
{
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
UINT Width;
UINT Height;
} WINED3DSURFACET_DESC;
struct IWineD3DSurfaceImpl
{
/* IUnknown & IWineD3DResource Information */
const IWineD3DSurfaceVtbl *lpVtbl;
IWineD3DResourceClass resource;
/* IWineD3DSurface fields */
IUnknown *container;
WINED3DSURFACET_DESC currentDesc;
UINT textureName;
UINT bytesPerPixel;
/* TODO: move this off into a management class(maybe!) */
BOOL nonpow2;
UINT pow2Width;
UINT pow2Height;
UINT pow2Size;
#if 0
/* precalculated x and y scalings for texture coords */
float pow2scalingFactorX; /* = (Width / pow2Width ) */
float pow2scalingFactorY; /* = (Height / pow2Height) */
#endif
BOOL lockable;
BOOL discard;
BOOL locked;
BOOL activeLock;
RECT lockedRect;
RECT dirtyRect;
BOOL Dirty;
BOOL inTexture;
BOOL inPBuffer;
glDescriptor glDescription;
};
/* ----------------- */
/* IDirect3DSurface8 */
......@@ -691,28 +782,12 @@ struct IDirect3DSurface8Impl
{
/* IUnknown fields */
const IDirect3DSurface8Vtbl *lpVtbl;
LONG ref;
LONG ref;
/* IDirect3DSurface8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
IUnknown *Container;
D3DSURFACE_DESC myDesc;
BYTE *allocatedMemory;
UINT textureName;
UINT bytesPerPixel;
BOOL lockable;
BOOL locked;
RECT lockedRect;
RECT dirtyRect;
BOOL Dirty;
BOOL inTexture;
BOOL inPBuffer;
IWineD3DSurface *wineD3DSurface;
IWineD3DSurface *wineD3DSurface;
};
#define D3D8_SURFACE(a) ((IWineD3DSurfaceImpl*)(a->wineD3DSurface))
/* IUnknown: */
extern HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface,REFIID refiid,LPVOID *obj);
......
......@@ -113,15 +113,15 @@ D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface) {
switch (This->ResourceType) {
case D3DRTYPE_SURFACE:
return ((IDirect3DSurface8Impl*) This)->myDesc.Pool;
return D3D8_SURFACE(((IDirect3DSurface8Impl*) This))->resource.pool;
case D3DRTYPE_TEXTURE:
return ((IDirect3DTexture8Impl*) This)->surfaces[0]->myDesc.Pool;
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 ((IDirect3DCubeTexture8Impl*) This)->surfaces[0][0]->myDesc.Pool;
return D3D8_SURFACE(((IDirect3DCubeTexture8Impl*) This)->surfaces[0][0])->resource.pool;
case D3DRTYPE_VERTEXBUFFER:
return ((IDirect3DVertexBuffer8Impl*) This)->currentDesc.Pool;
case D3DRTYPE_INDEXBUFFER:
......
......@@ -120,22 +120,22 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
ENTER_GL();
for (i = 0; i < This->levels; i++) {
if (i == 0 && This->surfaces[i]->textureName != 0 && This->Dirty == FALSE) {
glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
if (i == 0 && D3D8_SURFACE(This->surfaces[i])->textureName != 0 && This->Dirty == FALSE) {
glBindTexture(GL_TEXTURE_2D, D3D8_SURFACE(This->surfaces[i])->textureName);
checkGLcall("glBindTexture");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName);
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, D3D8_SURFACE(This->surfaces[i])->textureName);
/* No need to walk through all mip-map levels, since already all assigned */
i = This->levels;
} else {
if (i == 0) {
if (This->surfaces[i]->textureName == 0) {
glGenTextures(1, &This->surfaces[i]->textureName);
if (D3D8_SURFACE(This->surfaces[i])->textureName == 0) {
glGenTextures(1, &(D3D8_SURFACE(This->surfaces[i]))->textureName);
checkGLcall("glGenTextures");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName);
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, D3D8_SURFACE(This->surfaces[i])->textureName);
}
glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
glBindTexture(GL_TEXTURE_2D, D3D8_SURFACE(This->surfaces[i])->textureName);
checkGLcall("glBindTexture");
}
IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i);
......@@ -231,7 +231,7 @@ HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 ifa
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
This->Dirty = TRUE;
TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
return IDirect3DSurface8Impl_AddDirtyRect((LPDIRECT3DSURFACE8) This->surfaces[0], pDirtyRect);
return IWineD3DSurface_AddDirtyRect( (IWineD3DSurface*)(This->surfaces[0])->wineD3DSurface, pDirtyRect);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment