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
|
@ -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) {
|
||||
|
@ -203,11 +203,11 @@ 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 */);
|
||||
|
@ -226,6 +226,7 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
|
|||
tmp = 0.9f;
|
||||
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
|
||||
}
|
||||
IWineD3DBaseTexture_SetDirty(iface, TRUE);
|
||||
}
|
||||
|
||||
/* Bind the texture */
|
||||
|
@ -234,30 +235,33 @@ 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;
|
||||
}
|
||||
|
||||
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)");
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
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 */);
|
||||
IWineD3DContextManager_PopState(This->contextManager, textureDimensions, ENABLED, NOW /* make sure the state is applied now */);
|
||||
#else
|
||||
glDisable(textureDimensions);
|
||||
#endif
|
||||
|
@ -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,13 +104,14 @@ 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);
|
||||
|
||||
IWineD3DTexture_BindTexture(iface);
|
||||
ENTER_GL();
|
||||
/* If were dirty then reload the surfaces */
|
||||
if(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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue