Rebase against 9eecacbeb1561218d4870c83f89a233cabbf7e0c.

This commit is contained in:
Sebastian Lackner
2017-03-08 22:56:02 +01:00
parent 37b0772439
commit 3b1cd79e05
13 changed files with 130 additions and 577 deletions

View File

@@ -1,4 +1,4 @@
From a34bdbe6dd81562c6bad79e3c1662dd17333c447 Mon Sep 17 00:00:00 2001
From 5ee5e16ac78dcad58eaa40fe41ee7c771b8721cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Mon, 29 Apr 2013 18:49:53 +0200
Subject: wined3d: Send blits through the command stream.
@@ -6,10 +6,11 @@ Subject: wined3d: Send blits through the command stream.
This needs more work. This patch breaks error handling, and the split
between surface_blt and surface_blt_ugly isn't particularly nice.
---
dlls/wined3d/cs.c | 52 +++++++++++
dlls/wined3d/surface.c | 208 +++++++++++++++++++++++++----------------
dlls/wined3d/wined3d_private.h | 7 ++
3 files changed, 188 insertions(+), 79 deletions(-)
dlls/wined3d/cs.c | 52 +++++++++++++++
dlls/wined3d/surface.c | 140 ++++++++++++++++++++++++-----------------
dlls/wined3d/texture.c | 9 ++-
dlls/wined3d/wined3d_private.h | 7 +++
4 files changed, 148 insertions(+), 60 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 1366973c1e6..f2eb87e35b8 100644
@@ -96,10 +97,10 @@ index 1366973c1e6..f2eb87e35b8 100644
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 0dffdfa30f2..47ef3759b3e 100644
index cd82d46a001..637d300b2f5 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3737,7 +3737,7 @@ const struct blit_shader cpu_blit = {
@@ -3738,7 +3738,7 @@ const struct blit_shader cpu_blit = {
cpu_blit_blit_surface,
};
@@ -108,7 +109,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
{
@@ -3747,11 +3747,10 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3748,8 +3748,8 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
struct wined3d_texture *dst_texture = dst_surface->container;
struct wined3d_device *device = dst_texture->resource.device;
struct wined3d_swapchain *src_swapchain, *dst_swapchain;
@@ -118,11 +119,8 @@ index 0dffdfa30f2..47ef3759b3e 100644
+ unsigned int src_sub_resource_idx;
DWORD src_ds_flags, dst_ds_flags;
BOOL scale, convert;
- HRESULT hr;
static const DWORD simple_blit = WINED3D_BLT_ASYNC
| WINED3D_BLT_COLOR_FILL
@@ -3762,66 +3761,17 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3762,52 +3762,17 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
| WINED3D_BLT_DO_NOT_WAIT
| WINED3D_BLT_ALPHA_TEST;
@@ -150,20 +148,6 @@ index 0dffdfa30f2..47ef3759b3e 100644
+ src_swapchain = src_texture->swapchain;
}
-
- if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
- || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
- {
- WARN("Surface is busy, returning WINEDDERR_SURFACEBUSY.\n");
- return WINEDDERR_SURFACEBUSY;
- }
-
- if (FAILED(hr = wined3d_texture_check_box_dimensions(dst_texture, dst_surface->texture_level, &dst_box)))
- return hr;
-
- if (src_texture && FAILED(hr = wined3d_texture_check_box_dimensions(src_texture,
- src_surface->texture_level, &src_box)))
- return hr;
-
- if (!fx || !(fx->fx))
- flags &= ~WINED3D_BLT_FX;
-
@@ -194,7 +178,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
}
if (!device->d3d_initialized)
@@ -3846,11 +3796,6 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3832,11 +3797,6 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
goto fallback;
}
@@ -206,7 +190,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
dst_swapchain = dst_texture->swapchain;
/* This isn't strictly needed. FBO blits for example could deal with
@@ -3886,22 +3831,16 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3872,15 +3832,15 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
TRACE("Depth fill.\n");
if (!wined3d_format_convert_color_to_float(dst_texture->resource.format, NULL, fx->fill_color, &color))
@@ -217,22 +201,15 @@ index 0dffdfa30f2..47ef3759b3e 100644
- return WINED3D_OK;
+ return;
}
else
else if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_texture->resource.draw_binding,
src_rect, dst_surface, dst_texture->resource.draw_binding, dst_rect)))
{
- if (src_ds_flags != dst_ds_flags)
- {
- WARN("Rejecting depth / stencil blit between incompatible formats.\n");
- return WINED3DERR_INVALIDCALL;
- }
-
if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_texture->resource.draw_binding,
src_rect, dst_surface, dst_texture->resource.draw_binding, dst_rect)))
- return WINED3D_OK;
+ return;
- return WINED3D_OK;
+ return;
}
}
else
@@ -3937,7 +3876,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3916,7 +3876,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
goto fallback;
if (SUCCEEDED(surface_color_fill(dst_surface, dst_rect, &color)))
@@ -241,7 +218,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
}
else
{
@@ -3981,7 +3920,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3960,7 +3920,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
context, dst_texture->resource.draw_binding);
context_release(context);
}
@@ -250,7 +227,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
}
}
}
@@ -4005,7 +3944,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3984,7 +3944,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
wined3d_swapchain_present(dst_swapchain, NULL, NULL, dst_swapchain->win_handle, 0);
dst_swapchain->desc.swap_effect = swap_effect;
@@ -259,7 +236,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
}
if (fbo_blit_supported(&device->adapter->gl_info, blit_op,
@@ -4026,7 +3965,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -4005,7 +3965,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx,
~dst_texture->resource.draw_binding);
@@ -268,7 +245,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
}
blitter = wined3d_select_blitter(&device->adapter->gl_info, &device->adapter->d3d_info, blit_op,
@@ -4036,7 +3975,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -4015,7 +3975,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
{
blitter->blit_surface(device, blit_op, filter, src_surface,
src_rect, dst_surface, dst_rect, color_key);
@@ -277,7 +254,7 @@ index 0dffdfa30f2..47ef3759b3e 100644
}
}
}
@@ -4044,9 +3983,120 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -4023,9 +3983,73 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
fallback:
/* Special cases for render targets. */
if (SUCCEEDED(surface_blt_special(dst_surface, dst_rect, src_surface, src_rect, flags, fx, filter)))
@@ -294,17 +271,8 @@ index 0dffdfa30f2..47ef3759b3e 100644
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const struct wined3d_blt_fx *fx, 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};
+ struct wined3d_texture *dst_texture = dst_surface->container;
+ struct wined3d_texture *src_texture = NULL;
+ struct wined3d_device *device = dst_texture->resource.device;
+ unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface), src_sub_resource_idx;
+ struct wined3d_texture_sub_resource *dst_sub_resource =
+ &dst_texture->sub_resources[dst_sub_resource_idx];
+ struct wined3d_texture_sub_resource *src_sub_resource = NULL;
+ DWORD src_ds_flags, dst_ds_flags;
+ HRESULT hr;
+
+ TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
+ dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
@@ -323,44 +291,6 @@ index 0dffdfa30f2..47ef3759b3e 100644
+ fx->src_color_key.color_space_high_value);
+ }
+
+ if (src_surface)
+ {
+ src_texture = src_surface->container;
+ src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
+ src_sub_resource = &src_surface->container->sub_resources[src_sub_resource_idx];
+ }
+
+ if (dst_sub_resource->map_count || (src_sub_resource && src_sub_resource->map_count))
+ {
+ wined3d_cs_emit_sync(device->cs);
+ if (dst_sub_resource->map_count || (src_sub_resource && src_sub_resource->map_count))
+ {
+ WARN("Surface is busy, returning WINEDDERR_SURFACEBUSY.\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
+ }
+
+ if (FAILED(hr = wined3d_texture_check_box_dimensions(dst_texture, dst_surface->texture_level, &dst_box)))
+ return hr;
+
+ if (src_texture && FAILED(hr = wined3d_texture_check_box_dimensions(src_texture,
+ src_surface->texture_level, &src_box)))
+ return hr;
+
+ dst_ds_flags = dst_texture->resource.format_flags
+ & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+ if (src_surface)
+ src_ds_flags = src_surface->container->resource.format_flags
+ & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+ else
+ src_ds_flags = 0;
+
+ if (!(flags & WINED3D_BLT_DEPTH_FILL) && (src_ds_flags != dst_ds_flags))
+ {
+ WARN("Rejecting depth / stencil blit between incompatible formats.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ /* FIXME: We should select the blitter in the main thread, that way we can return an error if the blit
+ * is unsupported without duplicating all the checks... */
+ if (flags & WINED3D_BLT_COLOR_FILL && (dst_surface->container->resource.format_flags & WINED3DFMT_FLAG_BLOCKS))
@@ -400,6 +330,26 @@ index 0dffdfa30f2..47ef3759b3e 100644
+
+ return WINED3D_OK;
+}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index a65367398f0..7cd69134a0c 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -3190,8 +3190,13 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
|| (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
{
- WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
- return WINEDDERR_SURFACEBUSY;
+ wined3d_cs_emit_sync(dst_texture->resource.device->cs);
+ if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
+ || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
+ {
+ WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
}
if ((dst_format_flags & WINED3DFMT_FLAG_BLOCKS) && (flags & WINED3D_BLT_COLOR_FILL))
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a3716e937a5..1c3ba4644f1 100644
--- a/dlls/wined3d/wined3d_private.h

View File

@@ -2560,7 +2560,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
{
GLint vram_free_kb;
UINT64 vram_free;
@@ -2335,7 +2352,11 @@ HRESULT CDECL wined3d_device_set_vs_consts_b(struct wined3d_device *device,
@@ -2353,7 +2370,11 @@ HRESULT CDECL wined3d_device_set_vs_consts_b(struct wined3d_device *device,
}
else
{
@@ -2572,7 +2572,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
}
return WINED3D_OK;
@@ -2384,7 +2405,11 @@ HRESULT CDECL wined3d_device_set_vs_consts_i(struct wined3d_device *device,
@@ -2402,7 +2423,11 @@ HRESULT CDECL wined3d_device_set_vs_consts_i(struct wined3d_device *device,
}
else
{
@@ -2584,7 +2584,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
}
return WINED3D_OK;
@@ -2429,7 +2454,11 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
@@ -2447,7 +2472,11 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
memset(&device->recording->changed.vs_consts_f[start_idx], 1,
count * sizeof(*device->recording->changed.vs_consts_f));
else
@@ -2632,7 +2632,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
return WINED3D_OK;
}
@@ -3470,8 +3511,10 @@ HRESULT CDECL wined3d_device_begin_scene(struct wined3d_device *device)
@@ -3481,8 +3522,10 @@ HRESULT CDECL wined3d_device_begin_scene(struct wined3d_device *device)
HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
{
@@ -2643,7 +2643,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
TRACE("device %p.\n", device);
if (!device->inScene)
@@ -3480,6 +3523,7 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
@@ -3491,6 +3534,7 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
return WINED3DERR_INVALIDCALL;
}
@@ -2651,7 +2651,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
context = context_acquire(device, NULL, 0);
/* We only have to do this if we need to read the, swapbuffers performs a flush for us */
context->gl_info->gl_ops.gl.p_glFlush();
@@ -3487,6 +3531,7 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
@@ -3498,6 +3542,7 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
* fails. */
context_release(context);
@@ -2659,7 +2659,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
device->inScene = FALSE;
return WINED3D_OK;
}
@@ -3634,11 +3679,17 @@ void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device
@@ -3645,11 +3690,17 @@ void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device
start_idx, index_count, start_instance, instance_count, TRUE);
}
@@ -2677,7 +2677,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
struct wined3d_context *context;
struct wined3d_map_desc src;
HRESULT hr = WINED3D_OK;
@@ -3662,6 +3713,13 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
@@ -3673,6 +3724,13 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
}
context = context_acquire(device, NULL, 0);
@@ -2691,7 +2691,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
/* Only a prepare, since we're uploading entire volumes. */
wined3d_texture_prepare_texture(dst_texture, context, FALSE);
@@ -3669,15 +3727,22 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
@@ -3680,15 +3738,22 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
for (i = 0; i < level_count; ++i)
{
@@ -2714,7 +2714,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
if (FAILED(hr = wined3d_resource_unmap(&src_texture->resource, src_level + i)))
goto done;
}
@@ -3685,16 +3750,89 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
@@ -3696,16 +3761,89 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
done:
context_release(context);
return hr;
@@ -2804,7 +2804,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
TRACE("device %p, src_texture %p, dst_texture %p.\n", device, src_texture, dst_texture);
@@ -3731,6 +3869,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
@@ -3742,6 +3880,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL;
}
@@ -2812,7 +2812,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
level_count = min(wined3d_texture_get_level_count(src_texture),
wined3d_texture_get_level_count(dst_texture));
@@ -3753,9 +3892,21 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
@@ -3764,9 +3903,21 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
context_release(context);
/* Update every surface level of the texture. */
@@ -2834,7 +2834,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
{
unsigned int src_levels = src_texture->level_count;
unsigned int dst_levels = dst_texture->level_count;
@@ -3788,6 +3939,38 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
@@ -3799,6 +3950,38 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
FIXME("Unsupported texture type %#x.\n", type);
return WINED3DERR_INVALIDCALL;
}
@@ -2873,7 +2873,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
}
HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes)
@@ -3973,10 +4156,16 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
@@ -3984,10 +4167,16 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
if (dst_resource->type == WINED3D_RTYPE_BUFFER)
{
@@ -2890,7 +2890,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
return;
}
@@ -4097,8 +4286,14 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
@@ -4108,8 +4297,14 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL;
}
@@ -2905,7 +2905,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
}
if (dst_resource->type != WINED3D_RTYPE_TEXTURE_2D)
@@ -4244,10 +4439,15 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi
@@ -4255,10 +4450,15 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi
return WINED3DERR_INVALIDCALL;
}
@@ -2921,7 +2921,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
}
struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(const struct wined3d_device *device,
@@ -4817,7 +5017,11 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
@@ -4828,7 +5028,11 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
{
if (reset_state)
hr = wined3d_device_create_primary_opengl_context(device);
@@ -2933,7 +2933,7 @@ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
}
/* All done. There is no need to reload resources or shaders, this will happen automatically on the
@@ -5132,3 +5336,58 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
@@ -5143,3 +5347,58 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
else
return CallWindowProcA(proc, window, message, wparam, lparam);
}
@@ -3137,7 +3137,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
return hr;
}
@@ -2431,8 +2449,12 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
@@ -2432,8 +2450,12 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
{
struct wined3d_resource *resource = &s->container->resource;
struct wined3d_device *device = resource->device;
@@ -3150,7 +3150,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
const struct blit_shader *blitter;
HRESULT hr;
@@ -2443,6 +2465,7 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
@@ -2444,6 +2466,7 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
return WINED3DERR_INVALIDCALL;
}
@@ -3158,7 +3158,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
view_desc.format_id = resource->format->id;
view_desc.flags = 0;
view_desc.u.texture.level_idx = s->texture_level;
@@ -2458,6 +2481,19 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
@@ -2459,6 +2482,19 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
hr = blitter->color_fill(device, view, rect, color);
wined3d_rendertarget_view_decref(view);
@@ -3178,7 +3178,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
return hr;
}
@@ -2772,7 +2808,11 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
@@ -2773,7 +2809,11 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
/* Don't use PBOs for converted surfaces. During PBO conversion we look at
* WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is
* getting called. */
@@ -3190,7 +3190,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
{
TRACE("Removing the pbo attached to surface %p.\n", surface);
@@ -3737,7 +3777,11 @@ const struct blit_shader cpu_blit = {
@@ -3738,7 +3778,11 @@ const struct blit_shader cpu_blit = {
cpu_blit_blit_surface,
};
@@ -3202,26 +3202,21 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
{
@@ -3747,11 +3791,18 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3748,8 +3792,13 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
struct wined3d_texture *dst_texture = dst_surface->container;
struct wined3d_device *device = dst_texture->resource.device;
struct wined3d_swapchain *src_swapchain, *dst_swapchain;
+#if !defined(STAGING_CSMT)
struct wined3d_texture *src_texture = NULL;
unsigned int src_sub_resource_idx = 0;
DWORD src_ds_flags, dst_ds_flags;
BOOL scale, convert;
HRESULT hr;
+#else /* STAGING_CSMT */
+ struct wined3d_texture *src_texture;
+ unsigned int src_sub_resource_idx;
+ DWORD src_ds_flags, dst_ds_flags;
+ BOOL scale, convert;
+#endif /* STAGING_CSMT */
DWORD src_ds_flags, dst_ds_flags;
BOOL scale, convert;
static const DWORD simple_blit = WINED3D_BLT_ASYNC
| WINED3D_BLT_COLOR_FILL
@@ -3762,6 +3813,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3762,6 +3811,7 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
| WINED3D_BLT_DO_NOT_WAIT
| WINED3D_BLT_ALPHA_TEST;
@@ -3229,7 +3224,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
flags, fx, debug_d3dtexturefiltertype(filter));
@@ -3779,10 +3831,12 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3779,10 +3829,12 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
fx->src_color_key.color_space_high_value);
}
@@ -3241,8 +3236,8 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
+#if !defined(STAGING_CSMT)
}
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
@@ -3822,6 +3876,15 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
if (!fx || !(fx->fx))
@@ -3808,6 +3860,15 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
if (!once++)
FIXME("Can't handle WINED3D_BLT_DO_NOT_WAIT flag.\n");
flags &= ~WINED3D_BLT_DO_NOT_WAIT;
@@ -3258,7 +3253,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
}
if (!device->d3d_initialized)
@@ -3846,11 +3909,13 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3832,11 +3893,13 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
goto fallback;
}
@@ -3272,7 +3267,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
dst_swapchain = dst_texture->swapchain;
/* This isn't strictly needed. FBO blits for example could deal with
@@ -3886,13 +3951,21 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3872,15 +3935,26 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
TRACE("Depth fill.\n");
if (!wined3d_format_convert_color_to_float(dst_texture->resource.format, NULL, fx->fill_color, &color))
@@ -3288,25 +3283,18 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
+ return;
+#endif /* STAGING_CSMT */
}
else
else if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_texture->resource.draw_binding,
src_rect, dst_surface, dst_texture->resource.draw_binding, dst_rect)))
{
+#if !defined(STAGING_CSMT)
if (src_ds_flags != dst_ds_flags)
{
WARN("Rejecting depth / stencil blit between incompatible formats.\n");
@@ -3902,6 +3975,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_texture->resource.draw_binding,
src_rect, dst_surface, dst_texture->resource.draw_binding, dst_rect)))
return WINED3D_OK;
return WINED3D_OK;
+#else /* STAGING_CSMT */
+ if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_texture->resource.draw_binding,
+ src_rect, dst_surface, dst_texture->resource.draw_binding, dst_rect)))
+ return;
+ return;
+#endif /* STAGING_CSMT */
}
}
else
@@ -3937,7 +4015,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3916,7 +3990,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
goto fallback;
if (SUCCEEDED(surface_color_fill(dst_surface, dst_rect, &color)))
@@ -3318,7 +3306,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
}
else
{
@@ -3981,7 +4063,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3960,7 +4038,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
context, dst_texture->resource.draw_binding);
context_release(context);
}
@@ -3330,7 +3318,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
}
}
}
@@ -4005,7 +4091,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -3984,7 +4066,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
wined3d_swapchain_present(dst_swapchain, NULL, NULL, dst_swapchain->win_handle, 0);
dst_swapchain->desc.swap_effect = swap_effect;
@@ -3342,7 +3330,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
}
if (fbo_blit_supported(&device->adapter->gl_info, blit_op,
@@ -4026,7 +4116,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -4005,7 +4091,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx,
~dst_texture->resource.draw_binding);
@@ -3354,7 +3342,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
}
blitter = wined3d_select_blitter(&device->adapter->gl_info, &device->adapter->d3d_info, blit_op,
@@ -4036,7 +4130,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -4015,7 +4105,11 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
{
blitter->blit_surface(device, blit_op, filter, src_surface,
src_rect, dst_surface, dst_rect, color_key);
@@ -3366,7 +3354,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
}
}
}
@@ -4044,9 +4142,128 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
@@ -4023,9 +4117,81 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
fallback:
/* Special cases for render targets. */
if (SUCCEEDED(surface_blt_special(dst_surface, dst_rect, src_surface, src_rect, flags, fx, filter)))
@@ -3388,17 +3376,8 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const struct wined3d_blt_fx *fx, 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};
+ struct wined3d_texture *dst_texture = dst_surface->container;
+ struct wined3d_texture *src_texture = NULL;
+ struct wined3d_device *device = dst_texture->resource.device;
+ unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface), src_sub_resource_idx;
+ struct wined3d_texture_sub_resource *dst_sub_resource =
+ &dst_texture->sub_resources[dst_sub_resource_idx];
+ struct wined3d_texture_sub_resource *src_sub_resource = NULL;
+ DWORD src_ds_flags, dst_ds_flags;
+ HRESULT hr;
+
+ TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
+ dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
@@ -3417,44 +3396,6 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
+ fx->src_color_key.color_space_high_value);
+ }
+
+ if (src_surface)
+ {
+ src_texture = src_surface->container;
+ src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
+ src_sub_resource = &src_surface->container->sub_resources[src_sub_resource_idx];
+ }
+
+ if (dst_sub_resource->map_count || (src_sub_resource && src_sub_resource->map_count))
+ {
+ wined3d_cs_emit_sync(device->cs);
+ if (dst_sub_resource->map_count || (src_sub_resource && src_sub_resource->map_count))
+ {
+ WARN("Surface is busy, returning WINEDDERR_SURFACEBUSY.\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
+ }
+
+ if (FAILED(hr = wined3d_texture_check_box_dimensions(dst_texture, dst_surface->texture_level, &dst_box)))
+ return hr;
+
+ if (src_texture && FAILED(hr = wined3d_texture_check_box_dimensions(src_texture,
+ src_surface->texture_level, &src_box)))
+ return hr;
+
+ dst_ds_flags = dst_texture->resource.format_flags
+ & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+ if (src_surface)
+ src_ds_flags = src_surface->container->resource.format_flags
+ & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+ else
+ src_ds_flags = 0;
+
+ if (!(flags & WINED3D_BLT_DEPTH_FILL) && (src_ds_flags != dst_ds_flags))
+ {
+ WARN("Rejecting depth / stencil blit between incompatible formats.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ /* FIXME: We should select the blitter in the main thread, that way we can return an error if the blit
+ * is unsupported without duplicating all the checks... */
+ if (flags & WINED3D_BLT_COLOR_FILL && (dst_surface->container->resource.format_flags & WINED3DFMT_FLAG_BLOCKS))
@@ -3852,7 +3793,26 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
wined3d_texture_bind_and_dirtify(texture, context, FALSE);
@@ -3473,13 +3579,49 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
@@ -3190,8 +3296,18 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
|| (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
{
+#if !defined(STAGING_CSMT)
WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
return WINEDDERR_SURFACEBUSY;
+#else /* STAGING_CSMT */
+ wined3d_cs_emit_sync(dst_texture->resource.device->cs);
+ if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
+ || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
+ {
+ WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
+#endif /* STAGING_CSMT */
}
if ((dst_format_flags & WINED3DFMT_FLAG_BLOCKS) && (flags & WINED3D_BLT_COLOR_FILL))
@@ -3508,13 +3624,49 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
return WINED3D_OK;
}
@@ -3902,7 +3862,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
TRACE("texture %p, sub_resource_idx %u, dc %p.\n", texture, sub_resource_idx, dc);
@@ -3504,6 +3646,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
@@ -3539,6 +3691,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
if (texture->resource.map_count && !(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT))
return WINED3DERR_INVALIDCALL;
@@ -3910,7 +3870,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
if (device->d3d_initialized)
context = context_acquire(device, NULL, 0);
@@ -3521,11 +3664,40 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
@@ -3556,11 +3709,40 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
texture->flags |= WINED3D_TEXTURE_DC_IN_USE;
++texture->resource.map_count;
++sub_resource->map_count;
@@ -3951,7 +3911,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
}
HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC dc)
@@ -3556,6 +3728,7 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
@@ -3591,6 +3773,7 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
return WINED3DERR_INVALIDCALL;
}
@@ -3959,7 +3919,7 @@ diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
if (!(texture->resource.usage & WINED3DUSAGE_OWNDC) && !(device->wined3d->flags & WINED3D_NO3D))
wined3d_surface_destroy_dc(surface);
@@ -3566,4 +3739,9 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
@@ -3601,4 +3784,9 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
texture->flags &= ~WINED3D_TEXTURE_DC_IN_USE;
return WINED3D_OK;