mesa: Only expose GLES's EXT_texture_type_2_10_10_10_REV if supported in HW.
[mesa.git] / src / mesa / drivers / dri / i965 / gen6_clip_state.c
index 801b88fe047c37d79fe6a44d40c60b2dc09de35c..2fffb673bfc918dbdf979cf372eaea06147a6697 100644 (file)
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
+#include "compiler/brw_eu_defines.h"
 #include "brw_util.h"
 #include "intel_batchbuffer.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
 
-uint32_t
-brw_compute_userclip_flags(bool uses_clip_distance,
-                           GLbitfield clip_planes_enabled)
+bool
+brw_is_drawing_points(const struct brw_context *brw)
 {
-   if (uses_clip_distance) {
-      /* When using gl_ClipDistance, it is up to the shader to decide which
-       * clip distance values to use.
-       */
-      return clip_planes_enabled;
+   /* Determine if the primitives *reaching the SF* are points */
+   /* _NEW_POLYGON */
+   if (brw->ctx.Polygon.FrontMode == GL_POINT ||
+       brw->ctx.Polygon.BackMode == GL_POINT) {
+      return true;
+   }
+
+   if (brw->gs.base.prog_data) {
+      /* BRW_NEW_GS_PROG_DATA */
+      return brw_gs_prog_data(brw->gs.base.prog_data)->output_topology ==
+             _3DPRIM_POINTLIST;
+   } else if (brw->tes.base.prog_data) {
+      /* BRW_NEW_TES_PROG_DATA */
+      return brw_tes_prog_data(brw->tes.base.prog_data)->output_topology ==
+             BRW_TESS_OUTPUT_TOPOLOGY_POINT;
    } else {
-      /* When using clipping planes, we compact the ones that are in use so
-       * that they are always numbered consecutively from zero, so we need to
-       * enable clipping planes 0 through n-1 in the hardware regardless of
-       * which planes the user has selected.
-       */
-      return (1 << _mesa_bitcount_64(clip_planes_enabled)) - 1;
+      /* BRW_NEW_PRIMITIVE */
+      return brw->primitive == _3DPRIM_POINTLIST;
    }
 }
 
-static void
-upload_clip_state(struct brw_context *brw)
+bool
+brw_is_drawing_lines(const struct brw_context *brw)
 {
-   struct intel_context *intel = &brw->intel;
-   struct gl_context *ctx = &intel->ctx;
-   uint32_t depth_clamp = 0;
-   uint32_t provoking, userclip;
-
-   /* BRW_NEW_VERTEX_PROGRAM */
-   struct brw_vertex_program *vp =
-      (struct brw_vertex_program *)brw->vertex_program;
-
-   if (!ctx->Transform.DepthClamp)
-      depth_clamp = GEN6_CLIP_Z_TEST;
+   /* Determine if the primitives *reaching the SF* are points */
+   /* _NEW_POLYGON */
+   if (brw->ctx.Polygon.FrontMode == GL_LINE ||
+       brw->ctx.Polygon.BackMode == GL_LINE) {
+      return true;
+   }
 
-   /* _NEW_LIGHT */
-   if (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION) {
-      provoking =
-        (0 << GEN6_CLIP_TRI_PROVOKE_SHIFT) |
-        (1 << GEN6_CLIP_TRIFAN_PROVOKE_SHIFT) |
-        (0 << GEN6_CLIP_LINE_PROVOKE_SHIFT);
+   if (brw->gs.base.prog_data) {
+      /* BRW_NEW_GS_PROG_DATA */
+      return brw_gs_prog_data(brw->gs.base.prog_data)->output_topology ==
+             _3DPRIM_LINESTRIP;
+   } else if (brw->tes.base.prog_data) {
+      /* BRW_NEW_TES_PROG_DATA */
+      return brw_tes_prog_data(brw->tes.base.prog_data)->output_topology ==
+             BRW_TESS_OUTPUT_TOPOLOGY_LINE;
    } else {
-      provoking =
-        (2 << GEN6_CLIP_TRI_PROVOKE_SHIFT) |
-        (2 << GEN6_CLIP_TRIFAN_PROVOKE_SHIFT) |
-        (1 << GEN6_CLIP_LINE_PROVOKE_SHIFT);
+      /* BRW_NEW_PRIMITIVE */
+      switch (brw->primitive) {
+      case _3DPRIM_LINELIST:
+      case _3DPRIM_LINESTRIP:
+      case _3DPRIM_LINELOOP:
+         return true;
+      }
    }
-
-   /* _NEW_TRANSFORM */
-   userclip = brw_compute_userclip_flags(vp->program.UsesClipDistance,
-                                         ctx->Transform.ClipPlanesEnabled);
-
-   BEGIN_BATCH(4);
-   OUT_BATCH(_3DSTATE_CLIP << 16 | (4 - 2));
-   OUT_BATCH(GEN6_CLIP_STATISTICS_ENABLE);
-   OUT_BATCH(GEN6_CLIP_ENABLE |
-            GEN6_CLIP_API_OGL |
-            GEN6_CLIP_MODE_NORMAL |
-            GEN6_CLIP_XY_TEST |
-            userclip << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT |
-            depth_clamp |
-            provoking);
-   OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
-             U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
-             GEN6_CLIP_FORCE_ZERO_RTAINDEX);
-   ADVANCE_BATCH();
+   return false;
 }
 
-const struct brw_tracked_state gen6_clip_state = {
-   .dirty = {
-      .mesa  = _NEW_TRANSFORM | _NEW_LIGHT,
-      .brw   = BRW_NEW_CONTEXT | BRW_NEW_VERTEX_PROGRAM,
-      .cache = 0
-   },
-   .emit = upload_clip_state,
-};