i965: Add support for GL_ARB_cull_distance
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 13 May 2016 00:38:56 +0000 (17:38 -0700)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 13 May 2016 23:28:25 +0000 (16:28 -0700)
Signed-off-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_compiler.h
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/gen6_clip_state.c
src/mesa/drivers/dri/i965/gen8_ds_state.c
src/mesa/drivers/dri/i965/gen8_gs_state.c
src/mesa/drivers/dri/i965/gen8_vs_state.c
src/mesa/drivers/dri/i965/intel_extensions.c

index 580730589c398c63ca5f95c754571f438e3518ae..3d1dc88eebc789792deaa7e605c7952dff78092d 100644 (file)
@@ -592,6 +592,8 @@ struct brw_vue_prog_data {
    GLuint urb_read_length;
    GLuint total_grf;
 
+   uint32_t cull_distance_mask;
+
    /* Used for calculating urb partitions.  In the VS, this is the size of the
     * URB entry used for both input and output to the thread.  In the GS, this
     * is the size of the URB entry used for output.
index c888ef2bd67b6bd1ca933d26165e68a5d5688910..91efd344f90344478c0c67ecd01d961b85774029 100644 (file)
@@ -138,6 +138,10 @@ brw_codegen_gs_prog(struct brw_context *brw,
 
    GLbitfield64 outputs_written = gp->program.Base.OutputsWritten;
 
+   prog_data.base.cull_distance_mask =
+      ((1 << gp->program.Base.CullDistanceArraySize) - 1) <<
+      gp->program.Base.ClipDistanceArraySize;
+
    brw_compute_vue_map(brw->intelScreen->devinfo,
                        &prog_data.base.vue_map, outputs_written,
                        prog ? prog->SeparateShader : false);
index 27dc7e59f5d1fb43ffda1c72570e3afaf1a3070e..b7f1677caec4a4a083cbd57f0feaaa42b089be6a 100644 (file)
@@ -164,6 +164,10 @@ brw_codegen_tes_prog(struct brw_context *brw,
    prog_data.base.base.nr_params = param_count;
    prog_data.base.base.nr_image_params = tes->NumImages;
 
+   prog_data.base.cull_distance_mask =
+      ((1 << tep->program.Base.CullDistanceArraySize) - 1) <<
+      tep->program.Base.ClipDistanceArraySize;
+
    brw_nir_setup_glsl_uniforms(nir, shader_prog, &tep->program.Base,
                                &prog_data.base.base,
                                compiler->scalar_stage[MESA_SHADER_TESS_EVAL]);
index 3095d82d91eeff8ce69a5ccd703fc982fc253bae..1bbc315e9da34fa8329304ff2ad9c4a63d2f6220 100644 (file)
@@ -118,6 +118,10 @@ brw_codegen_vs_prog(struct brw_context *brw,
       prog_data.inputs_read |= VERT_BIT_EDGEFLAG;
    }
 
+   prog_data.base.cull_distance_mask =
+      ((1 << vp->program.Base.CullDistanceArraySize) - 1) <<
+      vp->program.Base.ClipDistanceArraySize;
+
    if (brw->gen < 6) {
       /* Put dummy slots into the VUE for the SF to put the replaced
        * point sprite coords in.  We shouldn't need these dummy slots,
index 8ae19c8d3701bfeea1f6106dcc2f399fdf29a063..26de633bae6d9e2e15cb0b5640a1b9145b1c9fdf 100644 (file)
@@ -50,6 +50,8 @@ upload_clip_state(struct brw_context *brw)
       dw2 |= GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE;
    }
 
+   dw1 |= brw->vs.prog_data->base.cull_distance_mask;
+
    if (brw->gen >= 7)
       dw1 |= GEN7_CLIP_EARLY_CULL;
 
index c73016897b11b34241082e9e8e6cc2c08aab1a11..95582ac44482400917978f4ca1640b21a09085ae 100644 (file)
@@ -69,7 +69,8 @@ gen8_upload_ds_state(struct brw_context *brw)
                  GEN7_DS_SIMD8_DISPATCH_ENABLE : 0) |
                 (tes_prog_data->domain == BRW_TESS_DOMAIN_TRI ?
                  GEN7_DS_COMPUTE_W_COORDINATE_ENABLE : 0));
-      OUT_BATCH(SET_FIELD(ctx->Transform.ClipPlanesEnabled,
+      OUT_BATCH(SET_FIELD(vue_prog_data->cull_distance_mask |
+                          ctx->Transform.ClipPlanesEnabled,
                           GEN8_DS_USER_CLIP_DISTANCE));
 
       if (brw->gen >= 9) {
index 0889311ad5c46fe4671c5fda1b7000176a1742d5..2741330106d385e82540fc8f1fe28a23720f81f6 100644 (file)
@@ -108,7 +108,8 @@ gen8_upload_gs_state(struct brw_context *brw)
       OUT_BATCH(dw8);
 
       /* DW9 / _NEW_TRANSFORM */
-      OUT_BATCH((ctx->Transform.ClipPlanesEnabled <<
+      OUT_BATCH((prog_data->cull_distance_mask |
+                 ctx->Transform.ClipPlanesEnabled <<
                  GEN8_GS_USER_CLIP_DISTANCE_SHIFT) |
                 (urb_entry_output_length << GEN8_GS_URB_OUTPUT_LENGTH_SHIFT) |
                 (urb_entry_write_offset <<
index fd59a86b77f2bfbe7b340150cd4b8b041befa4be..d4a345583d68e91cc372469d915053290bd678eb 100644 (file)
@@ -77,7 +77,8 @@ upload_vs_state(struct brw_context *brw)
              GEN6_VS_ENABLE);
 
    /* _NEW_TRANSFORM */
-   OUT_BATCH((ctx->Transform.ClipPlanesEnabled <<
+   OUT_BATCH(prog_data->cull_distance_mask |
+             (ctx->Transform.ClipPlanesEnabled <<
               GEN8_VS_USER_CLIP_DISTANCE_SHIFT));
    ADVANCE_BATCH();
 }
index 8d98788a8381d976403bd19263bfad74f17524ef..f8faaa36b0bf99138c438a1429511af5a0638cec 100644 (file)
@@ -289,6 +289,7 @@ intelInitExtensions(struct gl_context *ctx)
       ctx->Extensions.ARB_blend_func_extended =
          !driQueryOptionb(&brw->optionCache, "disable_blend_func_extended");
       ctx->Extensions.ARB_conditional_render_inverted = true;
+      ctx->Extensions.ARB_cull_distance = true;
       ctx->Extensions.ARB_draw_buffers_blend = true;
       ctx->Extensions.ARB_ES3_compatibility = true;
       ctx->Extensions.ARB_fragment_layer_viewport = true;