intel: activate the gl_BaseVertex lowering
authorAntia Puentes <apuentes@igalia.com>
Sat, 28 Apr 2018 12:09:22 +0000 (14:09 +0200)
committerAntia Puentes <apuentes@igalia.com>
Wed, 2 May 2018 09:24:46 +0000 (11:24 +0200)
Surplus code related to the basevertex is removed.

The Vertex Elements contain now:
* VE 1: <firstvertex, BaseInstance, VertexID, InstanceID>
* VE 2: <DrawID, is_indexed_draw, 0, 0>

Also fixes unreachable message.

Fixes OpenGL CTS tests:
* KHR-GL46.shader_draw_parameters_tests.ShaderDrawArraysInstancedParameters
* KHR-GL46.shader_draw_parameters_tests.ShaderMultiDrawArraysParameters
* KHR-GL46.shader_draw_parameters_tests.MultiDrawArraysIndirectCountParameters
* KHR-GL46.shader_draw_parameters_tests.ShaderDrawArraysParameters
* KHR-GL46.shader_draw_parameters_tests.ShaderMultiDrawArraysIndirectParameters

Fixes Piglit tests:
* arb_shader_draw_parameters-drawid-indirect baseinstance
* arb_shader_draw_parameters-basevertex

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102678

src/intel/compiler/brw_compiler.c
src/intel/compiler/brw_compiler.h
src/intel/compiler/brw_fs_nir.cpp
src/intel/compiler/brw_nir.c
src/intel/compiler/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_draw_upload.c
src/mesa/drivers/dri/i965/genX_state_upload.c

index d5f483798a9def7f905d7d69339be3b16f8d9d3f..6480dbefbf6bf4d9aeab610e662933737a3b01e6 100644 (file)
@@ -45,7 +45,8 @@
    .lower_device_index_to_zero = true,                                        \
    .native_integers = true,                                                   \
    .use_interpolated_input_intrinsics = true,                                 \
-   .vertex_id_zero_based = true
+   .vertex_id_zero_based = true,                                              \
+   .lower_base_vertex = true
 
 #define COMMON_SCALAR_OPTIONS                                                 \
    .lower_pack_half_2x16 = true,                                              \
