wined3d: Pass a texture and sub-resource index to wined3d_blitter_ops.blitter_blit().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-03-13 13:53:01 +03:30 committed by Alexandre Julliard
parent f09c498e46
commit 70a68144c1
4 changed files with 55 additions and 71 deletions

View File

@ -7795,13 +7795,11 @@ static BOOL arbfp_blit_supported(enum wined3d_blit_op blit_op, const struct wine
}
static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
struct wined3d_context *context, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx,
DWORD src_location, const RECT *src_rect, struct wined3d_texture *dst_texture,
unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
{
unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
struct wined3d_texture *src_texture = src_surface->container;
struct wined3d_texture *dst_texture = dst_surface->container;
struct wined3d_device *device = dst_texture->resource.device;
struct wined3d_arbfp_blitter *arbfp_blitter;
struct wined3d_color_key alpha_test_key;
@ -7812,15 +7810,15 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl
&dst_texture->resource, dst_location))
{
if ((next = blitter->next))
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, color_key, filter);
return next->ops->blitter_blit(next, op, context, src_texture, src_sub_resource_idx, src_location,
src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect, color_key, filter);
}
arbfp_blitter = CONTAINING_RECORD(blitter, struct wined3d_arbfp_blitter, blitter);
/* Now load the surface */
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& (surface_get_sub_resource(src_surface)->locations
&& (src_texture->sub_resources[src_sub_resource_idx].locations
& (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_DRAWABLE))
== WINED3D_LOCATION_DRAWABLE
&& !wined3d_resource_is_offscreen(&src_texture->resource))
@ -7857,16 +7855,16 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl
if (dst_location == WINED3D_LOCATION_DRAWABLE)
{
TRACE("Destination surface %p is onscreen.\n", dst_surface);
TRACE("Destination texture %p is onscreen.\n", dst_texture);
buffer = wined3d_texture_get_gl_buffer(dst_texture);
}
else
{
TRACE("Destination surface %p is offscreen.\n", dst_surface);
TRACE("Destination texture %p is offscreen.\n", dst_texture);
buffer = GL_COLOR_ATTACHMENT0;
}
context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER,
&dst_texture->resource, surface_get_sub_resource_idx(dst_surface), NULL, 0, dst_location);
&dst_texture->resource, dst_sub_resource_idx, NULL, 0, dst_location);
context_set_draw_buffer(context, buffer);
context_check_fbo_status(context, GL_DRAW_FRAMEBUFFER);
context_invalidate_state(context, STATE_FRAMEBUFFER);

View File

