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){
......
......@@ -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;
......
......@@ -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
......
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