From 9fbebe7a463a6852c15b79b8e8a74b0884ed3cbe Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Tue, 22 Aug 2017 00:17:19 +0200 Subject: [PATCH] Added patch to allow arbitrary viewports for d3d11 in wined3d. --- patches/patchinstall.sh | 27 +++ ...-Allow-arbitrary-viewports-for-d3d11.patch | 181 ++++++++++++++++++ patches/wined3d-Viewports/definition | 2 + 3 files changed, 210 insertions(+) create mode 100644 patches/wined3d-Viewports/0001-wined3d-Allow-arbitrary-viewports-for-d3d11.patch create mode 100644 patches/wined3d-Viewports/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 05b3312e..50fa72e9 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -457,6 +457,7 @@ patch_enable_all () enable_wined3d_Revert_Buffer_Upload="$1" enable_wined3d_Silence_FIXMEs="$1" enable_wined3d_UAV_Counters="$1" + enable_wined3d_Viewports="$1" enable_wined3d_WINED3DFMT_R32G32_UINT="$1" enable_wined3d_WINED3D_RS_COLORWRITEENABLE="$1" enable_wined3d_buffer_create="$1" @@ -1644,6 +1645,9 @@ patch_enable () wined3d-UAV_Counters) enable_wined3d_UAV_Counters="$2" ;; + wined3d-Viewports) + enable_wined3d_Viewports="$2" + ;; wined3d-WINED3DFMT_R32G32_UINT) enable_wined3d_WINED3DFMT_R32G32_UINT="$2" ;; @@ -2223,6 +2227,13 @@ if test "$enable_wined3d_WINED3D_RS_COLORWRITEENABLE" -eq 1; then enable_d3d11_Depth_Bias=1 fi +if test "$enable_wined3d_Viewports" -eq 1; then + if test "$enable_wined3d_Core_Context" -gt 1; then + abort "Patchset wined3d-Core_Context disabled, but wined3d-Viewports depends on that." + fi + enable_wined3d_Core_Context=1 +fi + if test "$enable_wined3d_DrawIndirect" -eq 1; then if test "$enable_wined3d_draw_primitive_arrays" -gt 1; then abort "Patchset wined3d-draw_primitive_arrays disabled, but wined3d-DrawIndirect depends on that." @@ -9734,6 +9745,22 @@ if test "$enable_wined3d_Limit_Vram" -eq 1; then ) >> "$patchlist" fi +# Patchset wined3d-Viewports +# | +# | This patchset has the following (direct or indirect) dependencies: +# | * d3d11-Depth_Bias, wined3d-Core_Context +# | +# | Modified files: +# | * dlls/d3d11/tests/d3d11.c, dlls/d3d8/directx.c, dlls/d3d9/directx.c, dlls/ddraw/ddraw_private.h, dlls/wined3d/state.c, +# | include/wine/wined3d.h +# | +if test "$enable_wined3d_Viewports" -eq 1; then + patch_apply wined3d-Viewports/0001-wined3d-Allow-arbitrary-viewports-for-d3d11.patch + ( + printf '%s\n' '+ { "Michael Müller", "wined3d: Allow arbitrary viewports for d3d11.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wined3d-WINED3DFMT_R32G32_UINT # | # | Modified files: diff --git a/patches/wined3d-Viewports/0001-wined3d-Allow-arbitrary-viewports-for-d3d11.patch b/patches/wined3d-Viewports/0001-wined3d-Allow-arbitrary-viewports-for-d3d11.patch new file mode 100644 index 00000000..c4772869 --- /dev/null +++ b/patches/wined3d-Viewports/0001-wined3d-Allow-arbitrary-viewports-for-d3d11.patch @@ -0,0 +1,181 @@ +From 3ad3617ce54aec7da8800ea0d8bb8cb18fbc4494 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Thu, 17 Aug 2017 19:29:30 +0200 +Subject: wined3d: Allow arbitrary viewports for d3d11. + +--- + dlls/d3d11/tests/d3d11.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ + dlls/d3d8/directx.c | 2 +- + dlls/d3d9/directx.c | 2 +- + dlls/ddraw/ddraw_private.h | 2 +- + dlls/wined3d/state.c | 23 +++++++++++-------- + include/wine/wined3d.h | 1 + + 6 files changed, 73 insertions(+), 12 deletions(-) + +diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c +index b3c7ef47aab..b1bc6620c7f 100644 +--- a/dlls/d3d11/tests/d3d11.c ++++ b/dlls/d3d11/tests/d3d11.c +@@ -21926,6 +21926,60 @@ static void test_fractional_viewports(void) + release_test_context(&test_context); + } + ++static void test_negative_viewports(void) ++{ ++ struct d3d11_test_context test_context; ++ ID3D11DeviceContext *context; ++ D3D11_VIEWPORT vp; ++ DWORD color; ++ ++ static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f}; ++ static const struct vec4 white = {1.0f, 1.0f, 1.0f, 1.0f}; ++ ++ if (!init_test_context(&test_context, NULL)) ++ return; ++ ++ context = test_context.immediate_context; ++ ++ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red); ++ draw_color_quad(&test_context, &white); ++ color = get_texture_color(test_context.backbuffer, 320, 240); ++ ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color); ++ ++ vp.TopLeftX = -640; ++ vp.TopLeftY = 0; ++ vp.Width = 640 * 2; ++ vp.Height = 480; ++ vp.MinDepth = 0.0f; ++ vp.MaxDepth = 1.0f; ++ ID3D11DeviceContext_RSSetViewports(context, 1, &vp); ++ ++ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red); ++ draw_color_quad(&test_context, &white); ++ color = get_texture_color(test_context.backbuffer, 320, 240); ++ ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color); ++ ++ vp.Width = 640; ++ ID3D11DeviceContext_RSSetViewports(context, 1, &vp); ++ ++ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red); ++ draw_color_quad(&test_context, &white); ++ color = get_texture_color(test_context.backbuffer, 320, 240); ++ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); ++ ++ vp.Width = 640 + 320; ++ ID3D11DeviceContext_RSSetViewports(context, 1, &vp); ++ ++ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red); ++ draw_color_quad(&test_context, &white); ++ color = get_texture_color(test_context.backbuffer, 320, 240); ++ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); ++ color = get_texture_color(test_context.backbuffer, 319, 240); ++ ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color); ++ ++ release_test_context(&test_context); ++} ++ + static void test_early_depth_stencil(void) + { + ID3D11DepthStencilState *depth_stencil_state; +@@ -22148,5 +22202,6 @@ START_TEST(d3d11) + test_gather(); + test_gather_c(); + test_fractional_viewports(); ++ test_negative_viewports(); + test_early_depth_stencil(); + } +diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c +index 24bd8315983..491efea31e2 100644 +--- a/dlls/d3d8/directx.c ++++ b/dlls/d3d8/directx.c +@@ -418,7 +418,7 @@ BOOL d3d8_init(struct d3d8 *d3d8) + DWORD flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING + | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER + | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART +- | WINED3D_LEGACY_CUBEMAP_FILTERING; ++ | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT; + + d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl; + d3d8->refcount = 1; +diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c +index fe7163fa88a..c1389529588 100644 +--- a/dlls/d3d9/directx.c ++++ b/dlls/d3d9/directx.c +@@ -580,7 +580,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended) + { + DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER + | WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR +- | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING; ++ | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT; + + if (!extended) + flags |= WINED3D_VIDMEM_ACCOUNTING; +diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h +index c693135e84b..912e8b6f531 100644 +--- a/dlls/ddraw/ddraw_private.h ++++ b/dlls/ddraw/ddraw_private.h +@@ -63,7 +63,7 @@ struct FvfToDecl + #define DDRAW_WINED3D_FLAGS (WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING \ + | WINED3D_RESTORE_MODE_ON_ACTIVATE | WINED3D_FOCUS_MESSAGES | WINED3D_PIXEL_CENTER_INTEGER \ + | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART \ +- | WINED3D_LEGACY_CUBEMAP_FILTERING) ++ | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT) + + enum ddraw_device_state + { +diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c +index a5a1a4bf90c..4424da4e850 100644 +--- a/dlls/wined3d/state.c ++++ b/dlls/wined3d/state.c +@@ -4629,11 +4629,13 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine + + if (target) + { +- if (vp.width > target->width) +- vp.width = target->width; +- if (vp.height > target->height) +- vp.height = target->height; +- ++ if (context->d3d_info->wined3d_creation_flags & WINED3D_LIMIT_VIEWPORT) ++ { ++ if (vp.width > target->width) ++ vp.width = target->width; ++ if (vp.height > target->height) ++ vp.height = target->height; ++ } + wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height); + } + else if (depth_stencil) +@@ -4675,10 +4677,13 @@ static void viewport_miscpart_cc(struct wined3d_context *context, + + if (target) + { +- if (vp.width > target->width) +- vp.width = target->width; +- if (vp.height > target->height) +- vp.height = target->height; ++ if (context->d3d_info->wined3d_creation_flags & WINED3D_LIMIT_VIEWPORT) ++ { ++ if (vp.width > target->width) ++ vp.width = target->width; ++ if (vp.height > target->height) ++ vp.height = target->height; ++ } + + wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height); + } +diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h +index 4378ba20fcb..df587733b20 100644 +--- a/include/wine/wined3d.h ++++ b/include/wine/wined3d.h +@@ -1325,6 +1325,7 @@ enum wined3d_shader_byte_code_format + #define WINED3D_LEGACY_CUBEMAP_FILTERING 0x00001000 + #define WINED3D_FORWARD_DEPTH_BIAS 0x00002000 + #define WINED3D_REQUEST_D3D10 0x00004000 ++#define WINED3D_LIMIT_VIEWPORT 0x00008000 + + #define WINED3D_RESZ_CODE 0x7fa05000 + +-- +2.14.1 + diff --git a/patches/wined3d-Viewports/definition b/patches/wined3d-Viewports/definition new file mode 100644 index 00000000..03d449ca --- /dev/null +++ b/patches/wined3d-Viewports/definition @@ -0,0 +1,2 @@ +Fixes: Allow arbitrary viewports for d3d11 in wined3d +Depends: wined3d-Core_Context