@ -2094,7 +2094,6 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
unsigned int sub_resource_idx, struct wined3d_context *context)
{
struct wined3d_texture *restore_texture;
struct wined3d_surface *surface;
struct wined3d_device *device;
unsigned int restore_idx;
unsigned int level;
@ -2116,7 +2115,6 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
}
device = texture->resource.device;
surface = texture->sub_resources[sub_resource_idx].u.surface;
restore_texture = context->current_rt.texture;
restore_idx = context->current_rt.sub_resource_idx;
if (restore_texture != texture || restore_idx != sub_resource_idx)
@ -2129,8 +2127,8 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
wined3d_texture_get_level_height(texture, level));
wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_COLOR_BLIT, context,
surface, WINED3D_LOCATION_TEXTURE_RGB, &r,
surface, WINED3D_LOCATION_DRAWABLE, &r,
texture, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB, &r,
texture, sub_resource_idx, WINED3D_LOCATION_DRAWABLE, &r,
NULL, WINED3D_TEXF_POINT);
if (restore_texture)
@ -2371,16 +2369,21 @@ static void fbo_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
}
static DWORD fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
struct wined3d_context *context, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx,
DWORD src_location, const RECT *src_rect, struct wined3d_texture *dst_texture,
unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter)
{
struct wined3d_resource *src_resource = &src_surface->container->resource;
struct wined3d_resource *dst_resource = &dst_surface->container->resource;
struct wined3d_device *device = dst_resource->device;
struct wined3d_resource *src_resource, *dst_resource;
enum wined3d_blit_op blit_op = op;
struct wined3d_device *device;
struct wined3d_blitter *next;
src_resource = &src_texture->resource;
dst_resource = &dst_texture->resource;
device = dst_resource->device;
if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_resource->format->id == src_resource->format->id)
{
if (dst_resource->format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
@ -2393,25 +2396,23 @@ static DWORD fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit
src_resource, src_location, dst_resource, dst_location))
{
if ((next = blitter->next))
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, colour_key, filter);
return next->ops->blitter_blit(next, op, context, src_texture, src_sub_resource_idx, src_location,
src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect, colour_key, filter);
}
if (blit_op == WINED3D_BLIT_OP_COLOR_BLIT)
{
TRACE("Colour blit.\n");
texture2d_blt_fbo(device, context, filter, src_surface->container,
surface_get_sub_resource_idx(src_surface), src_location, src_rect, dst_surface->container,
surface_get_sub_resource_idx(dst_surface), dst_location, dst_rect);
texture2d_blt_fbo(device, context, filter, src_texture, src_sub_resource_idx, src_location,
src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect);
return dst_location;
}
if (blit_op == WINED3D_BLIT_OP_DEPTH_BLIT)
{
TRACE("Depth/stencil blit.\n");
texture2d_depth_blt_fbo(device, context, src_surface->container, surface_get_sub_resource_idx(src_surface),
src_location, src_rect, dst_surface->container, surface_get_sub_resource_idx(dst_surface),
dst_location, dst_rect);
texture2d_depth_blt_fbo(device, context, src_texture, src_sub_resource_idx, src_location,
src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect);
return dst_location;
}
@ -2474,21 +2475,17 @@ static void raw_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
/* Context activation is done by the caller. */
static DWORD raw_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
struct wined3d_context *context, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx,
DWORD src_location, const RECT *src_rect, struct wined3d_texture *dst_texture,
unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int src_sub_resource_idx, dst_sub_resource_idx;
unsigned int src_level, src_layer, dst_level, dst_layer;
struct wined3d_texture *src_texture, *dst_texture;
struct wined3d_blitter *next;
GLuint src_name, dst_name;
DWORD location;
src_texture = src_surface->container;
dst_texture = dst_surface->container;
/* If we would need to copy from a renderbuffer or drawable, we'd probably
* be better of using the FBO blitter directly, since we'd need to use it
* to copy the resource contents to the texture anyway. */
@ -2504,17 +2501,15 @@ static DWORD raw_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit
}
TRACE("Forwarding to blitter %p.\n", next);
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, colour_key, filter);
return next->ops->blitter_blit(next, op, context, src_texture, src_sub_resource_idx, src_location,
src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect, colour_key, filter);
}
TRACE("Blit using ARB_copy_image.\n");
src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
src_level = src_sub_resource_idx % src_texture->level_count;
src_layer = src_sub_resource_idx / src_texture->level_count;
dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
dst_level = dst_sub_resource_idx % dst_texture->level_count;
dst_layer = dst_sub_resource_idx / dst_texture->level_count;
@ -2733,13 +2728,11 @@ static void ffp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
}
static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
struct wined3d_context *context, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx,
DWORD src_location, const RECT *src_rect, struct wined3d_texture *dst_texture,
unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
{
unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
struct wined3d_texture *src_texture = src_surface->container;
struct wined3d_texture *dst_texture = dst_surface->container;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_resource *src_resource, *dst_resource;
struct wined3d_color_key old_blt_key;
@ -2755,11 +2748,12 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit
if (!ffp_blit_supported(op, context, src_resource, src_location, dst_resource, dst_location))
{
if ((next = blitter->next))
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, color_key, filter);
return next->ops->blitter_blit(next, op, context, src_texture, src_sub_resource_idx, src_location,
src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect, color_key, filter);
}
TRACE("Blt from surface %p to rendertarget %p\n", src_surface, dst_surface);
TRACE("Blt from texture %p, %u to rendertarget %p, %u.\n",
src_texture, src_sub_resource_idx, dst_texture, dst_sub_resource_idx);
old_blt_key = src_texture->async.src_blt_color_key;
old_color_key_flags = src_texture->async.color_key_flags;
@ -2786,16 +2780,16 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit
if (dst_location == WINED3D_LOCATION_DRAWABLE)
{
TRACE("Destination surface %p is onscreen.\n", dst_surface);
TRACE("Destination texture %p is onscreen.\n", dst_texture);
buffer = wined3d_texture_get_gl_buffer(dst_texture);
}
else
{
TRACE("Destination surface %p is offscreen.\n", dst_surface);
TRACE("Destination texture %p is offscreen.\n", dst_texture);
buffer = GL_COLOR_ATTACHMENT0;
}
context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER,
dst_resource, surface_get_sub_resource_idx(dst_surface), NULL, 0, dst_location);
dst_resource, dst_sub_resource_idx, NULL, 0, dst_location);
context_set_draw_buffer(context, buffer);
context_check_fbo_status(context, GL_DRAW_FRAMEBUFFER);
context_invalidate_state(context, STATE_FRAMEBUFFER);
@ -3627,16 +3621,13 @@ static void cpu_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
}
static DWORD cpu_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
struct wined3d_context *context, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx,
DWORD src_location, const RECT *src_rect, struct wined3d_texture *dst_texture,
unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
{
struct wined3d_box dst_box = {dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, 0, 1};
struct wined3d_box src_box = {src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1};
unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
struct wined3d_texture *dst_texture = dst_surface->container;
struct wined3d_texture *src_texture = src_surface->container;
struct wined3d_blt_fx fx;
DWORD flags = 0;
@ -3795,8 +3786,8 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const struct wi
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
valid_locations = device->blitter->ops->blitter_blit(device->blitter,
WINED3D_BLIT_OP_DEPTH_BLIT, context,
src_surface, src_texture->resource.draw_binding, &src_rect,
dst_surface, dst_location, &dst_rect, NULL, filter);
src_texture, src_sub_resource_idx, src_texture->resource.draw_binding, &src_rect,
dst_texture, dst_sub_resource_idx, dst_location, &dst_rect, NULL, filter);
context_release(context);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, valid_locations);
@ -3900,8 +3891,8 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const struct wi
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
valid_locations = device->blitter->ops->blitter_blit(device->blitter, blit_op, context,
src_surface, src_texture->resource.draw_binding, &src_rect,
dst_surface, dst_location, &dst_rect, colour_key, filter);
src_texture, src_sub_resource_idx, src_texture->resource.draw_binding, &src_rect,
dst_texture, dst_sub_resource_idx, dst_location, &dst_rect, colour_key, filter);
context_release(context);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, valid_locations);

