Make all newly created surfces dirty, so that they are loaded properly
the first time around. Replace some calls to cubetexture in basetexture to calls to basetexture. Check that the level isn't out of bounds in calls to texture.
This commit is contained in:
parent
7e3918d53e
commit
e8855c48d8
|
@ -31,23 +31,23 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
|||
******************************************* */
|
||||
HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, LPVOID *ppobj)
|
||||
{
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
||||
/* FIXME: This needs to extend an IWineD3DBaseObject */
|
||||
if (IsEqualGUID(riid, &IID_IUnknown)
|
||||
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
||||
/* FIXME: This needs to extend an IWineD3DBaseObject */
|
||||
if (IsEqualGUID(riid, &IID_IUnknown)
|
||||
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|
||||
|| IsEqualGUID(riid, &IID_IWineD3DBaseTexture)) {
|
||||
IUnknown_AddRef(iface);
|
||||
*ppobj = This;
|
||||
return D3D_OK;
|
||||
}
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
ULONG ref = InterlockedIncrement(&This->resource.ref);
|
||||
|
||||
|
||||
TRACE("(%p) : AddRef increasing from %ld\n", This,ref - 1);
|
||||
IUnknown_AddRef(This->resource.parent);
|
||||
return ref;
|
||||
|
@ -67,7 +67,7 @@ ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
|
|||
}
|
||||
|
||||
/* class static */
|
||||
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface){
|
||||
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
TRACE("(%p) : ", This);
|
||||
if (This->baseTexture.textureName != 0) {
|
||||
|
@ -126,35 +126,35 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUn
|
|||
* so just pretend that they work unless something really needs a failure. */
|
||||
DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
|
||||
|
||||
if (This->resource.pool != D3DPOOL_MANAGED) {
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(LODNew >= This->baseTexture.levels)
|
||||
LODNew = This->baseTexture.levels - 1;
|
||||
This->baseTexture.LOD = LODNew;
|
||||
|
||||
|
||||
TRACE("(%p) : set bogus LOD to %d \n", This, This->baseTexture.LOD);
|
||||
|
||||
|
||||
return This->baseTexture.LOD;
|
||||
}
|
||||
|
||||
DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
|
||||
|
||||
if (This->resource.pool != D3DPOOL_MANAGED) {
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
|
||||
TRACE("(%p) : returning %d \n", This, This->baseTexture.LOD);
|
||||
|
||||
|
||||
return This->baseTexture.LOD;
|
||||
}
|
||||
|
||||
DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
|
||||
TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
|
||||
return This->baseTexture.levels;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ D3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3
|
|||
|
||||
void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
/* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
|
||||
/* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
|
||||
FIXME("(%p) : stub\n", This);
|
||||
return ;
|
||||
}
|
||||
|
@ -203,15 +203,15 @@ BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) {
|
|||
|
||||
HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
HRESULT hr = D3D_OK;
|
||||
UINT textureDimensions;
|
||||
|
||||
TRACE("(%p) : About to bind texture\n", This);
|
||||
|
||||
textureDimensions = IWineD3DCubeTexture_GetTextureDimensions(iface);
|
||||
textureDimensions = IWineD3DBaseTexture_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
|
||||
#else
|
||||
glEnable(textureDimensions);
|
||||
#endif
|
||||
|
||||
|
@ -225,7 +225,8 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
|
|||
GLclampf tmp;
|
||||
tmp = 0.9f;
|
||||
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
|
||||
}
|
||||
}
|
||||
IWineD3DBaseTexture_SetDirty(iface, TRUE);
|
||||
}
|
||||
|
||||
/* Bind the texture */
|
||||
|
@ -234,34 +235,37 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
|
|||
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;
|
||||
hr = 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;
|
||||
if (hr == D3D_OK) {
|
||||
/* 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)");
|
||||
}
|
||||
LEAVE_GL();
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface) {
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
UINT textureDimensions;
|
||||
|
||||
TRACE("(%p) : About to bind texture\n", This);
|
||||
textureDimensions = IWineD3DCubeTexture_GetTextureDimensions(iface);
|
||||
textureDimensions = IWineD3DBaseTexture_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
|
||||
IWineD3DContextManager_PopState(This->contextManager, textureDimensions, ENABLED, NOW /* make sure the state is applied now */);
|
||||
#else
|
||||
glDisable(textureDimensions);
|
||||
#endif
|
||||
|
||||
|
||||
LEAVE_GL();
|
||||
return D3D_OK;
|
||||
}
|
||||
|
@ -287,7 +291,6 @@ static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
|
|||
IWineD3DBaseTextureImpl_GetPriority,
|
||||
IWineD3DBaseTextureImpl_PreLoad,
|
||||
IWineD3DBaseTextureImpl_GetType,
|
||||
|
||||
/*IWineD3DBaseTexture*/
|
||||
IWineD3DBaseTextureImpl_SetLOD,
|
||||
IWineD3DBaseTextureImpl_GetLOD,
|
||||
|
|
|
@ -83,6 +83,7 @@ inline static Display *get_display( HDC hdc )
|
|||
_basetexture.levels = Levels; \
|
||||
_basetexture.filterType = (Usage & D3DUSAGE_AUTOGENMIPMAP) ? D3DTEXF_LINEAR : D3DTEXF_NONE; \
|
||||
_basetexture.LOD = 0; \
|
||||
_basetexture.dirty = TRUE; \
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
|
@ -443,7 +444,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
|
|||
}
|
||||
|
||||
if(MultisampleQuality > 0){
|
||||
FIXME("MultisampleQuality set to %ld, bstituting 0 \n" , MultisampleQuality);
|
||||
FIXME("MultisampleQuality set to %ld, substituting 0 \n" , MultisampleQuality);
|
||||
MultisampleQuality=0;
|
||||
}
|
||||
|
||||
|
@ -546,7 +547,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
|
|||
}
|
||||
|
||||
|
||||
IWineD3DSurface_CleanDirtyRect(*ppSurface);
|
||||
IWineD3DSurface_AddDirtyRect(*ppSurface, NULL);
|
||||
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->resource.allocatedMemory, object->resource.size);
|
||||
|
|
|
@ -67,8 +67,8 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
|
|||
IUnknown_Release(surfaceParent);
|
||||
}
|
||||
}
|
||||
|
||||
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
|
||||
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
} else {
|
||||
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
|
||||
|
@ -104,20 +104,21 @@ DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) {
|
|||
}
|
||||
|
||||
void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
|
||||
/* Override the IWineD3DResource Preload method */
|
||||
|
||||
/* Override the IWineD3DResource PreLoad method */
|
||||
unsigned int i;
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
|
||||
|
||||
TRACE("(%p) : About to load texture\n", This);
|
||||
|
||||
IWineD3DTexture_BindTexture(iface);
|
||||
|
||||
ENTER_GL();
|
||||
/* If were dirty then reload the surfaces */
|
||||
if(This->baseTexture.dirty != FALSE) {
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
IWineD3DSurface_LoadTexture(This->surfaces[i], GL_TEXTURE_2D, i);
|
||||
}
|
||||
|
||||
|
||||
/* No longer dirty */
|
||||
This->baseTexture.dirty = FALSE;
|
||||
}
|
||||
|
@ -206,38 +207,49 @@ HRESULT WINAPI IWineD3DTextureImpl_GetLevelDesc(IWineD3DTexture *iface, UINT Lev
|
|||
|
||||
HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface, UINT Level, IWineD3DSurface** ppSurfaceLevel) {
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
*ppSurfaceLevel = (IWineD3DSurface *) This->surfaces[Level];
|
||||
IWineD3DSurface_AddRef((IWineD3DSurface *) This->surfaces[Level]);
|
||||
TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT Level, D3DLOCKED_RECT *pLockedRect,
|
||||
CONST RECT *pRect, DWORD Flags) {
|
||||
HRESULT hr;
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
HRESULT hr = D3DERR_INVALIDCALL;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
|
||||
hr = IWineD3DSurface_LockRect((IWineD3DSurface *) This->surfaces[Level], pLockedRect, pRect, Flags);
|
||||
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
|
||||
} else {
|
||||
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
return D3DERR_INVALIDCALL;
|
||||
*ppSurfaceLevel = This->surfaces[Level];
|
||||
IWineD3DSurface_AddRef((IWineD3DSurface*) This->surfaces[Level]);
|
||||
hr = D3D_OK;
|
||||
TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
|
||||
}
|
||||
if (D3D_OK != hr) {
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
*ppSurfaceLevel = NULL; /* Just to be on the safe side.. */
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UINT Level) {
|
||||
HRESULT hr;
|
||||
HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT Level, D3DLOCKED_RECT *pLockedRect,
|
||||
CONST RECT *pRect, DWORD Flags) {
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
HRESULT hr = D3DERR_INVALIDCALL;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
hr = IWineD3DSurface_UnlockRect((IWineD3DSurface *) This->surfaces[Level]);
|
||||
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
|
||||
hr = IWineD3DSurface_LockRect((IWineD3DSurface *) This->surfaces[Level], pLockedRect, pRect, Flags);
|
||||
}
|
||||
if (D3D_OK == hr) {
|
||||
TRACE("(%p) Level (%d) success\n", This, Level);
|
||||
} else {
|
||||
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
return D3DERR_INVALIDCALL;
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UINT Level) {
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
HRESULT hr = D3DERR_INVALIDCALL;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
hr = IWineD3DSurface_UnlockRect(This->surfaces[Level]);
|
||||
}
|
||||
if ( D3D_OK == hr) {
|
||||
TRACE("(%p) Level (%d) success\n", This, Level);
|
||||
} else {
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
@ -255,7 +267,7 @@ const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
|
|||
IWineD3DTextureImpl_QueryInterface,
|
||||
IWineD3DTextureImpl_AddRef,
|
||||
IWineD3DTextureImpl_Release,
|
||||
/* IWineD3DResource */
|
||||
/* IWineD3DResource */
|
||||
IWineD3DTextureImpl_GetParent,
|
||||
IWineD3DTextureImpl_GetDevice,
|
||||
IWineD3DTextureImpl_SetPrivateData,
|
||||
|
@ -265,7 +277,7 @@ const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
|
|||
IWineD3DTextureImpl_GetPriority,
|
||||
IWineD3DTextureImpl_PreLoad,
|
||||
IWineD3DTextureImpl_GetType,
|
||||
/* IWineD3DBaseTexture */
|
||||
/* IWineD3DBaseTexture */
|
||||
IWineD3DTextureImpl_SetLOD,
|
||||
IWineD3DTextureImpl_GetLOD,
|
||||
IWineD3DTextureImpl_GetLevelCount,
|
||||
|
@ -276,8 +288,8 @@ const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
|
|||
IWineD3DTextureImpl_GetDirty,
|
||||
IWineD3DTextureImpl_BindTexture,
|
||||
IWineD3DTextureImpl_UnBindTexture,
|
||||
IWineD3DTextureImpl_GetTextureDimensions,
|
||||
/* IWineD3DTexture */
|
||||
IWineD3DTextureImpl_GetTextureDimensions,
|
||||
/* IWineD3DTexture */
|
||||
IWineD3DTextureImpl_GetLevelDesc,
|
||||
IWineD3DTextureImpl_GetSurfaceLevel,
|
||||
IWineD3DTextureImpl_LockRect,
|
||||
|
|
Loading…
Reference in New Issue