nouveau: match latest gallium changes
authorBen Skeggs <skeggsb@gmail.com>
Tue, 18 Dec 2007 00:27:44 +0000 (11:27 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Tue, 18 Dec 2007 00:27:44 +0000 (11:27 +1100)
src/mesa/pipe/nv40/nv40_state.c
src/mesa/pipe/nv40/nv40_state.h
src/mesa/pipe/nv40/nv40_surface.c
src/mesa/pipe/nv50/nv50_state.c
src/mesa/pipe/nv50/nv50_surface.c

index ceb6f46..12b2c2a 100644 (file)
@@ -7,39 +7,6 @@
 #include "nv40_state.h"
 
 static void *
-nv40_alpha_test_state_create(struct pipe_context *pipe,
-                            const struct pipe_alpha_test_state *cso)
-{
-       struct nv40_alpha_test_state *at;
-
-       at = malloc(sizeof(struct nv40_alpha_test_state));
-
-       at->enabled = cso->enabled ? 1 : 0;
-       at->func = nvgl_comparison_op(cso->func);
-       at->ref  = float_to_ubyte(cso->ref);
-
-       return (void *)at;
-}
-
-static void
-nv40_alpha_test_state_bind(struct pipe_context *pipe, void *hwcso)
-{
-       struct nv40_context *nv40 = (struct nv40_context *)pipe;
-       struct nv40_alpha_test_state *at = hwcso;
-
-       BEGIN_RING(curie, NV40TCL_ALPHA_TEST_ENABLE, 3);
-       OUT_RING  (at->enabled);
-       OUT_RING  (at->func);
-       OUT_RING  (at->ref);
-}
-
-static void
-nv40_alpha_test_state_delete(struct pipe_context *pipe, void *hwcso)
-{
-       free(hwcso);
-}
-
-static void *
 nv40_blend_state_create(struct pipe_context *pipe,
                        const struct pipe_blend_state *cso)
 {
@@ -414,61 +381,59 @@ nv40_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
        free(hwcso);
 }
 
+static void
+nv40_translate_stencil(const struct pipe_depth_stencil_alpha_state *cso,
+                      unsigned idx, struct nv40_stencil_push *hw)
+{
+       hw->enable = cso->stencil[idx].enabled ? 1 : 0;
+       hw->wmask = cso->stencil[idx].write_mask;
+       hw->func = nvgl_comparison_op(cso->stencil[idx].func);
+       hw->ref = cso->stencil[idx].ref_value;
+       hw->vmask = cso->stencil[idx].value_mask;
+       hw->fail = nvgl_stencil_op(cso->stencil[idx].fail_op);
+       hw->zfail = nvgl_stencil_op(cso->stencil[idx].zfail_op);
+       hw->zpass = nvgl_stencil_op(cso->stencil[idx].zpass_op);
+}
+
 static void *
-nv40_depth_stencil_state_create(struct pipe_context *pipe,
-                               const struct pipe_depth_stencil_state *cso)
+nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
+                       const struct pipe_depth_stencil_alpha_state *cso)
 {
-       struct nv40_depth_stencil_state *zs;
+       struct nv40_depth_stencil_alpha_state *hw;
 
-       /*XXX: ignored:
-        *      depth.occlusion_count
-        *      depth.clear
-        *      stencil.clear_value
-        */
-       zs = malloc(sizeof(struct nv40_depth_stencil_state));
-
-       zs->depth.func          = nvgl_comparison_op(cso->depth.func);
-       zs->depth.write_enable  = cso->depth.writemask ? 1 : 0;
-       zs->depth.test_enable   = cso->depth.enabled ? 1 : 0;
-
-       zs->stencil.back.enable = cso->stencil.back_enabled ? 1 : 0;
-       zs->stencil.back.wmask  = cso->stencil.write_mask[1];
-       zs->stencil.back.func   =
-               nvgl_comparison_op(cso->stencil.back_func);
-       zs->stencil.back.ref    = cso->stencil.ref_value[1];
-       zs->stencil.back.vmask  = cso->stencil.value_mask[1];
-       zs->stencil.back.fail   = nvgl_stencil_op(cso->stencil.back_fail_op);
-       zs->stencil.back.zfail  = nvgl_stencil_op(cso->stencil.back_zfail_op);
-       zs->stencil.back.zpass  = nvgl_stencil_op(cso->stencil.back_zpass_op);
-
-       zs->stencil.front.enable= cso->stencil.front_enabled ? 1 : 0;
-       zs->stencil.front.wmask = cso->stencil.write_mask[0];
-       zs->stencil.front.func  =
-               nvgl_comparison_op(cso->stencil.front_func);
-       zs->stencil.front.ref   = cso->stencil.ref_value[0];
-       zs->stencil.front.vmask = cso->stencil.value_mask[0];
-       zs->stencil.front.fail  = nvgl_stencil_op(cso->stencil.front_fail_op);
-       zs->stencil.front.zfail = nvgl_stencil_op(cso->stencil.front_zfail_op);
-       zs->stencil.front.zpass = nvgl_stencil_op(cso->stencil.front_zpass_op);
-
-       return (void *)zs;
+       hw = malloc(sizeof(struct nv40_depth_stencil_alpha_state));
+
+       hw->depth.func          = nvgl_comparison_op(cso->depth.func);
+       hw->depth.write_enable  = cso->depth.writemask ? 1 : 0;
+       hw->depth.test_enable   = cso->depth.enabled ? 1 : 0;
+
+       nv40_translate_stencil(cso, 0, &hw->stencil.front);
+       nv40_translate_stencil(cso, 1, &hw->stencil.back);
+
+       hw->alpha.enabled = cso->alpha.enabled ? 1 : 0;
+       hw->alpha.func = nvgl_comparison_op(cso->alpha.func);
+       hw->alpha.ref  = float_to_ubyte(cso->alpha.ref);
+
+       return (void *)hw;
 }
 
 static void
