From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/glsl_shader.c | 4 +++- dlls/wined3d/wined3d_private.h | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 600a6296c70..d1020339db0 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -12332,7 +12332,7 @@ static void test_pointsize(void) ok(color != 0xff00ffff, "Got unexpected color 0x%08x at (64, 64).\n", color); }
- todo_wine_if (j == 10) + todo_wine_if (j == 10 || (j == 11 && i == 10)) { color = get_readback_color(&rb, 63, 64); ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (63, 64).\n", color); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ea79e0361e0..463dbf47fd6 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -11759,6 +11759,7 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, struct wined3d_context_gl *context_gl = wined3d_context_gl(context); const struct wined3d_gl_info *gl_info = context_gl->gl_info; BOOL specular = !!(context->stream_info.use_map & (1u << WINED3D_FFP_SPECULAR)); + BOOL point_size = !!(context->stream_info.use_map & (1u << WINED3D_FFP_PSIZE)); BOOL diffuse = !!(context->stream_info.use_map & (1u << WINED3D_FFP_DIFFUSE)); BOOL normal = !!(context->stream_info.use_map & (1u << WINED3D_FFP_NORMAL)); const BOOL legacy_clip_planes = needs_legacy_glsl_syntax(gl_info); @@ -11799,7 +11800,7 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, * normal presence changes. */ if (!shader_glsl_full_ffp_varyings(gl_info) || (state->render_states[WINED3D_RS_COLORVERTEX] && (diffuse != context->last_was_diffuse || specular != context->last_was_specular)) - || normal != context->last_was_normal) + || normal != context->last_was_normal || point_size != context->last_was_point_size) context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_VERTEX;
if (use_ps(state) @@ -11824,6 +11825,7 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, context->last_was_diffuse = diffuse; context->last_was_specular = specular; context->last_was_normal = normal; + context->last_was_point_size = point_size; }
static void glsl_vertex_pipe_vs(struct wined3d_context *context, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 67ddf6f88cd..85badd3b2c3 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1907,12 +1907,12 @@ struct wined3d_context DWORD update_unordered_access_view_bindings : 1; DWORD update_compute_unordered_access_view_bindings : 1; DWORD update_primitive_type : 1; - DWORD update_patch_vertex_count : 1; DWORD last_was_rhw : 1; /* True iff last draw_primitive was in xyzrhw mode. */ DWORD last_was_vshader : 1; DWORD last_was_diffuse : 1; DWORD last_was_specular : 1; DWORD last_was_normal : 1; + DWORD last_was_point_size : 1; DWORD last_was_ffp_blit : 1; DWORD last_was_blit : 1; DWORD last_was_dual_source_blend : 1; @@ -1927,7 +1927,8 @@ struct wined3d_context DWORD destroyed : 1; DWORD destroy_delayed : 1; DWORD update_multisample_state : 1; - DWORD padding : 24; + DWORD update_patch_vertex_count : 1; + DWORD padding : 23;
DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
From: Elizabeth Figura zfigura@codeweavers.com
Do not check the stream info. In practice, this amounts to a difference if the usage is included in the vertex declaration but the corresponding stream is not bound. The just-added tests show that in this case it is correct to use per-vertex point size with a default size of one, rather than treating this case as equivalent to if the usage was not specified in the vertex declaration. --- dlls/d3d9/tests/visual.c | 19 ++++++++----------- dlls/wined3d/glsl_shader.c | 3 ++- dlls/wined3d/utils.c | 5 +++-- dlls/wined3d/vertexdeclaration.c | 4 +++- dlls/wined3d/wined3d_private.h | 3 ++- 5 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index d1020339db0..4b8a7a994b3 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -12332,17 +12332,14 @@ static void test_pointsize(void) ok(color != 0xff00ffff, "Got unexpected color 0x%08x at (64, 64).\n", color); }
- todo_wine_if (j == 10 || (j == 11 && i == 10)) - { - color = get_readback_color(&rb, 63, 64); - ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (63, 64).\n", color); - color = get_readback_color(&rb, 65, 64); - ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (65, 64).\n", color); - color = get_readback_color(&rb, 64, 63); - ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (64, 63).\n", color); - color = get_readback_color(&rb, 64, 65); - ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (64, 65).\n", color); - } + color = get_readback_color(&rb, 63, 64); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (63, 64).\n", color); + color = get_readback_color(&rb, 65, 64); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (65, 64).\n", color); + color = get_readback_color(&rb, 64, 63); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (64, 63).\n", color); + color = get_readback_color(&rb, 64, 65); + ok(color == 0xff00ffff, "Got unexpected color 0x%08x at (64, 65).\n", color); } else { diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 463dbf47fd6..ae618266d79 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -11756,15 +11756,16 @@ static void glsl_vertex_pipe_shader(struct wined3d_context *context, static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { + const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; struct wined3d_context_gl *context_gl = wined3d_context_gl(context); const struct wined3d_gl_info *gl_info = context_gl->gl_info; BOOL specular = !!(context->stream_info.use_map & (1u << WINED3D_FFP_SPECULAR)); - BOOL point_size = !!(context->stream_info.use_map & (1u << WINED3D_FFP_PSIZE)); BOOL diffuse = !!(context->stream_info.use_map & (1u << WINED3D_FFP_DIFFUSE)); BOOL normal = !!(context->stream_info.use_map & (1u << WINED3D_FFP_NORMAL)); const BOOL legacy_clip_planes = needs_legacy_glsl_syntax(gl_info); BOOL transformed = context->stream_info.position_transformed; BOOL wasrhw = context->last_was_rhw; + bool point_size = vdecl->point_size; unsigned int i;
context->last_was_rhw = transformed; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index a1c5a00d51f..98b58cbeb06 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6566,6 +6566,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings) { enum wined3d_material_color_source diffuse_source, emissive_source, ambient_source, specular_source; + const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; const struct wined3d_stream_info *si = &context->stream_info; const struct wined3d_d3d_info *d3d_info = context->d3d_info; unsigned int coord_idx, i; @@ -6576,7 +6577,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, { settings->transformed = 1; settings->point_size = state->primitive_type == WINED3D_PT_POINTLIST; - settings->per_vertex_point_size = !!(si->use_map & 1u << WINED3D_FFP_PSIZE); + settings->per_vertex_point_size = vdecl->point_size; if (!state->render_states[WINED3D_RS_FOGENABLE]) settings->fog_mode = WINED3D_FFP_VS_FOG_OFF; else if (state->render_states[WINED3D_RS_FOGTABLEMODE] != WINED3D_FOG_NONE) @@ -6625,7 +6626,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, settings->localviewer = !!state->render_states[WINED3D_RS_LOCALVIEWER]; settings->specular_enable = !!state->render_states[WINED3D_RS_SPECULARENABLE]; settings->point_size = state->primitive_type == WINED3D_PT_POINTLIST; - settings->per_vertex_point_size = !!(si->use_map & 1u << WINED3D_FFP_PSIZE); + settings->per_vertex_point_size = vdecl->point_size;
wined3d_get_material_colour_source(&diffuse_source, &emissive_source, &ambient_source, &specular_source, state, si); diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index c48c621bd11..d86b6afc41c 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -219,7 +219,9 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara alignment = 4;
if (e->usage == WINED3D_DECL_USAGE_POSITIONT) - declaration->position_transformed = TRUE; + declaration->position_transformed = true; + else if (e->usage == WINED3D_DECL_USAGE_PSIZE) + declaration->point_size = true;
/* Find the streams used in the declaration. The vertex buffers have * to be loaded when drawing, but filter tessellation pseudo streams. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 85badd3b2c3..ff192c1b3f4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3491,7 +3491,8 @@ struct wined3d_vertex_declaration struct wined3d_vertex_declaration_element *elements; unsigned int element_count;
- BOOL position_transformed; + bool position_transformed; + bool point_size; };
bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
From: Elizabeth Figura zfigura@codeweavers.com
Do not check the stream info. In practice, this amounts to a difference if the usage is included in the vertex declaration but the corresponding stream is not bound; however, tests show that in this case we should supply a default colour of zero. --- dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/device.c | 2 +- dlls/wined3d/glsl_shader.c | 4 ++-- dlls/wined3d/utils.c | 2 +- dlls/wined3d/vertexdeclaration.c | 4 ++++ dlls/wined3d/wined3d_private.h | 23 +++++++++++++---------- 6 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 4b8a7a994b3..b74836d79c4 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -26083,7 +26083,7 @@ static void test_color_vertex(void) ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
colour = getPixelColor(device, 320, 240); - todo_wine_if (i == 13 || i == 14 || i == 16 || i == 18 || i == 19) + todo_wine_if (i == 13 || i == 14 || i == 19) ok(color_match(colour, tests[i].result, 1), "Expected colour 0x%08x for test %u, got 0x%08x.\n", tests[i].result, i, colour); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 12786f4a068..c0648f2aace 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3383,7 +3383,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO lighting = state->render_states[WINED3D_RS_LIGHTING] && (dst_fvf & (WINED3DFVF_DIFFUSE | WINED3DFVF_SPECULAR)); wined3d_get_material_colour_source(&diffuse_source, &emissive_source, - &ambient_source, &specular_source, state, stream_info); + &ambient_source, &specular_source, state); output_colour_format = wined3d_get_format(device->adapter, WINED3DFMT_B8G8R8A8_UNORM, 0); material_specular_state_colour = state->render_states[WINED3D_RS_SPECULARENABLE] ? &state->material.specular : &black; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ae618266d79..0fbff8e4597 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -11759,13 +11759,13 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; struct wined3d_context_gl *context_gl = wined3d_context_gl(context); const struct wined3d_gl_info *gl_info = context_gl->gl_info; - BOOL specular = !!(context->stream_info.use_map & (1u << WINED3D_FFP_SPECULAR)); - BOOL diffuse = !!(context->stream_info.use_map & (1u << WINED3D_FFP_DIFFUSE)); BOOL normal = !!(context->stream_info.use_map & (1u << WINED3D_FFP_NORMAL)); const BOOL legacy_clip_planes = needs_legacy_glsl_syntax(gl_info); BOOL transformed = context->stream_info.position_transformed; BOOL wasrhw = context->last_was_rhw; bool point_size = vdecl->point_size; + bool specular = vdecl->specular; + bool diffuse = vdecl->diffuse; unsigned int i;
context->last_was_rhw = transformed; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 98b58cbeb06..df502af247f 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6629,7 +6629,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, settings->per_vertex_point_size = vdecl->point_size;
wined3d_get_material_colour_source(&diffuse_source, &emissive_source, - &ambient_source, &specular_source, state, si); + &ambient_source, &specular_source, state); settings->diffuse_source = diffuse_source; settings->emissive_source = emissive_source; settings->ambient_source = ambient_source; diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index d86b6afc41c..9affc604f13 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -222,6 +222,10 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara declaration->position_transformed = true; else if (e->usage == WINED3D_DECL_USAGE_PSIZE) declaration->point_size = true; + else if (e->usage == WINED3D_DECL_USAGE_COLOR && !e->usage_idx) + declaration->diffuse = true; + else if (e->usage == WINED3D_DECL_USAGE_COLOR && e->usage_idx == 1) + declaration->specular = true;
/* Find the streams used in the declaration. The vertex buffers have * to be loaded when drawing, but filter tessellation pseudo streams. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ff192c1b3f4..a1a981d5a4c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3493,6 +3493,8 @@ struct wined3d_vertex_declaration
bool position_transformed; bool point_size; + bool diffuse; + bool specular; };
bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, @@ -4625,21 +4627,22 @@ static inline void wined3d_not_from_cs(const struct wined3d_cs *cs) assert(cs->thread_id != GetCurrentThreadId()); }
-static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map, - enum wined3d_material_color_source source) +static inline enum wined3d_material_color_source validate_material_colour_source( + const struct wined3d_vertex_declaration *vdecl, enum wined3d_material_color_source source) { - if (source == WINED3D_MCS_COLOR1 && use_map & (1u << WINED3D_FFP_DIFFUSE)) + if (source == WINED3D_MCS_COLOR1 && vdecl->diffuse) return source; - if (source == WINED3D_MCS_COLOR2 && use_map & (1u << WINED3D_FFP_SPECULAR)) + if (source == WINED3D_MCS_COLOR2 && vdecl->specular) return source; return WINED3D_MCS_MATERIAL; }
static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse, enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient, - enum wined3d_material_color_source *specular, const struct wined3d_state *state, - const struct wined3d_stream_info *si) + enum wined3d_material_color_source *specular, const struct wined3d_state *state) { + const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; + if (!state->render_states[WINED3D_RS_LIGHTING]) { *diffuse = WINED3D_MCS_COLOR1; @@ -4656,10 +4659,10 @@ static inline void wined3d_get_material_colour_source(enum wined3d_material_colo return; }
- *diffuse = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]); - *emissive = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]); - *ambient = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]); - *specular = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]); + *diffuse = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]); + *emissive = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]); + *ambient = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]); + *specular = validate_material_colour_source(vdecl, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]); }
static inline void wined3d_vec4_transform(struct wined3d_vec4 *dst,
From: Elizabeth Figura zfigura@codeweavers.com
Do not check the stream info.
This would make a difference if the usage was included in the vertex declaration but the corresponding stream is not bound. However, in that case we supply a default stream containing zero, which provides the same behaviour as if the normal usage is not included in the vertex declaration. --- dlls/wined3d/glsl_shader.c | 2 +- dlls/wined3d/utils.c | 2 +- dlls/wined3d/vertexdeclaration.c | 2 ++ dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 0fbff8e4597..4e7655186bf 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -11759,13 +11759,13 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; struct wined3d_context_gl *context_gl = wined3d_context_gl(context); const struct wined3d_gl_info *gl_info = context_gl->gl_info; - BOOL normal = !!(context->stream_info.use_map & (1u << WINED3D_FFP_NORMAL)); const BOOL legacy_clip_planes = needs_legacy_glsl_syntax(gl_info); BOOL transformed = context->stream_info.position_transformed; BOOL wasrhw = context->last_was_rhw; bool point_size = vdecl->point_size; bool specular = vdecl->specular; bool diffuse = vdecl->diffuse; + bool normal = vdecl->normal; unsigned int i;
context->last_was_rhw = transformed; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index df502af247f..7d2bef8b7cc 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6620,7 +6620,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
settings->clipping = state->render_states[WINED3D_RS_CLIPPING] && state->render_states[WINED3D_RS_CLIPPLANEENABLE]; - settings->normal = !!(si->use_map & (1u << WINED3D_FFP_NORMAL)); + settings->normal = vdecl->normal; settings->normalize = settings->normal && state->render_states[WINED3D_RS_NORMALIZENORMALS]; settings->lighting = !!state->render_states[WINED3D_RS_LIGHTING]; settings->localviewer = !!state->render_states[WINED3D_RS_LOCALVIEWER]; diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index 9affc604f13..f2df8979089 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -226,6 +226,8 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara declaration->diffuse = true; else if (e->usage == WINED3D_DECL_USAGE_COLOR && e->usage_idx == 1) declaration->specular = true; + else if (e->usage == WINED3D_DECL_USAGE_NORMAL) + declaration->normal = true;
/* Find the streams used in the declaration. The vertex buffers have * to be loaded when drawing, but filter tessellation pseudo streams. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index a1a981d5a4c..14a91875014 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3495,6 +3495,7 @@ struct wined3d_vertex_declaration bool point_size; bool diffuse; bool specular; + bool normal; };
bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
From: Elizabeth Figura zfigura@codeweavers.com
Do not check the stream info.
This would make a difference if the usage was included in the vertex declaration but the corresponding stream is not bound; however, in that case we supply a default stream containing zero, which provides the same behaviour as if the usage is not included in the vertex declaration. --- dlls/wined3d/utils.c | 7 +++---- dlls/wined3d/vertexdeclaration.c | 2 ++ dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 7d2bef8b7cc..e0519942e1a 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6507,11 +6507,10 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_context *context, } else { - const struct wined3d_stream_info *si = &context->stream_info; unsigned int coord_idx = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; if ((state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] >> WINED3D_FFP_TCI_SHIFT) & WINED3D_FFP_TCI_MASK - || (coord_idx < WINED3D_MAX_FFP_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx))))) + || (coord_idx < WINED3D_MAX_FFP_TEXTURES && (state->vertex_declaration->texcoords & (1u << coord_idx)))) settings->texcoords_initialized |= 1u << i; } } @@ -6588,7 +6587,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) { coord_idx = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; - if (coord_idx < WINED3D_MAX_FFP_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx)))) + if (coord_idx < WINED3D_MAX_FFP_TEXTURES && (vdecl->texcoords & (1u << coord_idx))) settings->texcoords |= 1u << i; settings->texgen[i] = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; } @@ -6638,7 +6637,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) { coord_idx = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; - if (coord_idx < WINED3D_MAX_FFP_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx)))) + if (coord_idx < WINED3D_MAX_FFP_TEXTURES && (vdecl->texcoords & (1u << coord_idx))) settings->texcoords |= 1u << i; settings->texgen[i] = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; } diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index f2df8979089..7d74d9c385e 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -228,6 +228,8 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara declaration->specular = true; else if (e->usage == WINED3D_DECL_USAGE_NORMAL) declaration->normal = true; + else if (e->usage == WINED3D_DECL_USAGE_TEXCOORD) + declaration->texcoords |= (1u << e->usage_idx);
/* Find the streams used in the declaration. The vertex buffers have * to be loaded when drawing, but filter tessellation pseudo streams. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 14a91875014..63e05239ac0 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3496,6 +3496,7 @@ struct wined3d_vertex_declaration bool diffuse; bool specular; bool normal; + uint8_t texcoords; };
bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 10 ++++------ dlls/wined3d/context_gl.c | 19 ++----------------- dlls/wined3d/glsl_shader.c | 5 ++++- dlls/wined3d/utils.c | 2 ++ dlls/wined3d/wined3d_gl.h | 3 +-- dlls/wined3d/wined3d_private.h | 3 ++- 6 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index b74836d79c4..e924588630e 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -26083,10 +26083,9 @@ static void test_color_vertex(void) ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
colour = getPixelColor(device, 320, 240); - todo_wine_if (i == 13 || i == 14 || i == 19) - ok(color_match(colour, tests[i].result, 1), - "Expected colour 0x%08x for test %u, got 0x%08x.\n", - tests[i].result, i, colour); + ok(color_match(colour, tests[i].result, 1), + "Expected colour 0x%08x for test %u, got 0x%08x.\n", + tests[i].result, i, colour); }
refcount = IDirect3DDevice9_Release(device); @@ -28516,8 +28515,7 @@ static void test_default_diffuse(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
colour = getPixelColor(device, 320, 240); - todo_wine_if (j == 2) - ok(colour == vs_tests[j].expect_colour, "Got unexpected colour %08x.\n", colour); + ok(colour == vs_tests[j].expect_colour, "Got unexpected colour %08x.\n", colour);
winetest_pop_context(); } diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 49d54d49e33..75f94678e14 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -4938,23 +4938,8 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c { if (context->numbered_array_mask & (1u << i)) wined3d_context_gl_unload_numbered_array(context_gl, i); - if (!use_vs(state) && i == WINED3D_FFP_DIFFUSE) - { - if (!(context_gl->default_attrib_value_set & (1u << i)) || !context_gl->diffuse_attrib_to_1) - { - GL_EXTCALL(glVertexAttrib4f(i, 1.0f, 1.0f, 1.0f, 1.0f)); - context_gl->diffuse_attrib_to_1 = 1; - } - } - else - { - if (!(context_gl->default_attrib_value_set & (1u << i))) - { - GL_EXTCALL(glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f)); - if (i == WINED3D_FFP_DIFFUSE) - context_gl->diffuse_attrib_to_1 = 0; - } - } + if (!(context_gl->default_attrib_value_set & (1u << i))) + GL_EXTCALL(glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f)); context_gl->default_attrib_value_set |= 1u << i; continue; } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 4e7655186bf..b4bfbe1c55b 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -8937,7 +8937,10 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
if (!settings->lighting) { - shader_addline(buffer, "ffp_varying_diffuse = ffp_attrib_diffuse;\n"); + if (settings->diffuse) + shader_addline(buffer, "ffp_varying_diffuse = ffp_attrib_diffuse;\n"); + else + shader_addline(buffer, "ffp_varying_diffuse = vec4(1.0);\n"); shader_addline(buffer, "ffp_varying_specular = ffp_attrib_specular;\n"); return; } diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index e0519942e1a..8c90908ec76 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6577,6 +6577,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context, settings->transformed = 1; settings->point_size = state->primitive_type == WINED3D_PT_POINTLIST; settings->per_vertex_point_size = vdecl->point_size; + settings->diffuse = vdecl->diffuse; if (!state->render_states[WINED3D_RS_FOGENABLE]) settings->fog_mode = WINED3D_FFP_VS_FOG_OFF; else if (state->render_states[WINED3D_RS_FOGTABLEMODE] != WINED3D_FOG_NONE) @@ -6619,6 +6620,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
settings->clipping = state->render_states[WINED3D_RS_CLIPPING] && state->render_states[WINED3D_RS_CLIPPLANEENABLE]; + settings->diffuse = vdecl->diffuse; settings->normal = vdecl->normal; settings->normalize = settings->normal && state->render_states[WINED3D_RS_NORMALIZENORMALS]; settings->lighting = !!state->render_states[WINED3D_RS_LIGHTING]; diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 561de235379..ac875ce1fe7 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -608,12 +608,11 @@ struct wined3d_context_gl uint32_t dc_is_private : 1; uint32_t dc_has_format : 1; /* Only meaningful for private DCs. */ uint32_t fog_enabled : 1; - uint32_t diffuse_attrib_to_1 : 1; uint32_t rebind_fbo : 1; uint32_t needs_set : 1; uint32_t internal_format_set : 1; uint32_t valid : 1; - uint32_t padding : 24; + uint32_t padding : 25;
uint32_t default_attrib_value_set;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 63e05239ac0..abdb97f9d9f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2725,7 +2725,8 @@ struct wined3d_ffp_vs_settings DWORD ortho_fog : 1; DWORD flatshading : 1; DWORD specular_enable : 1; - DWORD padding : 17; + DWORD diffuse : 1; + DWORD padding : 16;
DWORD swizzle_map; /* MAX_ATTRIBS, 32 */
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=145968
Your paranoid android.
=== debian11b (64 bit WoW report) ===
Report validation errors: d3d10core:d3d10core crashed (c0000005) d3d11:d3d11 crashed (c0000005)
Jan Sikorski (@jsikorski) commented about dlls/wined3d/wined3d_private.h:
DWORD destroyed : 1; DWORD destroy_delayed : 1; DWORD update_multisample_state : 1;
- DWORD padding : 24;
- DWORD update_patch_vertex_count : 1;
Accidental change? (I guess `update_multisample_state` belongs up there with other update bits, if anything.)
On Tue Jun 4 14:57:19 2024 +0000, Jan Sikorski wrote:
Accidental change? (I guess `update_multisample_state` belongs up there with other update bits, if anything.)
It was broadly intentional, to keep fixed_function_usage_map aligned to 8 bytes, but also to keep the last_was_[usage] grouped together in the same dword.
The bits could probably be moved around a bit more optimally, though...
This merge request was approved by Jan Sikorski.