Rebase against cb468b682d2b7d088d0607259affe1680b558e24.

Thanks to Henri Verbeet for his assistance.
This commit is contained in:
Zebediah Figura 2018-07-06 16:02:23 +02:00
parent 686ab91ec6
commit 8ed2ef6f5c
3 changed files with 56 additions and 235 deletions

View File

@ -52,7 +52,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "e7f5dc194aeb586bb516b5fd191ad6924c4fcdd3"
echo "cb468b682d2b7d088d0607259affe1680b558e24"
}
# Show version information
@ -7547,11 +7547,9 @@ fi
# | dlls/wined3d/shader.c, dlls/wined3d/state.c, dlls/wined3d/wined3d_private.h
# |
if test "$enable_wined3d_Dual_Source_Blending" -eq 1; then
patch_apply wined3d-Dual_Source_Blending/0001-wined3d-Unroll-glsl-pixel-shader-output.patch
patch_apply wined3d-Dual_Source_Blending/0002-d3d11-tests-Add-basic-dual-source-blend-test.patch
patch_apply wined3d-Dual_Source_Blending/0003-wined3d-Implement-dual-source-blending.patch
(
printf '%s\n' '+ { "Michael Müller", "wined3d: Unroll glsl pixel shader output.", 1 },';
printf '%s\n' '+ { "Michael Müller", "d3d11/tests: Add basic dual source blend test.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Implement dual source blending.", 1 },';
) >> "$patchlist"

View File