-nv40_depth_stencil_state_bind(struct pipe_context *pipe, void *hwcso)
+nv40_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
 {
        struct nv40_context *nv40 = (struct nv40_context *)pipe;
-       struct nv40_depth_stencil_state *zs = hwcso;
+       struct nv40_depth_stencil_alpha_state *hw = hwcso;
 
        BEGIN_RING(curie, NV40TCL_DEPTH_FUNC, 3);
-       OUT_RINGp ((uint32_t *)&zs->depth, 3);
+       OUT_RINGp ((uint32_t *)&hw->depth, 3);
        BEGIN_RING(curie, NV40TCL_STENCIL_BACK_ENABLE, 16);
-       OUT_RINGp ((uint32_t *)&zs->stencil.back, 8);
-       OUT_RINGp ((uint32_t *)&zs->stencil.front, 8);
+       OUT_RINGp ((uint32_t *)&hw->stencil.back, 8);
+       OUT_RINGp ((uint32_t *)&hw->stencil.front, 8);
+       BEGIN_RING(curie, NV40TCL_ALPHA_TEST_ENABLE, 3);
+       OUT_RINGp ((uint32_t *)&hw->alpha.enabled, 3);
 }
 
 static void
-nv40_depth_stencil_state_delete(struct pipe_context *pipe, void *hwcso)
+nv40_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
 {
        free(hwcso);
 }
