From 18260d05820eca971873407e939007c12600660c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 17 May 2016 12:57:44 -0700 Subject: [PATCH] vc4: Add support for vertex color clamping in the rasterizer. This gets us precompile of vertex shaders at the state tracker level as well. --- src/gallium/drivers/vc4/vc4_program.c | 4 ++++ src/gallium/drivers/vc4/vc4_qir.h | 1 + src/gallium/drivers/vc4/vc4_screen.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 90c4b2d9014..5d036eb2604 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1840,6 +1840,9 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage, if (c->fs_key && c->fs_key->light_twoside) NIR_PASS_V(c->s, nir_lower_two_sided_color); + if (c->vs_key && c->vs_key->clamp_color) + NIR_PASS_V(c->s, nir_lower_clamp_color_outputs); + if (stage == QSTAGE_FRAG) NIR_PASS_V(c->s, nir_lower_clip_fs, c->key->ucp_enables); else @@ -2214,6 +2217,7 @@ vc4_update_compiled_vs(struct vc4_context *vc4, uint8_t prim_mode) vc4_setup_shared_key(vc4, &key->base, &vc4->verttex); key->base.shader_state = vc4->prog.bind_vs; key->compiled_fs_id = vc4->prog.fs->program_id; + key->clamp_color = vc4->rasterizer->base.clamp_vertex_color; for (int i = 0; i < ARRAY_SIZE(key->attr_formats); i++) key->attr_formats[i] = vc4->vtx->pipe[i].src_format; diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index f541c754c88..4ed5f18da16 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -340,6 +340,7 @@ struct vc4_vs_key { enum pipe_format attr_formats[8]; bool is_coord; bool per_vertex_point_size; + bool clamp_color; }; struct vc4_compile { diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c index 809ba5410aa..1e311117ad3 100644 --- a/src/gallium/drivers/vc4/vc4_screen.c +++ b/src/gallium/drivers/vc4/vc4_screen.c @@ -91,6 +91,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) { switch (param) { /* Supported features (boolean caps). */ + case PIPE_CAP_VERTEX_COLOR_CLAMPED: case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: @@ -157,7 +158,6 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: - case PIPE_CAP_VERTEX_COLOR_CLAMPED: case PIPE_CAP_USER_VERTEX_BUFFERS: case PIPE_CAP_QUERY_PIPELINE_STATISTICS: case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: -- 2.30.2