Added patch to emulate textureLod(samplerCubeShadow, ...) in wined3d using shadowCubeGrad.

This commit is contained in:
Sebastian Lackner 2017-07-11 22:21:35 +02:00
parent e2a70628df
commit e3b7fd770e
2 changed files with 118 additions and 0 deletions

View File

@ -9295,8 +9295,10 @@ fi
# |
if test "$enable_wined3d_sample_c_lz" -eq 1; then
patch_apply wined3d-sample_c_lz/0001-wined3d-Emulate-sample_c_lz-using-textureGradOffset-.patch
patch_apply wined3d-sample_c_lz/0002-wined3d-Emulate-textureLod-samplerCubeShadow-.-using.patch
(
printf '%s\n' '+ { "Michael Müller", "wined3d: Emulate sample_c_lz using textureGradOffset for sampler2DArrayShadow.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Emulate textureLod(samplerCubeShadow, ...) using shadowCubeGrad.", 1 },';
) >> "$patchlist"
fi

View File

@ -0,0 +1,116 @@
From d905b0fdca811863cb7966259cb2efe173a63fd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 11 Jul 2017 22:17:55 +0200
Subject: wined3d: Emulate textureLod(samplerCubeShadow, ...) using
shadowCubeGrad.
---
dlls/wined3d/glsl_shader.c | 54 ++++++++++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 82cca841475..1a446fe62a4 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -91,7 +91,7 @@ struct glsl_sample_function
enum wined3d_data_type data_type;
BOOL output_single_component;
unsigned int offset_size;
- BOOL emulate_lod;
+ enum wined3d_shader_resource_type emulate_lod;
};
enum heap_node_op
@@ -3417,6 +3417,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
enum wined3d_shader_resource_type resource_type = ctx->reg_maps->resource_info[resource_idx].type;
struct shader_glsl_ctx_priv *priv = ctx->backend_data;
const struct wined3d_gl_info *gl_info = ctx->gl_info;
+ BOOL legacy_syntax = needs_legacy_glsl_syntax(gl_info);
BOOL shadow = glsl_is_shadow_sampler(ctx->shader, priv->cur_ps_args, resource_idx, sampler_idx);
BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED;
BOOL texrect = ctx->reg_maps->shader_version.type == WINED3D_SHADER_TYPE_PIXEL
@@ -3429,6 +3430,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
unsigned int coord_size, deriv_size;
sample_function->data_type = ctx->reg_maps->resource_info[resource_idx].data_type;
+ sample_function->emulate_lod = WINED3D_SHADER_RESOURCE_NONE;
if (resource_type >= ARRAY_SIZE(resource_type_info))
{
@@ -3440,19 +3442,30 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
if (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_CUBE)
projected = FALSE;
- /* emulate textureLod(sampler2DArrayShadow, ...) using textureGradOffset */
- if (shadow && lod && resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY)
+ if (shadow && lod)
{
- sample_function->emulate_lod = TRUE;
- grad = offset = TRUE;
- lod = FALSE;
- }
- else
- {
- sample_function->emulate_lod = FALSE;
+ switch (resource_type)
+ {
+ /* emulate textureLod(sampler2DArrayShadow, ...) using textureGradOffset */
+ case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY:
+ sample_function->emulate_lod = resource_type;
+ grad = offset = TRUE;
+ lod = FALSE;
+ break;
+
+ /* emulate textureLod(samplerCubeShadow, ...) using shadowCubeGrad */
+ case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
+ sample_function->emulate_lod = resource_type;
+ grad = legacy_syntax = TRUE;
+ lod = FALSE;
+ break;
+
+ default:
+ break;
+ }
}
- if (needs_legacy_glsl_syntax(gl_info))
+ if (legacy_syntax)
{
if (shadow)
base = "shadow";
@@ -3492,7 +3505,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
sample_function->offset_size = offset ? deriv_size : 0;
sample_function->coord_mask = (1u << coord_size) - 1;
sample_function->deriv_mask = (1u << deriv_size) - 1;
- sample_function->output_single_component = shadow && !needs_legacy_glsl_syntax(gl_info);
+ sample_function->output_single_component = shadow && !legacy_syntax;
}
static void shader_glsl_release_sample_function(const struct wined3d_shader_context *ctx,
@@ -3685,8 +3698,21 @@ static void PRINTF_ATTR(9, 10) shader_glsl_gen_sample_code(const struct wined3d_
if (sample_function->emulate_lod)
{
if (strcmp(bias, "0")) FIXME("Don't know how to emulate lod level %s\n", bias);
- if (!dx) dx = "vec2(0.0, 0.0)";
- if (!dy) dy = "vec2(0.0, 0.0)";
+ switch (sample_function->emulate_lod)
+ {
+ case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY:
+ if (!dx) dx = "vec2(0.0, 0.0)";
+ if (!dy) dy = "vec2(0.0, 0.0)";
+ break;
+
+ case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
+ if (!dx) dx = "vec3(0.0, 0.0, 0.0)";
+ if (!dy) dy = "vec3(0.0, 0.0, 0.0)";
+ break;
+
+ default:
+ break;
+ }
if (!offset) offset = &dummy_offset;
}
if (dx && dy)
--
2.13.1