@@ -785,10 +750,6 @@ nv40_set_vertex_element(struct pipe_context *pipe, unsigned index,
 void
 nv40_init_state_functions(struct nv40_context *nv40)
 {
-       nv40->pipe.create_alpha_test_state = nv40_alpha_test_state_create;
-       nv40->pipe.bind_alpha_test_state = nv40_alpha_test_state_bind;
-       nv40->pipe.delete_alpha_test_state = nv40_alpha_test_state_delete;
-
        nv40->pipe.create_blend_state = nv40_blend_state_create;
        nv40->pipe.bind_blend_state = nv40_blend_state_bind;
        nv40->pipe.delete_blend_state = nv40_blend_state_delete;
@@ -802,9 +763,12 @@ nv40_init_state_functions(struct nv40_context *nv40)
        nv40->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind;
        nv40->pipe.delete_rasterizer_state = nv40_rasterizer_state_delete;
 
-       nv40->pipe.create_depth_stencil_state = nv40_depth_stencil_state_create;
-       nv40->pipe.bind_depth_stencil_state = nv40_depth_stencil_state_bind;
-       nv40->pipe.delete_depth_stencil_state = nv40_depth_stencil_state_delete;
+       nv40->pipe.create_depth_stencil_alpha_state =
+               nv40_depth_stencil_alpha_state_create;
+       nv40->pipe.bind_depth_stencil_alpha_state =
+               nv40_depth_stencil_alpha_state_bind;
+       nv40->pipe.delete_depth_stencil_alpha_state =
+               nv40_depth_stencil_alpha_state_delete;
 
        nv40->pipe.create_vs_state = nv40_vp_state_create;
        nv40->pipe.bind_vs_state = nv40_vp_state_bind;
index eb84738..e1a9d58 100644 (file)
@@ -3,12 +3,6 @@
 
 #include "pipe/p_state.h"
 
-struct nv40_alpha_test_state {
-       uint32_t enabled;
-       uint32_t func;
-       uint32_t ref;
-};
-
 struct nv40_blend_state {
        uint32_t b_enable;
        uint32_t b_srcfunc;
@@ -106,12 +100,6 @@ struct nv40_fragment_program {
        uint32_t fp_control;
 };
 
-struct nv40_depth_push {
-       uint32_t func;
-       uint32_t write_enable;
-       uint32_t test_enable;
-};
-
 struct nv40_stencil_push {
        uint32_t enable;
        uint32_t wmask;
@@ -123,12 +111,23 @@ struct nv40_stencil_push {
        uint32_t zpass;
 };
 
-struct nv40_depth_stencil_state {
-       struct nv40_depth_push depth;
-       union {
+struct nv40_depth_stencil_alpha_state {
+       struct {
+               uint32_t func;
+               uint32_t write_enable;
+               uint32_t test_enable;
+       } depth;
+
+       struct {
                struct nv40_stencil_push back;
                struct nv40_stencil_push front;
        } stencil;
+
+       struct {
+               uint32_t enabled;
+               uint32_t func;
+               uint32_t ref;
+       } alpha;
 };
 
 struct nv40_miptree {
index 15dc7f2..6a16a28 100644 (file)
 #include "pipe/p_util.h"
 #include "pipe/p_winsys.h"
 #include "pipe/p_inlines.h"
-#include "pipe/softpipe/sp_rgba_tile.h"
-
-
-#define CLIP_TILE \
-   do { \
-      if (x >= ps->width) \
-         return; \
-      if (y >= ps->height) \
-         return; \
-      if (x + w > ps->width) \
-         w = ps->width - x; \
-      if (y + h > ps->height) \
-         h = ps->height -y; \
-   } while(0)
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-nv40_get_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              void *p, int dst_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (dst_stride == 0) {
-      dst_stride = w0 * cpp;
-   }
-
-   pSrc = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
-   pDest = (ubyte *) p;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += dst_stride;
-      pSrc += ps->pitch * cpp;
-   }
-}
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-nv40_put_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              const void *p, int src_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (src_stride == 0) {
-      src_stride = w0 * cpp;
-   }
-
-   pSrc = (const ubyte *) p;
-   pDest = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += ps->pitch * cpp;
-      pSrc += src_stride;
-   }
-}
-
+#include "pipe/util/p_tile.h"
 
 static struct pipe_surface *
 nv40_get_tex_surface(struct pipe_context *pipe,
@@ -185,10 +104,10 @@ void
 nv40_init_surface_functions(struct nv40_context *nv40)
 {
    nv40->pipe.get_tex_surface = nv40_get_tex_surface;
-   nv40->pipe.get_tile = nv40_get_tile;
-   nv40->pipe.put_tile = nv40_put_tile;
-   nv40->pipe.get_tile_rgba = softpipe_get_tile_rgba;
-   nv40->pipe.put_tile_rgba = softpipe_put_tile_rgba;
+   nv40->pipe.get_tile = pipe_get_tile_raw;
+   nv40->pipe.put_tile = pipe_put_tile_raw;
+   nv40->pipe.get_tile_rgba = pipe_get_tile_rgba;
+   nv40->pipe.put_tile_rgba = pipe_put_tile_rgba;
    nv40->pipe.surface_data = nv40_surface_data;
    nv40->pipe.surface_copy = nv40_surface_copy;
    nv40->pipe.surface_fill = nv40_surface_fill;
index 0a27a46..25eac41 100644 (file)
@@ -7,23 +7,6 @@
 #include "nv50_state.h"
 
 static void *
-nv50_alpha_test_state_create(struct pipe_context *pipe,
-                            const struct pipe_alpha_test_state *cso)
-{
-       return NULL;
-}
-
-static void
-nv50_alpha_test_state_bind(struct pipe_context *pipe, void *hwcso)
-{
-}
-
-static void
-nv50_alpha_test_state_delete(struct pipe_context *pipe, void *hwcso)
-{
-}
-
-static void *
 nv50_blend_state_create(struct pipe_context *pipe,
                        const struct pipe_blend_state *cso)
 {
@@ -82,19 +65,19 @@ nv50_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
 }
 
 static void *
-nv50_depth_stencil_state_create(struct pipe_context *pipe,
-                               const struct pipe_depth_stencil_state *cso)
+nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
+                       const struct pipe_depth_stencil_alpha_state *cso)
 {
        return NULL;
 }
 
 static void
-nv50_depth_stencil_state_bind(struct pipe_context *pipe, void *hwcso)
+nv50_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
 {
 }
 
 static void
-nv50_depth_stencil_state_delete(struct pipe_context *pipe, void *hwcso)
+nv50_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
 {
 }
 
@@ -187,10 +170,6 @@ nv50_set_vertex_element(struct pipe_context *pipe, unsigned index,
 void
 nv50_init_state_functions(struct nv50_context *nv50)
 {
-       nv50->pipe.create_alpha_test_state = nv50_alpha_test_state_create;
-       nv50->pipe.bind_alpha_test_state = nv50_alpha_test_state_bind;
-       nv50->pipe.delete_alpha_test_state = nv50_alpha_test_state_delete;
-
        nv50->pipe.create_blend_state = nv50_blend_state_create;
        nv50->pipe.bind_blend_state = nv50_blend_state_bind;
        nv50->pipe.delete_blend_state = nv50_blend_state_delete;
@@ -204,9 +183,12 @@ nv50_init_state_functions(struct nv50_context *nv50)
        nv50->pipe.bind_rasterizer_state = nv50_rasterizer_state_bind;
        nv50->pipe.delete_rasterizer_state = nv50_rasterizer_state_delete;
 
-       nv50->pipe.create_depth_stencil_state = nv50_depth_stencil_state_create;
-       nv50->pipe.bind_depth_stencil_state = nv50_depth_stencil_state_bind;
-       nv50->pipe.delete_depth_stencil_state = nv50_depth_stencil_state_delete;
+       nv50->pipe.create_depth_stencil_alpha_state =
+               nv50_depth_stencil_alpha_state_create;
+       nv50->pipe.bind_depth_stencil_alpha_state =
+               nv50_depth_stencil_alpha_state_bind;
+       nv50->pipe.delete_depth_stencil_alpha_state =
+               nv50_depth_stencil_alpha_state_delete;
 
        nv50->pipe.create_vs_state = nv50_vp_state_create;
        nv50->pipe.bind_vs_state = nv50_vp_state_bind;
index 7e294cd..44e6728 100644 (file)
 #include "pipe/p_util.h"
 #include "pipe/p_winsys.h"
 #include "pipe/p_inlines.h"
-
-
-#define CLIP_TILE \
-   do { \
-      if (x >= ps->width) \
-         return; \
-      if (y >= ps->height) \
-         return; \
-      if (x + w > ps->width) \
-         w = ps->width - x; \
-      if (y + h > ps->height) \
-         h = ps->height -y; \
-   } while(0)
-
-
-/**
- * Note: this is exactly like a8r8g8b8_get_tile() in sp_surface.c
- * Share it someday.
- */
-static void
-nv50_get_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_surface *ps,
-                   uint x, uint y, uint w, uint h, float *p)
-{
-   const unsigned *src
-      = ((const unsigned *) (ps->map + ps->offset))
-      + y * ps->pitch + x;
-   unsigned i, j;
-   unsigned w0 = w;
-
-   CLIP_TILE;
-
-   switch (ps->format) {
-   case PIPE_FORMAT_A8R8G8B8_UNORM:
-      for (i = 0; i < h; i++) {
-         float *pRow = p;
-         for (j = 0; j < w; j++) {
-            const unsigned pixel = src[j];
-            pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
-            pRow[1] = UBYTE_TO_FLOAT((pixel >>  8) & 0xff);
-            pRow[2] = UBYTE_TO_FLOAT((pixel >>  0) & 0xff);
-            pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
-            pRow += 4;
-         }
-         src += ps->pitch;
-         p += w0 * 4;
-      }
-      break;
-   case PIPE_FORMAT_Z24S8_UNORM:
-      {
-         const float scale = 1.0 / (float) 0xffffff;
-         for (i = 0; i < h; i++) {
-            float *pRow = p;
-            for (j = 0; j < w; j++) {
-               const unsigned pixel = src[j];
-               pRow[0] =
-               pRow[1] =
-               pRow[2] =
-               pRow[3] = ((pixel & 0xffffff) >> 8) * scale;
-               pRow += 4;
-            }
-            src += ps->pitch;
-            p += w0 * 4;
-         }
-      }
-      break;
-   default:
-      assert(0);
-   }
-}
-
-
-static void
-nv50_put_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_surface *ps,
-                   uint x, uint y, uint w, uint h, const float *p)
-{
-   /* TODO */
-   assert(0);
-}
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-nv50_get_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              void *p, int dst_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (dst_stride == 0) {
-      dst_stride = w0 * cpp;
-   }
-
-   pSrc = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
-   pDest = (ubyte *) p;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += dst_stride;
-      pSrc += ps->pitch * cpp;
-   }
-}
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-nv50_put_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              const void *p, int src_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (src_stride == 0) {
-      src_stride = w0 * cpp;
-   }
-
-   pSrc = (const ubyte *) p;
-   pDest = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += ps->pitch * cpp;
-      pSrc += src_stride;
-   }
-}
-
+#include "pipe/util/p_tile.h"
 
 static struct pipe_surface *
 nv50_get_tex_surface(struct pipe_context *pipe,
@@ -230,10 +82,10 @@ void
 nv50_init_surface_functions(struct nv50_context *nv50)
 {
    nv50->pipe.get_tex_surface = nv50_get_tex_surface;
-   nv50->pipe.get_tile = nv50_get_tile;
-   nv50->pipe.put_tile = nv50_put_tile;
-   nv50->pipe.get_tile_rgba = nv50_get_tile_rgba;
-   nv50->pipe.put_tile_rgba = nv50_put_tile_rgba;
+   nv50->pipe.get_tile = pipe_get_tile_raw;
+   nv50->pipe.put_tile = pipe_put_tile_raw;
+   nv50->pipe.get_tile_rgba = pipe_get_tile_rgba;
+   nv50->pipe.put_tile_rgba = pipe_put_tile_rgba;
    nv50->pipe.surface_data = nv50_surface_data;
    nv50->pipe.surface_copy = nv50_surface_copy;
    nv50->pipe.surface_fill = nv50_surface_fill;