Matteo Bruni : wined3d: Add RESZ support.
Alexandre Julliard
julliard at winehq.org
Tue Feb 19 13:33:03 CST 2013
Module: wine
Branch: master
Commit: 5e28b0c9747369b752102e56b94e58a012b8cf6d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5e28b0c9747369b752102e56b94e58a012b8cf6d
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Mon Feb 18 13:56:23 2013 +0100
wined3d: Add RESZ support.
---
dlls/wined3d/device.c | 22 ++++++++++++++++++++++
dlls/wined3d/utils.c | 11 +++++++++++
include/wine/wined3d.h | 3 +++
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index bbd27df..c7874ba 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2212,6 +2212,22 @@ void CDECL wined3d_device_get_viewport(const struct wined3d_device *device, stru
*viewport = device->stateBlock->state.viewport;
}
+static void resolve_depth_buffer(struct wined3d_state *state)
+{
+ struct wined3d_texture *texture = state->textures[0];
+ struct wined3d_surface *depth_stencil, *surface;
+
+ if (!texture || texture->resource.type != WINED3D_RTYPE_TEXTURE
+ || !(texture->resource.format->flags & WINED3DFMT_FLAG_DEPTH))
+ return;
+ surface = surface_from_resource(texture->sub_resources[0]);
+ depth_stencil = state->fb->depth_stencil;
+ if (!depth_stencil)
+ return;
+
+ wined3d_surface_blt(surface, NULL, depth_stencil, NULL, 0, NULL, WINED3D_TEXF_POINT);
+}
+
void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
enum wined3d_render_state state, DWORD value)
{
@@ -2234,6 +2250,12 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
TRACE("Application is setting the old value over, nothing to do.\n");
else
device_invalidate_state(device, STATE_RENDER(state));
+
+ if (state == WINED3D_RS_POINTSIZE && value == WINED3D_RESZ_CODE)
+ {
+ TRACE("RESZ multisampled depth buffer resolve triggered.\n");
+ resolve_depth_buffer(&device->stateBlock->state);
+ }
}
DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state state)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 4b29ec8..7c508ee 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -126,6 +126,7 @@ static const struct wined3d_format_channels formats[] =
{WINED3DFMT_NVDB, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{WINED3DFMT_INST, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{WINED3DFMT_INTZ, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 8},
+ {WINED3DFMT_RESZ, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{WINED3DFMT_NVHU, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
{WINED3DFMT_NVHS, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
{WINED3DFMT_NULL, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
@@ -1712,6 +1713,15 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
gl_info->formats[idx].flags |= WINED3DFMT_FLAG_TEXTURE;
}
+ /* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
+ * support by checking for availability of MAKEFOURCC('R','E','S','Z') surfaces with
+ * RENDERTARGET usage. */
+ if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
+ {
+ idx = getFmtIdx(WINED3DFMT_RESZ);
+ gl_info->formats[idx].flags |= WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET;
+ }
+
for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)
{
struct wined3d_format *format = &gl_info->formats[idx];
@@ -1975,6 +1985,7 @@ const char *debug_d3dformat(enum wined3d_format_id format_id)
FMT_TO_STR(WINED3DFMT_B8G8R8A8_UNORM);
FMT_TO_STR(WINED3DFMT_B8G8R8X8_UNORM);
FMT_TO_STR(WINED3DFMT_INTZ);
+ FMT_TO_STR(WINED3DFMT_RESZ);
FMT_TO_STR(WINED3DFMT_NULL);
FMT_TO_STR(WINED3DFMT_R16);
FMT_TO_STR(WINED3DFMT_AL16);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 723d938..378a46b 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -245,6 +245,7 @@ enum wined3d_format_id
WINED3DFMT_NVHU = WINEMAKEFOURCC('N','V','H','U'),
WINED3DFMT_NVHS = WINEMAKEFOURCC('N','V','H','S'),
WINED3DFMT_INTZ = WINEMAKEFOURCC('I','N','T','Z'),
+ WINED3DFMT_RESZ = WINEMAKEFOURCC('R','E','S','Z'),
WINED3DFMT_NULL = WINEMAKEFOURCC('N','U','L','L'),
WINED3DFMT_R16 = WINEMAKEFOURCC(' ','R','1','6'),
WINED3DFMT_AL16 = WINEMAKEFOURCC('A','L','1','6'),
@@ -1216,6 +1217,8 @@ enum wined3d_display_rotation
#define WINED3D_LEGACY_DEPTH_BIAS 0x00000001
#define WINED3D_NO3D 0x00000002
+#define WINED3D_RESZ_CODE 0x7fa05000
+
/* dwDDFX */
/* arithmetic stretching along y axis */
#define WINEDDBLTFX_ARITHSTRETCHY 0x00000001
More information about the wine-cvs
mailing list