vc4: Add support for vertex color clamping in the rasterizer.
authorEric Anholt <eric@anholt.net>
Tue, 17 May 2016 19:57:44 +0000 (12:57 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 18 May 2016 01:09:58 +0000 (18:09 -0700)
This gets us precompile of vertex shaders at the state tracker level as
well.

src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/vc4/vc4_qir.h
src/gallium/drivers/vc4/vc4_screen.c

index 90c4b2d9014b461ace7c9a29249874f8dd5eae33..5d036eb2604b6a8859d18200d0d1041b98a2918d 100644 (file)
@@ -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;
index f541c754c8858ed5f512b6064f5210de7c3ceed3..4ed5f18da16e892b3f3fd2046b18a8cfc07faa43 100644 (file)
@@ -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 {
index 809ba5410aaa93938834558823b940175c44a918..1e311117ad33daa4eb3d131d6a9eb545353dc728 100644 (file)
@@ -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: