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
|
@ -203,11 +203,11 @@ BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) {
|
||||||
|
|
||||||
HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
|
HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
|
||||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||||
|
HRESULT hr = D3D_OK;
|
||||||
UINT textureDimensions;
|
UINT textureDimensions;
|
||||||
|
|
||||||
TRACE("(%p) : About to bind texture\n", This);
|
TRACE("(%p) : About to bind texture\n", This);
|
||||||
|
|
||||||
textureDimensions = IWineD3DCubeTexture_GetTextureDimensions(iface);
|
textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
#if 0 /* TODO: context manager support */
|
#if 0 /* TODO: context manager support */
|
||||||
IWineD3DContextManager_PushState(This->contextManager, textureDimensions, ENABLED, NOW /* make sure the state is applied now */);
|
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;
|
tmp = 0.9f;
|
||||||
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
|
glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
|
||||||
}
|
}
|
||||||
|
IWineD3DBaseTexture_SetDirty(iface, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bind the texture */
|
/* Bind the texture */
|
||||||
|
@ -234,30 +235,33 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
|
||||||
checkGLcall("glBindTexture");
|
checkGLcall("glBindTexture");
|
||||||
} else { /* this only happened if we've run out of openGL textures */
|
} 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");
|
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
|
/* 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
|
a property of the active texture unit, and another texture may have set it
|
||||||
to a different value */
|
to a different value */
|
||||||
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
|
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
|
||||||
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
|
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
|
||||||
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
|
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
|
||||||
|
|
||||||
return D3D_OK;
|
|
||||||
}
|
}
|
||||||
|
LEAVE_GL();
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface) {
|
HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface) {
|
||||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||||
UINT textureDimensions;
|
UINT textureDimensions;
|
||||||
|
|
||||||
TRACE("(%p) : About to bind texture\n", This);
|
TRACE("(%p) : About to bind texture\n", This);
|
||||||
textureDimensions = IWineD3DCubeTexture_GetTextureDimensions(iface);
|
textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
|
||||||
|
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
|
|
||||||
glBindTexture(textureDimensions, 0);
|
glBindTexture(textureDimensions, 0);
|
||||||
#if 0 /* TODO: context manager support */
|
#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
|
#else
|
||||||
glDisable(textureDimensions);
|
glDisable(textureDimensions);
|
||||||
#endif
|
#endif
|
||||||
|
@ -287,7 +291,6 @@ static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
|
||||||
IWineD3DBaseTextureImpl_GetPriority,
|
IWineD3DBaseTextureImpl_GetPriority,
|
||||||
IWineD3DBaseTextureImpl_PreLoad,
|
IWineD3DBaseTextureImpl_PreLoad,
|
||||||
IWineD3DBaseTextureImpl_GetType,
|
IWineD3DBaseTextureImpl_GetType,
|
||||||
|
|
||||||
/*IWineD3DBaseTexture*/
|
/*IWineD3DBaseTexture*/
|
||||||
IWineD3DBaseTextureImpl_SetLOD,
|
IWineD3DBaseTextureImpl_SetLOD,
|
||||||
IWineD3DBaseTextureImpl_GetLOD,
|
IWineD3DBaseTextureImpl_GetLOD,
|
||||||
|
|
|
@ -83,6 +83,7 @@ inline static Display *get_display( HDC hdc )
|
||||||
_basetexture.levels = Levels; \
|
_basetexture.levels = Levels; \
|
||||||
_basetexture.filterType = (Usage & D3DUSAGE_AUTOGENMIPMAP) ? D3DTEXF_LINEAR : D3DTEXF_NONE; \
|
_basetexture.filterType = (Usage & D3DUSAGE_AUTOGENMIPMAP) ? D3DTEXF_LINEAR : D3DTEXF_NONE; \
|
||||||
_basetexture.LOD = 0; \
|
_basetexture.LOD = 0; \
|
||||||
|
_basetexture.dirty = TRUE; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************
|
/**********************************************************
|
||||||
|
@ -443,7 +444,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MultisampleQuality > 0){
|
if(MultisampleQuality > 0){
|
||||||
FIXME("MultisampleQuality set to %ld, bstituting 0 \n" , MultisampleQuality);
|
FIXME("MultisampleQuality set to %ld, substituting 0 \n" , MultisampleQuality);
|
||||||
MultisampleQuality=0;
|
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",
|
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),
|
This, Width, Height, Format, debug_d3dformat(Format),
|
||||||
(WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->resource.allocatedMemory, object->resource.size);
|
(WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->resource.allocatedMemory, object->resource.size);
|
||||||
|
|
|
@ -67,8 +67,8 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
|
||||||
IUnknown_Release(surfaceParent);
|
IUnknown_Release(surfaceParent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
|
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
|
||||||
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
|
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
} else {
|
} else {
|
||||||
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
|
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) {
|
void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
|
||||||
/* Override the IWineD3DResource Preload method */
|
|
||||||
|
/* Override the IWineD3DResource PreLoad method */
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||||
|
|
||||||
TRACE("(%p) : About to load texture\n", This);
|
TRACE("(%p) : About to load texture\n", This);
|
||||||
IWineD3DTexture_BindTexture(iface);
|
|
||||||
|
|
||||||
|
IWineD3DTexture_BindTexture(iface);
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
/* If were dirty then reload the surfaces */
|
/* If were dirty then reload the surfaces */
|
||||||
if(This->baseTexture.dirty != FALSE) {
|
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) {
|
HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface, UINT Level, IWineD3DSurface** ppSurfaceLevel) {
|
||||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||||
*ppSurfaceLevel = (IWineD3DSurface *) This->surfaces[Level];
|
HRESULT hr = D3DERR_INVALIDCALL;
|
||||||
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;
|
|
||||||
|
|
||||||
if (Level < This->baseTexture.levels) {
|
if (Level < This->baseTexture.levels) {
|
||||||
|
*ppSurfaceLevel = This->surfaces[Level];
|
||||||
hr = IWineD3DSurface_LockRect((IWineD3DSurface *) This->surfaces[Level], pLockedRect, pRect, Flags);
|
IWineD3DSurface_AddRef((IWineD3DSurface*) This->surfaces[Level]);
|
||||||
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
|
hr = D3D_OK;
|
||||||
} else {
|
TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
|
||||||
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
}
|
||||||
return D3DERR_INVALIDCALL;
|
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;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UINT Level) {
|
HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT Level, D3DLOCKED_RECT *pLockedRect,
|
||||||
HRESULT hr;
|
CONST RECT *pRect, DWORD Flags) {
|
||||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||||
|
HRESULT hr = D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
if (Level < This->baseTexture.levels) {
|
if (Level < This->baseTexture.levels) {
|
||||||
hr = IWineD3DSurface_UnlockRect((IWineD3DSurface *) This->surfaces[Level]);
|
hr = IWineD3DSurface_LockRect((IWineD3DSurface *) This->surfaces[Level], pLockedRect, pRect, Flags);
|
||||||
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
|
}
|
||||||
|
if (D3D_OK == hr) {
|
||||||
|
TRACE("(%p) Level (%d) success\n", This, Level);
|
||||||
} else {
|
} else {
|
||||||
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||||
return D3DERR_INVALIDCALL;
|
}
|
||||||
|
|
||||||
|
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;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue