Added patch to implement support for conservative depth access in SM4 shaders.

This commit is contained in:
Sebastian Lackner 2017-07-22 20:30:27 +02:00
parent 69e273a07f
commit 2cb3198298
5 changed files with 240 additions and 4 deletions

View File

@ -448,6 +448,7 @@ patch_enable_all ()
enable_wined3d_Silence_FIXMEs="$1"
enable_wined3d_WINED3DFMT_R32G32_UINT="$1"
enable_wined3d_buffer_create="$1"
enable_wined3d_convervative_depth="$1"
enable_wined3d_draw_primitive_arrays="$1"
enable_wined3d_sample_c_lz="$1"
enable_wined3d_wined3d_guess_gl_vendor="$1"
@ -1604,6 +1605,9 @@ patch_enable ()
wined3d-buffer_create)
enable_wined3d_buffer_create="$2"
;;
wined3d-convervative_depth)
enable_wined3d_convervative_depth="$2"
;;
wined3d-draw_primitive_arrays)
enable_wined3d_draw_primitive_arrays="$2"
;;
@ -2157,6 +2161,13 @@ if test "$enable_wined3d_CSMT_Main" -eq 1; then
enable_wined3d_CSMT_Helper=1
fi
if test "$enable_wined3d_convervative_depth" -eq 1; then
if test "$enable_wined3d_Copy_Resource_Typeless" -gt 1; then
abort "Patchset wined3d-Copy_Resource_Typeless disabled, but wined3d-convervative_depth depends on that."
fi
enable_wined3d_Copy_Resource_Typeless=1
fi
if test "$enable_wined3d_Core_Context" -eq 1; then
if test "$enable_d3d11_Depth_Bias" -gt 1; then
abort "Patchset d3d11-Depth_Bias disabled, but wined3d-Core_Context depends on that."
@ -9397,6 +9408,24 @@ if test "$enable_wined3d_buffer_create" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-convervative_depth
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * d3d11-Depth_Bias, wined3d-1DTextures, wined3d-Copy_Resource_Typeless
# |
# | Modified files:
# | * dlls/wined3d/arb_program_shader.c, dlls/wined3d/directx.c, dlls/wined3d/glsl_shader.c, dlls/wined3d/shader.c,
# | dlls/wined3d/shader_sm4.c, dlls/wined3d/wined3d_gl.h, dlls/wined3d/wined3d_private.h
# |
if test "$enable_wined3d_convervative_depth" -eq 1; then
patch_apply wined3d-convervative_depth/0001-wined3d-Recognize-conservative-depth-output-register.patch
patch_apply wined3d-convervative_depth/0002-wined3d-Add-conservative-depth-access-information-to.patch
(
printf '%s\n' '+ { "Michael Müller", "wined3d: Recognize conservative depth output registers in sm4.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Add conservative depth access information to glsl pixel shaders.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-draw_primitive_arrays
# |
# | Modified files:

View File

@ -619,7 +619,7 @@ diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2771,6 +2771,16 @@ struct wined3d_state
@@ -2773,6 +2773,16 @@ struct wined3d_state
struct wined3d_rasterizer_state *rasterizer_state;
};
@ -636,7 +636,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
#define WINED3D_UNMAPPED_STAGE ~0u
/* Multithreaded flag. Removed from the public header to signal that
@@ -2882,6 +2892,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
@@ -2884,6 +2894,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
@ -649,7 +649,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
{
@@ -3069,7 +3085,11 @@ struct wined3d_texture
@@ -3071,7 +3087,11 @@ struct wined3d_texture
unsigned int map_count;
DWORD locations;
@ -661,7 +661,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
} sub_resources[1];
};
@@ -3384,6 +3404,9 @@ struct wined3d_cs_queue
@@ -3386,6 +3406,9 @@ struct wined3d_cs_queue
struct wined3d_cs_ops
{

View File

@ -0,0 +1,105 @@
From 7789f436e67ba0cf5c4be29f06e006ad883ac3f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 22 Jul 2017 19:36:13 +0200
Subject: wined3d: Recognize conservative depth output registers in sm4.
---
dlls/wined3d/arb_program_shader.c | 2 ++
dlls/wined3d/glsl_shader.c | 2 ++
dlls/wined3d/shader.c | 8 ++++++++
dlls/wined3d/shader_sm4.c | 4 ++++
dlls/wined3d/wined3d_private.h | 4 ++++
5 files changed, 20 insertions(+)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 612a51b62b1..fa72b4f28b7 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -1194,6 +1194,8 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
sprintf(register_name, "%s", rastout_reg_names[reg->idx[0].offset]);
break;
+ case WINED3DSPR_DEPTHOUT_GREATER_EQUAL:
+ case WINED3DSPR_DEPTHOUT_LESS_EQUAL:
case WINED3DSPR_DEPTHOUT:
strcpy(register_name, "result.depth");
break;
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index e9baf40f859..df27c3286e7 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -2911,6 +2911,8 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
sprintf(register_name, "%s", hwrastout_reg_names[reg->idx[0].offset]);
break;
+ case WINED3DSPR_DEPTHOUT_GREATER_EQUAL:
+ case WINED3DSPR_DEPTHOUT_LESS_EQUAL:
case WINED3DSPR_DEPTHOUT:
sprintf(register_name, "gl_FragDepth");
break;
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 8827641e368..8485a0e784a 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -2108,6 +2108,14 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer,
shader_addline(buffer, "oC");
break;
+ case WINED3DSPR_DEPTHOUT_GREATER_EQUAL:
+ shader_addline(buffer, "oDepth_greater_equal");
+ break;
+
+ case WINED3DSPR_DEPTHOUT_LESS_EQUAL:
+ shader_addline(buffer, "oDepth_less_equal");
+ break;
+
case WINED3DSPR_DEPTHOUT:
shader_addline(buffer, "oDepth");
break;
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index 123ecbc78a4..88259977832 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -333,6 +333,8 @@ enum wined3d_sm4_register_type
WINED3D_SM5_RT_COVERAGE = 0x23,
WINED3D_SM5_RT_LOCAL_THREAD_INDEX = 0x24,
WINED3D_SM5_RT_GS_INSTANCE_ID = 0x25,
+ WINED3D_SM5_RT_DEPTHOUT_GREATER_EQUAL = 0x26,
+ WINED3D_SM5_RT_DEPTHOUT_LESS_EQUAL = 0x27,
};
enum wined3d_sm4_output_primitive_type
@@ -1148,6 +1150,8 @@ static const enum wined3d_shader_register_type register_type_table[] =
/* WINED3D_SM5_RT_COVERAGE */ WINED3DSPR_COVERAGE,
/* WINED3D_SM5_RT_LOCAL_THREAD_INDEX */ WINED3DSPR_LOCALTHREADINDEX,
/* WINED3D_SM5_RT_GS_INSTANCE_ID */ WINED3DSPR_GSINSTID,
+ /* WINED3D_SM5_RT_DEPTHOUT_GREATER_EQUAL */ WINED3DSPR_DEPTHOUT_GREATER_EQUAL,
+ /* WINED3D_SM5_RT_DEPTHOUT_LESS_EQUAL*/ WINED3DSPR_DEPTHOUT_LESS_EQUAL,
};
static const struct wined3d_sm4_opcode_info *get_opcode_info(enum wined3d_sm4_opcode opcode)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index eea73fa2965..040b068ad0e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -490,6 +490,8 @@ enum wined3d_shader_register_type
WINED3DSPR_COVERAGE,
WINED3DSPR_SAMPLEMASK,
WINED3DSPR_GSINSTID,
+ WINED3DSPR_DEPTHOUT_GREATER_EQUAL,
+ WINED3DSPR_DEPTHOUT_LESS_EQUAL,
};
enum wined3d_data_type
@@ -3987,6 +3989,8 @@ static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
return FALSE;
case WINED3DSPR_DEPTHOUT: /* oDepth */
+ case WINED3DSPR_DEPTHOUT_GREATER_EQUAL:
+ case WINED3DSPR_DEPTHOUT_LESS_EQUAL:
case WINED3DSPR_CONSTBOOL: /* b# */
case WINED3DSPR_LOOP: /* aL */
case WINED3DSPR_PREDICATE: /* p0 */
--
2.13.1

