Henri Verbeet : wined3d: Track format conversion per-texture.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Oct 8 14:09:27 CDT 2014
Module: wine
Branch: master
Commit: 710694d9ca654f3d01a74a06240b0c6252b135be
URL: http://source.winehq.org/git/wine.git/?a=commit;h=710694d9ca654f3d01a74a06240b0c6252b135be
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Wed Oct 8 08:47:22 2014 +0200
wined3d: Track format conversion per-texture.
---
dlls/wined3d/arb_program_shader.c | 2 +-
dlls/wined3d/surface.c | 16 +++++++++-------
dlls/wined3d/texture.c | 17 ++++++-----------
dlls/wined3d/wined3d_private.h | 4 ++--
4 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 52b9d9d..6fbe296 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -7469,7 +7469,7 @@ static HRESULT arbfp_blit_set(void *blit_priv, struct wined3d_context *context,
struct arbfp_blit_type type;
struct arbfp_blit_desc *desc;
- if (surface->flags & SFLAG_CONVERTED)
+ if (surface->container->flags & WINED3D_TEXTURE_CONVERTED)
{
gl_info->gl_ops.gl.p_glEnable(textype);
checkGLcall("glEnable(textype)");
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 0967220..527601f 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -588,11 +588,12 @@ void surface_prepare_map_memory(struct wined3d_surface *surface)
static void surface_evict_sysmem(struct wined3d_surface *surface)
{
/* In some conditions the surface memory must not be freed:
- * SFLAG_CONVERTED: Converting the data back would take too long
+ * WINED3D_TEXTURE_CONVERTED: Converting the data back would take too long
* SFLAG_DYNLOCK: Avoid freeing the data for performance
* SFLAG_CLIENT: OpenGL uses our memory as backup */
- if (surface->resource.map_count || surface->flags & (SFLAG_CONVERTED | SFLAG_DYNLOCK
- | SFLAG_CLIENT | SFLAG_PIN_SYSMEM))
+ if (surface->resource.map_count
+ || surface->flags & (SFLAG_DYNLOCK | SFLAG_CLIENT | SFLAG_PIN_SYSMEM)
+ || surface->container->flags & WINED3D_TEXTURE_CONVERTED)
return;
wined3d_resource_free_sysmem(&surface->resource);
@@ -1323,7 +1324,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
struct wined3d_bo_address data;
/* Only support read back of converted P8 surfaces. */
- if (surface->flags & SFLAG_CONVERTED && format->id != WINED3DFMT_P8_UINT)
+ if (surface->container->flags & WINED3D_TEXTURE_CONVERTED && format->id != WINED3DFMT_P8_UINT)
{
ERR("Trying to read back converted surface %p with format %s.\n", surface, debug_d3dformat(format->id));
return;
@@ -4189,8 +4190,8 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
format = *wined3d_get_format(gl_info, conversion->dst_format);
/* Don't use PBOs for converted surfaces. During PBO conversion we look at
- * SFLAG_CONVERTED but it isn't set (yet) in all cases it is getting
- * called. */
+ * WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is
+ * getting called. */
if ((format.convert || conversion) && surface->pbo)
{
TRACE("Removing the pbo attached to surface %p.\n", surface);
@@ -5285,7 +5286,8 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
/* We want to avoid invalidating the sysmem location for converted
* surfaces, since otherwise we'd have to convert the data back when
* locking them. */
- if (dst_surface->flags & SFLAG_CONVERTED || dst_surface->container->resource.format->convert
+ if (dst_surface->container->flags & WINED3D_TEXTURE_CONVERTED
+ || dst_surface->container->resource.format->convert
|| wined3d_format_get_color_key_conversion(dst_surface->container, TRUE))
{
WARN_(d3d_perf)("Converted surface, using CPU blit.\n");
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index bc75305..fb0f0e8 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -765,7 +765,7 @@ void wined3d_texture_force_reload(struct wined3d_texture *texture)
unsigned int sub_count = texture->level_count * texture->layer_count;
unsigned int i;
- texture->flags &= ~(WINED3D_TEXTURE_RGB_ALLOCATED | WINED3D_TEXTURE_SRGB_ALLOCATED);
+ texture->flags &= ~(WINED3D_TEXTURE_RGB_ALLOCATED | WINED3D_TEXTURE_SRGB_ALLOCATED | WINED3D_TEXTURE_CONVERTED);
for (i = 0; i < sub_count; ++i)
{
texture->texture_ops->texture_sub_resource_invalidate_location(texture->sub_resources[i],
@@ -850,7 +850,6 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
const struct wined3d_format *format = texture->resource.format;
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_color_key_conversion *conversion;
- BOOL converted = FALSE;
GLenum internal;
UINT i;
@@ -858,11 +857,11 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
if (format->convert)
{
- converted = TRUE;
+ texture->flags |= WINED3D_TEXTURE_CONVERTED;
}
else if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
{
- converted = TRUE;
+ texture->flags |= WINED3D_TEXTURE_CONVERTED;
format = wined3d_get_format(gl_info, conversion->dst_format);
TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id));
}
@@ -889,11 +888,6 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
GLsizei width = surface->pow2Width;
const BYTE *mem = NULL;
- if (converted)
- surface->flags |= SFLAG_CONVERTED;
- else
- surface->flags &= ~SFLAG_CONVERTED;
-
if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
{
height *= format->height_scale.numerator;
@@ -905,13 +899,14 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
- if (surface->flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_CONVERTED)
+ if (surface->flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION)
+ || texture->flags & WINED3D_TEXTURE_CONVERTED
|| !surface->resource.heap_memory)
{
/* In some cases we want to disable client storage.
* SFLAG_NONPOW2 has a bigger opengl texture than the client memory, and different pitches
* SFLAG_DIBSECTION: Dibsections may have read / write protections on the memory. Avoid issues...
- * SFLAG_CONVERTED: The conversion destination memory is freed after loading the surface
+ * WINED3D_TEXTURE_CONVERTED: The conversion destination memory is freed after loading the surface
* heap_memory == NULL: Not defined in the extension. Seems to disable client storage effectively
*/
surface->flags &= ~SFLAG_CLIENT;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5ec5088..810da0f 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2128,6 +2128,7 @@ struct wined3d_texture_ops
#define WINED3D_TEXTURE_RGB_VALID 0x00000010
#define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000020
#define WINED3D_TEXTURE_SRGB_VALID 0x00000040
+#define WINED3D_TEXTURE_CONVERTED 0x00000080
struct wined3d_texture
{
@@ -2345,7 +2346,7 @@ void draw_textured_quad(const struct wined3d_surface *src_surface, struct wined3
void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) DECLSPEC_HIDDEN;
/* Surface flags: */
-#define SFLAG_CONVERTED 0x00000001 /* Converted for color keying or palettized. */
+#define SFLAG_DIBSECTION 0x00000001 /* Has a DIB section attached for GetDC. */
#define SFLAG_DISCARD 0x00000002 /* ??? */
#define SFLAG_NONPOW2 0x00000004 /* Surface sizes are not a power of 2 */
#define SFLAG_NORMCOORD 0x00000008 /* Set if GL texture coordinates are normalized (non-texture rectangle). */
@@ -2355,7 +2356,6 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) D
#define SFLAG_LOST 0x00000080 /* Surface lost flag for ddraw. */
#define SFLAG_GLCKEY 0x00000100 /* The GL texture was created with a color key. */
#define SFLAG_CLIENT 0x00000200 /* GL_APPLE_client_storage is used with this surface. */
-#define SFLAG_DIBSECTION 0x00000400 /* Has a DIB section attached for GetDC. */
struct wined3d_sampler
{
More information about the wine-cvs
mailing list