Signed-off-by: Paul Gofman gofmanp@gmail.com --- v4: - changed condition in wined3d_texture_is_multisample_location(); - don't reevaluate 'scale' variable.
dlls/wined3d/surface.c | 15 ++++++--------- dlls/wined3d/wined3d_private.h | 7 +++++++ 2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 50f0c9c06c..f8d3a88e1f 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -175,13 +175,6 @@ void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *co break; }
- /* Resolve the source surface first if needed. */ - if (wined3d_texture_gl_is_multisample_location(wined3d_texture_gl(src_texture), src_location) - && (src_texture->resource.format->id != dst_texture->resource.format->id - || abs(src_rect->bottom - src_rect->top) != abs(dst_rect->bottom - dst_rect->top) - || abs(src_rect->right - src_rect->left) != abs(dst_rect->right - dst_rect->left))) - src_location = WINED3D_LOCATION_RB_RESOLVED; - /* Make sure the locations are up-to-date. Loading the destination * surface isn't required if the entire surface is overwritten. (And is * in fact harmful if we're being called by surface_load_location() with @@ -2402,7 +2395,7 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_ struct wined3d_device *device = dst_texture->resource.device; struct wined3d_swapchain *src_swapchain, *dst_swapchain; const struct wined3d_color_key *colour_key = NULL; - DWORD dst_location, valid_locations; + DWORD src_location, dst_location, valid_locations; DWORD src_ds_flags, dst_ds_flags; struct wined3d_context *context; enum wined3d_blit_op blit_op; @@ -2629,8 +2622,12 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_ dst_location = dst_texture->resource.map_binding;
context = context_acquire(device, dst_texture, dst_sub_resource_idx); + src_location = (scale || convert || blit_op != WINED3D_BLIT_OP_COLOR_BLIT) + && wined3d_texture_is_multisample_location(context, src_texture, + src_texture->resource.draw_binding) ? WINED3D_LOCATION_RB_RESOLVED + : src_texture->resource.draw_binding; valid_locations = device->blitter->ops->blitter_blit(device->blitter, blit_op, context, - src_texture, src_sub_resource_idx, src_texture->resource.draw_binding, &src_rect, + src_texture, src_sub_resource_idx, src_location, &src_rect, dst_texture, dst_sub_resource_idx, dst_location, &dst_rect, colour_key, filter); context_release(context);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 876c7212a0..df1dba9286 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3808,6 +3808,13 @@ static inline BOOL wined3d_texture_gl_is_multisample_location(const struct wined return texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE || texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY; }
+static inline BOOL wined3d_texture_is_multisample_location(const struct wined3d_context *context, + const struct wined3d_texture *texture, DWORD location) +{ + return location == context->d3d_info->multisample_draw_location + && texture->resource.multisample_type != WINED3D_MULTISAMPLE_NONE; +} + void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl, const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
If either source or destination is multisampled scaled FBO blit results in GL_INVALID_OPERATION. Fixes black screen in 'BlazBlue Calamity Trigger'.
Signed-off-by: Paul Gofman gofmanp@gmail.com --- v4: - no changes.
dlls/d3d9/tests/visual.c | 88 +++++++++++++++++++++++++++++----------- dlls/wined3d/surface.c | 13 ++++-- 2 files changed, 74 insertions(+), 27 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 62c053b212..0e71e23018 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -4332,7 +4332,7 @@ static void test_multisample_stretch_rect(void) D3DTEXF_POINT, D3DTEXF_LINEAR, }; - IDirect3DSurface9 *rt, *ms_rt, *rt_r5g6b5; + IDirect3DSurface9 *rt, *ms_rt, *ms_rt2, *rt_r5g6b5; struct surface_readback rb; IDirect3DDevice9 *device; DWORD quality_levels; @@ -4367,27 +4367,30 @@ static void test_multisample_stretch_rect(void)
hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL); - ok(hr == S_OK, "Failed to create render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, quality_levels - 1, FALSE, &ms_rt, NULL); - ok(hr == S_OK, "Failed to create render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128, + D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, quality_levels - 1, FALSE, &ms_rt2, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, ms_rt); - ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff00ff, 0.0f, 0); - ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt); - ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(filters); ++i) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); - ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, filters[i]); - ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); color = getPixelColor(device, 64, 64); - ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); }
/* Scaling */ @@ -4395,29 +4398,67 @@ static void test_multisample_stretch_rect(void) for (i = 0; i < ARRAY_SIZE(filters); ++i) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); - ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + hr = IDirect3DDevice9_StretchRect(device, rt, NULL, ms_rt2, NULL, D3DTEXF_NONE); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, &rect, filters[i]); - ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + get_rt_readback(rt, &rb); + color = get_readback_color(&rb, 32, 32); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); + color = get_readback_color(&rb, 64, 64); + ok(color == 0xffffffff, "Test %u, got unexpected color 0x%08x.\n", i, color); + color = get_readback_color(&rb, 96, 96); + ok(color == 0xffffffff, "Test %u, got unexpected color 0x%08x.\n", i, color); + release_surface_readback(&rb); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + hr = IDirect3DDevice9_StretchRect(device, ms_rt, &rect, rt, NULL, filters[i]); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); get_rt_readback(rt, &rb); color = get_readback_color(&rb, 32, 32); - ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); color = get_readback_color(&rb, 64, 64); - ok(color == 0xffffffff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); color = get_readback_color(&rb, 96, 96); - ok(color == 0xffffffff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); release_surface_readback(&rb);
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 0.0f, 0); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + hr = IDirect3DDevice9_StretchRect(device, rt, NULL, ms_rt, &rect, filters[i]); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); - ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); hr = IDirect3DDevice9_StretchRect(device, ms_rt, &rect, rt, NULL, filters[i]); - ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + get_rt_readback(rt, &rb); + color = get_readback_color(&rb, 32, 32); + ok(color == 0xffffff00, "Test %u, got unexpected color 0x%08x.\n", i, color); + color = get_readback_color(&rb, 64, 64); + ok(color == 0xffffff00, "Test %u, got unexpected color 0x%08x.\n", i, color); + color = get_readback_color(&rb, 96, 96); + ok(color == 0xffffff00, "Test %u, got unexpected color 0x%08x.\n", i, color); + release_surface_readback(&rb); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff00ff, 0.0f, 0); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + hr = IDirect3DDevice9_StretchRect(device, rt, NULL, ms_rt, NULL, D3DTEXF_NONE); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + + hr = IDirect3DDevice9_StretchRect(device, ms_rt, &rect, ms_rt2, NULL, filters[i]); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); + hr = IDirect3DDevice9_StretchRect(device, ms_rt2, &rect, rt, NULL, filters[i]); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); get_rt_readback(rt, &rb); color = get_readback_color(&rb, 32, 32); - ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); color = get_readback_color(&rb, 64, 64); - ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); color = get_readback_color(&rb, 96, 96); - ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); release_surface_readback(&rb); }
@@ -4433,18 +4474,19 @@ static void test_multisample_stretch_rect(void) for (i = 0; i < ARRAY_SIZE(filters); ++i) { hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); - ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt_r5g6b5, NULL, filters[i]); - ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); hr = IDirect3DDevice9_StretchRect(device, rt_r5g6b5, NULL, rt, NULL, filters[i]); - ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr); + ok(hr == D3D_OK, "Test %u, got unexpected hr %#x.\n", i, hr); color = getPixelColor(device, 64, 64); - ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color); + ok(color == 0x00ff00ff, "Test %u, got unexpected color 0x%08x.\n", i, color); }
IDirect3DSurface9_Release(rt_r5g6b5);
done: + IDirect3DSurface9_Release(ms_rt2); IDirect3DSurface9_Release(ms_rt); IDirect3DSurface9_Release(rt); refcount = IDirect3DDevice9_Release(device); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index f8d3a88e1f..a2158e66d5 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2622,10 +2622,15 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_ dst_location = dst_texture->resource.map_binding;
context = context_acquire(device, dst_texture, dst_sub_resource_idx); - src_location = (scale || convert || blit_op != WINED3D_BLIT_OP_COLOR_BLIT) - && wined3d_texture_is_multisample_location(context, src_texture, - src_texture->resource.draw_binding) ? WINED3D_LOCATION_RB_RESOLVED - : src_texture->resource.draw_binding; + src_location = src_texture->resource.draw_binding; + if (scale || convert || blit_op != WINED3D_BLIT_OP_COLOR_BLIT) + { + if (wined3d_texture_is_multisample_location(context, dst_texture, dst_location)) + dst_location = WINED3D_LOCATION_RB_RESOLVED; + + if (wined3d_texture_is_multisample_location(context, src_texture, src_location)) + src_location = WINED3D_LOCATION_RB_RESOLVED; + } valid_locations = device->blitter->ops->blitter_blit(device->blitter, blit_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);
Signed-off-by: Paul Gofman gofmanp@gmail.com --- v4: - change 'scaled_resolve' condition in wined3d_adapter_gl_init_d3d_info().
dlls/wined3d/adapter_gl.c | 3 +++ dlls/wined3d/surface.c | 12 +++++++++--- dlls/wined3d/wined3d_gl.h | 1 + dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index 6e60c5323e..49f7f8724d 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -179,6 +179,8 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_EXT_fog_coord", EXT_FOG_COORD }, {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT }, {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE }, + {"GL_EXT_framebuffer_multisample_blit_scaled", + EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED}, {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT }, {"GL_EXT_memory_object", EXT_MEMORY_OBJECT }, {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS }, @@ -5162,6 +5164,7 @@ static void wined3d_adapter_gl_init_d3d_info(struct wined3d_adapter_gl *adapter_ d3d_info->srgb_write_control = !!gl_info->supported[ARB_FRAMEBUFFER_SRGB]; d3d_info->clip_control = !!gl_info->supported[ARB_CLIP_CONTROL]; d3d_info->full_ffp_varyings = !!(shader_caps.wined3d_caps & WINED3D_SHADER_CAP_FULL_FFP_VARYINGS); + d3d_info->scaled_resolve = !!gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED]; d3d_info->feature_level = feature_level_from_caps(gl_info, &shader_caps, &fragment_caps);
if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index a2158e66d5..7beac9436b 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -150,6 +150,7 @@ void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *co const struct wined3d_gl_info *gl_info; struct wined3d_context_gl *context_gl; unsigned int restore_idx; + BOOL use_resolve_filter; GLenum gl_filter; GLenum buffer; RECT s, d; @@ -160,10 +161,14 @@ void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *co wined3d_debug_location(src_location), wine_dbgstr_rect(src_rect), dst_texture, dst_sub_resource_idx, wined3d_debug_location(dst_location), wine_dbgstr_rect(dst_rect));
+ use_resolve_filter = wined3d_texture_gl_is_multisample_location(wined3d_texture_gl(src_texture), src_location) + && (abs(src_rect->bottom - src_rect->top) != abs(dst_rect->bottom - dst_rect->top) + || abs(src_rect->right - src_rect->left) != abs(dst_rect->right - dst_rect->left)); + switch (filter) { case WINED3D_TEXF_LINEAR: - gl_filter = GL_LINEAR; + gl_filter = use_resolve_filter ? GL_SCALED_RESOLVE_NICEST_EXT : GL_LINEAR; break;
default: @@ -171,7 +176,7 @@ void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *co /* fall through */ case WINED3D_TEXF_NONE: case WINED3D_TEXF_POINT: - gl_filter = GL_NEAREST; + gl_filter = use_resolve_filter ? GL_SCALED_RESOLVE_FASTEST_EXT : GL_NEAREST; break; }
@@ -2628,7 +2633,8 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_ if (wined3d_texture_is_multisample_location(context, dst_texture, dst_location)) dst_location = WINED3D_LOCATION_RB_RESOLVED;
- if (wined3d_texture_is_multisample_location(context, src_texture, src_location)) + if ((!context->d3d_info->scaled_resolve || blit_op != WINED3D_BLIT_OP_COLOR_BLIT || convert) + && wined3d_texture_is_multisample_location(context, src_texture, src_location)) src_location = WINED3D_LOCATION_RB_RESOLVED; } valid_locations = device->blitter->ops->blitter_blit(device->blitter, blit_op, context, diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 3372b4b6be..2cb25a3776 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -160,6 +160,7 @@ enum wined3d_gl_extension EXT_FOG_COORD, EXT_FRAMEBUFFER_BLIT, EXT_FRAMEBUFFER_MULTISAMPLE, + EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED, EXT_FRAMEBUFFER_OBJECT, EXT_GPU_PROGRAM_PARAMETERS, EXT_GPU_SHADER4, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index df1dba9286..fa39661221 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -226,6 +226,7 @@ struct wined3d_d3d_info uint32_t srgb_write_control : 1; uint32_t clip_control : 1; uint32_t full_ffp_varyings : 1; + uint32_t scaled_resolve : 1; enum wined3d_feature_level feature_level;
DWORD multisample_draw_location;