Commit 67f2ad45 authored by Oliver Stieber's avatar Oliver Stieber Committed by Alexandre Julliard

- Volume now inherits Resource. This isn't the way Microsoft implements

the interface but it is more correct way (Microsoft even have a resource type of volume). - Moved usage, format, allocatedMemory and size onto the resource class structure. - Refactored Preload for classes that inherit BaseTexture, preload now binds the texture instead of bind texture calling preload, bindTexture allocated a glTexture if there isn't one. - Added two new class static members BaseTexture_CleanUp and Resource_CleanUp that should be called by classes that implement BaseTexture or Resource.
parent 026a4b0d
......@@ -547,7 +547,7 @@ static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface, Display* display) {
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Height,
D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
WINED3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
......@@ -555,7 +555,7 @@ HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Heig
/* Note - Throw away MultisampleQuality and SharedHandle - only relevant for d3d9 */
res = IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8 *)device, Width, Height,
Format, MultiSample, Lockable,
(D3DFORMAT)Format, MultiSample, Lockable,
(IDirect3DSurface8 **)&d3dSurface);
if (res == D3D_OK) {
*ppSurface = d3dSurface->wineD3DSurface;
......
......@@ -259,7 +259,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface,
object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
object->ref = 1;
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
Format, Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object,
(WINED3DFORMAT)Format, Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object,
D3D9CB_CreateSurface);
if (hr != D3D_OK){
......
......@@ -1120,11 +1120,11 @@ typedef struct IDirect3DQuery9Impl {
/* Callbacks */
extern HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
D3DFORMAT Format, DWORD Usage, D3DPOOL Pool, UINT Level,
WINED3DFORMAT Format, DWORD Usage, D3DPOOL Pool, UINT Level,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
D3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
WINED3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle);
......
......@@ -901,7 +901,7 @@ IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl =
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
D3DFORMAT Format, DWORD Usage, D3DPOOL Pool, UINT Level,
WINED3DFORMAT Format, DWORD Usage, D3DPOOL Pool, UINT Level,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
......@@ -912,7 +912,7 @@ HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
Lockable = FALSE;
TRACE("relay\n");
res = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9 *)device, Width, Height, Format, Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface9 **)&d3dSurface, D3DRTYPE_SURFACE, Usage, Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, pSharedHandle);
res = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9 *)device, Width, Height, (D3DFORMAT)Format, Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface9 **)&d3dSurface, D3DRTYPE_SURFACE, Usage, Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, pSharedHandle);
if (res == D3D_OK) {
*ppSurface = d3dSurface->wineD3DSurface;
......
......@@ -159,7 +159,7 @@ HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapte
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Height,
D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
WINED3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
......@@ -167,7 +167,7 @@ HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Heig
IDirect3DDevice9Impl* pDeviceImpl = (IDirect3DDevice9Impl*) device;
res = IDirect3DDevice9_CreateRenderTarget((IDirect3DDevice9 *)device, Width, Height,
Format, MultiSample, MultisampleQuality, Lockable,
(D3DFORMAT) Format, MultiSample, MultisampleQuality, Lockable,
(IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
if (SUCCEEDED(res)) {
......
......@@ -234,7 +234,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UIN
object->lpVtbl = &Direct3DTexture9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage,
Format, Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object, D3D9CB_CreateSurface);
(WINED3DFORMAT)Format, Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object, D3D9CB_CreateSurface);
if (FAILED(hrc)) {
/* free up object */
......
......@@ -157,7 +157,7 @@ IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
D3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
WINED3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) {
IDirect3DVolume9Impl *object;
......
......@@ -254,7 +254,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 ifac
object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage,
Format, Pool, &object->wineD3DVolumeTexture, pSharedHandle,
(WINED3DFORMAT)Format, Pool, &object->wineD3DVolumeTexture, pSharedHandle,
(IUnknown *)object, D3D9CB_CreateVolume);
......
......@@ -58,6 +58,7 @@ ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
IWineD3DBaseTextureImpl_CleanUp(iface);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
......@@ -65,6 +66,19 @@ ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
return ref;
}
/* class static */
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface){
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p) : ", This);
if (This->baseTexture.textureName != 0) {
ENTER_GL();
TRACE("Deleting texture %d\n", This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.textureName);
LEAVE_GL();
}
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
}
/* ****************************************************
IWineD3DBaseTexture IWineD3DResource parts follow
**************************************************** */
......@@ -113,7 +127,7 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUn
DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
if (This->baseTexture.pool != D3DPOOL_MANAGED) {
if (This->resource.pool != D3DPOOL_MANAGED) {
return D3DERR_INVALIDCALL;
}
......@@ -129,7 +143,7 @@ DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LO
DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
if (This->baseTexture.pool != D3DPOOL_MANAGED) {
if (This->resource.pool != D3DPOOL_MANAGED) {
return D3DERR_INVALIDCALL;
}
......@@ -189,12 +203,66 @@ BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) {
HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : This shouldn't be called\n", This);
UINT textureDimensions;
TRACE("(%p) : About to bind texture\n", This);
textureDimensions = IWineD3DCubeTexture_GetTextureDimensions(iface);
ENTER_GL();
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PushState(This->contextManager, textureDimensions, ENABLED, NOW /* make sure the state is applied now */);
#else
glEnable(textureDimensions);
#endif
/* Generate a texture name if we don't already have one */
if (This->baseTexture.textureName == 0) {
glGenTextures(1, &This->baseTexture.textureName);
checkGLcall("glGenTextures");
TRACE("Generated texture %d\n", This->baseTexture.textureName);
if (This->resource.pool == D3DPOOL_DEFAULT) {
/* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp;
tmp = 0.9f;
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
}
}
/* Bind the texture */
if (This->baseTexture.textureName != 0) {
glBindTexture(textureDimensions, This->baseTexture.textureName);
checkGLcall("glBindTexture");
} else { /* this only happened if we've run out of openGL textures */
WARN("This texture doesn't have an openGL texture assigned to it\n");
return D3DERR_INVALIDCALL;
}
/* 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->baseTexture.levels - 1);
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
return D3D_OK;
}
HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : This shouldn't be called\n", This);
UINT textureDimensions;
TRACE("(%p) : About to bind texture\n", This);
textureDimensions = IWineD3DCubeTexture_GetTextureDimensions(iface);
ENTER_GL();
glBindTexture(textureDimensions, 0);
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PopState(This->contextManager, GL_TEXTURE_CUBE_MAP_ARB, ENABLED, NOW /* make sure the state is applied now */);
#else
glDisable(textureDimensions);
#endif
LEAVE_GL();
return D3D_OK;
}
......
......@@ -84,12 +84,7 @@ ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
}
}
}
if(This->baseTexture.textureName != 0){
ENTER_GL();
TRACE("Deleting texture %d\n", This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.textureName);
LEAVE_GL();
}
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
......@@ -131,35 +126,9 @@ void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty);
IWineD3DCubeTexture_BindTexture(iface);
ENTER_GL();
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_CUBE_MAP_ARB, ENABLED, NOW /* make sure the state is applied now */);
#else
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
/* Generate a texture name if we don't already have one */
if (This->baseTexture.textureName == 0) {
glGenTextures(1, &This->baseTexture.textureName);
checkGLcall("glGenTextures");
TRACE("Generated texture %d\n", This->baseTexture.textureName);
if (This->baseTexture.pool == D3DPOOL_DEFAULT) {
/* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp;
tmp = 0.9f;
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
}
}
/* Bind the texture */
if (This->baseTexture.textureName != 0) {
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->baseTexture.textureName);
checkGLcall("glBindTexture");
} else { /* this only happened if we've run out of openGL textures */
WARN("This texture doesn't have an openGL texture assigned to it\n");
return;
}
/* If were dirty then reload the surfaces */
if(This->baseTexture.dirty != FALSE) {
for (i = 0; i < This->baseTexture.levels; i++) {
......@@ -167,22 +136,9 @@ void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This->surfaces[j][i], cube_targets[j], i);
}
/* No longer dirty */
This->baseTexture.dirty = FALSE;
This->baseTexture.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->baseTexture.levels - 1);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PopState(This->contextManager, GL_TEXTURE_CUBE_MAP_ARB, DISABLED, DELAYED);
#endif
LEAVE_GL();
LEAVE_GL();
return ;
}
......@@ -233,32 +189,14 @@ BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) {
HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p) : %d \n", This, This->baseTexture.textureName);
ENTER_GL();
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_CUBE_MAP_ARB, ENABLED, NOW /* make sure the state is applied now */);
#else
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
glBindTexture(GLTEXTURECUBEMAP, This->baseTexture.textureName);
LEAVE_GL();
return D3D_OK;
TRACE("(%p) : relay to BaseTexture \n", This);
return IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
}
HRESULT WINAPI IWineD3DCubeTextureImpl_UnBindTexture(IWineD3DCubeTexture *iface) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p) \n", This);
ENTER_GL();
glBindTexture(GLTEXTURECUBEMAP, 0);
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PopState(This->contextManager, GL_TEXTURE_CUBE_MAP_ARB, ENABLED, NOW /* make sure the state is applied now */);
#else
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
LEAVE_GL();
return D3D_OK;
TRACE("(%p) : relay to BaseTexture \n", This);
return IWineD3DBaseTextureImpl_UnBindTexture((IWineD3DBaseTexture *)iface);
}
UINT WINAPI IWineD3DCubeTextureImpl_GetTextureDimensions(IWineD3DCubeTexture *iface){
......
......@@ -47,18 +47,20 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3D##type##Impl)); \
D3DMEMCHECK(object, pp##type); \
object->lpVtbl = &IWineD3D##type##_Vtbl; \
object->resource.wineD3DDevice = This; \
object->resource.parent = parent; \
object->resource.resourceType = d3dtype; \
object->resource.ref = 1; \
object->resource.wineD3DDevice = This; \
object->resource.parent = parent; \
object->resource.resourceType = d3dtype; \
object->resource.ref = 1; \
object->resource.pool = Pool; \
object->resource.format = Format; \
object->resource.usage = Usage; \
object->resource.size = 0; \
object->resource.allocatedMemory = 0; \
*pp##type = (IWineD3D##type *) object; \
}
#define D3DINITILIZEBASETEXTURE(_basetexture) { \
_basetexture.usage = Usage; \
_basetexture.levels = Levels; \
_basetexture.format = Format; \
_basetexture.pool = Pool; \
_basetexture.filterType = (Usage & D3DUSAGE_AUTOGENMIPMAP) ? D3DTEXF_LINEAR : D3DTEXF_NONE; \
_basetexture.LOD = 0; \
}
......@@ -296,22 +298,21 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT
IUnknown *parent) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexBufferImpl *object;
WINED3DFORMAT Format = WINED3DFMT_VERTEXDATA; /* Dummy format for now */
D3DCREATERESOURCEOBJECTINSTANCE(object, VertexBuffer, D3DRTYPE_VERTEXBUFFER)
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size);
object->currentDesc.Usage = Usage;
object->currentDesc.Pool = Pool;
object->currentDesc.FVF = FVF;
object->currentDesc.Size = Size;
object->resource.size = Size;
object->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->resource.size);
object->FVF = FVF;
TRACE("(%p) : Size=%d, Usage=%ld, FVF=%lx, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->allocatedMemory, object);
TRACE("(%p) : Size=%d, Usage=%ld, FVF=%lx, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->resource.allocatedMemory, object);
*ppVertexBuffer = (IWineD3DVertexBuffer *)object;
return D3D_OK;
}
HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface, UINT Length, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool, IWineD3DIndexBuffer** ppIndexBuffer,
WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DIndexBuffer** ppIndexBuffer,
HANDLE *sharedHandle, IUnknown *parent) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DIndexBufferImpl *object;
......@@ -320,14 +321,11 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface, UINT
/* Allocate the storage for the device */
D3DCREATERESOURCEOBJECTINSTANCE(object,IndexBuffer,D3DRTYPE_INDEXBUFFER)
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,Length);
object->currentDesc.Usage = Usage;
object->currentDesc.Pool = Pool;
object->currentDesc.Format= Format;
object->currentDesc.Size = Length;
object->resource.size = Length;
object->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,object->resource.size);
TRACE("(%p) : Len=%d, Use=%lx, Format=(%u,%s), Pool=%d - Memory@%p, Iface@%p\n", This, Length, Usage, Format,
debug_d3dformat(Format), Pool, object, object->allocatedMemory);
debug_d3dformat(Format), Pool, object, object->resource.allocatedMemory);
*ppIndexBuffer = (IWineD3DIndexBuffer *) object;
return D3D_OK;
......@@ -368,7 +366,7 @@ If this flag is set, the contents of the depth stencil buffer will be invalid af
******************************** */
HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,D3DRESOURCETYPE Type, DWORD Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, IUnknown *parent) {
HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,D3DRESOURCETYPE Type, DWORD Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, IUnknown *parent) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
unsigned int pow2Width, pow2Height;
......@@ -428,10 +426,6 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
object->currentDesc.Width = Width;
object->currentDesc.Height = Height;
object->currentDesc.Format = Format;
object->currentDesc.Type = Type;
object->currentDesc.Usage = Usage;
object->currentDesc.Pool = Pool;
object->currentDesc.Level = Level;
object->currentDesc.MultiSampleType = MultiSample;
object->currentDesc.MultiSampleQuality = MultisampleQuality;
......@@ -444,13 +438,13 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
*********************************/
if (Format == WINED3DFMT_DXT1) {
/* DXT1 is half byte per pixel */
object->currentDesc.Size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)) / 2;
object->resource.size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)) / 2;
} else if (Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3 ||
Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5) {
object->currentDesc.Size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4));
object->resource.size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4));
} else {
object->currentDesc.Size = (Width * object->bytesPerPixel) * Height;
object->resource.size = (Width * object->bytesPerPixel) * Height;
}
TRACE("Pool %d %d %d %d",Pool, D3DPOOL_DEFAULT, D3DPOOL_MANAGED, D3DPOOL_SYSTEMMEM);
......@@ -502,8 +496,8 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
object->locked = FALSE;
object->lockable = (WINED3DFMT_D16_LOCKABLE == Format) ? TRUE : Lockable;
/* TODO: memory management */
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,object->currentDesc.Size);
if(object->allocatedMemory == NULL ) {
object->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,object->resource.size);
if(object->resource.allocatedMemory == NULL ) {
FIXME("Out of memory!\n");
HeapFree(GetProcessHeap(),0,object);
*ppSurface = NULL;
......@@ -514,13 +508,13 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
IWineD3DSurface_CleanDirtyRect(*ppSurface);
TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n",
This, Width, Height, Format, debug_d3dformat(Format),
(WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->allocatedMemory, object->currentDesc.Size);
(WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->resource.allocatedMemory, object->resource.size);
return D3D_OK;
}
HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Width, UINT Height, UINT Levels,
DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool,
IWineD3DTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *parent,
D3DCB_CREATESURFACEFN D3DCB_CreateSurface) {
......@@ -587,7 +581,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Wid
HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface,
UINT Width, UINT Height, UINT Depth,
UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
WINED3DFORMAT Format, D3DPOOL Pool,
IWineD3DVolumeTexture** ppVolumeTexture,
HANDLE* pSharedHandle, IUnknown *parent,
D3DCB_CREATEVOLUMEFN D3DCB_CreateVolume) {
......@@ -649,15 +643,14 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface,
HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
UINT Width, UINT Height, UINT Depth,
DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
WINED3DFORMAT Format, D3DPOOL Pool,
IWineD3DVolume** ppVolume,
HANDLE* pSharedHandle, IUnknown *parent) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVolumeImpl *object; /** NOTE: impl ref allowed since this is a create function **/
D3DCREATEOBJECTINSTANCE(object, Volume)
object->resourceType = D3DRTYPE_VOLUME;
D3DCREATERESOURCEOBJECTINSTANCE(object, Volume, D3DRTYPE_VOLUME)
TRACE("(%p) : W(%d) H(%d) D(%d), Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
Depth, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
......@@ -665,15 +658,11 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
object->currentDesc.Width = Width;
object->currentDesc.Height = Height;
object->currentDesc.Depth = Depth;
object->currentDesc.Format = Format;
object->currentDesc.Type = D3DRTYPE_VOLUME;
object->currentDesc.Pool = Pool;
object->currentDesc.Usage = Usage;
object->bytesPerPixel = D3DFmtGetBpp(This, Format);
/** Note: Volume textures cannot be dxtn, hence no need to check here **/
object->currentDesc.Size = (Width * object->bytesPerPixel) * Height * Depth;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->currentDesc.Size);
object->resource.size = (Width * object->bytesPerPixel) * Height * Depth;
object->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->resource.size);
object->lockable = TRUE;
object->locked = FALSE;
memset(&object->lockedBox, 0, sizeof(D3DBOX));
......@@ -683,7 +672,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength,
UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
WINED3DFORMAT Format, D3DPOOL Pool,
IWineD3DCubeTexture** ppCubeTexture,
HANDLE* pSharedHandle, IUnknown *parent,
D3DCB_CREATESURFACEFN D3DCB_CreateSurface) {
......@@ -4001,7 +3990,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface,
drawPrimitive(iface, PrimitiveType, primCount, baseVIndex,
startIndex, idxStride,
((IWineD3DIndexBufferImpl *) pIB)->allocatedMemory,
((IWineD3DIndexBufferImpl *) pIB)->resource.allocatedMemory,
minIndex);
return D3D_OK;
......@@ -4033,7 +4022,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, D3DPRIM
HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType,
UINT MinVertexIndex,
UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
WINED3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData,
UINT VertexStreamZeroStride) {
int idxStride;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
......@@ -4270,7 +4259,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* iface, U
TRACE("(%p) : Spot Pos(%u,%u)\n", This, XHotSpot, YHotSpot);
if (WINED3DFMT_A8R8G8B8 != pSur->currentDesc.Format) {
if (WINED3DFMT_A8R8G8B8 != pSur->resource.format) {
ERR("(%p) : surface(%p) has an invalid format\n", This, pCursorBitmap);
return D3DERR_INVALIDCALL;
}
......
......@@ -584,7 +584,7 @@ HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter) {
of the same bpp but different resolutions */
/* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */
UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter, D3DFORMAT Format) {
UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter, WINED3DFORMAT Format) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d, Format: %s)\n", This, Adapter, debug_d3dformat(Format));
......@@ -638,7 +638,7 @@ UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter,
}
/* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */
HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINED3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter:%d, mode:%d, pMode:%p, format:%s)\n", This, Adapter, Mode, pMode, debug_d3dformat(Format));
......@@ -860,7 +860,7 @@ HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter,
}
HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
WINED3DFORMAT AdapterFormat, WINED3DFORMAT RenderTargetFormat, WINED3DFORMAT DepthStencilFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
This, Adapter,
......@@ -877,7 +877,7 @@ HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter
}
HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
......@@ -909,8 +909,8 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface,
}
HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface,
UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
D3DFORMAT BackBufferFormat, BOOL Windowed) {
UINT Adapter, D3DDEVTYPE CheckType, WINED3DFORMAT DisplayFormat,
WINED3DFORMAT BackBufferFormat, BOOL Windowed) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n",
......@@ -936,8 +936,8 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface,
}
HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%lu,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s)) ",
This,
......@@ -1026,7 +1026,7 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface,
return D3D_OK;
}
HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT SourceFormat, WINED3DFORMAT TargetFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
FIXME_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s))",
......
......@@ -385,7 +385,7 @@ void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedD
if (This->stateBlock->streamIsUP) {
data = (BYTE *)This->stateBlock->stream_source[nStream];
} else {
data = ((IWineD3DVertexBufferImpl *)This->stateBlock->stream_source[nStream])->allocatedMemory;
data = ((IWineD3DVertexBufferImpl *)This->stateBlock->stream_source[nStream])->resource.allocatedMemory;
}
} else {
#if 0 /* TODO: Vertex shader support */
......
......@@ -47,7 +47,6 @@ ULONG WINAPI IWineD3DIndexBufferImpl_AddRef(IWineD3DIndexBuffer *iface) {
IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
ULONG ref = InterlockedIncrement(&This->resource.ref);
TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
IUnknown_AddRef(This->resource.parent);
return ref;
}
......@@ -56,11 +55,8 @@ ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface) {
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
}
return ref;
}
......@@ -110,7 +106,7 @@ HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUn
HRESULT WINAPI IWineD3DIndexBufferImpl_Lock(IWineD3DIndexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
TRACE("(%p) : no real locking yet, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags);
*ppbData = (BYTE *)This->allocatedMemory + OffsetToLock;
*ppbData = (BYTE *)This->resource.allocatedMemory + OffsetToLock;
return D3D_OK;
}
HRESULT WINAPI IWineD3DIndexBufferImpl_Unlock(IWineD3DIndexBuffer *iface) {
......@@ -122,11 +118,11 @@ HRESULT WINAPI IWineD3DIndexBufferImpl_GetDesc(IWineD3DIndexBuffer *ifac
IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
TRACE("(%p)\n", This);
pDesc->Format = This->currentDesc.Format;
pDesc->Format = This->resource.format;
pDesc->Type = This->resource.resourceType;
pDesc->Usage = This->currentDesc.Usage;
pDesc->Pool = This->currentDesc.Pool;
pDesc->Size = This->currentDesc.Size;
pDesc->Usage = This->resource.usage;
pDesc->Pool = This->resource.pool;
pDesc->Size = This->resource.size;
return D3D_OK;
}
......
......@@ -52,12 +52,21 @@ ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface) {
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
IWineD3DResourceImpl_CleanUp(iface);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* class static (not in vtable) */
void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) :", This);
HeapFree(GetProcessHeap(), 0, This->resource.allocatedMemory);
This->resource.allocatedMemory = 0;
}
/* IDirect3DResource Interface follow: */
HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice** ppDevice) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
......
......@@ -66,8 +66,7 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
glDeleteTextures(1, &This->textureName);
LEAVE_GL();
}
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -93,15 +92,15 @@ HRESULT WINAPI IWineD3DSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGU
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
}
DWORD WINAPI IWineD3DSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) {
DWORD WINAPI IWineD3DSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
}
DWORD WINAPI IWineD3DSurfaceImpl_GetPriority(IWineD3DSurface *iface) {
DWORD WINAPI IWineD3DSurfaceImpl_GetPriority(IWineD3DSurface *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
}
void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
/* TODO: re-write the way textures and managed,
* use a 'opengl context manager' to manage RenderTarget surfaces
** *********************************************************/
......@@ -139,7 +138,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
FIXME("Mipmap surface has a glTexture bound to it!\n");
}
}
if (This->currentDesc.Pool == D3DPOOL_DEFAULT) {
if (This->resource.pool == D3DPOOL_DEFAULT) {
/* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp;
tmp = 0.9f;
......@@ -188,11 +187,11 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFAC
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : copying into %p\n", This, pDesc);
*(pDesc->Format) = This->currentDesc.Format;
*(pDesc->Type) = This->currentDesc.Type;
*(pDesc->Usage) = This->currentDesc.Usage;
*(pDesc->Pool) = This->currentDesc.Pool;
*(pDesc->Size) = This->currentDesc.Size; /* dx8 only */
*(pDesc->Format) = This->resource.format;
*(pDesc->Type) = This->resource.resourceType;
*(pDesc->Usage) = This->resource.usage;
*(pDesc->Pool) = This->resource.pool;
*(pDesc->Size) = This->resource.size; /* dx8 only */
*(pDesc->MultiSampleType) = This->currentDesc.MultiSampleType;
*(pDesc->MultiSampleQuality) = This->currentDesc.MultiSampleQuality;
*(pDesc->Width) = This->currentDesc.Width;
......@@ -221,30 +220,30 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
if (iface == This->resource.wineD3DDevice->backBuffer || iface == This->resource.wineD3DDevice->renderTarget ||
iface == This->resource.wineD3DDevice->frontBuffer || iface == This->resource.wineD3DDevice->depthStencilBuffer) {
if (iface == This->resource.wineD3DDevice->backBuffer) {
TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (iface == This->resource.wineD3DDevice->frontBuffer) {
TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (iface == This->resource.wineD3DDevice->renderTarget) {
TRACE("(%p, renderTarget) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
TRACE("(%p, renderTarget) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (iface == This->resource.wineD3DDevice->depthStencilBuffer) {
TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
}
} else {
TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, 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 (dxt3/5)
ie pitch = (width/4) * bytes per block */
if (This->currentDesc.Format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
pLockedRect->Pitch = (This->currentDesc.Width/4) * 8;
else if (This->currentDesc.Format == WINED3DFMT_DXT3 || This->currentDesc.Format == WINED3DFMT_DXT5) /* DXT3/5 is 16 bytes per block */
pLockedRect->Pitch = (This->currentDesc.Width/4) * 16;
if (This->resource.format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
pLockedRect->Pitch = (This->currentDesc.Width >> 2) << 3;
else if (This->resource.format == WINED3DFMT_DXT3 || This->resource.format == WINED3DFMT_DXT5) /* DXT3/5 is 16 bytes per block */
pLockedRect->Pitch = (This->currentDesc.Width >> 2) << 4;
else
pLockedRect->Pitch = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
if (NULL == pRect) {
pLockedRect->pBits = This->allocatedMemory;
pLockedRect->pBits = This->resource.allocatedMemory;
This->lockedRect.left = 0;
This->lockedRect.top = 0;
This->lockedRect.right = This->currentDesc.Width;
......@@ -253,10 +252,10 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
} else {
TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
if (This->currentDesc.Format == WINED3DFMT_DXT1) { /* DXT1 is half byte per pixel */
pLockedRect->pBits = This->allocatedMemory + (pLockedRect->Pitch * pRect->top) + ((pRect->left * This->bytesPerPixel/2));
if (This->resource.format == WINED3DFMT_DXT1) { /* DXT1 is half byte per pixel */
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + ((pRect->left * This->bytesPerPixel/2));
} else {
pLockedRect->pBits = This->allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
}
This->lockedRect.left = pRect->left;
This->lockedRect.top = pRect->top;
......@@ -265,11 +264,11 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
}
if (0 == This->currentDesc.Usage) { /* classic surface */
if (0 == This->resource.usage) { /* classic surface */
/* Nothing to do ;) */
} else if (D3DUSAGE_RENDERTARGET & This->currentDesc.Usage && !(Flags&D3DLOCK_DISCARD)) { /* render surfaces */
} else if (D3DUSAGE_RENDERTARGET & This->resource.usage && !(Flags&D3DLOCK_DISCARD)) { /* render surfaces */
if (iface == This->resource.wineD3DDevice->backBuffer || iface == This->resource.wineD3DDevice->renderTarget || iface == This->resource.wineD3DDevice->frontBuffer) {
GLint prev_store;
......@@ -281,7 +280,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
* for render->surface copy begin to begin of allocatedMemory
* unlock can be more easy
*/
pLockedRect->pBits = This->allocatedMemory;
pLockedRect->pBits = This->resource.allocatedMemory;
glFlush();
vcheckGLcall("glFlush");
......@@ -301,8 +300,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
{
long j;
GLenum format = D3DFmt2GLFmt(This->resource.wineD3DDevice, This->currentDesc.Format);
GLenum type = D3DFmt2GLType(This->resource.wineD3DDevice, This->currentDesc.Format);
GLenum format = D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format);
GLenum type = D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format);
for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
glReadPixels(This->lockedRect.left,
This->lockedRect.bottom - j - 1,
......@@ -321,15 +320,15 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
LEAVE_GL();
} else {
FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This, This->currentDesc.Usage);
FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This, This->resource.usage);
}
} else if (D3DUSAGE_DEPTHSTENCIL & This->currentDesc.Usage) { /* stencil surfaces */
} else if (D3DUSAGE_DEPTHSTENCIL & This->resource.usage) { /* stencil surfaces */
FIXME("TODO stencil depth surface locking surf@%p usage(%lu)\n", This, This->currentDesc.Usage);
FIXME("TODO stencil depth surface locking surf@%p usage(%lu)\n", This, This->resource.usage);
} else {
FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This, This->currentDesc.Usage);
FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This, This->resource.usage);
}
if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
......@@ -387,12 +386,12 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
goto unlock_end;
}
if (0 == This->currentDesc.Usage) { /* classic surface */
if (0 == This->resource.usage) { /* classic surface */
/**
* nothing to do
* waiting to reload the surface via IDirect3DDevice8::UpdateTexture
*/
} else if (D3DUSAGE_RENDERTARGET & This->currentDesc.Usage) { /* render surfaces */
} else if (D3DUSAGE_RENDERTARGET & This->resource.usage) { /* render surfaces */
if (iface == This->resource.wineD3DDevice->backBuffer || iface == This->resource.wineD3DDevice->frontBuffer || iface == This->resource.wineD3DDevice->renderTarget) {
GLint prev_store;
......@@ -466,18 +465,18 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1);
vcheckGLcall("glRasterPos2f");
switch (This->currentDesc.Format) {
switch (This->resource.format) {
case WINED3DFMT_R5G6B5:
{
glDrawPixels(This->lockedRect.right - This->lockedRect.left, (This->lockedRect.bottom - This->lockedRect.top)-1,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, This->allocatedMemory);
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, This->resource.allocatedMemory);
vcheckGLcall("glDrawPixels");
}
break;
case WINED3DFMT_R8G8B8:
{
glDrawPixels(This->lockedRect.right - This->lockedRect.left, (This->lockedRect.bottom - This->lockedRect.top)-1,
GL_RGB, GL_UNSIGNED_BYTE, This->allocatedMemory);
GL_RGB, GL_UNSIGNED_BYTE, This->resource.allocatedMemory);
vcheckGLcall("glDrawPixels");
}
break;
......@@ -487,14 +486,14 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
vcheckGLcall("glPixelStorei");
glDrawPixels(This->lockedRect.right - This->lockedRect.left, (This->lockedRect.bottom - This->lockedRect.top)-1,
GL_BGRA, GL_UNSIGNED_BYTE, This->allocatedMemory);
GL_BGRA, GL_UNSIGNED_BYTE, This->resource.allocatedMemory);
vcheckGLcall("glDrawPixels");
glPixelStorei(GL_PACK_SWAP_BYTES, prev_store);
vcheckGLcall("glPixelStorei");
}
break;
default:
FIXME("Unsupported Format %u in locking func\n", This->currentDesc.Format);
FIXME("Unsupported Format %u in locking func\n", This->resource.format);
}
glPixelZoom(1.0,1.0);
......@@ -514,19 +513,19 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
IWineD3DSurface_CleanDirtyRect(iface);
} else {
FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->currentDesc.Usage);
FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->resource.usage);
}
} else if (D3DUSAGE_DEPTHSTENCIL & This->currentDesc.Usage) { /* stencil surfaces */
} else if (D3DUSAGE_DEPTHSTENCIL & This->resource.usage) { /* stencil surfaces */
if (iface == This->resource.wineD3DDevice->depthStencilBuffer) {
FIXME("TODO stencil depth surface unlocking surf@%p usage(%lu)\n", This, This->currentDesc.Usage);
FIXME("TODO stencil depth surface unlocking surf@%p usage(%lu)\n", This, This->resource.usage);
} else {
FIXME("unsupported unlocking to StencilDepth surface surf@%p usage(%lu)\n", This, This->currentDesc.Usage);
FIXME("unsupported unlocking to StencilDepth surface surf@%p usage(%lu)\n", This, This->resource.usage);
}
} else {
FIXME("unsupported unlocking to surface surf@%p usage(%lu)\n", This, This->currentDesc.Usage);
FIXME("unsupported unlocking to surface surf@%p usage(%lu)\n", This, This->resource.usage);
}
unlock_end:
......@@ -561,15 +560,15 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
if (gl_level != 0)
FIXME("Surface in texture is only supported for level 0\n");
else if (This->currentDesc.Format == WINED3DFMT_P8 || This->currentDesc.Format == WINED3DFMT_A8P8 ||
This->currentDesc.Format == WINED3DFMT_DXT1 || This->currentDesc.Format == WINED3DFMT_DXT3 ||
This->currentDesc.Format == WINED3DFMT_DXT5)
FIXME("Format %d not supported\n", This->currentDesc.Format);
else if (This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8 ||
This->resource.format == WINED3DFMT_DXT1 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT5)
FIXME("Format %d not supported\n", This->resource.format);
else {
glCopyTexImage2D(gl_target,
0,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice,
This->currentDesc.Format),
This->resource.format),
0,
0,
This->currentDesc.Width,
......@@ -582,7 +581,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
return D3D_OK;
}
if ((This->currentDesc.Format == WINED3DFMT_P8 || This->currentDesc.Format == WINED3DFMT_A8P8) &&
if ((This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8) &&
!GL_SUPPORT(EXT_PALETTED_TEXTURE)) {
/**
* wanted a paletted texture and not really support it in HW
......@@ -592,14 +591,14 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
PALETTEENTRY* pal = This->resource.wineD3DDevice->palettes[This->resource.wineD3DDevice->currentPalette];
VOID* surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->currentDesc.Width * This->currentDesc.Height * sizeof(DWORD));
BYTE* dst = (BYTE*) surface;
BYTE* src = (BYTE*) This->allocatedMemory;
BYTE* src = (BYTE*) This->resource.allocatedMemory;
for (i = 0; i < This->currentDesc.Width * This->currentDesc.Height; i++) {
BYTE color = *src++;
*dst++ = pal[color].peRed;
*dst++ = pal[color].peGreen;
*dst++ = pal[color].peBlue;
if (This->currentDesc.Format == WINED3DFMT_A8P8)
if (This->resource.format == WINED3DFMT_A8P8)
*dst++ = pal[color].peFlags;
else
*dst++ = 0xFF;
......@@ -634,30 +633,30 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
return D3D_OK;
}
if (This->currentDesc.Format == WINED3DFMT_DXT1 ||
This->currentDesc.Format == WINED3DFMT_DXT3 ||
This->currentDesc.Format == WINED3DFMT_DXT5) {
if (This->resource.format == WINED3DFMT_DXT1 ||
This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT5) {
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
gl_target,
gl_level,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->currentDesc.Format),
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
This->currentDesc.Width,
This->currentDesc.Height,
0,
This->currentDesc.Size,
This->allocatedMemory);
This->resource.size,
This->resource.allocatedMemory);
ENTER_GL();
GL_EXTCALL(glCompressedTexImage2DARB)(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->currentDesc.Format),
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
This->currentDesc.Width,
This->currentDesc.Height,
0,
This->currentDesc.Size,
This->allocatedMemory);
This->resource.size,
This->resource.allocatedMemory);
checkGLcall("glCommpressedTexTexImage2D");
LEAVE_GL();
......@@ -669,26 +668,26 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
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(This->currentDesc.Format),
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->currentDesc.Format),
debug_d3dformat(This->resource.format),
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
This->currentDesc.Width,
This->currentDesc.Height,
0,
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->currentDesc.Format),
D3DFmt2GLType(This->resource.wineD3DDevice, This->currentDesc.Format),
This->allocatedMemory);
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
This->resource.allocatedMemory);
ENTER_GL();
glTexImage2D(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->currentDesc.Format),
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
This->currentDesc.Width,
This->currentDesc.Height,
0,
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->currentDesc.Format),
D3DFmt2GLType(This->resource.wineD3DDevice, This->currentDesc.Format),
This->allocatedMemory);
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
This->resource.allocatedMemory);
checkGLcall("glTexImage2D");
LEAVE_GL();
......@@ -729,16 +728,16 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
return D3DERR_INVALIDCALL;
}
TRACE("opened %s with format %s\n", filename, debug_d3dformat(This->currentDesc.Format));
TRACE("opened %s with format %s\n", filename, debug_d3dformat(This->resource.format));
fprintf(f, "P6\n%u %u\n255\n", This->currentDesc.Width, This->currentDesc.Height);
switch (This->currentDesc.Format) {
switch (This->resource.format) {
case WINED3DFMT_X8R8G8B8:
case WINED3DFMT_A8R8G8B8:
{
DWORD color;
for (i = 0; i < This->currentDesc.Width * This->currentDesc.Height; i++) {
color = ((DWORD*) This->allocatedMemory)[i];
color = ((DWORD*) This->resource.allocatedMemory)[i];
fputc((color >> 16) & 0xFF, f);
fputc((color >> 8) & 0xFF, f);
fputc((color >> 0) & 0xFF, f);
......@@ -749,7 +748,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
{
BYTE* color;
for (i = 0; i < This->currentDesc.Width * This->currentDesc.Height; i++) {
color = ((BYTE*) This->allocatedMemory) + (3 * i);
color = ((BYTE*) This->resource.allocatedMemory) + (3 * i);
fputc((color[0]) & 0xFF, f);
fputc((color[1]) & 0xFF, f);
fputc((color[2]) & 0xFF, f);
......@@ -760,7 +759,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
{
WORD color;
for (i = 0; i < This->currentDesc.Width * This->currentDesc.Height; i++) {
color = ((WORD*) This->allocatedMemory)[i];
color = ((WORD*) This->resource.allocatedMemory)[i];
fputc(((color >> 10) & 0x1F) * 255 / 31, f);
fputc(((color >> 5) & 0x1F) * 255 / 31, f);
fputc(((color >> 0) & 0x1F) * 255 / 31, f);
......@@ -771,7 +770,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
{
WORD color;
for (i = 0; i < This->currentDesc.Width * This->currentDesc.Height; i++) {
color = ((WORD*) This->allocatedMemory)[i];
color = ((WORD*) This->resource.allocatedMemory)[i];
fputc(((color >> 8) & 0x0F) * 255 / 15, f);
fputc(((color >> 4) & 0x0F) * 255 / 15, f);
fputc(((color >> 0) & 0x0F) * 255 / 15, f);
......@@ -783,7 +782,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
{
WORD color;
for (i = 0; i < This->currentDesc.Width * This->currentDesc.Height; i++) {
color = ((WORD*) This->allocatedMemory)[i];
color = ((WORD*) This->resource.allocatedMemory)[i];
fputc(((color >> 11) & 0x1F) * 255 / 31, f);
fputc(((color >> 5) & 0x3F) * 255 / 63, f);
fputc(((color >> 0) & 0x1F) * 255 / 31, f);
......@@ -791,7 +790,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
}
break;
default:
FIXME("Unimplemented dump mode format(%u,%s)\n", This->currentDesc.Format, debug_d3dformat(This->currentDesc.Format));
FIXME("Unimplemented dump mode format(%u,%s)\n", This->resource.format, debug_d3dformat(This->resource.format));
}
fclose(f);
return D3D_OK;
......@@ -853,7 +852,7 @@ IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
IWineD3DSurfaceImpl_QueryInterface,
IWineD3DSurfaceImpl_AddRef,
IWineD3DSurfaceImpl_Release,
/* IWineD3DResource */
/* IWineD3DResource */
IWineD3DSurfaceImpl_GetParent,
IWineD3DSurfaceImpl_GetDevice,
IWineD3DSurfaceImpl_SetPrivateData,
......
......@@ -58,7 +58,6 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
int i;
for (i = 0; i < This->baseTexture.levels; i++) {
if (This->surfaces[i] != NULL) {
/* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
......@@ -68,12 +67,7 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
IUnknown_Release(surfaceParent);
}
}
if (This->baseTexture.textureName != 0) {
ENTER_GL();
TRACE("Deleting texture %d\n", This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.textureName);
LEAVE_GL();
}
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
} else {
......@@ -115,35 +109,9 @@ void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
TRACE("(%p) : About to load texture\n", This);
ENTER_GL();
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_2D, ENABLED, NOW /* make sure the state is applied now */);
#endif
IWineD3DTexture_BindTexture(iface);
/* Generate a texture name if we don't already have one */
if (This->baseTexture.textureName == 0) {
glGenTextures(1, &This->baseTexture.textureName);
checkGLcall("glGenTextures");
TRACE("Generated texture %d\n", This->baseTexture.textureName);
if (This->baseTexture.pool == D3DPOOL_DEFAULT) {
/* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp;
tmp = 0.9f;
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
}
}
/* Bind the texture */
if (This->baseTexture.textureName != 0) {
glBindTexture(GL_TEXTURE_2D, This->baseTexture.textureName);
checkGLcall("glBindTexture");
} else { /* this only happened if we've run out of openGL textures */
WARN("This texture doesn't have an openGL texture assigned to it\n");
return;
}
ENTER_GL();
/* If were dirty then reload the surfaces */
if(This->baseTexture.dirty != FALSE) {
for (i = 0; i < This->baseTexture.levels; i++) {
......@@ -151,21 +119,8 @@ void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
}
/* No longer dirty */
This->baseTexture.dirty = FALSE;
This->baseTexture.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->baseTexture.levels - 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)");
/* TODO: disable texture support, if it wastn't enabled when we entered. */
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PopState(This->contextManager, GL_TEXTURE_2D, DISABLED,DELAYED
/* we don't care when the state is disabled(if atall) */);
#endif
LEAVE_GL();
return ;
......@@ -217,33 +172,14 @@ BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) {
HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
TRACE("(%p) : %d \n", This, This->baseTexture.textureName);
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_2D, ENABLED, NOW /* make sure the state is applied now */);
#endif
ENTER_GL();
IWineD3DTexture_PreLoad(iface); /* make sure the textures is preloaded */
#if 1 /* TODO: context manager support */
glEnable(GL_TEXTURE_2D); /* all this enable disable stuff is a bit of a mess */
#endif
glBindTexture(GL_TEXTURE_2D, This->baseTexture.textureName);
LEAVE_GL();
return D3D_OK;
TRACE("(%p) : relay to BaseTexture \n", This);
return IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
}
HRESULT WINAPI IWineD3DTextureImpl_UnBindTexture(IWineD3DTexture *iface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
TRACE("(%p) \n", This);
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PopState(This->contextManager, GL_TEXTURE_2D, DISABLED, DELAYED);
#endif
ENTER_GL();
#if 1 /* TODO: context manager support */
glBindTexture(GL_TEXTURE_2D, 0);
#endif
glDisable(GL_TEXTURE_2D); /* This should be queued! so that we don't keep enabling and disabling states. */
LEAVE_GL();
return D3D_OK;
TRACE("(%p) : relay to BaseTexture \n", This);
return IWineD3DBaseTextureImpl_UnBindTexture((IWineD3DBaseTexture *)iface);
}
UINT WINAPI IWineD3DTextureImpl_GetTextureDimensions(IWineD3DTexture *iface) {
......
......@@ -47,7 +47,6 @@ ULONG WINAPI IWineD3DVertexBufferImpl_AddRef(IWineD3DVertexBuffer *iface) {
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
ULONG ref = InterlockedIncrement(&This->resource.ref);
TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
IUnknown_AddRef(This->resource.parent);
return ref;
}
......@@ -56,11 +55,8 @@ ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface) {
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
}
return ref;
}
......@@ -109,9 +105,9 @@ HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, I
****************************************************** */
HRESULT WINAPI IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
TRACE("(%p) : returning memory of %p (base:%p,offset:%u)\n", This, This->allocatedMemory + OffsetToLock, This->allocatedMemory, OffsetToLock);
TRACE("(%p) : returning memory of %p (base:%p,offset:%u)\n", This, This->resource.allocatedMemory + OffsetToLock, This->resource.allocatedMemory, OffsetToLock);
/* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
*ppbData = This->allocatedMemory + OffsetToLock;
*ppbData = This->resource.allocatedMemory + OffsetToLock;
return D3D_OK;
}
HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
......@@ -123,12 +119,12 @@ HRESULT WINAPI IWineD3DVertexBufferImpl_GetDesc(IWineD3DVertexBuffer *if
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
TRACE("(%p)\n", This);
pDesc->Format = This->currentDesc.Format;
pDesc->Format = This->resource.format;
pDesc->Type = This->resource.resourceType;
pDesc->Usage = This->currentDesc.Usage;
pDesc->Pool = This->currentDesc.Pool;
pDesc->Size = This->currentDesc.Size;
pDesc->FVF = This->currentDesc.FVF;
pDesc->Usage = This->resource.usage;
pDesc->Pool = This->resource.pool;
pDesc->Size = This->resource.size;
pDesc->FVF = This->FVF;
return D3D_OK;
}
......
......@@ -2,7 +2,8 @@
* IWineD3DVolume implementation
*
* Copyright 2002-2005 Jason Edmeades
* Raphael Junqueira
* Copyright 2002-2005 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
......@@ -43,63 +44,64 @@ HRESULT WINAPI IWineD3DVolumeImpl_QueryInterface(IWineD3DVolume *iface, REFIID r
ULONG WINAPI IWineD3DVolumeImpl_AddRef(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->ref);
IUnknown_AddRef(This->parent);
return InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
return InterlockedIncrement(&This->resource.ref);
}
ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->parent); /* Released the reference to the d3dx object */
}
return ref;
}
/* *******************************************
IWineD3DVolume parts follow
******************************************* */
/* ****************************************************
IWineD3DSurface IWineD3DResource parts follow
**************************************************** */
HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
IUnknown_AddRef(This->parent);
*pParent = This->parent;
return D3D_OK;
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
}
HRESULT WINAPI IWineD3DVolumeImpl_GetDevice(IWineD3DVolume *iface, IWineD3DDevice** ppDevice) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : returning %p\n", This, This->wineD3DDevice);
*ppDevice = (IWineD3DDevice *) This->wineD3DDevice;
IWineD3DDevice_AddRef(*ppDevice);
return D3D_OK;
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
}
HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
}
DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
}
DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
}
void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
return IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
}
D3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
}
/* *******************************************
IWineD3DVolume parts follow
******************************************* */
HRESULT WINAPI IWineD3DVolumeImpl_GetContainer(IWineD3DVolume *iface, REFIID riid, void** ppContainer) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : returning %p\n", This, This->container);
......@@ -112,14 +114,14 @@ HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_D
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : copying into %p\n", This, pDesc);
*(pDesc->Format) = This->currentDesc.Format;
*(pDesc->Type) = This->currentDesc.Type;
*(pDesc->Usage) = This->currentDesc.Usage;
*(pDesc->Pool) = This->currentDesc.Pool;
*(pDesc->Size) = This->currentDesc.Size; /* dx8 only */
*(pDesc->Width) = This->currentDesc.Width;
*(pDesc->Height) = This->currentDesc.Height;
*(pDesc->Depth) = This->currentDesc.Depth;
*(pDesc->Format) = This->resource.format;
*(pDesc->Type) = This->resource.resourceType;
*(pDesc->Usage) = This->resource.usage;
*(pDesc->Pool) = This->resource.pool;
*(pDesc->Size) = This->resource.size; /* dx8 only */
*(pDesc->Width) = This->currentDesc.Width;
*(pDesc->Height) = This->currentDesc.Height;
*(pDesc->Depth) = This->currentDesc.Depth;
return D3D_OK;
}
......@@ -128,13 +130,13 @@ HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX*
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);
TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory);
pLockedVolume->RowPitch = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
pLockedVolume->SlicePitch = This->bytesPerPixel * This->currentDesc.Width * This->currentDesc.Height; /* Bytes / slice */
if (!pBox) {
TRACE("No box supplied - all is ok\n");
pLockedVolume->pBits = This->allocatedMemory;
pLockedVolume->pBits = This->resource.allocatedMemory;
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
......@@ -143,7 +145,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX*
This->lockedBox.Back = This->currentDesc.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->pBits = This->resource.allocatedMemory +
(pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
(pLockedVolume->RowPitch * pBox->Top) +
(pBox->Left * This->bytesPerPixel);
......@@ -240,7 +242,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IUnknown*
HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, GLenum gl_level) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
IWineD3DDeviceImpl *myDevice = This->wineD3DDevice;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
TRACE("Calling glTexImage3D %x level=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_3D,
......@@ -252,7 +254,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, GLenum gl_l
0,
D3DFmt2GLFmt(myDevice, This->currentDesc.Format),
D3DFmt2GLType(myDevice, This->currentDesc.Format),
This->allocatedMemory);
This->resource.allocatedMemory);
glTexImage3D(GL_TEXTURE_3D,
gl_level,
D3DFmt2GLIntFmt(myDevice, This->currentDesc.Format),
......@@ -262,7 +264,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, GLenum gl_l
0,
D3DFmt2GLFmt(myDevice, This->currentDesc.Format),
D3DFmt2GLType(myDevice, This->currentDesc.Format),
This->allocatedMemory);
This->resource.allocatedMemory);
checkGLcall("glTexImage3D");
return D3D_OK;
......@@ -274,12 +276,17 @@ IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
IWineD3DVolumeImpl_QueryInterface,
IWineD3DVolumeImpl_AddRef,
IWineD3DVolumeImpl_Release,
/* IWineD3DVolume */
/* IWineD3DResource */
IWineD3DVolumeImpl_GetParent,
IWineD3DVolumeImpl_GetDevice,
IWineD3DVolumeImpl_SetPrivateData,
IWineD3DVolumeImpl_GetPrivateData,
IWineD3DVolumeImpl_FreePrivateData,
IWineD3DVolumeImpl_SetPriority,
IWineD3DVolumeImpl_GetPriority,
IWineD3DVolumeImpl_PreLoad,
IWineD3DVolumeImpl_GetType,
/* IWineD3DVolume */
IWineD3DVolumeImpl_GetContainer,
IWineD3DVolumeImpl_GetDesc,
IWineD3DVolumeImpl_LockBox,
......
......@@ -64,12 +64,7 @@ ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *iface) {
IWineD3DVolume_Release((IWineD3DSurface *) This->volumes[i]);
}
}
if(This->baseTexture.textureName != 0){
ENTER_GL();
TRACE("Deleting texture %d\n", This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.textureName);
LEAVE_GL();
}
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
......@@ -111,34 +106,9 @@ void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
TRACE("(%p) : About to load texture\n", This);
ENTER_GL();
#if 0 /* TODO: context manager support */
IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_3D, ENABLED, NOW /* make sure the state is applied now */);
#endif
glEnable(GL_TEXTURE_3D); /* make sure texture support is enabled in this context */
/* Generate a texture name if we don't already have one */
if (This->baseTexture.textureName == 0) {
glGenTextures(1, &This->baseTexture.textureName);
checkGLcall("glGenTextures");
TRACE("Generated texture %d\n", This->baseTexture.textureName);
if (This->baseTexture.pool == D3DPOOL_DEFAULT) {
/* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp;
tmp = 0.9f;
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
}
}
/* Bind the texture */
if (This->baseTexture.textureName != 0) {
glBindTexture(GL_TEXTURE_3D, This->baseTexture.textureName);
checkGLcall("glBindTexture");
} else { /* this only happened if we've run out of openGL textures */
WARN("This texture doesn't have an openGL texture assigned to it\n");
return;
}
IWineD3DVolumeTexture_BindTexture(iface);
ENTER_GL();
/* If were dirty then reload the volumes */
if(This->baseTexture.dirty != FALSE) {
for (i = 0; i < This->baseTexture.levels; i++) {
......@@ -148,11 +118,6 @@ void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
/* No longer dirty */
This->baseTexture.dirty = FALSE;
}
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
checkGLcall("glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1)");
LEAVE_GL();
return ;
......@@ -204,25 +169,14 @@ BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface) {
HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : %d \n", This, This->baseTexture.textureName);
/* make sure that there is a texture to bind */
IWineD3DVolumeTexture_PreLoad(iface);
ENTER_GL();
glEnable(GL_TEXTURE_3D); /* all this enable disable stuff is a bit of a mess */
/* FIXME: change to use this->textureName */
glBindTexture(GL_TEXTURE_3D, This->baseTexture.textureName);
LEAVE_GL();
return D3D_OK;
TRACE("(%p) : relay to BaseTexture \n", This);
return IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
}
HRESULT WINAPI IWineD3DVolumeTextureImpl_UnBindTexture(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) \n", This);
ENTER_GL();
glBindTexture(GL_TEXTURE_3D, 0);
glDisable(GL_TEXTURE_3D);
LEAVE_GL();
return D3D_OK;
TRACE("(%p) : relay to BaseTexture \n", This);
return IWineD3DBaseTextureImpl_UnBindTexture((IWineD3DBaseTexture *)iface);
}
UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) {
......
......@@ -420,6 +420,11 @@ typedef struct IWineD3DResourceClass
IUnknown *parent;
D3DRESOURCETYPE resourceType;
IWineD3DDeviceImpl *wineD3DDevice;
D3DPOOL pool;
UINT size;
DWORD usage;
WINED3DFORMAT format;
BYTE *allocatedMemory;
} IWineD3DResourceClass;
......@@ -442,13 +447,13 @@ typedef struct IWineD3DVertexBufferImpl
IWineD3DResourceClass resource;
/* WineD3DVertexBuffer specifics */
BYTE *allocatedMemory;
D3DVERTEXBUFFER_DESC currentDesc;
DWORD FVF;
} IWineD3DVertexBufferImpl;
extern IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
/*****************************************************************************
* IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
*/
......@@ -459,9 +464,6 @@ typedef struct IWineD3DIndexBufferImpl
IWineD3DResourceClass resource;
/* WineD3DVertexBuffer specifics */
BYTE *allocatedMemory;
D3DINDEXBUFFER_DESC currentDesc;
} IWineD3DIndexBufferImpl;
extern IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
......@@ -474,7 +476,6 @@ typedef struct IWineD3DBaseTextureClass
UINT levels;
BOOL dirty;
D3DFORMAT format;
D3DPOOL pool;
DWORD usage;
UINT textureName;
UINT LOD;
......@@ -537,17 +538,12 @@ extern IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
*/
typedef struct IWineD3DVolumeImpl
{
/* IUnknown fields */
IWineD3DVolumeVtbl *lpVtbl;
DWORD ref; /* Note: Ref counting not required */
/* IUnknown & WineD3DResource fields */
IWineD3DVolumeVtbl *lpVtbl;
IWineD3DResourceClass resource;
/* WineD3DVolume Information */
IUnknown *parent;
D3DRESOURCETYPE resourceType;
IWineD3DDeviceImpl *wineD3DDevice;
D3DVOLUME_DESC currentDesc;
BYTE *allocatedMemory;
IUnknown *container;
UINT bytesPerPixel;
......@@ -584,11 +580,6 @@ extern IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
typedef struct _WINED3DSURFACET_DESC
{
D3DFORMAT Format;
D3DRESOURCETYPE Type;
DWORD Usage;
D3DPOOL Pool;
UINT Size;
UINT Level;
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
......@@ -608,7 +599,6 @@ struct IWineD3DSurfaceImpl
/* IWineD3DSurface fields */
IUnknown *container;
WINED3DSURFACET_DESC currentDesc;
BYTE *allocatedMemory;
UINT textureName;
UINT bytesPerPixel;
......@@ -810,7 +800,8 @@ GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
extern D3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
/*** class static members ***/
void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
/*** IUnknown methods ***/
extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
......@@ -835,7 +826,10 @@ GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
/*** class static members ***/
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
/*****************************************************************************
* IDirect3DVertexShader implementation structure
......
......@@ -162,7 +162,7 @@ typedef struct IWineD3DQuery IWineD3DQuery;
typedef HRESULT WINAPI (*D3DCB_CREATERENDERTARGETFN) (IUnknown *pDevice,
UINT Width,
UINT Height,
D3DFORMAT Format,
WINED3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality,
BOOL Lockable,
......@@ -172,7 +172,7 @@ typedef HRESULT WINAPI (*D3DCB_CREATERENDERTARGETFN) (IUnknown *pDevice,
typedef HRESULT WINAPI (*D3DCB_CREATESURFACEFN) (IUnknown *pDevice,
UINT Width,
UINT Height,
D3DFORMAT Format,
WINED3DFORMAT Format,
DWORD Usage,
D3DPOOL Pool,
UINT Level,
......@@ -182,7 +182,7 @@ typedef HRESULT WINAPI (*D3DCB_CREATESURFACEFN) (IUnknown *pDevice,
typedef HRESULT WINAPI (*D3DCB_CREATEDEPTHSTENCILSURFACEFN) (IUnknown *pDevice,
UINT Width,
UINT Height,
D3DFORMAT Format,
WINED3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality,
BOOL Discard,
......@@ -194,7 +194,7 @@ typedef HRESULT WINAPI (*D3DCB_CREATEVOLUMEFN) (IUnknown *pDevice,
UINT Width,
UINT Height,
UINT Depth,
D3DFORMAT Format,
WINED3DFORMAT Format,
D3DPOOL Pool,
DWORD Usage,
IWineD3DVolume **ppVolume,
......@@ -221,15 +221,15 @@ DECLARE_INTERFACE_(IWineD3D,IUnknown)
STDMETHOD_(UINT,GetAdapterCount)(THIS) PURE;
STDMETHOD(RegisterSoftwareDevice)(THIS_ void * pInitializeFunction) PURE;
STDMETHOD_(HMONITOR,GetAdapterMonitor)(THIS_ UINT Adapter) PURE;
STDMETHOD_(UINT,GetAdapterModeCount)(THIS_ UINT Adapter, D3DFORMAT Format) PURE;
STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter, UINT Mode, D3DFORMAT Format, D3DDISPLAYMODE * pMode) PURE;
STDMETHOD_(UINT,GetAdapterModeCount)(THIS_ UINT Adapter, WINED3DFORMAT Format) PURE;
STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter, UINT Mode, WINED3DFORMAT Format, D3DDISPLAYMODE * pMode) PURE;
STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter, D3DDISPLAYMODE *pMode) PURE;
STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter, DWORD Flags, WINED3DADAPTER_IDENTIFIER* pIdentifier) PURE;
STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQuality) PURE;
STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) PURE;
STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed) PURE;
STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) PURE;
STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) PURE;
STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQuality) PURE;
STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, WINED3DFORMAT RenderTargetFormat, WINED3DFORMAT DepthStencilFormat) PURE;
STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter, D3DDEVTYPE CheckType, WINED3DFORMAT DisplayFormat, WINED3DFORMAT BackBufferFormat, BOOL Windowed) PURE;
STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) PURE;
STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT SourceFormat, WINED3DFORMAT TargetFormat) PURE;
STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS *pCaps) PURE;
STDMETHOD(CreateDevice)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType,HWND hFocusWindow, DWORD BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface, IUnknown *parent, D3DCB_CREATERENDERTARGETFN pFn) PURE;
};
......@@ -274,13 +274,13 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
/*** IWineD3DDevice methods ***/
STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IWineD3DVertexBuffer **ppVertexBuffer, HANDLE *sharedHandle, IUnknown *parent) PURE;
STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DIndexBuffer** ppIndexBuffer, HANDLE* pSharedHandle, IUnknown *parent) PURE;
STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DIndexBuffer** ppIndexBuffer, HANDLE* pSharedHandle, IUnknown *parent) PURE;
STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock **ppStateBlock, IUnknown *parent) PURE;
STDMETHOD(CreateSurface)(THIS_ UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface** ppSurface, D3DRESOURCETYPE Type, DWORD Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, IUnknown *parent) PURE;
STDMETHOD(CreateTexture)(THIS_ UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn) PURE;
STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DVolumeTexture** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATEVOLUMEFN pFn) PURE;
STDMETHOD(CreateVolume)(THIS_ UINT Width, UINT Height, UINT Depth, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DVolume** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent) PURE;
STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DCubeTexture** ppCubeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn) PURE;
STDMETHOD(CreateSurface)(THIS_ UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface** ppSurface, D3DRESOURCETYPE Type, DWORD Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, IUnknown *parent) PURE;
STDMETHOD(CreateTexture)(THIS_ UINT Width, UINT Height, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn) PURE;
STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DVolumeTexture** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATEVOLUMEFN pFn) PURE;
STDMETHOD(CreateVolume)(THIS_ UINT Width, UINT Height, UINT Depth, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DVolume** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent) PURE;
STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DCubeTexture** ppCubeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn) PURE;
STDMETHOD(CreateQuery)(THIS_ WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown *pParent);
STDMETHOD(CreateAdditionalSwapChain)(THIS_ WINED3DPRESENT_PARAMETERS* pPresentationParameters, void** pSwapChain, IUnknown* pParent, D3DCB_CREATERENDERTARGETFN pFn, D3DCB_CREATEDEPTHSTENCILSURFACEFN pFn2);
STDMETHOD(CreateVertexDeclaration)(THIS_ CONST VOID* pDeclaration, IWineD3DVertexDeclaration** ppDecl, IUnknown* pParent) PURE;
......@@ -378,7 +378,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE;
STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,INT baseVIdx, UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE;
STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE;
STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void * pIndexData,D3DFORMAT IndexDataFormat,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE;
STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void * pIndexData,WINED3DFORMAT IndexDataFormat,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE;
STDMETHOD(DrawRectPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE;
STDMETHOD(DrawTriPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE;
STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE;
......@@ -1024,18 +1024,23 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
* IWineD3DVolume interface
*/
#define INTERFACE IWineD3DVolume
DECLARE_INTERFACE_(IWineD3DVolume,IUnknown)
DECLARE_INTERFACE_(IWineD3DVolume,IWineD3DResource)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IWineD3DVolume methods ***/
/*** IWineD3DResource methods ***/
STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
STDMETHOD(GetDevice)(THIS_ IWineD3DDevice ** ppDevice) PURE;
STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE;
STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE;
STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE;
STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE;
STDMETHOD_(DWORD,GetPriority)(THIS) PURE;
STDMETHOD_(void,PreLoad)(THIS) PURE;
STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE;
/*** IWineD3DVolume methods ***/
STDMETHOD(GetContainer)(THIS_ REFIID riid, void ** ppContainer) PURE;
STDMETHOD(GetDesc)(THIS_ WINED3DVOLUME_DESC * pDesc) PURE;
STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) PURE;
......@@ -1052,12 +1057,17 @@ DECLARE_INTERFACE_(IWineD3DVolume,IUnknown)
#define IWineD3DVolume_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IWineD3DVolume_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IWineD3DVolume_Release(p) (p)->lpVtbl->Release(p)
/*** IWineD3DVolume methods ***/
/*** IWineD3DResource methods ***/
#define IWineD3DVolume_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
#define IWineD3DVolume_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IWineD3DVolume_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
#define IWineD3DVolume_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
#define IWineD3DVolume_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
#define IWineD3DVolume_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
#define IWineD3DVolume_GetPriority(p) (p)->lpVtbl->GetPriority(p)
#define IWineD3DVolume_PreLoad(p) (p)->lpVtbl->PreLoad(p)
#define IWineD3DVolume_GetType(p) (p)->lpVtbl->GetType(p)
/*** IWineD3DVolume methods ***/
#define IWineD3DVolume_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b)
#define IWineD3DVolume_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a)
#define IWineD3DVolume_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c)
......
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