@ -1,155 +0,0 @@
From 9d3a4a7d1bdfe70717fb0e3b3fa9ec615a861f4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 18 Aug 2017 19:55:37 +0200
Subject: [PATCH] wined3d: Unroll glsl pixel shader output.
---
dlls/wined3d/glsl_shader.c | 53 +++++++++++++++++++++++++++++-----------------
1 file changed, 33 insertions(+), 20 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 583c014..bde786e 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -3017,7 +3017,8 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
WARN("Write to render target %u, only %d supported.\n",
reg->idx[0].offset, gl_info->limits.buffers);
- sprintf(register_name, "%s[%u]", get_fragment_output(gl_info), reg->idx[0].offset);
+ sprintf(register_name, needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[%u]" : "ps_out%u",
+ reg->idx[0].offset);
break;
case WINED3DSPR_RASTOUT:
@@ -7394,20 +7395,20 @@ static void shader_glsl_generate_patch_constant_setup(struct wined3d_string_buff
static void shader_glsl_generate_srgb_write_correction(struct wined3d_string_buffer *buffer,
const struct wined3d_gl_info *gl_info)
{
- const char *output = get_fragment_output(gl_info);
+ const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0";
- shader_addline(buffer, "tmp0.xyz = pow(%s[0].xyz, vec3(srgb_const0.x));\n", output);
+ shader_addline(buffer, "tmp0.xyz = pow(%s.xyz, vec3(srgb_const0.x));\n", output);
shader_addline(buffer, "tmp0.xyz = tmp0.xyz * vec3(srgb_const0.y) - vec3(srgb_const0.z);\n");
- shader_addline(buffer, "tmp1.xyz = %s[0].xyz * vec3(srgb_const0.w);\n", output);
- shader_addline(buffer, "bvec3 srgb_compare = lessThan(%s[0].xyz, vec3(srgb_const1.x));\n", output);
- shader_addline(buffer, "%s[0].xyz = mix(tmp0.xyz, tmp1.xyz, vec3(srgb_compare));\n", output);
- shader_addline(buffer, "%s[0] = clamp(%s[0], 0.0, 1.0);\n", output, output);
+ shader_addline(buffer, "tmp1.xyz = %s.xyz * vec3(srgb_const0.w);\n", output);
+ shader_addline(buffer, "bvec3 srgb_compare = lessThan(%s.xyz, vec3(srgb_const1.x));\n", output);
+ shader_addline(buffer, "%s.xyz = mix(tmp0.xyz, tmp1.xyz, vec3(srgb_compare));\n", output);
+ shader_addline(buffer, "%s = clamp(%s, 0.0, 1.0);\n", output, output);
}
static void shader_glsl_generate_fog_code(struct wined3d_string_buffer *buffer,
const struct wined3d_gl_info *gl_info, enum wined3d_ffp_ps_fog_mode mode)
{
- const char *output = get_fragment_output(gl_info);
+ const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0";
switch (mode)
{
@@ -7432,13 +7433,15 @@ static void shader_glsl_generate_fog_code(struct wined3d_string_buffer *buffer,
return;
}
- shader_addline(buffer, "%s[0].xyz = mix(ffp_fog.color.xyz, %s[0].xyz, clamp(fog, 0.0, 1.0));\n",
+ shader_addline(buffer, "%s.xyz = mix(ffp_fog.color.xyz, %s.xyz, clamp(fog, 0.0, 1.0));\n",
output, output);
}
static void shader_glsl_generate_alpha_test(struct wined3d_string_buffer *buffer,
const struct wined3d_gl_info *gl_info, enum wined3d_cmp_func alpha_func)
{
+ const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0";
+
/* alpha_func is the PASS condition, not the DISCARD condition. Instead of
* flipping all the operators here, just negate the comparison below. */
static const char * const comparison_operator[] =
@@ -7457,8 +7460,8 @@ static void shader_glsl_generate_alpha_test(struct wined3d_string_buffer *buffer
return;
if (alpha_func != WINED3D_CMP_NEVER)
- shader_addline(buffer, "if (!(%s[0].a %s alpha_test_ref))\n",
- get_fragment_output(gl_info), comparison_operator[alpha_func - WINED3D_CMP_NEVER]);
+ shader_addline(buffer, "if (!(%s.a %s alpha_test_ref))\n",
+ output, comparison_operator[alpha_func - WINED3D_CMP_NEVER]);
shader_addline(buffer, " discard;\n");
}
@@ -7502,10 +7505,11 @@ static void shader_glsl_generate_ps_epilogue(const struct wined3d_gl_info *gl_in
const struct ps_compile_args *args)
{
const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
+ const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0";
/* Pixel shaders < 2.0 place the resulting color in R0 implicitly. */
if (reg_maps->shader_version.major < 2)
- shader_addline(buffer, "%s[0] = R0;\n", get_fragment_output(gl_info));
+ shader_addline(buffer, "%s = R0;\n", output);
if (args->srgb_correction)
shader_glsl_generate_srgb_write_correction(buffer, gl_info);
@@ -7695,9 +7699,12 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
if (!needs_legacy_glsl_syntax(gl_info))
{
- if (shader_glsl_use_explicit_attrib_location(gl_info))
- shader_addline(buffer, "layout(location = 0) ");
- shader_addline(buffer, "out vec4 ps_out[%u];\n", gl_info->limits.buffers);
+ for (i = 0; i < gl_info->limits.buffers; i++)
+ {
+ if (shader_glsl_use_explicit_attrib_location(gl_info))
+ shader_addline(buffer, "layout(location = %u) ", i);
+ shader_addline(buffer, "out vec4 ps_out%u;\n", i);
+ }
}
if (shader->limits->constant_float + extra_constants_needed >= gl_info->limits.glsl_ps_float_constants)
@@ -9272,6 +9279,7 @@ static void shader_glsl_ffp_fragment_op(struct wined3d_string_buffer *buffer, un
static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *priv,
const struct ffp_frag_settings *settings, const struct wined3d_context *context)
{
+ const char *output = needs_legacy_glsl_syntax(context->gl_info) ? "gl_FragData[0]" : "ps_out0";
struct wined3d_string_buffer *tex_reg_name = string_buffer_get(&priv->string_buffers);
enum wined3d_cmp_func alpha_test_func = settings->alpha_test_func + 1;
struct wined3d_string_buffer *buffer = &priv->shader_buffer;
@@ -9360,7 +9368,7 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
{
if (shader_glsl_use_explicit_attrib_location(gl_info))
shader_addline(buffer, "layout(location = 0) ");
- shader_addline(buffer, "out vec4 ps_out[1];\n");
+ shader_addline(buffer, "out vec4 ps_out0;\n");
}
shader_addline(buffer, "vec4 tmp0, tmp1;\n");
@@ -9691,8 +9699,7 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
}
}
- shader_addline(buffer, "%s[0] = ffp_varying_specular * specular_enable + ret;\n",
- get_fragment_output(gl_info));
+ shader_addline(buffer, "%s = ffp_varying_specular * specular_enable + ret;\n", output);
if (settings->sRGB_write)
shader_glsl_generate_srgb_write_correction(buffer, gl_info);
@@ -10245,8 +10252,14 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
if (!needs_legacy_glsl_syntax(gl_info))
{
- GL_EXTCALL(glBindFragDataLocation(program_id, 0, "ps_out"));
- checkGLcall("glBindFragDataLocation");
+ for (i = 0; i < gl_info->limits.buffers; i++)
+ {
+ char var[12];
+
+ sprintf(var, "ps_out%u", i);
+ GL_EXTCALL(glBindFragDataLocation(program_id, i, var));
+ checkGLcall("glBindFragDataLocation");
+ }
}
}
--
2.7.4

View File

@ -1,23 +1,23 @@
From 95c99274a4dc0d36c3dc4436b21ebe0d3d046717 Mon Sep 17 00:00:00 2001
From e0d173b54b5c76ffc1eda2f973d0d470e3c20cca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 18 Aug 2017 23:51:59 +0200
Subject: [PATCH] wined3d: Implement dual source blending.
---
dlls/d3d11/tests/d3d11.c | 2 +-
dlls/wined3d/context.c | 11 ++++++++-
dlls/wined3d/directx.c | 12 ++++++++-
dlls/wined3d/glsl_shader.c | 45 ++++++++++++++++++++++++++--------
dlls/wined3d/context.c | 11 ++++++++++-
dlls/wined3d/directx.c | 10 ++++++++++
dlls/wined3d/glsl_shader.c | 20 +++++++++++++++++---
dlls/wined3d/shader.c | 2 ++
dlls/wined3d/state.c | 14 +++++++++--
dlls/wined3d/wined3d_private.h | 24 ++++++++++++++++--
7 files changed, 93 insertions(+), 17 deletions(-)
dlls/wined3d/state.c | 14 ++++++++++++--
dlls/wined3d/wined3d_private.h | 24 ++++++++++++++++++++++--
7 files changed, 74 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index fbb6794d725..075fe8f72cc 100644
index 413c07a..b44d5b5 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -27739,7 +27739,7 @@ static void test_dual_blending(void)
@@ -27727,7 +27727,7 @@ static void test_dual_blending(void)
ID3D11DeviceContext_ClearRenderTargetView(context, rtv[1], white);
ID3D11DeviceContext_Draw(context, 3, 0);
@ -27,7 +27,7 @@ index fbb6794d725..075fe8f72cc 100644
ID3D11BlendState_Release(blend_state);
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 21ad11d9586..ec5af4f5a46 100644
index 21ad11d..ec5af4f 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3131,10 +3131,19 @@ static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const
@ -52,10 +52,10 @@ index 21ad11d9586..ec5af4f5a46 100644
{
i = wined3d_bit_scan(&mask);
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index bfe743131fb..63cd4f33041 100644
index 9ecc4ed..dae2ba7 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -3528,6 +3528,12 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
@@ -3515,6 +3515,12 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
gl_info->limits.buffers = min(MAX_RENDER_TARGET_VIEWS, gl_max);
TRACE("Max draw buffers: %u.\n", gl_max);
}
@ -68,24 +68,22 @@ index bfe743131fb..63cd4f33041 100644
if (gl_info->supported[ARB_MULTITEXTURE])
{
if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
@@ -4327,7 +4333,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
@@ -4314,6 +4320,10 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
for (i = 0; i < gl_info->limits.buffers; ++i)
d3d_info->valid_rt_mask |= (1u << i);
- if (!d3d_info->shader_color_key)
+ d3d_info->valid_dual_rt_mask = 0;
+ for (i = 0; i < gl_info->limits.dual_buffers; ++i)
+ d3d_info->valid_dual_rt_mask |= (1u << i);
+
+ if (!d3d_info->shader_color_key)
if (!d3d_info->shader_color_key)
{
/* We do not want to deal with re-creating immutable texture storage for color keying emulation. */
WARN("Disabling ARB_texture_storage because fragment pipe doesn't support color keying.\n");
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 8003ca53e04..cbb3a8d2273 100644
index af50c8b..fc61b6f 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -3026,6 +3026,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
@@ -3036,6 +3036,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
break;
case WINED3DSPR_COLOROUT:
@ -93,68 +91,48 @@ index 8003ca53e04..cbb3a8d2273 100644
if (reg->idx[0].offset >= gl_info->limits.buffers)
WARN("Write to render target %u, only %d supported.\n",
reg->idx[0].offset, gl_info->limits.buffers);
@@ -7835,11 +7836,23 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
if (!needs_legacy_glsl_syntax(gl_info))
@@ -7892,7 +7893,10 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
{
- for (i = 0; i < gl_info->limits.buffers; i++)
const struct wined3d_shader_signature *output_signature = &shader->output_signature;
- shader_addline(buffer, "vec4 ps_out[%u];\n", gl_info->limits.buffers);
+ if (args->dual_source_blend)
{
- if (shader_glsl_use_explicit_attrib_location(gl_info))
- shader_addline(buffer, "layout(location = %u) ", i);
- shader_addline(buffer, "out vec4 ps_out%u;\n", i);
+ for (i = 0; i < gl_info->limits.dual_buffers * 2; i++)
+ {
+ if (shader_glsl_use_explicit_attrib_location(gl_info))
+ shader_addline(buffer, "layout(location = %u, index = %u) ", i / 2, i % 2);
+ shader_addline(buffer, "out vec4 ps_out%u;\n", i);
+ }
+ }
+ shader_addline(buffer, "vec4 ps_out[%u];\n", gl_info->limits.dual_buffers * 2);
+ else
+ {
+ for (i = 0; i < gl_info->limits.buffers; i++)
+ {
+ if (shader_glsl_use_explicit_attrib_location(gl_info))
+ shader_addline(buffer, "layout(location = %u) ", i);
+ shader_addline(buffer, "out vec4 ps_out%u;\n", i);
+ }
}
}
@@ -10445,13 +10458,25 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
if (!needs_legacy_glsl_syntax(gl_info))
+ shader_addline(buffer, "vec4 ps_out[%u];\n", gl_info->limits.buffers);
if (output_signature->element_count)
{
- for (i = 0; i < gl_info->limits.buffers; i++)
- {
- char var[12];
+ char var[12];
- sprintf(var, "ps_out%u", i);
- GL_EXTCALL(glBindFragDataLocation(program_id, i, var));
- checkGLcall("glBindFragDataLocation");
+ if (wined3d_dualblend_enabled(state, gl_info))
+ {
+ for (i = 0; i < gl_info->limits.dual_buffers * 2; i++)
for (i = 0; i < output_signature->element_count; ++i)
@@ -7907,7 +7911,12 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
continue;
}
if (shader_glsl_use_explicit_attrib_location(gl_info))
- shader_addline(buffer, "layout(location = %u) ", output->semantic_idx);
+ {
+ sprintf(var, "ps_out%u", i);
+ GL_EXTCALL(glBindFragDataLocationIndexed(program_id, i / 2, i % 2, var));
+ checkGLcall("glBindFragDataLocationIndexed");
+ if (args->dual_source_blend)
+ shader_addline(buffer, "layout(location = %u, index = %u) ", output->semantic_idx / 2, output->semantic_idx % 2);
+ else
+ shader_addline(buffer, "layout(location = %u) ", output->semantic_idx);
+ }
+ }
+ else
+ {
+ for (i = 0; i < gl_info->limits.buffers; i++)
shader_addline(buffer, "out %s4 color_out%u;\n",
component_type_info[output->component_type].glsl_vector_type, output->semantic_idx);
}
@@ -7920,7 +7929,12 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
{
i = wined3d_bit_scan(&mask);
if (shader_glsl_use_explicit_attrib_location(gl_info))
- shader_addline(buffer, "layout(location = %u) ", i);
+ {
+ sprintf(var, "ps_out%u", i);
+ GL_EXTCALL(glBindFragDataLocation(program_id, i, var));
+ checkGLcall("glBindFragDataLocation");
+ if (args->dual_source_blend)
+ shader_addline(buffer, "layout(location = %u, index = %u) ", i / 2, i % 2);
+ else
+ shader_addline(buffer, "layout(location = %u) ", i);
+ }
shader_addline(buffer, "out vec4 color_out%u;\n", i);
}
}
}
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 20d4f0773dd..f2e3c23976f 100644
index 20d4f07..f2e3c23 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -4101,6 +4101,8 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
@ -167,7 +145,7 @@ index 20d4f0773dd..f2e3c23976f 100644
static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 2dd6ac2a639..a2e95a4a568 100644
index 3b2f845..6d243a4 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -533,12 +533,14 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st
@ -210,10 +188,10 @@ index 2dd6ac2a639..a2e95a4a568 100644
state->render_states[WINED3D_RS_SRCBLEND],
state->render_states[WINED3D_RS_DESTBLEND], rt_format);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 80d7dcf3ccb..13cef2c7af9 100644
index a25c296..b41d65c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -194,6 +194,7 @@ struct wined3d_d3d_info
@@ -190,6 +190,7 @@ struct wined3d_d3d_info
BOOL vs_clipping;
BOOL shader_color_key;
DWORD valid_rt_mask;
@ -221,7 +199,7 @@ index 80d7dcf3ccb..13cef2c7af9 100644
DWORD wined3d_creation_flags;
BOOL shader_double_precision;
enum wined3d_feature_level feature_level;
@@ -1355,7 +1356,8 @@ struct ps_compile_args
@@ -1351,7 +1352,8 @@ struct ps_compile_args
DWORD flatshading : 1;
DWORD alpha_test_func : 3;
DWORD render_offscreen : 1;
@ -231,7 +209,7 @@ index 80d7dcf3ccb..13cef2c7af9 100644
};
enum fog_src_type
@@ -1915,7 +1917,8 @@ struct wined3d_context
@@ -1911,7 +1913,8 @@ struct wined3d_context
DWORD transform_feedback_paused : 1;
DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
@ -241,7 +219,7 @@ index 80d7dcf3ccb..13cef2c7af9 100644
DWORD constant_update_mask;
DWORD numbered_array_mask;
@@ -2540,6 +2543,7 @@ struct wined3d_fbo_ops
@@ -2536,6 +2539,7 @@ struct wined3d_fbo_ops
struct wined3d_gl_limits
{
UINT buffers;
@ -249,7 +227,7 @@ index 80d7dcf3ccb..13cef2c7af9 100644
UINT lights;
UINT textures;
UINT texture_coords;
@@ -2881,6 +2885,22 @@ struct wined3d_state
@@ -2877,6 +2881,22 @@ struct wined3d_state
struct wined3d_rasterizer_state *rasterizer_state;
};
@ -273,5 +251,5 @@ index 80d7dcf3ccb..13cef2c7af9 100644
{
GLuint tex_1d;
--
2.17.1
2.7.4