View File

@ -0,0 +1,100 @@
From 233f63ce576d8d2f321fb41c281a9ff1f62ae491 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 22 Jul 2017 19:39:40 +0200
Subject: wined3d: Add conservative depth access information to glsl pixel
shaders.
---
dlls/wined3d/directx.c | 1 +
dlls/wined3d/glsl_shader.c | 10 ++++++++++
dlls/wined3d/shader.c | 11 +++++++++++
dlls/wined3d/wined3d_gl.h | 1 +
dlls/wined3d/wined3d_private.h | 1 +
5 files changed, 24 insertions(+)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index d2815b8b3ac..82f6300d0f5 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -116,6 +116,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_clip_control", ARB_CLIP_CONTROL },
{"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
{"GL_ARB_compute_shader", ARB_COMPUTE_SHADER },
+ {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH },
{"GL_ARB_copy_buffer", ARB_COPY_BUFFER },
{"GL_ARB_copy_image", ARB_COPY_IMAGE },
{"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index df27c3286e7..c6c3011b9bb 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -7312,10 +7312,20 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
* nvidia drivers write a warning if we don't do so. */
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n");
+ if (gl_info->supported[ARB_CONSERVATIVE_DEPTH] && shader->u.ps.depth_compare)
+ shader_addline(buffer, "#extension GL_ARB_conservative_depth : enable\n");
/* Base Declarations */
shader_generate_glsl_declarations(context, buffer, shader, reg_maps, &priv_ctx);
+ if (gl_info->supported[ARB_CONSERVATIVE_DEPTH])
+ {
+ if (shader->u.ps.depth_compare == WINED3DSPR_DEPTHOUT_GREATER_EQUAL)
+ shader_addline(buffer, "layout (depth_greater) out float gl_FragDepth;\n");
+ else if (shader->u.ps.depth_compare == WINED3DSPR_DEPTHOUT_LESS_EQUAL)
+ shader_addline(buffer, "layout (depth_less) out float gl_FragDepth;\n");
+ }
+
/* Declare uniforms for NP2 texcoord fixup:
* This is NOT done inside the loop that declares the texture samplers
* since the NP2 fixup code is currently only used for the GeforceFX
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 8485a0e784a..e48709fb597 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1133,6 +1133,17 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
FIXME("Invalid instruction %#x for shader type %#x.\n",
ins.handler_idx, shader_version.type);
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT)
+ {
+ if (ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUT_GREATER_EQUAL ||
+ ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUT_LESS_EQUAL)
+ {
+ if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
+ shader->u.ps.depth_compare = ins.declaration.dst.reg.type;
+ else
+ FIXME("Invalid instruction depth declaration for shader type %#x.\n", shader_version.type);
+ }
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT)
{
if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h
index a048dc1d74e..4fe1971b5e6 100644
--- a/dlls/wined3d/wined3d_gl.h
+++ b/dlls/wined3d/wined3d_gl.h
@@ -50,6 +50,7 @@ enum wined3d_gl_extension
ARB_CLIP_CONTROL,
ARB_COLOR_BUFFER_FLOAT,
ARB_COMPUTE_SHADER,
+ ARB_CONSERVATIVE_DEPTH,
ARB_COPY_BUFFER,
ARB_COPY_IMAGE,
ARB_DEBUG_OUTPUT,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 040b068ad0e..b62aeb26bbd 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3899,6 +3899,7 @@ struct wined3d_pixel_shader
/* Some information about the shader behavior */
BOOL color0_mov;
DWORD color0_reg;
+ DWORD depth_compare;
};
struct wined3d_compute_shader
--
2.13.1

View File

@ -0,0 +1,2 @@
Fixes: Implement support for conservative depth access in SM4 shaders
Depends: wined3d-Copy_Resource_Typeless