View File

@ -309,7 +309,6 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
{
struct wined3d_texture *texture = swapchain->back_buffers[0];
struct wined3d_surface *back_buffer = texture->sub_resources[0].u.surface;
struct wined3d_device *device = swapchain->device;
enum wined3d_texture_filter_type filter;
DWORD location;
@ -329,8 +328,8 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
location = WINED3D_LOCATION_RB_RESOLVED;
wined3d_texture_validate_location(texture, 0, WINED3D_LOCATION_DRAWABLE);
device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_COLOR_BLIT, context, back_buffer,
location, src_rect, back_buffer, WINED3D_LOCATION_DRAWABLE, dst_rect, NULL, filter);
device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_COLOR_BLIT, context, texture, 0,
location, src_rect, texture, 0, WINED3D_LOCATION_DRAWABLE, dst_rect, NULL, filter);
wined3d_texture_invalidate_location(texture, 0, WINED3D_LOCATION_DRAWABLE);
}

View File

@ -2109,9 +2109,10 @@ struct wined3d_blitter_ops
unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect,
struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter);
struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location,
const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key,
enum wined3d_texture_filter_type filter);
};
void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
@ -3343,11 +3344,6 @@ static inline unsigned int surface_get_sub_resource_idx(const struct wined3d_sur
return surface->texture_layer * surface->container->level_count + surface->texture_level;
}
static inline struct wined3d_texture_sub_resource *surface_get_sub_resource(struct wined3d_surface *surface)
{
return &surface->container->sub_resources[surface_get_sub_resource_idx(surface)];
}
HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const struct wined3d_box *dst_box,
struct wined3d_surface *src_surface, const struct wined3d_box *src_box, DWORD flags,
const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;