[PATCH 5/5] wined3d: Upload texture data through the texture ops in wined3d_cs_exec_blt_sub_resource().
Henri Verbeet
hverbeet at codeweavers.com
Fri Jun 7 07:52:31 CDT 2019
Since we want to avoid directly calling GL-specific code here.
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/wined3d/cs.c | 8 ++++----
dlls/wined3d/texture.c | 32 ++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d_private.h | 4 ++++
3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index e1f94f45eed..a95ba502f32 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2242,10 +2242,10 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void *
wined3d_texture_get_pitch(src_texture, op->src_sub_resource_idx % src_texture->level_count,
&row_pitch, &slice_pitch);
- wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), FALSE);
- wined3d_texture_upload_data(dst_texture, op->dst_sub_resource_idx, context,
- dst_texture->resource.format, &op->src_box, wined3d_const_bo_address(&addr),
- row_pitch, slice_pitch, op->dst_box.left, op->dst_box.top, op->dst_box.front, FALSE);
+ dst_texture->texture_ops->texture_upload_data(context, wined3d_const_bo_address(&addr),
+ dst_texture->resource.format, &op->src_box, row_pitch, slice_pitch, dst_texture,
+ op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB,
+ op->dst_box.left, op->dst_box.top, op->dst_box.front);
wined3d_texture_validate_location(dst_texture, op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_invalidate_location(dst_texture, op->dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index dc60d874bd6..6e1cc047502 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2453,9 +2453,39 @@ static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned in
}
}
+static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
+ const struct wined3d_const_bo_address *src_bo_addr, const struct wined3d_format *src_format,
+ const struct wined3d_box *src_box, unsigned int src_row_pitch, unsigned int src_slice_pitch,
+ struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, unsigned int dst_location,
+ unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
+{
+ BOOL srgb = FALSE;
+
+ TRACE("context %p, src_bo_addr %s, src_format %s, src_box %s, src_row_pitch %u, src_slice_pitch %u, "
+ "dst_texture %p, dst_sub_resource_idx %u, dst_location %s, dst_x %u, dst_y %u, dst_z %u.\n",
+ context, debug_const_bo_address(src_bo_addr), debug_d3dformat(src_format->id), debug_box(src_box),
+ src_row_pitch, src_slice_pitch, dst_texture, dst_sub_resource_idx,
+ wined3d_debug_location(dst_location), dst_x, dst_y, dst_z);
+
+ if (dst_location == WINED3D_LOCATION_TEXTURE_SRGB)
+ {
+ srgb = TRUE;
+ }
+ else if (dst_location != WINED3D_LOCATION_TEXTURE_RGB)
+ {
+ FIXME("Unhandled location %s.\n", wined3d_debug_location(dst_location));
+ return;
+ }
+
+ wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), srgb);
+ wined3d_texture_upload_data(dst_texture, dst_sub_resource_idx, context, src_format,
+ src_box, src_bo_addr, src_row_pitch, src_slice_pitch, dst_x, dst_y, dst_z, srgb);
+}
+
static const struct wined3d_texture_ops texture2d_ops =
{
texture2d_load_location,
+ wined3d_texture_gl_upload_data,
};
struct wined3d_texture * __cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
@@ -2829,6 +2859,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in
static const struct wined3d_texture_ops texture1d_ops =
{
texture1d_load_location,
+ wined3d_texture_gl_upload_data,
};
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
@@ -3244,6 +3275,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
static const struct wined3d_texture_ops texture3d_ops =
{
texture3d_load_location,
+ wined3d_texture_gl_upload_data,
};
HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 42140831a0a..70a3c630039 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3382,6 +3382,10 @@ struct wined3d_texture_ops
{
BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location);
+ void (*texture_upload_data)(struct wined3d_context *context, const struct wined3d_const_bo_address *src_bo_addr,
+ const struct wined3d_format *src_format, const struct wined3d_box *src_box, unsigned int src_row_pitch,
+ unsigned int src_slice_pitch, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
+ unsigned int dst_location, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z);
};
#define WINED3D_TEXTURE_COND_NP2 0x00000001
--
2.11.0
More information about the wine-devel
mailing list