[PATCH 7/7] wined3d: Merge wined3d_surface_prepare() and wined3d_volume_prepare_location().
Henri Verbeet
hverbeet at codeweavers.com
Mon Apr 18 12:06:32 CDT 2016
From: Stefan Dösinger <stefan at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/wined3d/surface.c | 52 ++--------------------------
dlls/wined3d/texture.c | 77 +++++++++++++++++++++++++++++++-----------
dlls/wined3d/volume.c | 37 +-------------------
dlls/wined3d/wined3d_private.h | 8 ++---
4 files changed, 63 insertions(+), 111 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index f43b186..00b87a0 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -429,22 +429,6 @@ HRESULT wined3d_surface_create_dc(struct wined3d_surface *surface)
return WINED3D_OK;
}
-static void surface_prepare_system_memory(struct wined3d_surface *surface)
-{
- TRACE("surface %p.\n", surface);
-
- if (surface->resource.heap_memory)
- return;
-
- /* Whatever surface we have, make sure that there is memory allocated
- * for the downloaded copy, or a PBO to map. */
- if (!wined3d_resource_allocate_sysmem(&surface->resource))
- ERR("Failed to allocate system memory.\n");
-
- if (surface_get_sub_resource(surface)->locations & WINED3D_LOCATION_SYSMEM)
- ERR("Surface without system memory has WINED3D_LOCATION_SYSMEM set.\n");
-}
-
static void surface_evict_sysmem(struct wined3d_surface *surface)
{
unsigned int sub_resource_idx = surface_get_sub_resource_idx(surface);
@@ -4396,38 +4380,6 @@ HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_tex
* WINED3D_NO3D mode. */
void wined3d_surface_prepare(struct wined3d_surface *surface, struct wined3d_context *context, DWORD location)
{
- struct wined3d_texture *texture = surface->container;
-
- switch (location)
- {
- case WINED3D_LOCATION_SYSMEM:
- surface_prepare_system_memory(surface);
- break;
-
- case WINED3D_LOCATION_USER_MEMORY:
- if (!texture->user_memory)
- ERR("Map binding is set to WINED3D_LOCATION_USER_MEMORY but surface->user_memory is NULL.\n");
- break;
-
- case WINED3D_LOCATION_BUFFER:
- wined3d_texture_prepare_buffer_object(texture,
- surface_get_sub_resource_idx(surface), context->gl_info);
- break;
-
- case WINED3D_LOCATION_TEXTURE_RGB:
- wined3d_texture_prepare_texture(texture, context, FALSE);
- break;
-
- case WINED3D_LOCATION_TEXTURE_SRGB:
- wined3d_texture_prepare_texture(texture, context, TRUE);
- break;
-
- case WINED3D_LOCATION_RB_MULTISAMPLE:
- wined3d_texture_prepare_rb(texture, context->gl_info, TRUE);
- break;
-
- case WINED3D_LOCATION_RB_RESOLVED:
- wined3d_texture_prepare_rb(texture, context->gl_info, FALSE);
- break;
- }
+ wined3d_texture_prepare_location(surface->container,
+ surface_get_sub_resource_idx(surface), context, location);
}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index e4ff67c..c8a7695 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1019,7 +1019,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
}
/* Context activation is done by the caller. */
-void wined3d_texture_prepare_buffer_object(struct wined3d_texture *texture,
+static void wined3d_texture_prepare_buffer_object(struct wined3d_texture *texture,
unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info)
{
GLuint *buffer_object;
@@ -1076,7 +1076,7 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win
texture->flags |= alloc_flag;
}
-void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
+static void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
const struct wined3d_gl_info *gl_info, BOOL multisample)
{
const struct wined3d_format *format = texture->resource.format;
@@ -1138,6 +1138,60 @@ void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
}
}
+/* Context activation is done by the caller. Context may be NULL in
+ * WINED3D_NO3D mode. */
+BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, DWORD location)
+{
+ switch (location)
+ {
+ case WINED3D_LOCATION_SYSMEM:
+ if (texture->sub_resources[sub_resource_idx].resource->heap_memory)
+ return TRUE;
+
+ if (!wined3d_resource_allocate_sysmem(texture->sub_resources[sub_resource_idx].resource))
+ {
+ ERR("Failed to allocate system memory.\n");
+ return FALSE;
+ }
+ return TRUE;
+
+ case WINED3D_LOCATION_USER_MEMORY:
+ if (!texture->user_memory)
+ ERR("Map binding is set to WINED3D_LOCATION_USER_MEMORY but surface->user_memory is NULL.\n");
+ return TRUE;
+
+ case WINED3D_LOCATION_BUFFER:
+ wined3d_texture_prepare_buffer_object(texture, sub_resource_idx, context->gl_info);
+ return TRUE;
+
+ case WINED3D_LOCATION_TEXTURE_RGB:
+ wined3d_texture_prepare_texture(texture, context, FALSE);
+ return TRUE;
+
+ case WINED3D_LOCATION_TEXTURE_SRGB:
+ wined3d_texture_prepare_texture(texture, context, TRUE);
+ return TRUE;
+
+ case WINED3D_LOCATION_DRAWABLE:
+ if (!texture->swapchain)
+ ERR("Texture %p does not have a drawable.\n", texture);
+ return TRUE;
+
+ case WINED3D_LOCATION_RB_MULTISAMPLE:
+ wined3d_texture_prepare_rb(texture, context->gl_info, TRUE);
+ return TRUE;
+
+ case WINED3D_LOCATION_RB_RESOLVED:
+ wined3d_texture_prepare_rb(texture, context->gl_info, FALSE);
+ return TRUE;
+
+ default:
+ ERR("Invalid location %s.\n", wined3d_debug_location(location));
+ return FALSE;
+ }
+}
+
void CDECL wined3d_texture_generate_mipmaps(struct wined3d_texture *texture)
{
/* TODO: Implement filters using GL_SGI_generate_mipmaps. */
@@ -1250,13 +1304,6 @@ static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned in
return SUCCEEDED(surface_load_location(texture->sub_resources[sub_resource_idx].u.surface, context, location));
}
-static BOOL texture2d_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- struct wined3d_context *context, DWORD location)
-{
- wined3d_surface_prepare(texture->sub_resources[sub_resource_idx].u.surface, context, location);
- return TRUE;
-}
-
/* Context activation is done by the caller. */
static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
{
@@ -1339,7 +1386,6 @@ static const struct wined3d_texture_ops texture2d_ops =
{
texture2d_upload_data,
texture2d_load_location,
- texture2d_prepare_location,
texture2d_prepare_texture,
texture2d_cleanup_sub_resources,
};
@@ -1486,8 +1532,8 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
{
TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n",
wined3d_debug_location(texture->resource.map_binding));
- if ((ret = texture->texture_ops->texture_prepare_location(texture,
- sub_resource_idx, context, texture->resource.map_binding)))
+ if ((ret = wined3d_texture_prepare_location(texture, sub_resource_idx,
+ context, texture->resource.map_binding)))
wined3d_texture_validate_location(texture, sub_resource_idx, texture->resource.map_binding);
}
else
@@ -1871,12 +1917,6 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
return wined3d_volume_load_location(texture->sub_resources[sub_resource_idx].u.volume, context, location);
}
-static BOOL texture3d_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- struct wined3d_context *context, DWORD location)
-{
- return wined3d_volume_prepare_location(texture->sub_resources[sub_resource_idx].u.volume, context, location);
-}
-
static void texture3d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
{
unsigned int sub_count = texture->level_count * texture->layer_count;
@@ -1923,7 +1963,6 @@ static const struct wined3d_texture_ops texture3d_ops =
{
texture3d_upload_data,
texture3d_load_location,
- texture3d_prepare_location,
texture3d_prepare_texture,
texture3d_cleanup_sub_resources,
};
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 89d5ead..9798650 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -27,47 +27,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
-static BOOL volume_prepare_system_memory(struct wined3d_volume *volume)
-{
- if (volume->resource.heap_memory)
- return TRUE;
-
- if (!wined3d_resource_allocate_sysmem(&volume->resource))
- {
- ERR("Failed to allocate system memory.\n");
- return FALSE;
- }
- return TRUE;
-}
-
/* Context activation is done by the caller. Context may be NULL in
* WINED3D_NO3D mode. */
BOOL wined3d_volume_prepare_location(struct wined3d_volume *volume,
struct wined3d_context *context, DWORD location)
{
- struct wined3d_texture *texture = volume->container;
-
- switch (location)
- {
- case WINED3D_LOCATION_SYSMEM:
- return volume_prepare_system_memory(volume);
-
- case WINED3D_LOCATION_BUFFER:
- wined3d_texture_prepare_buffer_object(texture, volume->texture_level, context->gl_info);
- return TRUE;
-
- case WINED3D_LOCATION_TEXTURE_RGB:
- wined3d_texture_prepare_texture(texture, context, FALSE);
- return TRUE;
-
- case WINED3D_LOCATION_TEXTURE_SRGB:
- wined3d_texture_prepare_texture(texture, context, TRUE);
- return TRUE;
-
- default:
- ERR("Invalid location %s.\n", wined3d_debug_location(location));
- return FALSE;
- }
+ return wined3d_texture_prepare_location(volume->container, volume->texture_level, context, location);
}
/* This call just uploads data, the caller is responsible for binding the
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index d3e1fba..1bdf20d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2428,8 +2428,6 @@ struct wined3d_texture_ops
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data);
BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location);
- BOOL (*texture_prepare_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- struct wined3d_context *context, DWORD location);
void (*texture_prepare_texture)(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb);
void (*texture_cleanup_sub_resources)(struct wined3d_texture *texture);
@@ -2567,10 +2565,8 @@ void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void *wined3d_texture_map_bo_address(const struct wined3d_bo_address *data, size_t size,
const struct wined3d_gl_info *gl_info, GLenum binding, DWORD flags) DECLSPEC_HIDDEN;
-void wined3d_texture_prepare_buffer_object(struct wined3d_texture *texture,
- unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
-void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
- const struct wined3d_gl_info *gl_info, BOOL multisample) DECLSPEC_HIDDEN;
+BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void wined3d_texture_prepare_texture(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
--
2.1.4
More information about the wine-patches
mailing list