lima/ppir: enable vectorize optimization
[mesa.git] / src / gallium / drivers / i915 / i915_state_dynamic.c
index 7e1759786586add17cfa614165bfd777e40f7545..434b09d4e0e3b63b3de40e18b7228f5649318262 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2003 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -46,7 +46,7 @@
  * (active) state every time a 4kb boundary is crossed.
  */
 
-static INLINE void set_dynamic(struct i915_context *i915,
+static inline void set_dynamic(struct i915_context *i915,
                                unsigned offset,
                                const unsigned state)
 {
@@ -60,7 +60,7 @@ static INLINE void set_dynamic(struct i915_context *i915,
 
 
 
-static INLINE void set_dynamic_array(struct i915_context *i915,
+static inline void set_dynamic_array(struct i915_context *i915,
                                      unsigned offset,
                                      const unsigned *src,
                                      unsigned dwords)
@@ -193,6 +193,59 @@ const struct i915_tracked_state i915_upload_DEPTHSCALE = {
 
 
 
+/***********************************************************************
+ * Polygon stipple
+ *
+ * The i915 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
+ *
+ * XXX: does stipple pattern need to be adjusted according to
+ * the window position?
+ *
+ * XXX: possibly need workaround for conform paths test.
+ */
+static void upload_STIPPLE(struct i915_context *i915)
+{
+   unsigned st[2];
+
+   st[0] = _3DSTATE_STIPPLE;
+   st[1] = 0;
+
+   /* I915_NEW_RASTERIZER
+    */
+   if (i915->rasterizer)
+      st[1] |= i915->rasterizer->st;
+
+   /* I915_NEW_STIPPLE
+    */
+   {
+      const ubyte *mask = (const ubyte *)i915->poly_stipple.stipple;
+      ubyte p[4];
+
+      p[0] = mask[12] & 0xf;
+      p[1] = mask[8] & 0xf;
+      p[2] = mask[4] & 0xf;
+      p[3] = mask[0] & 0xf;
+
+      /* Not sure what to do about fallbacks, so for now just dont:
+       */
+      st[1] |= ((p[0] << 0) |
+                (p[1] << 4) |
+                (p[2] << 8) |
+                (p[3] << 12));
+   }
+
+   set_dynamic_array(i915, I915_DYNAMIC_STP_0, st, 2);
+}
+
+const struct i915_tracked_state i915_upload_STIPPLE = {
+   "STIPPLE",
+   upload_STIPPLE,
+   I915_NEW_RASTERIZER | I915_NEW_STIPPLE
+};
+
+
+
 /***********************************************************************
  * Scissor enable
  */
@@ -243,6 +296,7 @@ static const struct i915_tracked_state *atoms[] = {
    &i915_upload_BLENDCOLOR,
    &i915_upload_IAB,
    &i915_upload_DEPTHSCALE,
+   &i915_upload_STIPPLE,
    &i915_upload_SCISSOR_ENABLE,
    &i915_upload_SCISSOR_RECT
 };
@@ -254,7 +308,7 @@ static void update_dynamic(struct i915_context *i915)
 {
    int i;
 
-   for (i = 0; i < Elements(atoms); i++)
+   for (i = 0; i < ARRAY_SIZE(atoms); i++)
       if (i915->dirty & atoms[i]->dirty)
          atoms[i]->update(i915);
 }
@@ -262,5 +316,5 @@ static void update_dynamic(struct i915_context *i915)
 struct i915_tracked_state i915_hw_dynamic = {
    "dynamic",
    update_dynamic,
-   ~0 /* all state atoms, becuase we do internal checking */
+   ~0 /* all state atoms, because we do internal checking */
 };