nv50: 3d driver skeleton
authorBen Skeggs <skeggsb@gmail.com>
Wed, 5 Dec 2007 03:01:01 +0000 (14:01 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Wed, 5 Dec 2007 03:01:01 +0000 (14:01 +1100)
23 files changed:
src/mesa/drivers/dri/nouveau_winsys/Makefile
src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys.c
src/mesa/drivers/dri/nouveau_winsys/nv50_region.c
src/mesa/pipe/Makefile
src/mesa/pipe/nouveau/nouveau_gldefs.h [new file with mode: 0644]
src/mesa/pipe/nouveau/nouveau_winsys.h
src/mesa/pipe/nv40/nv40_context.h
src/mesa/pipe/nv40/nv40_state.c
src/mesa/pipe/nv40/nv40_vbo.c
src/mesa/pipe/nv40/nvgl_pipe.h [deleted file]
src/mesa/pipe/nv50/Makefile [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_clear.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_context.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_context.h [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_dma.h [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_draw.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_miptree.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_query.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_region.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_state.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_state.h [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_surface.c [new file with mode: 0644]
src/mesa/pipe/nv50/nv50_vbo.c [new file with mode: 0644]

index 97b861526f421989ac47b60157fbfce454376f71..292ec5e0a437830780b5b7bd0da2465bbe63e448 100644 (file)
@@ -8,7 +8,8 @@ MINIGLX_SOURCES =
 
 PIPE_DRIVERS = \
        $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a \
-       $(TOP)/src/mesa/pipe/nv40/libnv40.a
+       $(TOP)/src/mesa/pipe/nv40/libnv40.a \
+       $(TOP)/src/mesa/pipe/nv50/libnv50.a
 
 DRIVER_SOURCES = \
        nouveau_bo.c \
index 6840ec5f7549324e9191a62e22a3fa2adc2b6d96..e35b6009e349de52135861bb260f57f18203ef7b 100644 (file)
@@ -181,6 +181,10 @@ nouveau_pipe_create(struct nouveau_context *nv)
        case 0x40:
                hw_create = nv40_create;
                break;
+       case 0x50:
+       case 0x80:
+               hw_create = nv50_create;
+               break;
        default:
                NOUVEAU_ERR("Unknown chipset NV%02x\n", (int)nv->chipset);
                return NULL;
index 75bfcaf6c8ae3ed07b5798884dc53fc92399842d..168cbdfb7c2bbe1ccc57ea44e24a77353a5c6930 100644 (file)
@@ -125,7 +125,7 @@ nv50_region_fill(struct nouveau_context *nv,
        OUT_RING  (dst->pitch);
        OUT_RING  (dst->height);
 
-       BEGIN_RING(Nv2D, 0x0580, 4);
+       BEGIN_RING(Nv2D, 0x0580, 3);
        OUT_RING  (4);
        OUT_RING  (rect_format);
        OUT_RING  (value);
index 135f1fd19d702ea1bf2d661741c3b19749a692e7..7394ad7f6117685c9f18fbe19772a72e114b171b 100644 (file)
@@ -3,6 +3,7 @@ default:
        cd i915simple ; make
        cd failover ; make
        cd nv40; make
+       cd nv50; make
 
 clean:
        rm -f `find . -name \*.[oa]`
diff --git a/src/mesa/pipe/nouveau/nouveau_gldefs.h b/src/mesa/pipe/nouveau/nouveau_gldefs.h
new file mode 100644 (file)
index 0000000..15ff318
--- /dev/null
@@ -0,0 +1,198 @@
+#ifndef __NVGL_PIPE_H__
+#define __NVGL_PIPE_H__
+
+#include <GL/gl.h>
+
+static INLINE unsigned
+nvgl_blend_func(unsigned factor)
+{
+       switch (factor) {
+       case PIPE_BLENDFACTOR_ONE:
+               return GL_ONE;
+       case PIPE_BLENDFACTOR_SRC_COLOR:
+               return GL_SRC_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA:
+               return GL_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_DST_ALPHA:
+               return GL_DST_ALPHA;
+       case PIPE_BLENDFACTOR_DST_COLOR:
+               return GL_DST_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+               return GL_SRC_ALPHA_SATURATE;
+       case PIPE_BLENDFACTOR_CONST_COLOR:
+               return GL_CONSTANT_COLOR;
+       case PIPE_BLENDFACTOR_CONST_ALPHA:
+               return GL_CONSTANT_ALPHA;
+       case PIPE_BLENDFACTOR_ZERO:
+               return GL_ZERO;
+       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+               return GL_ONE_MINUS_SRC_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+               return GL_ONE_MINUS_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+               return GL_ONE_MINUS_DST_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_COLOR:
+               return GL_ONE_MINUS_DST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+               return GL_ONE_MINUS_CONSTANT_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+               return GL_ONE_MINUS_CONSTANT_ALPHA;
+       default:
+               return GL_ONE;
+       }
+}
+
+static INLINE unsigned
+nvgl_blend_eqn(unsigned func)
+{
+       switch (func) {
+       case PIPE_BLEND_ADD:
+               return GL_FUNC_ADD;
+       case PIPE_BLEND_SUBTRACT:
+               return GL_FUNC_SUBTRACT;
+       case PIPE_BLEND_REVERSE_SUBTRACT:
+               return GL_FUNC_REVERSE_SUBTRACT;
+       case PIPE_BLEND_MIN:
+               return GL_MIN;
+       case PIPE_BLEND_MAX:
+               return GL_MAX;
+       default:
+               return GL_FUNC_ADD;
+       }
+}
+
+static INLINE unsigned
+nvgl_logicop_func(unsigned func)
+{
+       switch (func) {
+       case PIPE_LOGICOP_CLEAR:
+               return GL_CLEAR;
+       case PIPE_LOGICOP_NOR:
+               return GL_NOR;
+       case PIPE_LOGICOP_AND_INVERTED:
+               return GL_AND_INVERTED;
+       case PIPE_LOGICOP_COPY_INVERTED:
+               return GL_COPY_INVERTED;
+       case PIPE_LOGICOP_AND_REVERSE:
+               return GL_AND_REVERSE;
+       case PIPE_LOGICOP_INVERT:
+               return GL_INVERT;
+       case PIPE_LOGICOP_XOR:
+               return GL_XOR;
+       case PIPE_LOGICOP_NAND:
+               return GL_NAND;
+       case PIPE_LOGICOP_AND:
+               return GL_AND;
+       case PIPE_LOGICOP_EQUIV:
+               return GL_EQUIV;
+       case PIPE_LOGICOP_NOOP:
+               return GL_NOOP;
+       case PIPE_LOGICOP_OR_INVERTED:
+               return GL_OR_INVERTED;
+       case PIPE_LOGICOP_COPY:
+               return GL_COPY;
+       case PIPE_LOGICOP_OR_REVERSE:
+               return GL_OR_REVERSE;
+       case PIPE_LOGICOP_OR:
+               return GL_OR;
+       case PIPE_LOGICOP_SET:
+               return GL_SET;
+       default:
+               return GL_CLEAR;
+       }
+}
+
+static INLINE unsigned
+nvgl_comparison_op(unsigned op)
+{
+       switch (op) {
+       case PIPE_FUNC_NEVER:
+               return GL_NEVER;
+       case PIPE_FUNC_LESS:
+               return GL_LESS;
+       case PIPE_FUNC_EQUAL:
+               return GL_EQUAL;
+       case PIPE_FUNC_LEQUAL:
+               return GL_LEQUAL;
+       case PIPE_FUNC_GREATER:
+               return GL_GREATER;
+       case PIPE_FUNC_NOTEQUAL:
+               return GL_NOTEQUAL;
+       case PIPE_FUNC_GEQUAL:
+               return GL_GEQUAL;
+       case PIPE_FUNC_ALWAYS:
+               return GL_ALWAYS;
+       default:
+               return GL_NEVER;
+       }
+}
+
+static INLINE unsigned
+nvgl_polygon_mode(unsigned mode)
+{
+       switch (mode) {
+       case PIPE_POLYGON_MODE_FILL:
+               return GL_FILL;
+       case PIPE_POLYGON_MODE_LINE:
+               return GL_LINE;
+       case PIPE_POLYGON_MODE_POINT:
+               return GL_POINT;
+       default:
+               return GL_FILL;
+       }
+}
+
+static INLINE unsigned
+nvgl_stencil_op(unsigned op)
+{
+       switch (op) {
+       case PIPE_STENCIL_OP_KEEP:
+               return GL_KEEP;
+       case PIPE_STENCIL_OP_ZERO:
+               return GL_ZERO;
+       case PIPE_STENCIL_OP_REPLACE:
+               return GL_REPLACE;
+       case PIPE_STENCIL_OP_INCR:
+               return GL_INCR;
+       case PIPE_STENCIL_OP_DECR:
+               return GL_DECR;
+       case PIPE_STENCIL_OP_INCR_WRAP:
+               return GL_INCR_WRAP;
+       case PIPE_STENCIL_OP_DECR_WRAP:
+               return GL_DECR_WRAP;
+       case PIPE_STENCIL_OP_INVERT:
+               return GL_INVERT;
+       default:
+               return GL_KEEP;
+       }
+}
+
+static INLINE unsigned
+nvgl_primitive(unsigned prim) {
+       switch (prim) {
+       case PIPE_PRIM_POINTS:
+               return GL_POINTS + 1;
+       case PIPE_PRIM_LINES:
+               return GL_LINES + 1;
+       case PIPE_PRIM_LINE_LOOP:
+               return GL_LINE_LOOP + 1;
+       case PIPE_PRIM_LINE_STRIP:
+               return GL_LINE_STRIP + 1;
+       case PIPE_PRIM_TRIANGLES:
+               return GL_TRIANGLES + 1;
+       case PIPE_PRIM_TRIANGLE_STRIP:
+               return GL_TRIANGLE_STRIP + 1;
+       case PIPE_PRIM_TRIANGLE_FAN:
+               return GL_TRIANGLE_FAN + 1;
+       case PIPE_PRIM_QUADS:
+               return GL_QUADS + 1;
+       case PIPE_PRIM_QUAD_STRIP:
+               return GL_QUAD_STRIP + 1;
+       case PIPE_PRIM_POLYGON:
+               return GL_POLYGON + 1;
+       default:
+               return GL_POINTS + 1;
+       }
+}
+
+#endif
index 1dc15f93ecdd0d96c03aa93fbccaa335475cafea..40e4bfae54e1dcd5e76e995079ce47c25908b12d 100644 (file)
@@ -67,4 +67,7 @@ struct nouveau_winsys {
 extern struct pipe_context *
 nv40_create(struct pipe_winsys *, struct nouveau_winsys *, unsigned chipset);
 
+extern struct pipe_context *
+nv50_create(struct pipe_winsys *, struct nouveau_winsys *, unsigned chipset);
+
 #endif
index ec07a8837066820aea7ec9bb78003d7d12c98abc..65a197ae2f1f29db5715890b4203675f88a56510 100644 (file)
@@ -8,6 +8,7 @@
 #include "pipe/draw/draw_vertex.h"
 
 #include "pipe/nouveau/nouveau_winsys.h"
+#include "pipe/nouveau/nouveau_gldefs.h"
 
 #include "nv40_state.h"
 
index 1e7513c0bbc804a8554e70c89c1c190db8d7a3e6..937de7face1e04929164bd8b91d4f542b4157989 100644 (file)
@@ -6,8 +6,6 @@
 #include "nv40_dma.h"
 #include "nv40_state.h"
 
-#include "nvgl_pipe.h"
-
 static void *
 nv40_alpha_test_state_create(struct pipe_context *pipe,
                             const struct pipe_alpha_test_state *cso)
index cc71fb99de20ccf4d387a4a28f8317599aa48a94..5e919c5ca97f7d8ee39a40df54496aa17ce651e6 100644 (file)
@@ -5,7 +5,6 @@
 #include "nv40_context.h"
 #include "nv40_dma.h"
 #include "nv40_state.h"
-#include "nvgl_pipe.h"
 
 boolean
 nv40_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
diff --git a/src/mesa/pipe/nv40/nvgl_pipe.h b/src/mesa/pipe/nv40/nvgl_pipe.h
deleted file mode 100644 (file)
index 15ff318..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-#ifndef __NVGL_PIPE_H__
-#define __NVGL_PIPE_H__
-
-#include <GL/gl.h>
-
-static INLINE unsigned
-nvgl_blend_func(unsigned factor)
-{
-       switch (factor) {
-       case PIPE_BLENDFACTOR_ONE:
-               return GL_ONE;
-       case PIPE_BLENDFACTOR_SRC_COLOR:
-               return GL_SRC_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA:
-               return GL_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_DST_ALPHA:
-               return GL_DST_ALPHA;
-       case PIPE_BLENDFACTOR_DST_COLOR:
-               return GL_DST_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-               return GL_SRC_ALPHA_SATURATE;
-       case PIPE_BLENDFACTOR_CONST_COLOR:
-               return GL_CONSTANT_COLOR;
-       case PIPE_BLENDFACTOR_CONST_ALPHA:
-               return GL_CONSTANT_ALPHA;
-       case PIPE_BLENDFACTOR_ZERO:
-               return GL_ZERO;
-       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
-               return GL_ONE_MINUS_SRC_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-               return GL_ONE_MINUS_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
-               return GL_ONE_MINUS_DST_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_COLOR:
-               return GL_ONE_MINUS_DST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
-               return GL_ONE_MINUS_CONSTANT_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
-               return GL_ONE_MINUS_CONSTANT_ALPHA;
-       default:
-               return GL_ONE;
-       }
-}
-
-static INLINE unsigned
-nvgl_blend_eqn(unsigned func)
-{
-       switch (func) {
-       case PIPE_BLEND_ADD:
-               return GL_FUNC_ADD;
-       case PIPE_BLEND_SUBTRACT:
-               return GL_FUNC_SUBTRACT;
-       case PIPE_BLEND_REVERSE_SUBTRACT:
-               return GL_FUNC_REVERSE_SUBTRACT;
-       case PIPE_BLEND_MIN:
-               return GL_MIN;
-       case PIPE_BLEND_MAX:
-               return GL_MAX;
-       default:
-               return GL_FUNC_ADD;
-       }
-}
-
-static INLINE unsigned
-nvgl_logicop_func(unsigned func)
-{
-       switch (func) {
-       case PIPE_LOGICOP_CLEAR:
-               return GL_CLEAR;
-       case PIPE_LOGICOP_NOR:
-               return GL_NOR;
-       case PIPE_LOGICOP_AND_INVERTED:
-               return GL_AND_INVERTED;
-       case PIPE_LOGICOP_COPY_INVERTED:
-               return GL_COPY_INVERTED;
-       case PIPE_LOGICOP_AND_REVERSE:
-               return GL_AND_REVERSE;
-       case PIPE_LOGICOP_INVERT:
-               return GL_INVERT;
-       case PIPE_LOGICOP_XOR:
-               return GL_XOR;
-       case PIPE_LOGICOP_NAND:
-               return GL_NAND;
-       case PIPE_LOGICOP_AND:
-               return GL_AND;
-       case PIPE_LOGICOP_EQUIV:
-               return GL_EQUIV;
-       case PIPE_LOGICOP_NOOP:
-               return GL_NOOP;
-       case PIPE_LOGICOP_OR_INVERTED:
-               return GL_OR_INVERTED;
-       case PIPE_LOGICOP_COPY:
-               return GL_COPY;
-       case PIPE_LOGICOP_OR_REVERSE:
-               return GL_OR_REVERSE;
-       case PIPE_LOGICOP_OR:
-               return GL_OR;
-       case PIPE_LOGICOP_SET:
-               return GL_SET;
-       default:
-               return GL_CLEAR;
-       }
-}
-
-static INLINE unsigned
-nvgl_comparison_op(unsigned op)
-{
-       switch (op) {
-       case PIPE_FUNC_NEVER:
-               return GL_NEVER;
-       case PIPE_FUNC_LESS:
-               return GL_LESS;
-       case PIPE_FUNC_EQUAL:
-               return GL_EQUAL;
-       case PIPE_FUNC_LEQUAL:
-               return GL_LEQUAL;
-       case PIPE_FUNC_GREATER:
-               return GL_GREATER;
-       case PIPE_FUNC_NOTEQUAL:
-               return GL_NOTEQUAL;
-       case PIPE_FUNC_GEQUAL:
-               return GL_GEQUAL;
-       case PIPE_FUNC_ALWAYS:
-               return GL_ALWAYS;
-       default:
-               return GL_NEVER;
-       }
-}
-
-static INLINE unsigned
-nvgl_polygon_mode(unsigned mode)
-{
-       switch (mode) {
-       case PIPE_POLYGON_MODE_FILL:
-               return GL_FILL;
-       case PIPE_POLYGON_MODE_LINE:
-               return GL_LINE;
-       case PIPE_POLYGON_MODE_POINT:
-               return GL_POINT;
-       default:
-               return GL_FILL;
-       }
-}
-
-static INLINE unsigned
-nvgl_stencil_op(unsigned op)
-{
-       switch (op) {
-       case PIPE_STENCIL_OP_KEEP:
-               return GL_KEEP;
-       case PIPE_STENCIL_OP_ZERO:
-               return GL_ZERO;
-       case PIPE_STENCIL_OP_REPLACE:
-               return GL_REPLACE;
-       case PIPE_STENCIL_OP_INCR:
-               return GL_INCR;
-       case PIPE_STENCIL_OP_DECR:
-               return GL_DECR;
-       case PIPE_STENCIL_OP_INCR_WRAP:
-               return GL_INCR_WRAP;
-       case PIPE_STENCIL_OP_DECR_WRAP:
-               return GL_DECR_WRAP;
-       case PIPE_STENCIL_OP_INVERT:
-               return GL_INVERT;
-       default:
-               return GL_KEEP;
-       }
-}
-
-static INLINE unsigned
-nvgl_primitive(unsigned prim) {
-       switch (prim) {
-       case PIPE_PRIM_POINTS:
-               return GL_POINTS + 1;
-       case PIPE_PRIM_LINES:
-               return GL_LINES + 1;
-       case PIPE_PRIM_LINE_LOOP:
-               return GL_LINE_LOOP + 1;
-       case PIPE_PRIM_LINE_STRIP:
-               return GL_LINE_STRIP + 1;
-       case PIPE_PRIM_TRIANGLES:
-               return GL_TRIANGLES + 1;
-       case PIPE_PRIM_TRIANGLE_STRIP:
-               return GL_TRIANGLE_STRIP + 1;
-       case PIPE_PRIM_TRIANGLE_FAN:
-               return GL_TRIANGLE_FAN + 1;
-       case PIPE_PRIM_QUADS:
-               return GL_QUADS + 1;
-       case PIPE_PRIM_QUAD_STRIP:
-               return GL_QUAD_STRIP + 1;
-       case PIPE_PRIM_POLYGON:
-               return GL_POLYGON + 1;
-       default:
-               return GL_POINTS + 1;
-       }
-}
-
-#endif
diff --git a/src/mesa/pipe/nv50/Makefile b/src/mesa/pipe/nv50/Makefile
new file mode 100644 (file)
index 0000000..af3fa0e
--- /dev/null
@@ -0,0 +1,26 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nv50
+
+DRIVER_SOURCES = \
+       nv50_clear.c \
+       nv50_context.c \
+       nv50_draw.c \
+       nv50_miptree.c \
+       nv50_query.c \
+       nv50_region.c \
+       nv50_state.c \
+       nv50_surface.c \
+       nv50_vbo.c
+
+C_SOURCES = \
+       $(COMMON_SOURCES) \
+       $(DRIVER_SOURCES)
+
+ASM_SOURCES = 
+
+include ../Makefile.template
+
+symlinks:
+
diff --git a/src/mesa/pipe/nv50/nv50_clear.c b/src/mesa/pipe/nv50/nv50_clear.c
new file mode 100644 (file)
index 0000000..85af1af
--- /dev/null
@@ -0,0 +1,15 @@
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+
+#include "nv50_context.h"
+#include "nv50_dma.h"
+
+
+void
+nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps,
+          unsigned clearValue)
+{
+       pipe->region_fill(pipe, ps->region, 0, 0, 0, ps->width, ps->height,
+                         clearValue);
+}
diff --git a/src/mesa/pipe/nv50/nv50_context.c b/src/mesa/pipe/nv50/nv50_context.c
new file mode 100644 (file)
index 0000000..6fceb13
--- /dev/null
@@ -0,0 +1,215 @@
+#include "pipe/draw/draw_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
+#include "pipe/p_util.h"
+
+#include "nv50_context.h"
+#include "nv50_dma.h"
+
+static boolean
+nv50_is_format_supported(struct pipe_context *pipe, uint format)
+{
+       switch (format) {
+       case PIPE_FORMAT_U_A8_R8_G8_B8:
+       case PIPE_FORMAT_Z24_S8:
+               return TRUE;
+       default:
+               break;
+       };
+
+       return FALSE;
+}
+
+static const char *
+nv50_get_name(struct pipe_context *pipe)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+       static char buffer[128];
+
+       snprintf(buffer, sizeof(buffer), "NV%02X", nv50->chipset);
+       return buffer;
+}
+
+static const char *
+nv50_get_vendor(struct pipe_context *pipe)
+{
+       return "nouveau";
+}
+
+static int
+nv50_get_param(struct pipe_context *pipe, int param)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
+               return 32;
+       case PIPE_CAP_NPOT_TEXTURES:
+               return 0;
+       case PIPE_CAP_TWO_SIDED_STENCIL:
+               return 1;
+       case PIPE_CAP_GLSL:
+               return 0;
+       case PIPE_CAP_S3TC:
+               return 0;
+       case PIPE_CAP_ANISOTROPIC_FILTER:
+               return 0;
+       case PIPE_CAP_POINT_SPRITE:
+               return 0;
+       case PIPE_CAP_MAX_RENDER_TARGETS:
+               return 8;
+       case PIPE_CAP_OCCLUSION_QUERY:
+               return 0;
+       case PIPE_CAP_TEXTURE_SHADOW_MAP:
+               return 0;
+       case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+               return 13;
+       case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+               return 10;
+       case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+               return 13;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0;
+       }
+}
+
+static float
+nv50_get_paramf(struct pipe_context *pipe, int param)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_LINE_WIDTH:
+       case PIPE_CAP_MAX_LINE_WIDTH_AA:
+               return 10.0;
+       case PIPE_CAP_MAX_POINT_WIDTH:
+       case PIPE_CAP_MAX_POINT_WIDTH_AA:
+               return 64.0;
+       case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+               return 16.0;
+       case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+               return 4.0;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0.0;
+       }
+}
+
+static void
+nv50_flush(struct pipe_context *pipe, unsigned flags)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+       struct nouveau_winsys *nvws = nv50->nvws;
+       
+       if (flags & PIPE_FLUSH_WAIT) {
+               nvws->notifier_reset(nv50->sync, 0);
+               BEGIN_RING(tesla, 0x104, 1);
+               OUT_RING  (0);
+               BEGIN_RING(tesla, 0x100, 1);
+               OUT_RING  (0);
+       }
+
+       FIRE_RING();
+
+       if (flags & PIPE_FLUSH_WAIT)
+               nvws->notifier_wait(nv50->sync, 0, 0, 2000);
+}
+
+static void
+nv50_destroy(struct pipe_context *pipe)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+
+       draw_destroy(nv50->draw);
+       free(nv50);
+}
+
+static boolean
+nv50_init_hwctx(struct nv50_context *nv50, int tesla_class)
+{
+       struct nouveau_winsys *nvws = nv50->nvws;
+       int ret;
+
+       if ((ret = nvws->grobj_alloc(nvws, tesla_class, &nv50->tesla))) {
+               NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
+               return FALSE;
+       }
+
+       BEGIN_RING(tesla, NV50TCL_DMA_NOTIFY, 1);
+       OUT_RING  (nv50->sync->handle);
+
+       FIRE_RING ();
+       return TRUE;
+}
+
+#define GRCLASS5097_CHIPSETS 0x00000000
+#define GRCLASS8297_CHIPSETS 0x00000010
+struct pipe_context *
+nv50_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
+           unsigned chipset)
+{
+       struct nv50_context *nv50;
+       int tesla_class, ret;
+
+       if ((chipset & 0xf0) != 0x50 && (chipset & 0xf0) != 0x80) {
+               NOUVEAU_ERR("Not a G8x chipset\n");
+               return NULL;
+       }
+
+       if (GRCLASS5097_CHIPSETS & (1 << (chipset & 0x0f))) {
+               tesla_class = 0x5097;
+       } else
+       if (GRCLASS8297_CHIPSETS & (1 << (chipset & 0x0f))) {
+               tesla_class = 0x8297;
+       } else {
+               NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset);
+               return NULL;
+       }
+
+       nv50 = CALLOC_STRUCT(nv50_context);
+       if (!nv50)
+               return NULL;
+       nv50->chipset = chipset;
+       nv50->nvws = nvws;
+
+       if ((ret = nvws->notifier_alloc(nvws, 1, &nv50->sync))) {
+               NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
+               free(nv50);
+               return NULL;
+       }
+
+       if (!nv50_init_hwctx(nv50, tesla_class)) {
+               free(nv50);
+               return NULL;
+       }
+
+       nv50->pipe.winsys = pipe_winsys;
+
+       nv50->pipe.destroy = nv50_destroy;
+       nv50->pipe.is_format_supported = nv50_is_format_supported;
+       nv50->pipe.get_name = nv50_get_name;
+       nv50->pipe.get_vendor = nv50_get_vendor;
+       nv50->pipe.get_param = nv50_get_param;
+       nv50->pipe.get_paramf = nv50_get_paramf;
+
+       nv50->pipe.draw_arrays = nv50_draw_arrays;
+       nv50->pipe.draw_elements = nv50_draw_elements;
+       nv50->pipe.clear = nv50_clear;
+
+       nv50->pipe.begin_query = nv50_query_begin;
+       nv50->pipe.end_query = nv50_query_end;
+       nv50->pipe.wait_query = nv50_query_wait;
+
+       nv50->pipe.mipmap_tree_layout = nv50_miptree_layout;
+
+       nv50->pipe.flush = nv50_flush;
+
+       nv50_init_region_functions(nv50);
+       nv50_init_surface_functions(nv50);
+       nv50_init_state_functions(nv50);
+
+       nv50->draw = draw_create();
+       assert(nv50->draw);
+       draw_set_rasterize_stage(nv50->draw, nv50_draw_render_stage(nv50));
+
+       return &nv50->pipe;
+}
+
+               
diff --git a/src/mesa/pipe/nv50/nv50_context.h b/src/mesa/pipe/nv50/nv50_context.h
new file mode 100644 (file)
index 0000000..f7fa485
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef __NV50_CONTEXT_H__
+#define __NV50_CONTEXT_H__
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+
+#include "pipe/draw/draw_vertex.h"
+
+#include "pipe/nouveau/nouveau_winsys.h"
+#include "pipe/nouveau/nouveau_gldefs.h"
+
+#include "nv50_state.h"
+
+#define NOUVEAU_ERR(fmt, args...) \
+       fprintf(stderr, "%s:%d -  "fmt, __func__, __LINE__, ##args);
+#define NOUVEAU_MSG(fmt, args...) \
+       fprintf(stderr, "nouveau: "fmt, ##args);
+
+struct nv50_context {
+       struct pipe_context pipe;
+       struct nouveau_winsys *nvws;
+
+       struct draw_context *draw;
+
+       int chipset;
+       struct nouveau_grobj *tesla;
+       struct nouveau_notifier *sync;
+       uint32_t *pushbuf;
+};
+
+
+extern void nv50_init_region_functions(struct nv50_context *nv50);
+extern void nv50_init_surface_functions(struct nv50_context *nv50);
+extern void nv50_init_state_functions(struct nv50_context *nv50);
+
+/* nv50_draw.c */
+extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50);
+
+/* nv50_miptree.c */
+extern boolean nv50_miptree_layout(struct pipe_context *,
+                                  struct pipe_mipmap_tree *);
+/* nv50_vbo.c */
+extern boolean nv50_draw_arrays(struct pipe_context *, unsigned mode,
+                               unsigned start, unsigned count);
+extern boolean nv50_draw_elements(struct pipe_context *pipe,
+                                 struct pipe_buffer_handle *indexBuffer,
+                                 unsigned indexSize,
+                                 unsigned mode, unsigned start,
+                                 unsigned count);
+
+/* nv50_clear.c */
+extern void nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps,
+                      unsigned clearValue);
+
+/* nv50_query.c */
+extern void nv50_query_begin(struct pipe_context *, struct pipe_query_object *);
+extern void nv50_query_end(struct pipe_context *, struct pipe_query_object *);
+extern void nv50_query_wait(struct pipe_context *, struct pipe_query_object *);
+
+
+#endif
diff --git a/src/mesa/pipe/nv50/nv50_dma.h b/src/mesa/pipe/nv50/nv50_dma.h
new file mode 100644 (file)
index 0000000..f8121b6
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef __NV50_DMA_H__
+#define __NV50_DMA_H__
+
+#include "pipe/nouveau/nouveau_winsys.h"
+
+#define BEGIN_RING(obj,mthd,size) do {                                         \
+       nv50->pushbuf = nv50->nvws->begin_ring(nv50->obj, (mthd), (size));     \
+} while(0)
+
+#define BEGIN_RING_NI(obj,mthd,size) do {                                      \
+       BEGIN_RING(obj, (mthd) | 0x40000000, (size));                          \
+} while(0)
+
+#define OUT_RING(data) do {                                                    \
+       (*nv50->pushbuf++) = (data);                                           \
+} while(0)
+
+#define OUT_RINGp(src,size) do {                                               \
+       memcpy(nv50->pushbuf, (src), (size) * 4);                              \
+       nv50->pushbuf += (size);                                               \
+} while(0)
+
+#define OUT_RINGf(data) do {                                                   \
+       union { float v; uint32_t u; } c;                                      \
+       c.v = (data);                                                          \
+       OUT_RING(c.u);                                                         \
+} while(0)
+
+#define FIRE_RING() do {                                                       \
+       nv50->nvws->fire_ring(nv50->nvws->channel);                            \
+} while(0)
+
+#define OUT_RELOC(bo,data,flags,vor,tor) do {                                  \
+       nv50->nvws->out_reloc(nv50->nvws->channel, nv50->pushbuf,              \
+                             (struct nouveau_bo *)(bo),                       \
+                             (data), (flags), (vor), (tor));                  \
+       OUT_RING(0);                                                           \
+} while(0)
+
+/* Raw data + flags depending on FB/TT buffer */
+#define OUT_RELOCd(bo,data,flags,vor,tor) do {                                 \
+       OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor));        \
+} while(0)
+
+/* FB/TT object handle */
+#define OUT_RELOCo(bo,flags) do {                                              \
+       OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR,                            \
+                 nv50->nvws->channel->vram->handle,                           \
+                 nv50->nvws->channel->gart->handle);                          \
+} while(0)
+
+/* Low 32-bits of offset */
+#define OUT_RELOCl(bo,delta,flags) do {                                        \
+       OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0);              \
+} while(0)
+
+/* High 32-bits of offset */
+#define OUT_RELOCh(bo,delta,flags) do {                                        \
+       OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0);             \
+} while(0)
+
+#endif
diff --git a/src/mesa/pipe/nv50/nv50_draw.c b/src/mesa/pipe/nv50/nv50_draw.c
new file mode 100644 (file)
index 0000000..9708892
--- /dev/null
@@ -0,0 +1,63 @@
+#include "pipe/draw/draw_private.h"
+#include "pipe/p_util.h"
+
+#include "nv50_context.h"
+
+struct nv50_draw_stage {
+       struct draw_stage draw;
+       struct nv50_context *nv50;
+};
+
+static void
+nv50_draw_begin(struct draw_stage *draw)
+{
+       NOUVEAU_ERR("\n");
+}
+
+static void
+nv50_draw_end(struct draw_stage *draw)
+{
+       NOUVEAU_ERR("\n");
+}
+
+static void
+nv50_draw_point(struct draw_stage *draw, struct prim_header *prim)
+{
+       NOUVEAU_ERR("\n");
+}
+
+static void
+nv50_draw_line(struct draw_stage *draw, struct prim_header *prim)
+{
+       NOUVEAU_ERR("\n");
+}
+
+static void
+nv50_draw_tri(struct draw_stage *draw, struct prim_header *prim)
+{
+       NOUVEAU_ERR("\n");
+}
+
+static void
+nv50_draw_reset_stipple_counter(struct draw_stage *draw)
+{
+       NOUVEAU_ERR("\n");
+}
+
+struct draw_stage *
+nv50_draw_render_stage(struct nv50_context *nv50)
+{
+       struct nv50_draw_stage *nv50draw = CALLOC_STRUCT(nv50_draw_stage);
+
+       nv50draw->nv50 = nv50;
+       nv50draw->draw.draw = nv50->draw;
+       nv50draw->draw.begin = nv50_draw_begin;
+       nv50draw->draw.point = nv50_draw_point;
+       nv50draw->draw.line = nv50_draw_line;
+       nv50draw->draw.tri = nv50_draw_tri;
+       nv50draw->draw.end = nv50_draw_end;
+       nv50draw->draw.reset_stipple_counter = nv50_draw_reset_stipple_counter;
+
+       return &nv50draw->draw;
+}
+
diff --git a/src/mesa/pipe/nv50/nv50_miptree.c b/src/mesa/pipe/nv50/nv50_miptree.c
new file mode 100644 (file)
index 0000000..cf0e530
--- /dev/null
@@ -0,0 +1,13 @@
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_util.h"
+
+#include "nv50_context.h"
+
+boolean
+nv50_miptree_layout(struct pipe_context *pipe, struct pipe_mipmap_tree *mt)
+{
+       NOUVEAU_ERR("unimplemented\n");
+       return TRUE;
+}
+
diff --git a/src/mesa/pipe/nv50/nv50_query.c b/src/mesa/pipe/nv50/nv50_query.c
new file mode 100644 (file)
index 0000000..1ce4894
--- /dev/null
@@ -0,0 +1,23 @@
+#include "pipe/p_context.h"
+
+#include "nv50_context.h"
+#include "nv50_dma.h"
+
+void
+nv50_query_begin(struct pipe_context *pipe, struct pipe_query_object *q)
+{
+       NOUVEAU_ERR("unimplemented\n");
+}
+
+void
+nv50_query_end(struct pipe_context *pipe, struct pipe_query_object *q)
+{
+       NOUVEAU_ERR("unimplemented\n");
+}
+
+void
+nv50_query_wait(struct pipe_context *pipe, struct pipe_query_object *q)
+{
+       NOUVEAU_ERR("unimplemented\n");
+}
+
diff --git a/src/mesa/pipe/nv50/nv50_region.c b/src/mesa/pipe/nv50/nv50_region.c
new file mode 100644 (file)
index 0000000..d5a071c
--- /dev/null
@@ -0,0 +1,85 @@
+#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
+
+#include "nv50_context.h"
+#include "nv50_dma.h"
+
+static ubyte *
+nv50_region_map(struct pipe_context *pipe, struct pipe_region *region)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+       struct pipe_winsys *ws = nv50->pipe.winsys;
+
+       if (!region->map_refcount++) {
+               region->map = ws->buffer_map(ws, region->buffer,
+                                            PIPE_BUFFER_FLAG_WRITE |
+                                            PIPE_BUFFER_FLAG_READ);
+       }
+
+       return region->map;
+}
+
+static void
+nv50_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+       struct pipe_winsys *ws = nv50->pipe.winsys;
+
+       if (!--region->map_refcount) {
+               ws->buffer_unmap(ws, region->buffer);
+               region->map = NULL;
+       }
+}
+
+static void
+nv50_region_data(struct pipe_context *pipe,
+              struct pipe_region *dst,
+              unsigned dst_offset,
+              unsigned dstx, unsigned dsty,
+              const void *src, unsigned src_pitch,
+              unsigned srcx, unsigned srcy, unsigned width, unsigned height)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+       struct nouveau_winsys *nvws = nv50->nvws;
+
+       nvws->region_data(nvws, dst, dst_offset, dstx, dsty,
+                         src, src_pitch, srcx, srcy, width, height);
+}
+
+
+static void
+nv50_region_copy(struct pipe_context *pipe, struct pipe_region *dst,
+                unsigned dst_offset, unsigned dstx, unsigned dsty,
+                struct pipe_region *src, unsigned src_offset,
+                unsigned srcx, unsigned srcy, unsigned width, unsigned height)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+       struct nouveau_winsys *nvws = nv50->nvws;
+
+       nvws->region_copy(nvws, dst, dst_offset, dstx, dsty,
+                         src, src_offset, srcx, srcy, width, height);
+}
+
+static void
+nv50_region_fill(struct pipe_context *pipe,
+                struct pipe_region *dst, unsigned dst_offset,
+                unsigned dstx, unsigned dsty,
+                unsigned width, unsigned height, unsigned value)
+{
+       struct nv50_context *nv50 = (struct nv50_context *)pipe;
+       struct nouveau_winsys *nvws = nv50->nvws;
+
+       nvws->region_fill(nvws, dst, dst_offset, dstx, dsty,
+                         width, height, value);
+}
+
+void
+nv50_init_region_functions(struct nv50_context *nv50)
+{
+       nv50->pipe.region_map = nv50_region_map;
+       nv50->pipe.region_unmap = nv50_region_unmap;
+       nv50->pipe.region_data = nv50_region_data;
+       nv50->pipe.region_copy = nv50_region_copy;
+       nv50->pipe.region_fill = nv50_region_fill;
+}
+
diff --git a/src/mesa/pipe/nv50/nv50_state.c b/src/mesa/pipe/nv50/nv50_state.c
new file mode 100644 (file)
index 0000000..0674c30
--- /dev/null
@@ -0,0 +1,242 @@
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_util.h"
+
+#include "nv50_context.h"
+#include "nv50_dma.h"
+#include "nv50_state.h"
+
+static void *
+nv50_alpha_test_state_create(struct pipe_context *pipe,
+                            const struct pipe_alpha_test_state *cso)
+{
+}
+
+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)
+{
+}
+
+static void
+nv50_blend_state_bind(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void
+nv50_blend_state_delete(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void *
+nv50_sampler_state_create(struct pipe_context *pipe,
+                         const struct pipe_sampler_state *cso)
+{
+}
+
+static void
+nv50_sampler_state_bind(struct pipe_context *pipe, unsigned unit,
+                       void *hwcso)
+{
+}
+
+static void
+nv50_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void *
+nv50_rasterizer_state_create(struct pipe_context *pipe,
+                            const struct pipe_rasterizer_state *cso)
+{
+}
+
+static void
+nv50_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void
+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)
+{
+}
+
+static void
+nv50_depth_stencil_state_bind(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void
+nv50_depth_stencil_state_delete(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void *
+nv50_vp_state_create(struct pipe_context *pipe,
+                    const struct pipe_shader_state *cso)
+{
+}
+
+static void
+nv50_vp_state_bind(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void
+nv50_vp_state_delete(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void *
+nv50_fp_state_create(struct pipe_context *pipe,
+                    const struct pipe_shader_state *cso)
+{
+}
+
+static void
+nv50_fp_state_bind(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void
+nv50_fp_state_delete(struct pipe_context *pipe, void *hwcso)
+{
+}
+
+static void
+nv50_set_blend_color(struct pipe_context *pipe,
+                    const struct pipe_blend_color *bcol)
+{
+}
+
+static void
+nv50_set_clip_state(struct pipe_context *pipe,
+                   const struct pipe_clip_state *clip)
+{
+}
+
+static void
+nv50_set_clear_color_state(struct pipe_context *pipe,
+                          const struct pipe_clear_color_state *ccol)
+{
+}
+
+static void
+nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
+                        const struct pipe_constant_buffer *buf )
+{
+}
+
+static void
+nv50_set_framebuffer_state(struct pipe_context *pipe,
+                          const struct pipe_framebuffer_state *fb)
+{
+}
+
+static void
+nv50_set_polygon_stipple(struct pipe_context *pipe,
+                        const struct pipe_poly_stipple *stipple)
+{
+}
+
+static void
+nv50_set_sampler_units(struct pipe_context *pipe,
+                      uint num_samplers, const uint *units)
+{
+}
+
+static void
+nv50_set_scissor_state(struct pipe_context *pipe,
+                      const struct pipe_scissor_state *s)
+{
+}
+
+static void
+nv50_set_texture_state(struct pipe_context *pipe, unsigned unit,
+                      struct pipe_mipmap_tree *miptree)
+{
+}
+
+static void
+nv50_set_viewport_state(struct pipe_context *pipe,
+                       const struct pipe_viewport_state *vpt)
+{
+}
+
+static void
+nv50_set_vertex_buffer(struct pipe_context *pipe, unsigned index,
+                      const struct pipe_vertex_buffer *vb)
+{
+}
+
+static void
+nv50_set_vertex_element(struct pipe_context *pipe, unsigned index,
+                       const struct pipe_vertex_element *ve)
+{
+}
+
+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;
+
+       nv50->pipe.create_sampler_state = nv50_sampler_state_create;
+       nv50->pipe.bind_sampler_state = nv50_sampler_state_bind;
+       nv50->pipe.delete_sampler_state = nv50_sampler_state_delete;
+
+       nv50->pipe.create_rasterizer_state = nv50_rasterizer_state_create;
+       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_vs_state = nv50_vp_state_create;
+       nv50->pipe.bind_vs_state = nv50_vp_state_bind;
+       nv50->pipe.delete_vs_state = nv50_vp_state_delete;
+
+       nv50->pipe.create_fs_state = nv50_fp_state_create;
+       nv50->pipe.bind_fs_state = nv50_fp_state_bind;
+       nv50->pipe.delete_fs_state = nv50_fp_state_delete;
+
+       nv50->pipe.set_blend_color = nv50_set_blend_color;
+       nv50->pipe.set_clip_state = nv50_set_clip_state;
+       nv50->pipe.set_clear_color_state = nv50_set_clear_color_state;
+       nv50->pipe.set_constant_buffer = nv50_set_constant_buffer;
+       nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state;
+       nv50->pipe.set_polygon_stipple = nv50_set_polygon_stipple;
+       nv50->pipe.set_sampler_units = nv50_set_sampler_units;
+       nv50->pipe.set_scissor_state = nv50_set_scissor_state;
+       nv50->pipe.set_texture_state = nv50_set_texture_state;
+       nv50->pipe.set_viewport_state = nv50_set_viewport_state;
+
+       nv50->pipe.set_vertex_buffer = nv50_set_vertex_buffer;
+       nv50->pipe.set_vertex_element = nv50_set_vertex_element;
+
+//     nv50->pipe.set_feedback_state = nv50_set_feedback_state;
+//     nv50->pipe.set_feedback_buffer = nv50_set_feedback_buffer;
+}
+
diff --git a/src/mesa/pipe/nv50/nv50_state.h b/src/mesa/pipe/nv50/nv50_state.h
new file mode 100644 (file)
index 0000000..a3b781d
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __NV50_STATE_H__
+#define __NV50_STATE_H__
+
+#include "pipe/p_state.h"
+
+
+#endif
diff --git a/src/mesa/pipe/nv50/nv50_surface.c b/src/mesa/pipe/nv50/nv50_surface.c
new file mode 100644 (file)
index 0000000..68013c0
--- /dev/null
@@ -0,0 +1,229 @@
+
+/**************************************************************************
+ * 
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * 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
+ * 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.
+ * 
+ **************************************************************************/
+
+#include "nv50_context.h"
+#include "pipe/p_defines.h"
+#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->region->map + ps->offset))
+      + y * ps->region->pitch + x;
+   unsigned i, j;
+   unsigned w0 = w;
+
+   CLIP_TILE;
+
+   switch (ps->format) {
+   case PIPE_FORMAT_U_A8_R8_G8_B8:
+      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->region->pitch;
+         p += w0 * 4;
+      }
+      break;
+   case PIPE_FORMAT_Z24_S8:
+      {
+         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->region->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->region->cpp;
+   const uint w0 = w;
+   const ubyte *pSrc;
+   ubyte *pDest;
+   uint i;
+
+   assert(ps->region->map);
+
+   CLIP_TILE;
+
+   if (dst_stride == 0) {
+      dst_stride = w0 * cpp;
+   }
+
+   pSrc = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+   pDest = (ubyte *) p;
+
+   for (i = 0; i < h; i++) {
+      memcpy(pDest, pSrc, w0 * cpp);
+      pDest += dst_stride;
+      pSrc += ps->region->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->region->cpp;
+   const uint w0 = w;
+   const ubyte *pSrc;
+   ubyte *pDest;
+   uint i;
+
+   assert(ps->region->map);
+
+   CLIP_TILE;
+
+   if (src_stride == 0) {
+      src_stride = w0 * cpp;
+   }
+
+   pSrc = (const ubyte *) p;
+   pDest = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+
+   for (i = 0; i < h; i++) {
+      memcpy(pDest, pSrc, w0 * cpp);
+      pDest += ps->region->pitch * cpp;
+      pSrc += src_stride;
+   }
+}
+
+
+/*
+ * XXX note: same as code in sp_surface.c
+ */
+static struct pipe_surface *
+nv50_get_tex_surface(struct pipe_context *pipe,
+                     struct pipe_mipmap_tree *mt,
+                     unsigned face, unsigned level, unsigned zslice)
+{
+   struct pipe_surface *ps;
+   unsigned offset;  /* in bytes */
+
+   offset = mt->level[level].level_offset;
+
+   if (mt->target == PIPE_TEXTURE_CUBE) {
+      offset += mt->level[level].image_offset[face] * mt->cpp;
+   }
+   else if (mt->target == PIPE_TEXTURE_3D) {
+      offset += mt->level[level].image_offset[zslice] * mt->cpp;
+   }
+   else {
+      assert(face == 0);
+      assert(zslice == 0);
+   }
+
+   ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format);
+   if (ps) {
+      assert(ps->format);
+      assert(ps->refcount);
+      pipe_region_reference(&ps->region, mt->region);
+      ps->width = mt->level[level].width;
+      ps->height = mt->level[level].height;
+      ps->offset = offset;
+   }
+   return ps;
+}
+
+
+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;
+}
diff --git a/src/mesa/pipe/nv50/nv50_vbo.c b/src/mesa/pipe/nv50/nv50_vbo.c
new file mode 100644 (file)
index 0000000..faae08f
--- /dev/null
@@ -0,0 +1,25 @@
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+#include "pipe/p_util.h"
+
+#include "nv50_context.h"
+#include "nv50_dma.h"
+#include "nv50_state.h"
+
+boolean
+nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
+                unsigned count)
+{
+       NOUVEAU_ERR("unimplemented\n");
+       return TRUE;
+}
+
+boolean
+nv50_draw_elements(struct pipe_context *pipe,
+                  struct pipe_buffer_handle *indexBuffer, unsigned indexSize,
+                  unsigned mode, unsigned start, unsigned count)
+{
+       NOUVEAU_ERR("unimplemented\n");
+       return TRUE;
+}
+