wined3d-SWVP-shaders, wined3d-Indexed_Vertex_Blending: Updates from Paul Gofman.

Should fix https://bugs.winehq.org/show_bug.cgi?id=46790.
This commit is contained in:
Zebediah Figura 2019-03-07 17:30:08 -06:00
parent 3a1bf0a033
commit 6260ab9bce
3 changed files with 152 additions and 99 deletions

View File

@ -1,4 +1,4 @@
From 57a3158c7da70934f8d2412efd9568cc973c1d31 Mon Sep 17 00:00:00 2001
From 205894feb8deb4c552b9df91636ad76d69847e13 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Mon, 25 Feb 2019 20:28:35 +0300
Subject: [PATCH 5/5] wined3d: Support indexed vertex blending.
@ -7,10 +7,10 @@ Signed-off-by: Paul Gofman <gofmanp@gmail.com>
---
dlls/d3d9/tests/visual.c | 6 +-
dlls/wined3d/glsl_shader.c | 164 ++++++++++++++++++++++++++-----
dlls/wined3d/utils.c | 6 +-
dlls/wined3d/utils.c | 1 +
dlls/wined3d/vertexdeclaration.c | 9 ++
dlls/wined3d/wined3d_private.h | 11 ++-
5 files changed, 166 insertions(+), 30 deletions(-)
5 files changed, 163 insertions(+), 28 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index a1d663f43a..a452f37944 100644
@ -44,7 +44,7 @@ index a1d663f43a..a452f37944 100644
hr = IDirect3DDevice9_SetSoftwareVertexProcessing(device, FALSE);
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index e2d04702ad..dc5c24e035 100644
index 4ff5a0622c..48a30856f8 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -150,6 +150,9 @@ struct shader_glsl_priv
@ -65,7 +65,7 @@ index e2d04702ad..dc5c24e035 100644
GLint projection_matrix_location;
GLint normal_matrix_location;
GLint texture_matrix_location[WINED3D_MAX_TEXTURES];
@@ -1897,28 +1901,41 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
@@ -1903,28 +1907,41 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
}
if (update_mask & WINED3D_SHADER_CONST_FFP_MODELVIEW)
@ -121,7 +121,7 @@ index e2d04702ad..dc5c24e035 100644
}
}
@@ -9214,8 +9231,7 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
@@ -9242,8 +9259,7 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
{
{"vec4", "ffp_attrib_position"}, /* WINED3D_FFP_POSITION */
{"vec4", "ffp_attrib_blendweight"}, /* WINED3D_FFP_BLENDWEIGHT */
@ -131,7 +131,7 @@ index e2d04702ad..dc5c24e035 100644
{"vec3", "ffp_attrib_normal"}, /* WINED3D_FFP_NORMAL */
{"float", "ffp_attrib_psize"}, /* WINED3D_FFP_PSIZE */
{"vec4", "ffp_attrib_diffuse"}, /* WINED3D_FFP_DIFFUSE */
@@ -9231,6 +9247,9 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
@@ -9259,6 +9275,9 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
string_buffer_clear(buffer);
shader_glsl_add_version_declaration(buffer, gl_info);
@ -141,7 +141,7 @@ index e2d04702ad..dc5c24e035 100644
if (shader_glsl_use_explicit_attrib_location(gl_info))
shader_addline(buffer, "#extension GL_ARB_explicit_attrib_location : enable\n");
@@ -9245,7 +9264,18 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
@@ -9273,7 +9292,18 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
}
shader_addline(buffer, "\n");
@ -161,7 +161,7 @@ index e2d04702ad..dc5c24e035 100644
shader_addline(buffer, "uniform mat4 ffp_projection_matrix;\n");
shader_addline(buffer, "uniform mat3 ffp_normal_matrix;\n");
shader_addline(buffer, "uniform mat4 ffp_texture_matrix[%u];\n", WINED3D_MAX_TEXTURES);
@@ -9307,6 +9337,8 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
@@ -9335,6 +9365,8 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
shader_addline(buffer, "\nvoid main()\n{\n");
shader_addline(buffer, "float m;\n");
shader_addline(buffer, "vec3 r;\n");
@ -170,7 +170,7 @@ index e2d04702ad..dc5c24e035 100644
for (i = 0; i < ARRAY_SIZE(attrib_info); ++i)
{
@@ -9336,8 +9368,21 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
@@ -9364,8 +9396,21 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
shader_addline(buffer, "ffp_attrib_blendweight[%u] -= ffp_attrib_blendweight[%u];\n", settings->vertexblends, i);
shader_addline(buffer, "vec4 ec_pos = vec4(0.0);\n");
@ -194,7 +194,7 @@ index e2d04702ad..dc5c24e035 100644
shader_addline(buffer, "gl_Position = ffp_projection_matrix * ec_pos;\n");
if (settings->clipping)
@@ -9361,7 +9406,19 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
@@ -9389,7 +9434,19 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
else
{
for (i = 0; i < settings->vertexblends + 1; ++i)
@ -215,7 +215,7 @@ index e2d04702ad..dc5c24e035 100644
}
if (settings->normalize)
@@ -10234,6 +10291,39 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
@@ -10262,6 +10319,39 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
string_buffer_sprintf(name, "ffp_modelview_matrix[%u]", i);
vs->modelview_matrix_location[i] = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer));
}
@ -230,9 +230,9 @@ index e2d04702ad..dc5c24e035 100644
+
+ wined3d_gl_limits_get_uniform_block_range(&gl_info->limits, WINED3D_SHADER_TYPE_VERTEX,
+ &base, &count);
+ assert(count >= 1);
+ assert(count >= 2);
+
+ GL_EXTCALL(glUniformBlockBinding(program_id, vs->modelview_block_index, base + count));
+ GL_EXTCALL(glUniformBlockBinding(program_id, vs->modelview_block_index, base + 1));
+ checkGLcall("glUniformBlockBinding");
+ if (priv->ubo_modelview == -1)
+ {
@ -242,7 +242,7 @@ index e2d04702ad..dc5c24e035 100644
+ GL_EXTCALL(glBufferData(GL_UNIFORM_BUFFER,
+ sizeof(struct wined3d_matrix) * MAX_VERTEX_BLEND_UBO, NULL, GL_DYNAMIC_DRAW));
+ checkGLcall("glBufferData (UBO)");
+ GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + count, priv->ubo_modelview));
+ GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + 1, priv->ubo_modelview));
+ checkGLcall("glBindBufferBase");
+ }
+ }
@ -255,7 +255,7 @@ index e2d04702ad..dc5c24e035 100644
vs->projection_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_projection_matrix"));
vs->normal_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_normal_matrix"));
for (i = 0; i < WINED3D_MAX_TEXTURES; ++i)
@@ -10813,7 +10903,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
@@ -10841,7 +10931,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
entry->constant_update_mask |= WINED3D_SHADER_CONST_FFP_MODELVIEW
| WINED3D_SHADER_CONST_FFP_PROJ;
@ -264,7 +264,7 @@ index e2d04702ad..dc5c24e035 100644
{
if (entry->vs.modelview_matrix_location[i] != -1)
{
@@ -10822,6 +10912,9 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
@@ -10850,6 +10940,9 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
}
}
@ -274,7 +274,7 @@ index e2d04702ad..dc5c24e035 100644
for (i = 0; i < WINED3D_MAX_TEXTURES; ++i)
{
if (entry->vs.texture_matrix_location[i] != -1)
@@ -11358,7 +11451,17 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
@@ -11387,7 +11480,17 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
fragment_pipe->get_caps(gl_info, &fragment_caps);
priv->ffp_proj_control = fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_PROJ_CONTROL;
priv->legacy_lighting = device->wined3d->flags & WINED3D_LEGACY_FFP_LIGHTING;
@ -293,7 +293,7 @@ index e2d04702ad..dc5c24e035 100644
device->vertex_priv = vertex_priv;
device->fragment_priv = fragment_priv;
device->shader_priv = priv;
@@ -11391,6 +11494,14 @@ static void shader_glsl_free(struct wined3d_device *device)
@@ -11420,6 +11523,14 @@ static void shader_glsl_free(struct wined3d_device *device)
string_buffer_free(&priv->shader_buffer);
priv->fragment_pipe->free_private(device);
priv->vertex_pipe->vp_free(device);
@ -308,7 +308,7 @@ index e2d04702ad..dc5c24e035 100644
if (priv->ubo_vs_c != -1)
{
@@ -11807,7 +11918,11 @@ static void glsl_vertex_pipe_vp_get_caps(const struct wined3d_gl_info *gl_info,
@@ -11836,7 +11947,11 @@ static void glsl_vertex_pipe_vp_get_caps(const struct wined3d_gl_info *gl_info,
caps->ffp_generic_attributes = TRUE;
caps->max_active_lights = WINED3D_MAX_ACTIVE_LIGHTS;
caps->max_vertex_blend_matrices = MAX_VERTEX_BLENDS;
@ -321,7 +321,7 @@ index e2d04702ad..dc5c24e035 100644
caps->vertex_processing_caps = WINED3DVTXPCAPS_TEXGEN
| WINED3DVTXPCAPS_MATERIALSOURCE7
| WINED3DVTXPCAPS_VERTEXFOG
@@ -12006,7 +12121,8 @@ static void glsl_vertex_pipe_pixel_shader(struct wined3d_context *context,
@@ -12035,7 +12150,8 @@ static void glsl_vertex_pipe_pixel_shader(struct wined3d_context *context,
static void glsl_vertex_pipe_world(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id)
{
@ -332,10 +332,10 @@ index e2d04702ad..dc5c24e035 100644
static void glsl_vertex_pipe_vertexblend(struct wined3d_context *context,
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 3785ae104b..f2362b0266 100644
index f0ffe6a62d..4f44ff7a11 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -6331,6 +6331,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
@@ -6332,6 +6332,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
settings->flatshading = FALSE;
settings->swizzle_map = si->swizzle_map;
@ -343,18 +343,6 @@ index 3785ae104b..f2362b0266 100644
}
int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry)
@@ -6462,8 +6463,9 @@ void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *g
*base += *count;
if (i == WINED3D_SHADER_TYPE_VERTEX)
{
- /* Reserve binding location for vs_c UBO. */
- ++*base;
+ /* Reserve binding locations for vs_c UBO and modelview UBO
+ used for indexed vertex blending. */
+ *base += 2;
}
}
diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c
index cd8bb5e423..d37f3ce860 100644
--- a/dlls/wined3d/vertexdeclaration.c
@ -376,10 +364,10 @@ index cd8bb5e423..d37f3ce860 100644
switch(element->format)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cfad5aba07..ce4f553f6a 100644
index ed719e0919..4eb8498873 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -275,6 +275,7 @@ static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup
@@ -277,6 +277,7 @@ static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup
#define MAX_UNORDERED_ACCESS_VIEWS 8
#define MAX_TGSM_REGISTERS 8192
#define MAX_VERTEX_BLENDS 4
@ -387,7 +375,7 @@ index cfad5aba07..ce4f553f6a 100644
#define MAX_RENDER_TARGETS 8
struct min_lookup
@@ -2846,7 +2847,8 @@ struct wined3d_ffp_vs_settings
@@ -2848,7 +2849,8 @@ struct wined3d_ffp_vs_settings
DWORD ortho_fog : 1;
DWORD flatshading : 1;
DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
@ -397,7 +385,7 @@ index cfad5aba07..ce4f553f6a 100644
DWORD texgen[WINED3D_MAX_TEXTURES];
};
@@ -4743,6 +4745,13 @@ static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
@@ -4746,6 +4748,13 @@ static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
assert(cs->thread_id != GetCurrentThreadId());
}

View File

@ -1,4 +1,4 @@
From 168e4d29d3880dcb9db75c0a90a459037ee707d5 Mon Sep 17 00:00:00 2001
From 22aa526b9442ac184b928d16fd354d97b92a7a39 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Mon, 25 Feb 2019 13:17:01 +0300
Subject: [PATCH 1/5] wined3d: Use UBO for vertex shader float constants if
@ -6,15 +6,44 @@ Subject: [PATCH 1/5] wined3d: Use UBO for vertex shader float constants if
Signed-off-by: Paul Gofman <gofmanp@gmail.com>
---
dlls/d3d8/directx.c | 2 +-
dlls/d3d9/directx.c | 2 +-
dlls/wined3d/adapter_gl.c | 3 +
dlls/wined3d/glsl_shader.c | 113 +++++++++++++++++++++++++++++----
dlls/wined3d/glsl_shader.c | 126 ++++++++++++++++++++++++++++++---
dlls/wined3d/shader.c | 2 +
dlls/wined3d/utils.c | 5 ++
dlls/wined3d/state.c | 5 ++
dlls/wined3d/wined3d_private.h | 2 +
5 files changed, 114 insertions(+), 11 deletions(-)
include/wine/wined3d.h | 1 +
8 files changed, 130 insertions(+), 13 deletions(-)
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index 09188cc2ae..657227357c 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -419,7 +419,7 @@ BOOL d3d8_init(struct d3d8 *d3d8)
DWORD flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING
| WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
| WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART
- | WINED3D_LEGACY_CUBEMAP_FILTERING;
+ | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LEGACY_SHADER_CONSTANTS;
d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl;
d3d8->refcount = 1;
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index c507991aaa..7cdf5ddbb9 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -585,7 +585,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
| WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
| WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING
- | WINED3D_NORMALIZED_DEPTH_BIAS;
+ | WINED3D_NORMALIZED_DEPTH_BIAS | WINED3D_LEGACY_SHADER_CONSTANTS;
if (!extended)
flags |= WINED3D_VIDMEM_ACCOUNTING;
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
index 964e51944f..86df4003db 100644
index a61e87344b..abd7114ff2 100644
--- a/dlls/wined3d/adapter_gl.c
+++ b/dlls/wined3d/adapter_gl.c
@@ -3087,6 +3087,9 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info, struct
@ -28,7 +57,7 @@ index 964e51944f..86df4003db 100644
}
if (gl_info->supported[ARB_TESSELLATION_SHADER])
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 476ae2fae0..ecc1d7fbf8 100644
index 84899be004..710abbe2a0 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -138,6 +138,10 @@ struct shader_glsl_priv
@ -50,7 +79,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
};
struct glsl_hs_program
@@ -1145,12 +1150,48 @@ static inline void walk_constant_heap_clamped(const struct wined3d_gl_info *gl_i
@@ -1145,12 +1150,54 @@ static inline void walk_constant_heap_clamped(const struct wined3d_gl_info *gl_i
checkGLcall("walk_constant_heap_clamped()");
}
@ -77,6 +106,12 @@ index 476ae2fae0..ecc1d7fbf8 100644
+ const struct wined3d_vec4 *data;
+ unsigned max_const_used;
+
+ if (priv->ubo_vs_c == -1)
+ {
+ ERR("UBO is not initialized.\n");
+ return;
+ }
+
+ bind_and_orphan_consts_ubo(gl_info, priv);
+ max_const_used = shader->reg_maps.usesrelconstF
+ ? WINED3D_MAX_VS_CONSTS_F : shader->reg_maps.constant_float_count;
@ -100,7 +135,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
/* 1.X pshaders have the constants clamped to [-1;1] implicitly. */
if (shader->reg_maps.shader_version.major == 1
@@ -1801,7 +1842,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
@@ -1801,7 +1848,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
if (update_mask & WINED3D_SHADER_CONST_VS_F)
shader_glsl_load_constants_f(vshader, gl_info, state->vs_consts_f,
@ -109,7 +144,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
if (update_mask & WINED3D_SHADER_CONST_VS_I)
shader_glsl_load_constants_i(vshader, gl_info, state->vs_consts_i,
@@ -1954,7 +1995,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
@@ -1954,7 +2001,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
if (update_mask & WINED3D_SHADER_CONST_PS_F)
shader_glsl_load_constants_f(pshader, gl_info, state->ps_consts_f,
@ -118,17 +153,30 @@ index 476ae2fae0..ecc1d7fbf8 100644
if (update_mask & WINED3D_SHADER_CONST_PS_I)
shader_glsl_load_constants_i(pshader, gl_info, state->ps_consts_i,
@@ -2093,6 +2134,9 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
@@ -2093,6 +2140,12 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
struct constant_heap *heap = &priv->vconst_heap;
UINT i;
+ if (!(device->adapter->d3d_info.wined3d_creation_flags & WINED3D_LEGACY_SHADER_CONSTANTS))
+ WARN("Called without legacy shader constant mode.\n");
+
+ if (priv->consts_ubo)
+ return;
+
for (i = start; i < count + start; ++i)
{
update_heap_entry(heap, i, priv->next_constant_version);
@@ -2408,6 +2452,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
@@ -2105,6 +2158,9 @@ static void shader_glsl_update_float_pixel_constants(struct wined3d_device *devi
struct constant_heap *heap = &priv->pconst_heap;
UINT i;
+ if (!(device->adapter->d3d_info.wined3d_creation_flags & WINED3D_LEGACY_SHADER_CONSTANTS))
+ WARN("Called without legacy shader constant mode.\n");
+
for (i = start; i < count + start; ++i)
{
update_heap_entry(heap, i, priv->next_constant_version);
@@ -2408,6 +2464,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
const struct wined3d_shader_version *version = &reg_maps->shader_version;
const struct vs_compile_args *vs_args = ctx_priv->cur_vs_args;
const struct ps_compile_args *ps_args = ctx_priv->cur_ps_args;
@ -136,7 +184,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_shader_indexable_temp *idx_temp_reg;
unsigned int uniform_block_base, uniform_block_count;
@@ -2428,7 +2473,15 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
@@ -2428,7 +2485,15 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
}
/* Declare the constants (aka uniforms) */
@ -153,7 +201,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
{
unsigned max_constantsF;
@@ -2493,11 +2546,12 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
@@ -2493,11 +2558,12 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
}
else
{
@ -168,7 +216,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
}
/* Always declare the full set of constants, the compiler can remove the
@@ -10104,17 +10158,44 @@ static struct glsl_ffp_fragment_shader *shader_glsl_find_ffp_fragment_shader(str
@@ -10120,17 +10186,44 @@ static struct glsl_ffp_fragment_shader *shader_glsl_find_ffp_fragment_shader(str
static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *gl_info,
@ -181,9 +229,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
- for (i = 0; i < vs_c_count; ++i)
+ if (priv->consts_ubo && vs_c_count)
{
- string_buffer_sprintf(name, "vs_c[%u]", i);
- vs->uniform_f_locations[i] = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer));
+ {
+ unsigned int base, count;
+
+ vs->vs_c_block_index = GL_EXTCALL(glGetUniformBlockIndex(program_id, "vs_c_ubo"));
@ -194,19 +240,21 @@ index 476ae2fae0..ecc1d7fbf8 100644
+ wined3d_gl_limits_get_uniform_block_range(&gl_info->limits, WINED3D_SHADER_TYPE_VERTEX,
+ &base, &count);
+ assert(count >= 1);
+ GL_EXTCALL(glUniformBlockBinding(program_id, vs->vs_c_block_index, base + count + 1));
+ GL_EXTCALL(glUniformBlockBinding(program_id, vs->vs_c_block_index, base));
+ checkGLcall("glUniformBlockBinding");
+ if (priv->ubo_vs_c == -1)
+ {
+ GL_EXTCALL(glGenBuffers(1, &priv->ubo_vs_c));
+ GL_EXTCALL(glBindBuffer(GL_UNIFORM_BUFFER, priv->ubo_vs_c));
+ checkGLcall("glBindBuffer (UBO)");
+ GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + count + 1, priv->ubo_vs_c));
+ GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base, priv->ubo_vs_c));
+ checkGLcall("glBindBufferBase");
+ }
+ }
+ else if (!priv->consts_ubo)
+ {
{
- string_buffer_sprintf(name, "vs_c[%u]", i);
- vs->uniform_f_locations[i] = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer));
+ for (i = 0; i < vs_c_count; ++i)
+ {
+ string_buffer_sprintf(name, "vs_c[%u]", i);
@ -218,15 +266,16 @@ index 476ae2fae0..ecc1d7fbf8 100644
for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
{
@@ -11194,6 +11275,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
@@ -11210,6 +11303,8 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
if (!(priv = heap_alloc_zero(sizeof(*priv))))
return E_OUTOFMEMORY;
+ priv->consts_ubo = gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT];
+ priv->consts_ubo = (device->adapter->d3d_info.wined3d_creation_flags & WINED3D_LEGACY_SHADER_CONSTANTS)
+ && gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT];
string_buffer_list_init(&priv->string_buffers);
if (!(vertex_priv = vertex_pipe->vp_alloc(&glsl_shader_backend, priv)))
@@ -11248,6 +11330,8 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
@@ -11264,6 +11359,8 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
device->fragment_priv = fragment_priv;
device->shader_priv = priv;
@ -235,7 +284,7 @@ index 476ae2fae0..ecc1d7fbf8 100644
return WINED3D_OK;
fail:
@@ -11275,6 +11359,13 @@ static void shader_glsl_free(struct wined3d_device *device)
@@ -11291,6 +11388,13 @@ static void shader_glsl_free(struct wined3d_device *device)
priv->fragment_pipe->free_private(device);
priv->vertex_pipe->vp_free(device);
@ -262,27 +311,27 @@ index 2db4a3cbc2..e34b6548cd 100644
wined3d_insert_bits(reg_maps->constf, reg->idx[0].offset, 1, 0x1);
}
}
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index d77cb1ce11..104e276585 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -6462,6 +6462,11 @@ void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *g
if (i == shader_type)
return;
*base += *count;
+ if (i == WINED3D_SHADER_TYPE_VERTEX)
+ {
+ /* Reserve binding location for vs_c UBO. */
+ ++*base;
+ }
}
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 3af60e1351..d84b42d2ea 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4392,6 +4392,11 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
unsigned int i, base, count;
ERR("Unrecognized shader type %#x.\n", shader_type);
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
+ if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_SHADER_CONSTANTS)
+ {
+ WARN("Called in legacy shader constant mode.\n");
+ return;
+ }
if (STATE_IS_GRAPHICS_CONSTANT_BUFFER(state_id))
shader_type = state_id - STATE_GRAPHICS_CONSTANT_BUFFER(0);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ea41abdaf8..5edff2ecee 100644
index a5a3f34737..81507db891 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1051,6 +1051,7 @@ struct wined3d_shader_reg_maps
@@ -1053,6 +1053,7 @@ struct wined3d_shader_reg_maps
struct wined3d_shader_tgsm *tgsm;
SIZE_T tgsm_capacity;
unsigned int tgsm_count;
@ -290,7 +339,7 @@ index ea41abdaf8..5edff2ecee 100644
};
/* Keeps track of details for TEX_M#x# instructions which need to maintain
@@ -2590,6 +2591,7 @@ struct wined3d_gl_limits
@@ -2592,6 +2593,7 @@ struct wined3d_gl_limits
UINT glsl_varyings;
UINT glsl_vs_float_constants;
UINT glsl_ps_float_constants;
@ -298,6 +347,18 @@ index ea41abdaf8..5edff2ecee 100644
UINT arb_vs_float_constants;
UINT arb_vs_native_constants;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 86fde6a1f2..c597897f43 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1348,6 +1348,7 @@ enum wined3d_shader_type
#define WINED3D_NO_PRIMITIVE_RESTART 0x00000800
#define WINED3D_LEGACY_CUBEMAP_FILTERING 0x00001000
#define WINED3D_NORMALIZED_DEPTH_BIAS 0x00002000
+#define WINED3D_LEGACY_SHADER_CONSTANTS 0x00004000
#define WINED3D_RESZ_CODE 0x7fa05000
--
2.20.1

View File

@ -1,4 +1,4 @@
From 9507b08a2a3e640879f69bbfac0dd600eb127580 Mon Sep 17 00:00:00 2001
From 7fd5eef6fefa01881ac93471672b391b5e8346e7 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Mon, 25 Feb 2019 15:23:33 +0300
Subject: [PATCH 5/5] wined3d: Support SWVP mode vertex shaders.
@ -15,7 +15,7 @@ Signed-off-by: Paul Gofman <gofmanp@gmail.com>
7 files changed, 103 insertions(+), 48 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 5f7944b93a..cef0759610 100644
index 23c2a7d47f..265285730f 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -6913,15 +6913,11 @@ float4 main(const float4 color : COLOR) : SV_TARGET
@ -97,7 +97,7 @@ index a0d7b9caaf..09cd09db94 100644
expected_color, color);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 6649e5078d..8d7f03ecc3 100644
index 956333afe6..b67d534cfe 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4080,6 +4080,14 @@ void CDECL wined3d_device_set_software_vertex_processing(struct wined3d_device *
@ -116,7 +116,7 @@ index 6649e5078d..8d7f03ecc3 100644
}
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 6acb730fe4..8bdb952f38 100644
index 01e79a7ecc..3d9280dc70 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -140,7 +140,9 @@ struct shader_glsl_priv
@ -148,7 +148,7 @@ index 6acb730fe4..8bdb952f38 100644
NULL, GL_STREAM_DRAW));
checkGLcall("glBufferData");
}
@@ -1162,33 +1164,45 @@ static void bind_and_orphan_consts_ubo(const struct wined3d_gl_info *gl_info, st
@@ -1162,14 +1164,16 @@ static void bind_and_orphan_consts_ubo(const struct wined3d_gl_info *gl_info, st
/* Context activation is done by the caller. */
static void shader_glsl_load_constants_f(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info,
const struct wined3d_vec4 *constants, const GLint *constant_locations, const struct constant_heap *heap,
@ -165,6 +165,10 @@ index 6acb730fe4..8bdb952f38 100644
+ unsigned int const_count;
unsigned max_const_used;
if (priv->ubo_vs_c == -1)
@@ -1179,22 +1183,32 @@ static void shader_glsl_load_constants_f(const struct wined3d_shader *shader, co
}
bind_and_orphan_consts_ubo(gl_info, priv);
- max_const_used = shader->reg_maps.usesrelconstF
- ? WINED3D_MAX_VS_CONSTS_F : shader->reg_maps.constant_float_count;
@ -201,7 +205,7 @@ index 6acb730fe4..8bdb952f38 100644
checkGLcall("glBufferSubData");
return;
}
@@ -1842,7 +1856,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
@@ -1848,7 +1862,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
if (update_mask & WINED3D_SHADER_CONST_VS_F)
shader_glsl_load_constants_f(vshader, gl_info, state->vs_consts_f,
@ -211,7 +215,7 @@ index 6acb730fe4..8bdb952f38 100644
if (update_mask & WINED3D_SHADER_CONST_VS_I)
shader_glsl_load_constants_i(vshader, gl_info, state->vs_consts_i,
@@ -1995,7 +2010,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
@@ -2001,7 +2016,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
if (update_mask & WINED3D_SHADER_CONST_PS_F)
shader_glsl_load_constants_f(pshader, gl_info, state->ps_consts_f,
@ -221,7 +225,7 @@ index 6acb730fe4..8bdb952f38 100644
if (update_mask & WINED3D_SHADER_CONST_PS_I)
shader_glsl_load_constants_i(pshader, gl_info, state->ps_consts_i,
@@ -2137,7 +2153,7 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
@@ -2146,7 +2162,7 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
if (priv->consts_ubo)
return;
@ -230,7 +234,7 @@ index 6acb730fe4..8bdb952f38 100644
{
update_heap_entry(heap, i, priv->next_constant_version);
}
@@ -2479,7 +2495,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
@@ -2491,7 +2507,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
shader_addline(buffer,"layout(std140) uniform vs_c_ubo\n"
"{ \n"
" vec4 %s_c[%u];\n"
@ -239,7 +243,7 @@ index 6acb730fe4..8bdb952f38 100644
}
else if (shader->limits->constant_float > 0)
{
@@ -10189,12 +10205,13 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
@@ -10217,12 +10233,13 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
}
else if (!priv->consts_ubo)
{
@ -255,7 +259,7 @@ index 6acb730fe4..8bdb952f38 100644
}
for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
@@ -10513,6 +10530,10 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
@@ -10541,6 +10558,10 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
vs_list = &ffp_shader->linked_programs;
}
@ -266,7 +270,7 @@ index 6acb730fe4..8bdb952f38 100644
hshader = state->shader[WINED3D_SHADER_TYPE_HULL];
if (!(context->shader_update_mask & (1u << WINED3D_SHADER_TYPE_HULL)) && ctx_data->glsl_program)
hs_id = ctx_data->glsl_program->hs.id;
@@ -11266,7 +11287,7 @@ static void constant_heap_free(struct constant_heap *heap)
@@ -11294,7 +11315,7 @@ static void constant_heap_free(struct constant_heap *heap)
static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
const struct fragment_pipeline *fragment_pipe)
{
@ -275,10 +279,10 @@ index 6acb730fe4..8bdb952f38 100644
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct fragment_caps fragment_caps;
void *vertex_priv, *fragment_priv;
@@ -11276,6 +11297,18 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
return E_OUTOFMEMORY;
@@ -11305,6 +11326,18 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
priv->consts_ubo = gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT];
priv->consts_ubo = (device->adapter->d3d_info.wined3d_creation_flags & WINED3D_LEGACY_SHADER_CONSTANTS)
&& gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT];
+ priv->max_vs_consts_f = priv->consts_ubo
+ ? gl_info->limits.glsl_max_uniform_block_size / sizeof(struct wined3d_vec4)
+ : gl_info->limits.glsl_vs_float_constants;
@ -294,7 +298,7 @@ index 6acb730fe4..8bdb952f38 100644
string_buffer_list_init(&priv->string_buffers);
if (!(vertex_priv = vertex_pipe->vp_alloc(&glsl_shader_backend, priv)))
@@ -11305,7 +11338,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
@@ -11334,7 +11367,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
goto fail;
}
@ -470,10 +474,10 @@ index 0c6bb93317..1051307e88 100644
WARN("Invalid shader version %u.%u (%#x).\n", major, minor, *byte_code);
return NULL;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9655660a5b..e48c2a730d 100644
index c01100e0a4..857fc8a06d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4425,6 +4425,13 @@ static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader,
@@ -4428,6 +4428,13 @@ static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader,
return FALSE;
}