From a6d26527c61178a4408ce37833ab281f05248fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 24 Jul 2017 00:15:55 +0200 Subject: [PATCH] wined3d: Implement forceEarlyDepthStencil shader global flag. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 3 +++ dlls/wined3d/shader.c | 23 +++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 3 +++ 3 files changed, 29 insertions(+) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index f96f48d97d1..7290fc71a12 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -7393,6 +7393,9 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context if (shader->limits->constant_float + extra_constants_needed >= gl_info->limits.glsl_ps_float_constants) FIXME("Insufficient uniforms to run this shader.\n"); + if (shader->u.ps.force_early_depth_stencil) + shader_addline(buffer, "layout(early_fragment_tests) in;\n"); + shader_addline(buffer, "void main()\n{\n"); /* Direct3D applications expect integer vPos values, while OpenGL drivers diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 8827641e368..d9504ef9ceb 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1085,6 +1085,21 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st else reg_maps->cb_sizes[reg->idx[0].offset] = reg->idx[1].offset; } + else if (ins.handler_idx == WINED3DSIH_DCL_GLOBAL_FLAGS) + { + if (ins.flags & WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL) + { + if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL) + shader->u.ps.force_early_depth_stencil = TRUE; + else + FIXME("Invalid instruction %#x for shader type %#x.\n", + ins.handler_idx, shader_version.type); + } + else + { + WARN("Ignoring global flags %#x.\n", ins.flags); + } + } else if (ins.handler_idx == WINED3DSIH_DCL_GS_INSTANCES) { if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY) @@ -1760,6 +1775,14 @@ static void shader_dump_global_flags(struct wined3d_string_buffer *buffer, DWORD shader_addline(buffer, " | "); } + if (global_flags & WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL) + { + shader_addline(buffer, "forceEarlyDepthStencil"); + global_flags &= ~WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL; + if (global_flags) + shader_addline(buffer, " | "); + } + if (global_flags & WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS) { shader_addline(buffer, "enableRawAndStructuredBuffers"); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ccf05635f0e..eae451bf5e3 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -559,6 +559,7 @@ enum wined3d_shader_interpolation_mode enum wined3d_shader_global_flags { WINED3DSGF_REFACTORING_ALLOWED = 0x1, + WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x4, WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x8, }; @@ -3866,6 +3867,8 @@ struct wined3d_pixel_shader /* Some information about the shader behavior */ BOOL color0_mov; DWORD color0_reg; + + BOOL force_early_depth_stencil; }; struct wined3d_compute_shader