wined3d: Store texture sub-resources in IWineD3DBaseTextureClass.
This commit is contained in:
parent
11c7a67ac3
commit
958b523707
|
@ -27,9 +27,10 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
|
||||
|
||||
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
|
||||
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format_desc *format_desc,
|
||||
WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
|
||||
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT layer_count, UINT level_count,
|
||||
WINED3DRESOURCETYPE resource_type, IWineD3DDeviceImpl *device, UINT size, DWORD usage,
|
||||
const struct wined3d_format_desc *format_desc, WINED3DPOOL pool, IUnknown *parent,
|
||||
const struct wined3d_parent_ops *parent_ops)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -41,7 +42,17 @@ HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DR
|
|||
return hr;
|
||||
}
|
||||
|
||||
texture->baseTexture.levels = levels;
|
||||
texture->baseTexture.sub_resources = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
level_count * layer_count * sizeof(*texture->baseTexture.sub_resources));
|
||||
if (!texture->baseTexture.sub_resources)
|
||||
{
|
||||
ERR("Failed to allocate sub-resource array.\n");
|
||||
resource_cleanup((IWineD3DResource *)texture);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
texture->baseTexture.layer_count = layer_count;
|
||||
texture->baseTexture.level_count = level_count;
|
||||
texture->baseTexture.filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
|
||||
texture->baseTexture.LOD = 0;
|
||||
texture->baseTexture.texture_rgb.dirty = TRUE;
|
||||
|
@ -66,6 +77,7 @@ HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DR
|
|||
void basetexture_cleanup(IWineD3DBaseTexture *iface)
|
||||
{
|
||||
basetexture_unload(iface);
|
||||
HeapFree(GetProcessHeap(), 0, ((IWineD3DBaseTextureImpl *)iface)->baseTexture.sub_resources);
|
||||
resource_cleanup((IWineD3DResource *)iface);
|
||||
}
|
||||
|
||||
|
@ -115,8 +127,8 @@ DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(LODNew >= This->baseTexture.levels)
|
||||
LODNew = This->baseTexture.levels - 1;
|
||||
if (LODNew >= This->baseTexture.level_count)
|
||||
LODNew = This->baseTexture.level_count - 1;
|
||||
|
||||
if(This->baseTexture.LOD != LODNew) {
|
||||
This->baseTexture.LOD = LODNew;
|
||||
|
@ -145,8 +157,8 @@ DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
|
|||
DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface)
|
||||
{
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
|
||||
return This->baseTexture.levels;
|
||||
TRACE("iface %p, returning %u.\n", iface, This->baseTexture.level_count);
|
||||
return This->baseTexture.level_count;
|
||||
}
|
||||
|
||||
HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType)
|
||||
|
@ -301,10 +313,11 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
|
|||
* relying on the partial GL_ARB_texture_non_power_of_two emulation with texture rectangles
|
||||
* (ie, do not care for cond_np2 here, just look for GL_TEXTURE_RECTANGLE_ARB)
|
||||
*/
|
||||
if(textureDimensions != GL_TEXTURE_RECTANGLE_ARB) {
|
||||
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)");
|
||||
if (textureDimensions != GL_TEXTURE_RECTANGLE_ARB)
|
||||
{
|
||||
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %u.\n", This->baseTexture.level_count - 1);
|
||||
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.level_count - 1);
|
||||
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.level_count)");
|
||||
}
|
||||
if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
|
||||
/* Cubemaps are always set to clamp, regardless of the sampler state. */
|
||||
|
@ -444,17 +457,18 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
|||
glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, glValue);
|
||||
checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
|
||||
|
||||
if(!cond_np2) {
|
||||
if(gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
|
||||
if (!cond_np2)
|
||||
{
|
||||
if (gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE)
|
||||
glValue = This->baseTexture.LOD;
|
||||
} else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
|
||||
glValue = This->baseTexture.levels - 1;
|
||||
} else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD) {
|
||||
else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.level_count)
|
||||
glValue = This->baseTexture.level_count - 1;
|
||||
else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD)
|
||||
/* baseTexture.LOD is already clamped in the setter */
|
||||
glValue = This->baseTexture.LOD;
|
||||
} else {
|
||||
else
|
||||
glValue = gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL];
|
||||
}
|
||||
|
||||
/* Note that D3DSAMP_MAXMIPLEVEL specifies the biggest mipmap(default 0), while
|
||||
* GL_TEXTURE_MAX_LEVEL specifies the smallest mimap used(default 1000).
|
||||
* So D3DSAMP_MAXMIPLEVEL is the same as GL_TEXTURE_BASE_LEVEL.
|
||||
|
|
|
@ -31,11 +31,12 @@ static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3
|
|||
{
|
||||
/* Override the IWineD3DResource Preload method. */
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
|
||||
IWineD3DDeviceImpl *device = This->resource.device;
|
||||
struct wined3d_context *context = NULL;
|
||||
unsigned int i, j;
|
||||
BOOL srgb_mode;
|
||||
BOOL *dirty;
|
||||
UINT i;
|
||||
|
||||
switch (srgb)
|
||||
{
|
||||
|
@ -72,19 +73,18 @@ static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3
|
|||
if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
|
||||
|| This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
|
||||
{
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j)
|
||||
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
|
||||
|
||||
if (palette9_changed(surface))
|
||||
{
|
||||
if (palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[j][i]))
|
||||
{
|
||||
TRACE("Reloading surface because the d3d8/9 palette was changed.\n");
|
||||
/* TODO: This is not necessarily needed with hw palettized texture support. */
|
||||
IWineD3DSurface_LoadLocation(This->surfaces[j][i], SFLAG_INSYSMEM, NULL);
|
||||
/* Make sure the texture is reloaded because of the palette change,
|
||||
* this kills performance though :( */
|
||||
IWineD3DSurface_ModifyLocation(This->surfaces[j][i], SFLAG_INTEXTURE, FALSE);
|
||||
}
|
||||
TRACE("Reloading surface %p because the d3d8/9 palette was changed.\n", surface);
|
||||
/* TODO: This is not necessarily needed with hw palettized texture support. */
|
||||
IWineD3DSurface_LoadLocation((IWineD3DSurface *)surface, SFLAG_INSYSMEM, NULL);
|
||||
/* Make sure the texture is reloaded because of the palette change,
|
||||
* this kills performance though :( */
|
||||
IWineD3DSurface_ModifyLocation((IWineD3DSurface *)surface, SFLAG_INTEXTURE, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,12 +93,9 @@ static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3
|
|||
* since the last load then reload the surfaces. */
|
||||
if (*dirty)
|
||||
{
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j)
|
||||
{
|
||||
IWineD3DSurface_LoadTexture(This->surfaces[j][i], srgb_mode);
|
||||
}
|
||||
IWineD3DSurface_LoadTexture((IWineD3DSurface *)This->baseTexture.sub_resources[i], srgb_mode);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -114,26 +111,24 @@ static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3
|
|||
|
||||
static void cubetexture_cleanup(IWineD3DCubeTextureImpl *This)
|
||||
{
|
||||
unsigned int i, j;
|
||||
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
|
||||
UINT i;
|
||||
|
||||
TRACE("(%p) : Cleaning up.\n", This);
|
||||
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
for (j = 0; j < 6; ++j)
|
||||
{
|
||||
IWineD3DSurface *surface = This->surfaces[j][i];
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[i];
|
||||
|
||||
if (surface)
|
||||
{
|
||||
/* Clean out the texture name we gave to the surface so that the
|
||||
* surface doesn't try and release it. */
|
||||
surface_set_texture_name(surface, 0, TRUE);
|
||||
surface_set_texture_name(surface, 0, FALSE);
|
||||
surface_set_texture_target(surface, 0);
|
||||
IWineD3DSurface_SetContainer(surface, NULL);
|
||||
IWineD3DSurface_Release(surface);
|
||||
}
|
||||
if (surface)
|
||||
{
|
||||
/* Clean out the texture name we gave to the surface so that the
|
||||
* surface doesn't try and release it. */
|
||||
surface_set_texture_name(surface, 0, TRUE);
|
||||
surface_set_texture_name(surface, 0, FALSE);
|
||||
surface_set_texture_target(surface, 0);
|
||||
IWineD3DSurface_SetContainer(surface, NULL);
|
||||
IWineD3DSurface_Release(surface);
|
||||
}
|
||||
}
|
||||
basetexture_cleanup((IWineD3DBaseTexture *)This);
|
||||
|
@ -207,21 +202,25 @@ static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
|
|||
cubetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
|
||||
}
|
||||
|
||||
static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface) {
|
||||
unsigned int i, j;
|
||||
static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface)
|
||||
{
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
TRACE("(%p)\n", This);
|
||||
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
|
||||
UINT i;
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
/* Unload all the surfaces and reset the texture name. If UnLoad was called on the
|
||||
* surface before, this one will be a NOP and vice versa. Unloading an unloaded
|
||||
* surface is fine
|
||||
*/
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
|
||||
IWineD3DSurface_UnLoad(This->surfaces[j][i]);
|
||||
surface_set_texture_name(This->surfaces[j][i], 0, TRUE);
|
||||
surface_set_texture_name(This->surfaces[j][i], 0, FALSE);
|
||||
}
|
||||
* surface is fine. */
|
||||
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[i];
|
||||
|
||||
IWineD3DSurface_UnLoad(surface);
|
||||
surface_set_texture_name(surface, 0, TRUE);
|
||||
surface_set_texture_name(surface, 0, FALSE);
|
||||
}
|
||||
|
||||
basetexture_unload((IWineD3DBaseTexture *)iface);
|
||||
|
@ -281,16 +280,19 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *i
|
|||
TRACE("(%p) : relay to BaseTexture\n", This);
|
||||
|
||||
hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
|
||||
if (set_gl_texture_desc && SUCCEEDED(hr)) {
|
||||
UINT i, j;
|
||||
for (i = 0; i < This->baseTexture.levels; ++i) {
|
||||
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j) {
|
||||
if(This->baseTexture.is_srgb) {
|
||||
surface_set_texture_name(This->surfaces[j][i], This->baseTexture.texture_srgb.name, TRUE);
|
||||
} else {
|
||||
surface_set_texture_name(This->surfaces[j][i], This->baseTexture.texture_rgb.name, FALSE);
|
||||
}
|
||||
}
|
||||
if (set_gl_texture_desc && SUCCEEDED(hr))
|
||||
{
|
||||
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[i];
|
||||
|
||||
if (This->baseTexture.is_srgb)
|
||||
surface_set_texture_name(surface, This->baseTexture.texture_srgb.name, TRUE);
|
||||
else
|
||||
surface_set_texture_name(surface, This->baseTexture.texture_rgb.name, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,82 +316,120 @@ static BOOL WINAPI IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture *iface)
|
|||
/* *******************************************
|
||||
IWineD3DCubeTexture IWineD3DCubeTexture parts follow
|
||||
******************************************* */
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface,
|
||||
UINT level, WINED3DSURFACE_DESC *desc)
|
||||
{
|
||||
IWineD3DCubeTextureImpl *texture = (IWineD3DCubeTextureImpl *)iface;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
TRACE("(%p) level (%d)\n", This, Level);
|
||||
return IWineD3DSurface_GetDesc(This->surfaces[0][Level], pDesc);
|
||||
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
|
||||
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
return IWineD3DSurface_GetDesc((IWineD3DSurface *)texture->baseTexture.sub_resources[level], desc);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetCubeMapSurface(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level, IWineD3DSurface** ppCubeMapSurface) {
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetCubeMapSurface(IWineD3DCubeTexture *iface,
|
||||
WINED3DCUBEMAP_FACES face, UINT level, IWineD3DSurface **surface)
|
||||
{
|
||||
IWineD3DCubeTextureImpl *texture = (IWineD3DCubeTextureImpl *)iface;
|
||||
UINT idx = face * texture->baseTexture.level_count + level;
|
||||
|
||||
if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
|
||||
*ppCubeMapSurface = This->surfaces[FaceType][Level];
|
||||
IWineD3DSurface_AddRef(*ppCubeMapSurface);
|
||||
TRACE("iface %p, face %u, level %u, surface %p.\n",
|
||||
iface, face, level, surface);
|
||||
|
||||
hr = WINED3D_OK;
|
||||
}
|
||||
if (WINED3D_OK == hr) {
|
||||
TRACE("(%p) -> faceType(%d) level(%d) returning surface@%p\n", This, FaceType, Level, This->surfaces[FaceType][Level]);
|
||||
} else {
|
||||
WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
return hr;
|
||||
if (face >= texture->baseTexture.layer_count)
|
||||
{
|
||||
WARN("face %u >= layer_count %u.\n", face, texture->baseTexture.layer_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
*surface = (IWineD3DSurface *)texture->baseTexture.sub_resources[idx];
|
||||
IWineD3DSurface_AddRef(*surface);
|
||||
|
||||
TRACE("Returning surface %p.\n", *surface);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_LockRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_LockRect(IWineD3DCubeTexture *iface,
|
||||
WINED3DCUBEMAP_FACES face, UINT level, WINED3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
|
||||
{
|
||||
IWineD3DCubeTextureImpl *texture = (IWineD3DCubeTextureImpl *)iface;
|
||||
UINT idx = face * texture->baseTexture.level_count + level;
|
||||
|
||||
if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
|
||||
hr = IWineD3DSurface_LockRect(This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
|
||||
TRACE("iface %p, face %u, level %u, locked_rect %p, rect %s, flags %#x.\n",
|
||||
iface, face, level, locked_rect, wine_dbgstr_rect(rect), flags);
|
||||
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
if (WINED3D_OK == hr) {
|
||||
TRACE("(%p) -> faceType(%d) level(%d) returning memory@%p success(%u)\n", This, FaceType, Level, pLockedRect->pBits, hr);
|
||||
} else {
|
||||
WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
|
||||
if (face >= texture->baseTexture.layer_count)
|
||||
{
|
||||
WARN("face %u >= layer_count %u.\n", face, texture->baseTexture.layer_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
return hr;
|
||||
return IWineD3DSurface_LockRect((IWineD3DSurface *)texture->baseTexture.sub_resources[idx],
|
||||
locked_rect, rect, flags);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, UINT Level) {
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *iface,
|
||||
WINED3DCUBEMAP_FACES face, UINT level)
|
||||
{
|
||||
IWineD3DCubeTextureImpl *texture = (IWineD3DCubeTextureImpl *)iface;
|
||||
UINT idx = face * texture->baseTexture.level_count + level;
|
||||
|
||||
if (Level < This->baseTexture.levels && FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
|
||||
hr = IWineD3DSurface_UnlockRect(This->surfaces[FaceType][Level]);
|
||||
TRACE("iface %p, face %u, level %u.\n",
|
||||
iface, face, level);
|
||||
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
if (WINED3D_OK == hr) {
|
||||
TRACE("(%p) -> faceType(%d) level(%d) success(%u)\n", This, FaceType, Level, hr);
|
||||
} else {
|
||||
WARN("(%p) level(%d) overflow Levels(%d) Or FaceType(%d)\n", This, Level, This->baseTexture.levels, FaceType);
|
||||
if (face >= texture->baseTexture.layer_count)
|
||||
{
|
||||
WARN("face %u >= layer_count %u.\n", face, texture->baseTexture.layer_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
return hr;
|
||||
|
||||
return IWineD3DSurface_UnlockRect((IWineD3DSurface *)texture->baseTexture.sub_resources[idx]);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
This->baseTexture.texture_rgb.dirty = TRUE;
|
||||
This->baseTexture.texture_srgb.dirty = TRUE;
|
||||
TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
|
||||
if (FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
|
||||
surface_add_dirty_rect(This->surfaces[FaceType][0], pDirtyRect);
|
||||
hr = WINED3D_OK;
|
||||
} else {
|
||||
WARN("(%p) overflow FaceType(%d)\n", This, FaceType);
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface,
|
||||
WINED3DCUBEMAP_FACES face, const RECT *dirty_rect)
|
||||
{
|
||||
IWineD3DCubeTextureImpl *texture = (IWineD3DCubeTextureImpl *)iface;
|
||||
UINT idx = face * texture->baseTexture.level_count;
|
||||
|
||||
TRACE("iface %p, face %u, dirty_rect %s.\n",
|
||||
iface, face, wine_dbgstr_rect(dirty_rect));
|
||||
|
||||
if (face >= texture->baseTexture.layer_count)
|
||||
{
|
||||
WARN("face %u >= layer_count %u.\n", face, texture->baseTexture.layer_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
return hr;
|
||||
|
||||
texture->baseTexture.texture_rgb.dirty = TRUE;
|
||||
texture->baseTexture.texture_srgb.dirty = TRUE;
|
||||
surface_add_dirty_rect((IWineD3DSurface *)texture->baseTexture.sub_resources[idx], dirty_rect);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
static const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
|
||||
|
@ -478,8 +518,8 @@ HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UIN
|
|||
|
||||
texture->lpVtbl = &IWineD3DCubeTexture_Vtbl;
|
||||
|
||||
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_CUBETEXTURE,
|
||||
device, 0, usage, format_desc, pool, parent, parent_ops);
|
||||
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, 6, levels,
|
||||
WINED3DRTYPE_CUBETEXTURE, device, 0, usage, format_desc, pool, parent, parent_ops);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize basetexture, returning %#x\n", hr);
|
||||
|
@ -510,7 +550,7 @@ HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UIN
|
|||
|
||||
/* Generate all the surfaces. */
|
||||
tmp_w = edge_length;
|
||||
for (i = 0; i < texture->baseTexture.levels; ++i)
|
||||
for (i = 0; i < texture->baseTexture.level_count; ++i)
|
||||
{
|
||||
/* Create the 6 faces. */
|
||||
for (j = 0; j < 6; ++j)
|
||||
|
@ -524,20 +564,22 @@ HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UIN
|
|||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
|
||||
};
|
||||
UINT idx = j * texture->baseTexture.level_count + i;
|
||||
IWineD3DSurface *surface;
|
||||
|
||||
hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
|
||||
format, usage, pool, i /* Level */, j, &texture->surfaces[j][i]);
|
||||
format, usage, pool, i /* Level */, j, &surface);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
|
||||
texture->surfaces[j][i] = NULL;
|
||||
cubetexture_cleanup(texture);
|
||||
return hr;
|
||||
}
|
||||
|
||||
IWineD3DSurface_SetContainer(texture->surfaces[j][i], (IWineD3DBase *)texture);
|
||||
TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[j][i]);
|
||||
surface_set_texture_target(texture->surfaces[j][i], cube_targets[j]);
|
||||
IWineD3DSurface_SetContainer(surface, (IWineD3DBase *)texture);
|
||||
surface_set_texture_target(surface, cube_targets[j]);
|
||||
texture->baseTexture.sub_resources[idx] = (IWineD3DResourceImpl *)surface;
|
||||
TRACE("Created surface level %u @ %p.\n", i, surface);
|
||||
}
|
||||
tmp_w = max(1, tmp_w >> 1);
|
||||
}
|
||||
|
|
|
@ -479,9 +479,8 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
|
|||
|
||||
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
|
||||
{
|
||||
IWineD3DSurfaceImpl *surf;
|
||||
|
||||
surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)stateblock->textures[0])->surfaces[0];
|
||||
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)stateblock->textures[0];
|
||||
IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[0];
|
||||
|
||||
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT)
|
||||
{
|
||||
|
@ -3097,9 +3096,8 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d
|
|||
|
||||
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
|
||||
{
|
||||
IWineD3DSurfaceImpl *surf;
|
||||
|
||||
surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0];
|
||||
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)stateblock->textures[0];
|
||||
IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[0];
|
||||
|
||||
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format_desc->alpha_mask)
|
||||
{
|
||||
|
|
|
@ -69,15 +69,16 @@ static void texture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRG
|
|||
if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
|
||||
|| This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
|
||||
{
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
if (palette9_changed((IWineD3DSurfaceImpl *)This->surfaces[i]))
|
||||
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
|
||||
if (palette9_changed(surface))
|
||||
{
|
||||
TRACE("Reloading surface because the d3d8/9 palette was changed.\n");
|
||||
/* TODO: This is not necessarily needed with hw palettized texture support. */
|
||||
IWineD3DSurface_LoadLocation(This->surfaces[i], SFLAG_INSYSMEM, NULL);
|
||||
IWineD3DSurface_LoadLocation((IWineD3DSurface *)surface, SFLAG_INSYSMEM, NULL);
|
||||
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
|
||||
IWineD3DSurface_ModifyLocation(This->surfaces[i], SFLAG_INTEXTURE, FALSE);
|
||||
IWineD3DSurface_ModifyLocation((IWineD3DSurface *)surface, SFLAG_INTEXTURE, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,9 +87,9 @@ static void texture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRG
|
|||
* since the last load then reload the surfaces. */
|
||||
if (*dirty)
|
||||
{
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DSurface_LoadTexture(This->surfaces[i], srgb_mode);
|
||||
IWineD3DSurface_LoadTexture((IWineD3DSurface *)This->baseTexture.sub_resources[i], srgb_mode);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -108,17 +109,18 @@ static void texture_cleanup(IWineD3DTextureImpl *This)
|
|||
|
||||
TRACE("(%p) : Cleaning up\n", This);
|
||||
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
if (This->surfaces[i])
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[i];
|
||||
if (surface)
|
||||
{
|
||||
/* Clean out the texture name we gave to the surface so that the
|
||||
* surface doesn't try and release it */
|
||||
surface_set_texture_name(This->surfaces[i], 0, TRUE);
|
||||
surface_set_texture_name(This->surfaces[i], 0, FALSE);
|
||||
surface_set_texture_target(This->surfaces[i], 0);
|
||||
IWineD3DSurface_SetContainer(This->surfaces[i], 0);
|
||||
IWineD3DSurface_Release(This->surfaces[i]);
|
||||
surface_set_texture_name(surface, 0, TRUE);
|
||||
surface_set_texture_name(surface, 0, FALSE);
|
||||
surface_set_texture_target(surface, 0);
|
||||
IWineD3DSurface_SetContainer(surface, NULL);
|
||||
IWineD3DSurface_Release(surface);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,10 +206,12 @@ static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
|
|||
* surface before, this one will be a NOP and vice versa. Unloading an unloaded
|
||||
* surface is fine
|
||||
*/
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
IWineD3DSurface_UnLoad(This->surfaces[i]);
|
||||
surface_set_texture_name(This->surfaces[i], 0, FALSE); /* Delete rgb name */
|
||||
surface_set_texture_name(This->surfaces[i], 0, TRUE); /* delete srgb name */
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[i];
|
||||
IWineD3DSurface_UnLoad(surface);
|
||||
surface_set_texture_name(surface, 0, FALSE); /* Delete rgb name */
|
||||
surface_set_texture_name(surface, 0, TRUE); /* delete srgb name */
|
||||
}
|
||||
|
||||
basetexture_unload((IWineD3DBaseTexture *)iface);
|
||||
|
@ -276,14 +280,20 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface, BO
|
|||
gl_tex = &This->baseTexture.texture_rgb;
|
||||
}
|
||||
|
||||
for (i = 0; i < This->baseTexture.levels; ++i) {
|
||||
surface_set_texture_name(This->surfaces[i], gl_tex->name, This->baseTexture.is_srgb);
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[i];
|
||||
surface_set_texture_name(surface, gl_tex->name, This->baseTexture.is_srgb);
|
||||
}
|
||||
/* Conditinal non power of two textures use a different clamping default. If we're using the GL_WINE_normalized_texrect
|
||||
* partial driver emulation, we're dealing with a GL_TEXTURE_2D texture which has the address mode set to repeat - something
|
||||
* that prevents us from hitting the accelerated codepath. Thus manually set the GL state. The same applies to filtering.
|
||||
* Even if the texture has only one mip level, the default LINEAR_MIPMAP_LINEAR filter causes a SW fallback on macos.
|
||||
*/
|
||||
|
||||
/* Conditinal non power of two textures use a different clamping
|
||||
* default. If we're using the GL_WINE_normalized_texrect partial
|
||||
* driver emulation, we're dealing with a GL_TEXTURE_2D texture which
|
||||
* has the address mode set to repeat - something that prevents us
|
||||
* from hitting the accelerated codepath. Thus manually set the GL
|
||||
* state. The same applies to filtering. Even if the texture has only
|
||||
* one mip level, the default LINEAR_MIPMAP_LINEAR filter causes a SW
|
||||
* fallback on macos. */
|
||||
if(IWineD3DBaseTexture_IsCondNP2(iface)) {
|
||||
ENTER_GL();
|
||||
glTexParameteri(IWineD3DTexture_GetTextureDimensions(iface), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
@ -326,11 +336,12 @@ static BOOL WINAPI IWineD3DTextureImpl_IsCondNP2(IWineD3DTexture *iface) {
|
|||
static HRESULT WINAPI IWineD3DTextureImpl_GetLevelDesc(IWineD3DTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
if (Level < This->baseTexture.level_count)
|
||||
{
|
||||
TRACE("(%p) Level (%d)\n", This, Level);
|
||||
return IWineD3DSurface_GetDesc(This->surfaces[Level], pDesc);
|
||||
return IWineD3DSurface_GetDesc((IWineD3DSurface *)This->baseTexture.sub_resources[Level], pDesc);
|
||||
}
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
WARN("(%p) level %u >= level_count %u.\n", This, Level, This->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
|
@ -338,14 +349,15 @@ static HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface
|
|||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
*ppSurfaceLevel = This->surfaces[Level];
|
||||
IWineD3DSurface_AddRef(This->surfaces[Level]);
|
||||
if (Level < This->baseTexture.level_count)
|
||||
{
|
||||
*ppSurfaceLevel = (IWineD3DSurface *)This->baseTexture.sub_resources[Level];
|
||||
IWineD3DSurface_AddRef(*ppSurfaceLevel);
|
||||
hr = WINED3D_OK;
|
||||
TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
|
||||
}
|
||||
if (WINED3D_OK != hr) {
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
WARN("(%p) level %u >= level_count %u.\n", This, Level, This->baseTexture.level_count);
|
||||
*ppSurfaceLevel = NULL; /* Just to be on the safe side.. */
|
||||
}
|
||||
return hr;
|
||||
|
@ -356,13 +368,15 @@ static HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT
|
|||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
hr = IWineD3DSurface_LockRect(This->surfaces[Level], pLockedRect, pRect, Flags);
|
||||
if (Level < This->baseTexture.level_count)
|
||||
{
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[Level];
|
||||
hr = IWineD3DSurface_LockRect(surface, pLockedRect, pRect, Flags);
|
||||
}
|
||||
if (WINED3D_OK == hr) {
|
||||
TRACE("(%p) Level (%d) success\n", This, Level);
|
||||
} else {
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
WARN("(%p) level %u >= level_count %u.\n", This, Level, This->baseTexture.level_count);
|
||||
}
|
||||
|
||||
return hr;
|
||||
|
@ -372,13 +386,15 @@ static HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UIN
|
|||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
hr = IWineD3DSurface_UnlockRect(This->surfaces[Level]);
|
||||
if (Level < This->baseTexture.level_count)
|
||||
{
|
||||
IWineD3DSurface *surface = (IWineD3DSurface *)This->baseTexture.sub_resources[Level];
|
||||
hr = IWineD3DSurface_UnlockRect(surface);
|
||||
}
|
||||
if ( WINED3D_OK == hr) {
|
||||
TRACE("(%p) Level (%d) success\n", This, Level);
|
||||
} else {
|
||||
WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
WARN("(%p) level %u >= level_count %u.\n", This, Level, This->baseTexture.level_count);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
@ -388,7 +404,7 @@ static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, C
|
|||
This->baseTexture.texture_rgb.dirty = TRUE;
|
||||
This->baseTexture.texture_srgb.dirty = TRUE;
|
||||
TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
|
||||
surface_add_dirty_rect(This->surfaces[0], pDirtyRect);
|
||||
surface_add_dirty_rect((IWineD3DSurface *)This->baseTexture.sub_resources[0], pDirtyRect);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
@ -497,8 +513,8 @@ HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT
|
|||
|
||||
texture->lpVtbl = &IWineD3DTexture_Vtbl;
|
||||
|
||||
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_TEXTURE,
|
||||
device, 0, usage, format_desc, pool, parent, parent_ops);
|
||||
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, 1, levels,
|
||||
WINED3DRTYPE_TEXTURE, device, 0, usage, format_desc, pool, parent, parent_ops);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize basetexture, returning %#x.\n", hr);
|
||||
|
@ -565,22 +581,24 @@ HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT
|
|||
/* Generate all the surfaces. */
|
||||
tmp_w = width;
|
||||
tmp_h = height;
|
||||
for (i = 0; i < texture->baseTexture.levels; ++i)
|
||||
for (i = 0; i < texture->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DSurface *surface;
|
||||
|
||||
/* Use the callback to create the texture surface. */
|
||||
hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h, format_desc->format,
|
||||
usage, pool, i, WINED3DCUBEMAP_FACE_POSITIVE_X, &texture->surfaces[i]);
|
||||
usage, pool, i, 0, &surface);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
|
||||
texture->surfaces[i] = NULL;
|
||||
texture_cleanup(texture);
|
||||
return hr;
|
||||
}
|
||||
|
||||
IWineD3DSurface_SetContainer(texture->surfaces[i], (IWineD3DBase *)texture);
|
||||
TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[i]);
|
||||
surface_set_texture_target(texture->surfaces[i], texture->target);
|
||||
IWineD3DSurface_SetContainer(surface, (IWineD3DBase *)texture);
|
||||
surface_set_texture_target(surface, texture->target);
|
||||
texture->baseTexture.sub_resources[i] = (IWineD3DResourceImpl *)surface;
|
||||
TRACE("Created surface level %u @ %p.\n", i, surface);
|
||||
/* Calculate the next mipmap level. */
|
||||
tmp_w = max(1, tmp_w >> 1);
|
||||
tmp_h = max(1, tmp_h >> 1);
|
||||
|
|
|
@ -2771,8 +2771,8 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
|
|||
|
||||
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
|
||||
{
|
||||
IWineD3DSurfaceImpl *surf;
|
||||
surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0];
|
||||
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)stateblock->textures[0];
|
||||
IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[0];
|
||||
|
||||
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format_desc->alpha_mask)
|
||||
{
|
||||
|
|
|
@ -51,17 +51,19 @@ static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINE
|
|||
* since the last load then reload the volumes. */
|
||||
if (This->baseTexture.texture_rgb.dirty)
|
||||
{
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
|
||||
IWineD3DVolume *volume = (IWineD3DVolume *)This->baseTexture.sub_resources[i];
|
||||
IWineD3DVolume_LoadTexture(volume, i, srgb_mode);
|
||||
}
|
||||
}
|
||||
else if (srgb_was_toggled)
|
||||
{
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
volume_add_dirty_box(This->volumes[i], NULL);
|
||||
IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
|
||||
IWineD3DVolume *volume = (IWineD3DVolume *)This->baseTexture.sub_resources[i];
|
||||
volume_add_dirty_box(volume, NULL);
|
||||
IWineD3DVolume_LoadTexture(volume, i, srgb_mode);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -81,9 +83,9 @@ static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This)
|
|||
|
||||
TRACE("(%p) : Cleaning up.\n", This);
|
||||
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DVolume *volume = This->volumes[i];
|
||||
IWineD3DVolume *volume = (IWineD3DVolume *)This->baseTexture.sub_resources[i];
|
||||
|
||||
if (volume)
|
||||
{
|
||||
|
@ -172,8 +174,9 @@ static void WINAPI IWineD3DVolumeTextureImpl_UnLoad(IWineD3DVolumeTexture *iface
|
|||
* surface before, this one will be a NOP and vice versa. Unloading an unloaded
|
||||
* surface is fine
|
||||
*/
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
IWineD3DVolume_UnLoad(This->volumes[i]);
|
||||
for (i = 0; i < This->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DVolume_UnLoad((IWineD3DVolume *)This->baseTexture.sub_resources[i]);
|
||||
}
|
||||
|
||||
basetexture_unload((IWineD3DBaseTexture *)iface);
|
||||
|
@ -250,65 +253,85 @@ static BOOL WINAPI IWineD3DVolumeTextureImpl_IsCondNP2(IWineD3DVolumeTexture *if
|
|||
/* *******************************************
|
||||
IWineD3DVolumeTexture IWineD3DVolumeTexture parts follow
|
||||
******************************************* */
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface, UINT Level,WINED3DVOLUME_DESC *pDesc) {
|
||||
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
|
||||
if (Level < This->baseTexture.levels) {
|
||||
TRACE("(%p) Level (%d)\n", This, Level);
|
||||
return IWineD3DVolume_GetDesc(This->volumes[Level], pDesc);
|
||||
} else {
|
||||
WARN("(%p) Level (%d)\n", This, Level);
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface,
|
||||
UINT level, WINED3DVOLUME_DESC *desc)
|
||||
{
|
||||
IWineD3DVolumeTextureImpl *texture = (IWineD3DVolumeTextureImpl *)iface;
|
||||
|
||||
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
|
||||
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
return WINED3D_OK;
|
||||
|
||||
return IWineD3DVolume_GetDesc((IWineD3DVolume *)texture->baseTexture.sub_resources[level], desc);
|
||||
}
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTexture *iface, UINT Level, IWineD3DVolume** ppVolumeLevel) {
|
||||
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
|
||||
if (Level < This->baseTexture.levels) {
|
||||
*ppVolumeLevel = This->volumes[Level];
|
||||
IWineD3DVolume_AddRef(*ppVolumeLevel);
|
||||
TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel);
|
||||
} else {
|
||||
WARN("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTexture *iface,
|
||||
UINT level, IWineD3DVolume **volume)
|
||||
{
|
||||
IWineD3DVolumeTextureImpl *texture = (IWineD3DVolumeTextureImpl *)iface;
|
||||
|
||||
TRACE("iface %p, level %u, volume %p.\n", iface, level, volume);
|
||||
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
*volume = (IWineD3DVolume *)texture->baseTexture.sub_resources[level];
|
||||
IWineD3DVolume_AddRef(*volume);
|
||||
|
||||
TRACE("Returning volume %p.\n", *volume);
|
||||
|
||||
return WINED3D_OK;
|
||||
|
||||
}
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_LockBox(IWineD3DVolumeTexture *iface, UINT Level, WINED3DLOCKED_BOX* pLockedVolume, CONST WINED3DBOX* pBox, DWORD Flags) {
|
||||
HRESULT hr;
|
||||
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
hr = IWineD3DVolume_LockBox(This->volumes[Level], pLockedVolume, pBox, Flags);
|
||||
TRACE("(%p) Level (%d) success(%u)\n", This, Level, hr);
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_LockBox(IWineD3DVolumeTexture *iface,
|
||||
UINT level, WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags)
|
||||
{
|
||||
IWineD3DVolumeTextureImpl *texture = (IWineD3DVolumeTextureImpl *)iface;
|
||||
|
||||
} else {
|
||||
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
|
||||
iface, level, locked_box, box, flags);
|
||||
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
return hr;
|
||||
|
||||
return IWineD3DVolume_LockBox((IWineD3DVolume *)texture->baseTexture.sub_resources[level], locked_box, box, flags);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_UnlockBox(IWineD3DVolumeTexture *iface, UINT Level) {
|
||||
HRESULT hr;
|
||||
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_UnlockBox(IWineD3DVolumeTexture *iface, UINT level)
|
||||
{
|
||||
IWineD3DVolumeTextureImpl *texture = (IWineD3DVolumeTextureImpl *)iface;
|
||||
|
||||
if (Level < This->baseTexture.levels) {
|
||||
hr = IWineD3DVolume_UnlockBox(This->volumes[Level]);
|
||||
TRACE("(%p) -> level(%d) success(%u)\n", This, Level, hr);
|
||||
TRACE("iface %p, level %u.\n", iface, level);
|
||||
|
||||
} else {
|
||||
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
if (level >= texture->baseTexture.level_count)
|
||||
{
|
||||
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
return hr;
|
||||
|
||||
return IWineD3DVolume_UnlockBox((IWineD3DVolume *)texture->baseTexture.sub_resources[level]);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, CONST WINED3DBOX* pDirtyBox) {
|
||||
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
|
||||
This->baseTexture.texture_rgb.dirty = TRUE;
|
||||
This->baseTexture.texture_srgb.dirty = TRUE;
|
||||
TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
|
||||
volume_add_dirty_box(This->volumes[0], pDirtyBox);
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, const WINED3DBOX *dirty_box)
|
||||
{
|
||||
IWineD3DVolumeTextureImpl *texture = (IWineD3DVolumeTextureImpl *)iface;
|
||||
|
||||
TRACE("iface %p, dirty_box %p.\n", iface, dirty_box);
|
||||
|
||||
texture->baseTexture.texture_rgb.dirty = TRUE;
|
||||
texture->baseTexture.texture_srgb.dirty = TRUE;
|
||||
volume_add_dirty_box((IWineD3DVolume *)texture->baseTexture.sub_resources[0], dirty_box);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
@ -399,8 +422,8 @@ HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT
|
|||
|
||||
texture->lpVtbl = &IWineD3DVolumeTexture_Vtbl;
|
||||
|
||||
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_VOLUMETEXTURE,
|
||||
device, 0, usage, format_desc, pool, parent, parent_ops);
|
||||
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, 1, levels,
|
||||
WINED3DRTYPE_VOLUMETEXTURE, device, 0, usage, format_desc, pool, parent, parent_ops);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize basetexture, returning %#x.\n", hr);
|
||||
|
@ -418,21 +441,23 @@ HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT
|
|||
tmp_h = height;
|
||||
tmp_d = depth;
|
||||
|
||||
for (i = 0; i < texture->baseTexture.levels; ++i)
|
||||
for (i = 0; i < texture->baseTexture.level_count; ++i)
|
||||
{
|
||||
IWineD3DVolume *volume;
|
||||
|
||||
/* Create the volume. */
|
||||
hr = IWineD3DDeviceParent_CreateVolume(device->device_parent, parent,
|
||||
tmp_w, tmp_h, tmp_d, format, pool, usage, &texture->volumes[i]);
|
||||
tmp_w, tmp_h, tmp_d, format, pool, usage, &volume);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
|
||||
texture->volumes[i] = NULL;
|
||||
volumetexture_cleanup(texture);
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* Set its container to this texture. */
|
||||
IWineD3DVolume_SetContainer(texture->volumes[i], (IWineD3DBase *)texture);
|
||||
IWineD3DVolume_SetContainer(volume, (IWineD3DBase *)texture);
|
||||
texture->baseTexture.sub_resources[i] = (IWineD3DResourceImpl *)volume;
|
||||
|
||||
/* Calculate the next mipmap level. */
|
||||
tmp_w = max(1, tmp_w >> 1);
|
||||
|
|
|
@ -1860,7 +1860,9 @@ struct gl_texture
|
|||
typedef struct IWineD3DBaseTextureClass
|
||||
{
|
||||
struct gl_texture texture_rgb, texture_srgb;
|
||||
UINT levels;
|
||||
IWineD3DResourceImpl **sub_resources;
|
||||
UINT layer_count;
|
||||
UINT level_count;
|
||||
float pow2Matrix[16];
|
||||
UINT LOD;
|
||||
WINED3DTEXTUREFILTERTYPE filterType;
|
||||
|
@ -1899,9 +1901,10 @@ WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture
|
|||
BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
|
||||
DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
|
||||
DWORD basetexture_get_lod(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
|
||||
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
|
||||
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format_desc *format_desc,
|
||||
WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
|
||||
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT layer_count, UINT level_count,
|
||||
WINED3DRESOURCETYPE resource_type, IWineD3DDeviceImpl *device, UINT size, DWORD usage,
|
||||
const struct wined3d_format_desc *format_desc, WINED3DPOOL pool, IUnknown *parent,
|
||||
const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
|
||||
HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface,
|
||||
WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
|
||||
BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty) DECLSPEC_HIDDEN;
|
||||
|
@ -1919,7 +1922,6 @@ typedef struct IWineD3DTextureImpl
|
|||
IWineD3DBaseTextureClass baseTexture;
|
||||
|
||||
/* IWineD3DTexture */
|
||||
IWineD3DSurface *surfaces[MAX_MIP_LEVELS];
|
||||
UINT target;
|
||||
BOOL cond_np2;
|
||||
|
||||
|
@ -1938,9 +1940,6 @@ typedef struct IWineD3DCubeTextureImpl
|
|||
const IWineD3DCubeTextureVtbl *lpVtbl;
|
||||
IWineD3DResourceClass resource;
|
||||
IWineD3DBaseTextureClass baseTexture;
|
||||
|
||||
/* IWineD3DCubeTexture */
|
||||
IWineD3DSurface *surfaces[6][MAX_MIP_LEVELS];
|
||||
} IWineD3DCubeTextureImpl;
|
||||
|
||||
HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
|
||||
|
@ -1987,9 +1986,6 @@ typedef struct IWineD3DVolumeTextureImpl
|
|||
const IWineD3DVolumeTextureVtbl *lpVtbl;
|
||||
IWineD3DResourceClass resource;
|
||||
IWineD3DBaseTextureClass baseTexture;
|
||||
|
||||
/* IWineD3DVolumeTexture */
|
||||
IWineD3DVolume *volumes[MAX_MIP_LEVELS];
|
||||
} IWineD3DVolumeTextureImpl;
|
||||
|
||||
HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height,
|
||||
|
|
Loading…
Reference in New Issue