summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-10-03 16:49:15 -0400
committerErik Faye-Lund <[email protected]>2019-10-17 10:41:36 +0200
commit3b4fc2401bc71051ed0f4bae967d6f9405a315ab (patch)
treec3ac2e65f5859dd58e0eaafbf992f8ff1ba1b12c /src/mesa
parent878c94288a8aed3479517660be3e9a88f9b44269 (diff)
mesa/gallium: automatically lower point-size
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c5
-rw-r--r--src/mesa/state_tracker/st_context.c5
-rw-r--r--src/mesa/state_tracker/st_context.h1
-rw-r--r--src/mesa/state_tracker/st_program.c9
-rw-r--r--src/mesa/state_tracker/st_program.h3
5 files changed, 22 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index f79c401e3e7..0f4b3b48387 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -52,6 +52,7 @@
#include "st_atom.h"
#include "st_program.h"
#include "st_texture.h"
+#include "st_util.h"
static unsigned
@@ -216,6 +217,10 @@ st_update_vp( struct st_context *st )
key.clip_negative_one_to_one =
st->ctx->Transform.ClipDepthMode == GL_NEGATIVE_ONE_TO_ONE;
+ /* _NEW_POINT */
+ key.lower_point_size = st->lower_point_size &&
+ !st_point_size_per_vertex(st->ctx);
+
st->vp_variant = st_get_vp_variant(st, stvp, &key);
}
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 8d4705bcc68..6997e70035a 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -677,6 +677,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
!screen->get_param(screen, PIPE_CAP_FLATSHADE);
st->lower_alpha_test =
!screen->get_param(screen, PIPE_CAP_ALPHA_TEST);
+ st->lower_point_size =
+ !screen->get_param(screen, PIPE_CAP_POINT_SIZE_FIXED);
st->has_hw_atomics =
screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
@@ -740,7 +742,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
st->shader_has_one_variant[MESA_SHADER_VERTEX] =
st->has_shareable_shaders &&
!st->clamp_frag_depth_in_shader &&
- !st->clamp_vert_color_in_shader;
+ !st->clamp_vert_color_in_shader &&
+ !st->lower_point_size;
st->shader_has_one_variant[MESA_SHADER_FRAGMENT] =
st->has_shareable_shaders &&
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 99f43828f44..433e27160da 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -149,6 +149,7 @@ struct st_context
boolean has_signed_vertex_buffer_offset;
boolean lower_flatshade;
boolean lower_alpha_test;
+ boolean lower_point_size;
/**
* If a shader can be created when we get its source.
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index f1d3f7b3ce7..857a5444fcc 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -647,6 +647,9 @@ st_create_vp_variant(struct st_context *st,
{
struct st_vp_variant *vpv = CALLOC_STRUCT(st_vp_variant);
struct pipe_context *pipe = st->pipe;
+
+ static const gl_state_index16 point_size_state[STATE_LENGTH] =
+ { STATE_INTERNAL, STATE_POINT_SIZE_CLAMPED, 0 };
struct gl_program_parameter_list *params = stvp->Base.Parameters;
vpv->key = *key;
@@ -671,6 +674,12 @@ st_create_vp_variant(struct st_context *st,
vpv->num_inputs++;
}
+ if (key->lower_point_size) {
+ _mesa_add_state_reference(params, point_size_state);
+ NIR_PASS_V(vpv->tgsi.ir.nir, nir_lower_point_size_mov,
+ point_size_state);
+ }
+
st_finalize_nir(st, &stvp->Base, stvp->shader_program,
vpv->tgsi.ir.nir);
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index b84d219e3c8..85934ee1df5 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -193,6 +193,9 @@ struct st_vp_variant_key
/** both for ARB_depth_clamp */
bool lower_depth_clamp;
bool clip_negative_one_to_one;
+
+ /** lower glPointSize to gl_PointSize */
+ boolean lower_point_size;
};