From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/ffp_gl.c | 1 + dlls/wined3d/glsl_shader.c | 31 +++++++++------------------- dlls/wined3d/shader_spirv.c | 4 ---- dlls/wined3d/stateblock.c | 37 ++++++++++++++++++++++++++++++++++ dlls/wined3d/utils.c | 33 ------------------------------ dlls/wined3d/wined3d_private.h | 6 ++++-- 6 files changed, 51 insertions(+), 61 deletions(-)
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index 3bcd67f9c02..84ae038f176 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1677,6 +1677,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) {144, 144}, {149, 150}, {153, 153}, + {157, 160}, {162, 165}, {167, 193}, {195, 209}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 237733ec738..e4b90cafa74 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1655,13 +1655,16 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl checkGLcall("setting FFP lights uniforms"); }
-static void shader_glsl_pointsize_uniform(const struct wined3d_context_gl *context_gl, +static void shader_glsl_pointsize_uniform(struct wined3d_context_gl *context_gl, const struct wined3d_state *state, struct glsl_shader_prog_link *prog) { const struct wined3d_gl_info *gl_info = context_gl->gl_info; - float size, att[3]; + const struct wined3d_ffp_vs_constants *constants; float min, max;
+ constants = wined3d_buffer_load_sysmem( + context_gl->c.device->push_constants[WINED3D_PUSH_CONSTANTS_VS_FFP], &context_gl->c); + get_pointsize_minmax(&context_gl->c, state, &min, &max);
GL_EXTCALL(glUniform1f(prog->vs.pointsize_min_location, min)); @@ -1669,15 +1672,13 @@ static void shader_glsl_pointsize_uniform(const struct wined3d_context_gl *conte GL_EXTCALL(glUniform1f(prog->vs.pointsize_max_location, max)); checkGLcall("glUniform1f");
- get_pointsize(&context_gl->c, state, &size, att); - - GL_EXTCALL(glUniform1f(prog->vs.pointsize_location, size)); + GL_EXTCALL(glUniform1f(prog->vs.pointsize_location, int_to_float(state->render_states[WINED3D_RS_POINTSIZE]))); checkGLcall("glUniform1f"); - GL_EXTCALL(glUniform1f(prog->vs.pointsize_c_att_location, att[0])); + GL_EXTCALL(glUniform1f(prog->vs.pointsize_c_att_location, constants->point.scale_const)); checkGLcall("glUniform1f"); - GL_EXTCALL(glUniform1f(prog->vs.pointsize_l_att_location, att[1])); + GL_EXTCALL(glUniform1f(prog->vs.pointsize_l_att_location, constants->point.scale_linear)); checkGLcall("glUniform1f"); - GL_EXTCALL(glUniform1f(prog->vs.pointsize_q_att_location, att[2])); + GL_EXTCALL(glUniform1f(prog->vs.pointsize_q_att_location, constants->point.scale_quad)); checkGLcall("glUniform1f"); }
@@ -11925,9 +11926,6 @@ static void glsl_vertex_pipe_projection(struct wined3d_context *context, static void glsl_vertex_pipe_viewport(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE)) - && state->render_states[WINED3D_RS_POINTSCALEENABLE]) - context->constant_update_mask |= WINED3D_SHADER_CONST_VS_POINTSIZE; context->constant_update_mask |= WINED3D_SHADER_CONST_POS_FIXUP | WINED3D_SHADER_CONST_FFP_PROJ; }
@@ -11937,13 +11935,6 @@ static void glsl_vertex_pipe_pointsize(struct wined3d_context *context, context->constant_update_mask |= WINED3D_SHADER_CONST_VS_POINTSIZE; }
-static void glsl_vertex_pipe_pointscale(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - if (!use_vs(state)) - context->constant_update_mask |= WINED3D_SHADER_CONST_VS_POINTSIZE; -} - static void glsl_vertex_pointsprite_core(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { @@ -12033,10 +12024,6 @@ static const struct wined3d_state_entry_template glsl_vertex_pipe_vp_states[] = {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), state_pointsprite }, ARB_POINT_SPRITE }, {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), state_pointsprite_w }, WINED3D_GL_LEGACY_CONTEXT }, {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), glsl_vertex_pointsprite_core}, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_POINTSCALEENABLE), {STATE_RENDER(WINED3D_RS_POINTSCALEENABLE), glsl_vertex_pipe_pointscale}, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_POINTSCALE_A), {STATE_RENDER(WINED3D_RS_POINTSCALEENABLE), NULL }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_POINTSCALE_B), {STATE_RENDER(WINED3D_RS_POINTSCALEENABLE), NULL }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_POINTSCALE_C), {STATE_RENDER(WINED3D_RS_POINTSCALEENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_POINTSIZE_MAX), {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), NULL }, WINED3D_GL_EXT_NONE }, {STATE_POINT_ENABLE, {STATE_POINT_ENABLE, glsl_vertex_pipe_shader}, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_SHADEMODE), {STATE_RENDER(WINED3D_RS_SHADEMODE), glsl_vertex_pipe_shademode}, WINED3D_GLSL_130 }, diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index a5461d3d998..c533ca2798a 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1171,10 +1171,6 @@ static const struct wined3d_state_entry_template spirv_vertex_pipe_vk_vp_states[ {STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE), {STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_POINTSIZE), {STATE_RENDER(WINED3D_RS_POINTSIZE), state_nop}}, {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), state_nop}}, - {STATE_RENDER(WINED3D_RS_POINTSCALEENABLE), {STATE_RENDER(WINED3D_RS_POINTSCALEENABLE), state_nop}}, - {STATE_RENDER(WINED3D_RS_POINTSCALE_A), {STATE_RENDER(WINED3D_RS_POINTSCALE_A), state_nop}}, - {STATE_RENDER(WINED3D_RS_POINTSCALE_B), {STATE_RENDER(WINED3D_RS_POINTSCALE_B), state_nop}}, - {STATE_RENDER(WINED3D_RS_POINTSCALE_C), {STATE_RENDER(WINED3D_RS_POINTSCALE_C), state_nop}}, {STATE_RENDER(WINED3D_RS_POINTSIZE_MAX), {STATE_RENDER(WINED3D_RS_POINTSIZE_MAX), state_nop}}, {STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), {STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), state_nop}}, {STATE_LIGHT_TYPE, {STATE_LIGHT_TYPE, state_nop}}, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 54bea64afcc..9fde09b0ff1 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -63,6 +63,7 @@ struct wined3d_saved_states uint32_t ffp_ps_constants : 1; uint32_t texture_matrices : 1; uint32_t modelview_matrices : 1; + uint32_t point_scale : 1; };
struct stage_state @@ -1585,6 +1586,13 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb stateblock->changed.modelview_matrices = 1; break;
+ case WINED3D_RS_POINTSCALEENABLE: + case WINED3D_RS_POINTSCALE_A: + case WINED3D_RS_POINTSCALE_B: + case WINED3D_RS_POINTSCALE_C: + stateblock->changed.point_scale = 1; + break; + default: break; } @@ -1730,6 +1738,7 @@ void CDECL wined3d_stateblock_set_viewport(struct wined3d_stateblock *stateblock
stateblock->stateblock_state.viewport = *viewport; stateblock->changed.viewport = TRUE; + stateblock->changed.point_scale = TRUE; }
void CDECL wined3d_stateblock_set_scissor_rect(struct wined3d_stateblock *stateblock, const RECT *rect) @@ -2261,6 +2270,7 @@ static void wined3d_stateblock_invalidate_push_constants(struct wined3d_stateblo stateblock->changed.transforms = 1; memset(stateblock->changed.transform, 0xff, sizeof(stateblock->changed.transform)); stateblock->changed.modelview_matrices = 1; + stateblock->changed.point_scale = 1; }
static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state, @@ -2874,6 +2884,10 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, break;
case WINED3D_RS_ADAPTIVETESS_Y: + case WINED3D_RS_POINTSCALEENABLE: + case WINED3D_RS_POINTSCALE_A: + case WINED3D_RS_POINTSCALE_B: + case WINED3D_RS_POINTSCALE_C: case WINED3D_RS_TEXTUREFACTOR: break;
@@ -3572,6 +3586,29 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, sizeof(constants.texture_matrices), constants.texture_matrices); }
+ if (changed->point_scale) + { + struct wined3d_ffp_point_constants constants; + + if (state->rs[WINED3D_RS_POINTSCALEENABLE]) + { + float scale_factor = state->viewport.height * state->viewport.height; + + constants.scale_const = int_to_float(state->rs[WINED3D_RS_POINTSCALE_A]) / scale_factor; + constants.scale_linear = int_to_float(state->rs[WINED3D_RS_POINTSCALE_B]) / scale_factor; + constants.scale_quad = int_to_float(state->rs[WINED3D_RS_POINTSCALE_C]) / scale_factor; + } + else + { + constants.scale_const = 1.0f; + constants.scale_linear = 0.0f; + constants.scale_quad = 0.0f; + } + + wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_VS_POINTSIZE, + offsetof(struct wined3d_ffp_vs_constants, point), sizeof(constants), &constants); + } + if (changed->ffp_ps_constants) { static const struct wined3d_color specular_enabled = {1.0f, 1.0f, 1.0f, 0.0f}; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 3a13045f625..0eda0acc4e9 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5693,39 +5693,6 @@ void get_pointsize_minmax(const struct wined3d_context *context, const struct wi *out_max = max.f; }
-void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state, - float *out_pointsize, float *out_att) -{ - /* POINTSCALEENABLE controls how point size value is treated. If set to - * true, the point size is scaled with respect to height of viewport. - * When set to false point size is in pixels. */ - union - { - DWORD d; - float f; - } pointsize, a, b, c; - - out_att[0] = 1.0f; - out_att[1] = 0.0f; - out_att[2] = 0.0f; - - pointsize.d = state->render_states[WINED3D_RS_POINTSIZE]; - a.d = state->render_states[WINED3D_RS_POINTSCALE_A]; - b.d = state->render_states[WINED3D_RS_POINTSCALE_B]; - c.d = state->render_states[WINED3D_RS_POINTSCALE_C]; - - /* Always use first viewport, this path does not apply to d3d10/11 multiple viewports case. */ - if (state->render_states[WINED3D_RS_POINTSCALEENABLE]) - { - float scale_factor = state->viewports[0].height * state->viewports[0].height; - - out_att[0] = a.f / scale_factor; - out_att[1] = b.f / scale_factor; - out_att[2] = c.f / scale_factor; - } - *out_pointsize = pointsize.f; -} - void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state, float *start, float *end) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7de83d3b1cd..eff2400fd8f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2779,6 +2779,10 @@ struct wined3d_ffp_vs_constants } modelview; struct wined3d_matrix projection_matrix; struct wined3d_matrix texture_matrices[WINED3D_MAX_FFP_TEXTURES]; + struct wined3d_ffp_point_constants + { + float scale_const, scale_linear, scale_quad; + } point; struct wined3d_material material; struct wined3d_ffp_light_constants { @@ -4389,8 +4393,6 @@ void get_texture_matrix(const struct wined3d_stream_info *si, const struct wined3d_stateblock_state *state, const unsigned int tex, struct wined3d_matrix *mat); void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state, float *out_min, float *out_max); -void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state, - float *out_pointsize, float *out_att); void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state, float *start, float *end);