index e3bf535a519173c2120c6ee6b3bdb14696ca0b2a..8b4e6fe2e2947dda81d7ffbc54d6ae024a886a71 100644 (file)
@@ -977,7 +977,6 @@ struct brw_vs_prog_data {
 
    bool uses_vertexid;
    bool uses_instanceid;
-   bool uses_basevertex;
    bool uses_is_indexed_draw;
    bool uses_firstvertex;
    bool uses_baseinstance;
index 22beb0e00d1a7c3c07ca2377cad5354c5645623f..02aaf14401925b9649b05b159e9fc82bde5a8bca 100644 (file)
@@ -112,10 +112,10 @@ emit_system_values_block(nir_block *block, fs_visitor *v)
       nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
       switch (intrin->intrinsic) {
       case nir_intrinsic_load_vertex_id:
-         unreachable("should be lowered by lower_vertex_id().");
+      case nir_intrinsic_load_base_vertex:
+         unreachable("should be lowered by nir_lower_system_values().");
 
       case nir_intrinsic_load_vertex_id_zero_base:
-      case nir_intrinsic_load_base_vertex:
       case nir_intrinsic_load_is_indexed_draw:
       case nir_intrinsic_load_first_vertex:
       case nir_intrinsic_load_instance_id:
@@ -2420,10 +2420,10 @@ fs_visitor::nir_emit_vs_intrinsic(const fs_builder &bld,
 
    switch (instr->intrinsic) {
    case nir_intrinsic_load_vertex_id:
-      unreachable("should be lowered by lower_vertex_id()");
+   case nir_intrinsic_load_base_vertex:
+      unreachable("should be lowered by nir_lower_system_values()");
 
    case nir_intrinsic_load_vertex_id_zero_base:
-   case nir_intrinsic_load_base_vertex:
    case nir_intrinsic_load_instance_id:
    case nir_intrinsic_load_base_instance:
    case nir_intrinsic_load_draw_id: {
index a624deb6d2ac60318609b256eb13e9a5e76b4b54..9998c59586ebd71ae26dd96553e54334c340e824 100644 (file)
@@ -238,8 +238,7 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
     */
    const bool has_sgvs =
       nir->info.system_values_read &
-      (BITFIELD64_BIT(SYSTEM_VALUE_BASE_VERTEX) |
-       BITFIELD64_BIT(SYSTEM_VALUE_FIRST_VERTEX) |
+      (BITFIELD64_BIT(SYSTEM_VALUE_FIRST_VERTEX) |
        BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE) |
        BITFIELD64_BIT(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) |
        BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID));
@@ -261,7 +260,6 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
             nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
 
             switch (intrin->intrinsic) {
-            case nir_intrinsic_load_base_vertex:
             case nir_intrinsic_load_first_vertex:
             case nir_intrinsic_load_base_instance:
             case nir_intrinsic_load_vertex_id_zero_base:
@@ -280,7 +278,6 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
 
                nir_intrinsic_set_base(load, num_inputs);
                switch (intrin->intrinsic) {
-               case nir_intrinsic_load_base_vertex:
                case nir_intrinsic_load_first_vertex:
                   nir_intrinsic_set_component(load, 0);
                   break;
index 898df90225fbd762f2511eae35880c00a610bd56..4464a91398867d48e716d5cf319c3aba956a024d 100644 (file)
@@ -2825,8 +2825,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
     * incoming vertex attribute.  So, add an extra slot.
     */
    if (shader->info.system_values_read &
-       (BITFIELD64_BIT(SYSTEM_VALUE_BASE_VERTEX) |
-        BITFIELD64_BIT(SYSTEM_VALUE_FIRST_VERTEX) |
+       (BITFIELD64_BIT(SYSTEM_VALUE_FIRST_VERTEX) |
         BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE) |
         BITFIELD64_BIT(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) |
         BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID))) {
@@ -2840,10 +2839,6 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
       nr_attribute_slots++;
    }
 
-   if (shader->info.system_values_read &
-       BITFIELD64_BIT(SYSTEM_VALUE_BASE_VERTEX))
-      prog_data->uses_basevertex = true;
-
    if (shader->info.system_values_read &
        BITFIELD64_BIT(SYSTEM_VALUE_IS_INDEXED_DRAW))
       prog_data->uses_is_indexed_draw = true;
index 05ad32e2eddb10bc41d413d1b2f4445c15e3d052..25ba372c449c178c214ac7f07e986a828219b486 100644 (file)
@@ -825,16 +825,12 @@ brw_draw_single_prim(struct gl_context *ctx,
    const struct brw_vs_prog_data *vs_prog_data =
       brw_vs_prog_data(brw->vs.base.prog_data);
    if (prim_id > 0) {
-      const bool uses_firstvertex =
-         vs_prog_data->uses_basevertex ||
-         vs_prog_data->uses_firstvertex;
-
       const bool uses_draw_parameters =
-         uses_firstvertex ||
+         vs_prog_data->uses_firstvertex ||
          vs_prog_data->uses_baseinstance;
 
       if ((uses_draw_parameters && prim->is_indirect) ||
-          (uses_firstvertex &&
+          (vs_prog_data->uses_firstvertex &&
            brw->draw.params.firstvertex != new_firstvertex) ||
           (vs_prog_data->uses_baseinstance &&
            brw->draw.params.gl_baseinstance != new_baseinstance))
index 55566a7de440c9dc478cca1ae18b7f10549ebada..b1be269ca9183c4ffb6e16b75ee8d866b434b0f6 100644 (file)
@@ -704,11 +704,8 @@ brw_prepare_shader_draw_parameters(struct brw_context *brw)
    const struct brw_vs_prog_data *vs_prog_data =
       brw_vs_prog_data(brw->vs.base.prog_data);
 
-   const bool uses_firstvertex =
-      vs_prog_data->uses_basevertex || vs_prog_data->uses_firstvertex;
-
    /* For non-indirect draws, upload the shader draw parameters */
-   if ((uses_firstvertex || vs_prog_data->uses_baseinstance) &&
+   if ((vs_prog_data->uses_firstvertex || vs_prog_data->uses_baseinstance) &&
        brw->draw.draw_params_bo == NULL) {
       brw_upload_data(&brw->upload,
                       &brw->draw.params, sizeof(brw->draw.params), 4,
index 093954054fc2a21dc620dc2ab45085fdd7ae1999..b1867c1a1ccaf2650be29003cabeb994762eea91 100644 (file)
@@ -541,7 +541,6 @@ genX(emit_vertices)(struct brw_context *brw)
 
    const bool uses_draw_params =
       vs_prog_data->uses_firstvertex ||
-      vs_prog_data->uses_basevertex ||
       vs_prog_data->uses_baseinstance;
 
    const bool uses_derived_draw_params =