Merge branch 'master' of git+ssh://geckosenator@git.freedesktop.org/git/mesa/mesa
authorSean D'Epagnier <sean@depagnier.com>
Sat, 17 Feb 2007 00:46:11 +0000 (17:46 -0700)
committerSean D'Epagnier <sean@depagnier.com>
Sat, 17 Feb 2007 00:46:11 +0000 (17:46 -0700)
17 files changed:
doxygen/Makefile
doxygen/array_cache.doxy [deleted file]
doxygen/common.doxy
doxygen/doxy.bat
doxygen/glapi.doxy
doxygen/header.html
doxygen/main.doxy
doxygen/math.doxy
doxygen/shader.doxy
doxygen/swrast.doxy
doxygen/swrast_setup.doxy
doxygen/tnl.doxy
doxygen/tnl_dd.doxy
doxygen/vbo.doxy [new file with mode: 0644]
src/mesa/drivers/dri/nouveau/nv10_state.c
src/mesa/drivers/dri/nouveau/nv20_state.c
src/mesa/drivers/dri/nouveau/nv50_state.c

index 055b17386df33078ce11e6d84cd5b0aea3e935b0..e67900474e2f4683fedafe25d41b2c6b871e1690 100644 (file)
@@ -9,7 +9,7 @@ all: full subset
 FULL = \\r
        main.doxy \\r
        math.doxy \\r
-       array_cache.doxy \\r
+       vbo.doxy \\r
        glapi.doxy \\r
        shader.doxy \\r
        swrast.doxy \\r
diff --git a/doxygen/array_cache.doxy b/doxygen/array_cache.doxy
deleted file mode 100644 (file)
index ae0b1fa..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-# Doxyfile 0.1
-
-@INCLUDE               = common.doxy
-
-#---------------------------------------------------------------------------
-# General configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME           = "Mesa array_cache"
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT                  = ../src/mesa/array_cache/
-FILE_PATTERNS          = *.c \
-                         *.h
-RECURSIVE              = NO
-EXCLUDE                = 
-EXCLUDE_PATTERNS       = 
-EXAMPLE_PATH           = 
-EXAMPLE_PATTERNS       = 
-EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = 
-INPUT_FILTER           = 
-FILTER_SOURCE_FILES    = NO
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-HTML_OUTPUT            = array_cache
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING   = YES
-MACRO_EXPANSION        = NO
-EXPAND_ONLY_PREDEF     = NO
-SEARCH_INCLUDES        = YES
-INCLUDE_PATH           = 
-INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = 
-EXPAND_AS_DEFINED      = 
-SKIP_FUNCTION_MACROS   = YES
-#---------------------------------------------------------------------------
-# Configuration::addtions related to external references   
-#---------------------------------------------------------------------------
-TAGFILES               = main.tag=../core \
-                        math.tag=../math \
-                         shader.tag=../shader \
-                        swrast.tag=../swrast \
-                        swrast_setup.tag=../swrast_setup \
-                        tnl.tag=../tnl \
-                        tnl_dd.tag=../tnl_dd
-GENERATE_TAGFILE       = array_cache.tag
index 1b5e5fece600e333375c22b366669012833f20f6..48f0c95d6d693b58e306b30cdfdb1eb636129031 100644 (file)
@@ -23,7 +23,7 @@ PROJECT_NAME           = Mesa
 # This could be handy for archiving the generated documentation or 
 # if some version control system is used.
 
-PROJECT_NUMBER         = 6.2
+PROJECT_NUMBER         = 6.5
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
 # base path where the generated documentation will be put. 
index 2d8b567ce3a70e22b68e88ee867addc3d7b06e49..7a53f6ebc29538fa737ad2aa07e5aa4033789eb4 100644 (file)
@@ -1,5 +1,5 @@
 doxygen tnl_dd.doxy\r
-doxygen array_cache.doxy\r
+doxygen vbo.doxy\r
 doxygen math.doxy\r
 doxygen swrast.doxy\r
 doxygen swrast_setup.doxy\r
@@ -10,7 +10,7 @@ doxygen shader.doxy
 \r
 echo Building again, to resolve tags\r
 doxygen tnl_dd.doxy\r
-doxygen array_cache.doxy\r
+doxygen vbo.doxy\r
 doxygen math.doxy\r
 doxygen swrast.doxy\r
 doxygen swrast_setup.doxy\r
index eafc2a109adec53735468dea66edfd54ac01c601..3290f8455a1edd450e9d5695f645a6efc8e729a2 100644 (file)
@@ -45,5 +45,5 @@ TAGFILES               = main.tag=../core \
                          swrast.tag=../swrast \
                          swrast_setup.tag=../swrast_setup \
                          tnl.tag=../tnl \
-                         array_cache.tag=array_cache
+                         vbo.tag=vbo
 GENERATE_TAGFILE       = swrast.tag
index 5ca2763e0dfebd9762867cb59bf1e22118f5ad0d..7fca3ee5d38af9096ef7d07602de06662708d068 100644 (file)
@@ -7,7 +7,7 @@
 <div class="qindex">\r
 <a class="qindex" href="../main/index.html">core</a> |\r
 <a class="qindex" href="../glapi/index.html">glapi</a> |\r
-<a class="qindex" href="../array_cache/index.html">array_cache</a> |\r
+<a class="qindex" href="../vbo/index.html">vbo</a> |\r
 <a class="qindex" href="../math/index.html">math</a> |\r
 <a class="qindex" href="../shader/index.html">shader</a> |\r
 <a class="qindex" href="../swrast/index.html">swrast</a> |\r
index 3cb05967aa23e29cf8709df26774f08f8c089be3..416b4338e8757f46741281438814681cefacdf99 100644 (file)
@@ -40,7 +40,7 @@ SKIP_FUNCTION_MACROS   = YES
 # Configuration::addtions related to external references   
 #---------------------------------------------------------------------------
 TAGFILES               = tnl_dd.tag=../tnl_dd \
-                        array_cache.tag=../array_cache \
+                        vbo.tag=../vbo \
                          glapi.tag=../glapi \
                          math.tag=../math \
                          shader.tag=../shader \
index 72ec2e3cd26e2bd81a9b10787ef1ddca9327a362..388af40fe5bd5bd03104f8e1ab2fb5e32322412f 100644 (file)
@@ -45,5 +45,5 @@ TAGFILES               = tnl_dd.tag=../tnl_dd \
                          swrast.tag=../swrast \
                          swrast_setup.tag=../swrast_setup \
                          tnl.tag=../tnl \
-                         array_cache.tag=../array_cache
+                         vbo.tag=../vbo
 GENERATE_TAGFILE       = math.tag
index 44fc7c4cfed350154b01a9a9f093c79e84de9f3a..d8ad14cc76ce63661b7b12de9333d8317ca63e84 100644 (file)
@@ -45,5 +45,5 @@ TAGFILES               = main.tag=../core \
                          swrast.tag=../swrast \
                          swrast_setup.tag=../swrast_setup \
                          tnl.tag=../tnl \
-                         array_cache.tag=array_cache
+                         vbo.tag=vbo
 GENERATE_TAGFILE       = swrast.tag
index b0ba953676b0f5212828ba177d1801211235ce01..fa07afd594f55b135926aa16be2e262eb8d48126 100644 (file)
@@ -44,5 +44,5 @@ TAGFILES               = main.tag=../core \
                          tnl_dd.tag=../tnl_dd \
                          swrast_setup.tag=../swrast_setup \
                          tnl.tag=../tnl \
-                         array_cache.tag=array_cache
+                         vbo.tag=vbo
 GENERATE_TAGFILE       = swrast.tag
index 9e2d72e36e7473d798657e97197fb7b2128aac84..ee6f3ffdc8fba12d8cf9d845c7c335ea4c608768 100644 (file)
@@ -45,5 +45,5 @@ TAGFILES               = tnl_dd.tag=../tnl_dd \
                          math.tag=../math \
                          swrast.tag=../swrast \
                          tnl.tag=../tnl \
-                         array_cache.tag=../array_cache
+                         vbo.tag=../vbo
 GENERATE_TAGFILE       = swrast_setup.tag
index 67f992f11e866fd01c92001cb173a0e031e243f5..a4f76a295396c06ea967dfb1054e5ceb3a18b070 100644 (file)
@@ -46,5 +46,5 @@ TAGFILES               = tnl_dd.tag=../tnl \
                          shader.tag=../shader \
                          swrast.tag=../swrast \
                          swrast_setup.tag=swrast_setup \
-                         array_cache.tag=array_cache
+                         vbo.tag=vbo
 GENERATE_TAGFILE       = tnl.tag
index b7bd6e974406dde6d95cbb679e1177a0a61255aa..b241f67f4baae8206dce108bc33cdfc350b8f7dc 100644 (file)
@@ -45,5 +45,5 @@ TAGFILES               = main.tag=../core \
                          swrast.tag=../swrast \
                          swrast_setup.tag=../swrast_setup \
                          tnl.tag=../tnl \
-                         array_cache.tag=array_cache
+                         vbo.tag=vbo
 GENERATE_TAGFILE       = tnl_dd.tag
diff --git a/doxygen/vbo.doxy b/doxygen/vbo.doxy
new file mode 100644 (file)
index 0000000..6dfb21c
--- /dev/null
@@ -0,0 +1,50 @@
+# Doxyfile 0.1
+
+@INCLUDE               = common.doxy
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = "Mesa vbo"
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = ../src/mesa/vbo/
+FILE_PATTERNS          = *.c \
+                         *.h
+RECURSIVE              = NO
+EXCLUDE                = 
+EXCLUDE_PATTERNS       = 
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = 
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+HTML_OUTPUT            = vbo
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = 
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = main.tag=../core \
+                        math.tag=../math \
+                         shader.tag=../shader \
+                        swrast.tag=../swrast \
+                        swrast_setup.tag=../swrast_setup \
+                        tnl.tag=../tnl \
+                        tnl_dd.tag=../tnl_dd
+GENERATE_TAGFILE       = vbo.tag
index d69c6824ed587085fd939345f741b8d3a0916b80..e0475bb3da0d55663553e9dc69955a27ed2854fb 100644 (file)
@@ -34,6 +34,29 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "mtypes.h"
 #include "colormac.h"
 
+static void nv10ViewportScale(nouveauContextPtr nmesa)
+{
+       GLcontext *ctx = nmesa->glCtx;
+       GLuint w = ctx->Viewport.Width;
+       GLuint h = ctx->Viewport.Height;
+
+       GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5;
+       switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) {
+               case 16:
+                       max_depth *= 32767.0;
+                       break;
+               case 24:
+                       max_depth *= 16777215.0;
+                       break;
+       }
+
+       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4);
+       OUT_RING_CACHEf ((((GLfloat) w) * 0.5) - 2048.0);
+       OUT_RING_CACHEf ((((GLfloat) h) * 0.5) - 2048.0);
+       OUT_RING_CACHEf (max_depth);
+       OUT_RING_CACHEf (0.0);
+}
+
 static void nv10AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
 {
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
@@ -98,16 +121,27 @@ static void nv10ClearColor(GLcontext *ctx, const GLfloat color[4])
 
 static void nv10ClearDepth(GLcontext *ctx, GLclampd d)
 {
-       /* FIXME: check if 16 or 24/32 bits depth buffer */
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nmesa->clear_value=((nmesa->clear_value&0x000000FF)|(((uint32_t)(d*0xFFFFFF))<<8));
+
+       switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) {
+               case 16:
+                       nmesa->clear_value = (uint32_t)(d*0x7FFF);
+                       break;
+               case 24:
+                       nmesa->clear_value = ((nmesa->clear_value&0x000000FF) |
+                               (((uint32_t)(d*0xFFFFFF))<<8));
+                       break;
+       }
 }
 
 static void nv10ClearStencil(GLcontext *ctx, GLint s)
 {
-       /* FIXME: not valid for 16 bits depth buffer (0 stencil bits) */
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nmesa->clear_value=((nmesa->clear_value&0xFFFFFF00)|(s&0x000000FF));
+
+       if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 24) {
+               nmesa->clear_value = ((nmesa->clear_value&0xFFFFFF00)|
+                       (s&0x000000FF));
+       }
 }
 
 static void nv10ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
@@ -164,9 +198,17 @@ static void nv10DepthMask(GLcontext *ctx, GLboolean flag)
 static void nv10DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
 {
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+       GLfloat depth_scale = 16777216.0;
+       if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 16) {
+               depth_scale = 32768.0;
+       }
+
        BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2);
-       OUT_RING_CACHEf(nearval);
-       OUT_RING_CACHEf(farval);
+       OUT_RING_CACHEf(nearval * depth_scale);
+       OUT_RING_CACHEf(farval * depth_scale);
+
+       nv10ViewportScale(nmesa);
 }
 
 /** Specify the current buffer for writing */
@@ -616,8 +658,10 @@ static void nv10WindowMoved(nouveauContextPtr nmesa)
        OUT_RING(0);
 
        BEGIN_RING_CACHE(NvSub3D,
-             NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 2);
+             NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1);
         OUT_RING_CACHE(((w+x-1) << 16) | x | 0x08000800);
+       BEGIN_RING_CACHE(NvSub3D,
+             NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1);
         OUT_RING_CACHE(((h+y-1) << 16) | y | 0x08000800);
        for (i=1; i<8; i++) {
                BEGIN_RING_CACHE(NvSub3D,
@@ -628,18 +672,7 @@ static void nv10WindowMoved(nouveauContextPtr nmesa)
                OUT_RING_CACHE(0);
        }
 
-       /* viewport transform */
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
-       OUT_RING_CACHEf ((GLfloat) x);
-       OUT_RING_CACHEf ((GLfloat) (y+h));
-       OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf (0.0);
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4);
-       OUT_RING_CACHEf ((((GLfloat) w) * 0.5) - 2048.0);
-       OUT_RING_CACHEf ((((GLfloat) h) * 0.5) - 2048.0);
-       OUT_RING_CACHEf (16777215.0 * 0.5);
-       OUT_RING_CACHEf (0.0);
+       nv10ViewportScale(nmesa);
 }
 
 /* Initialise any card-specific non-GL related state */
@@ -700,6 +733,13 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color,
        OUT_RING_CACHE(color[0]->offset);
        OUT_RING_CACHE(depth ? depth->offset : color[0]->offset);
 
+       /* Always set to bottom left of buffer */
+       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
+       OUT_RING_CACHEf (0.0);
+       OUT_RING_CACHEf ((GLfloat) h);
+       OUT_RING_CACHEf (0.0);
+       OUT_RING_CACHEf (0.0);
+
        return GL_TRUE;
 }
 
index 8e38d6eba00c06d50c1d4babf35ca4c724a7f0dd..030713c0dbb0103cc3ff85e632a85cf328799e82 100644 (file)
@@ -41,8 +41,8 @@ static void nv20AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
        CLAMPED_FLOAT_TO_UBYTE(ubRef, ref);
 
        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC, 2);
-       OUT_RING_CACHE(func);     /* NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC */
-       OUT_RING_CACHE(ubRef);    /* NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF  */
+       OUT_RING_CACHE(func);
+       OUT_RING_CACHE(ubRef);
 }
 
 static void nv20BlendColor(GLcontext *ctx, const GLfloat color[4])
@@ -76,6 +76,11 @@ static void nv20BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfac
        OUT_RING_CACHE((dfactorA<<16) | dfactorRGB);
 }
 
+static void nv20Clear(GLcontext *ctx, GLbitfield mask)
+{
+       /* TODO */
+}
+
 static void nv20ClearColor(GLcontext *ctx, const GLfloat color[4])
 {
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
@@ -297,7 +302,11 @@ static void nv20Enable(GLcontext *ctx, GLenum cap, GLboolean state)
 //             case GL_POST_COLOR_MATRIX_COLOR_TABLE:
 //             case GL_POST_CONVOLUTION_COLOR_TABLE:
 //             case GL_RESCALE_NORMAL:
-//             case GL_SCISSOR_TEST:
+               case GL_SCISSOR_TEST:
+                       /* No enable bit, nv20Scissor will adjust to max range */
+                       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                                                ctx->Scissor.Width, ctx->Scissor.Height);
+                       break;
 //             case GL_SEPARABLE_2D:
                case GL_STENCIL_TEST:
                        // TODO BACK and FRONT ?
@@ -511,9 +520,22 @@ static void nv20PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
 }
 
 /** Set the scale and units used to calculate depth values */
-void (*PolygonOffset)(GLcontext *ctx, GLfloat factor, GLfloat units);
+static void nv20PolygonOffset(GLcontext *ctx, GLfloat factor, GLfloat units)
+{
+        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR, 2);
+        OUT_RING_CACHEf(factor);
+        OUT_RING_CACHEf(units);
+}
+
 /** Set the polygon stippling pattern */
-void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
+static void nv20PolygonStipple(GLcontext *ctx, const GLubyte *mask )
+{
+        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN(0), 32);
+        OUT_RING_CACHEp(mask, 32);
+}
+
 /* Specifies the current buffer for reading */
 void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
 /** Set rasterization mode */
@@ -522,6 +544,22 @@ void (*RenderMode)(GLcontext *ctx, GLenum mode );
 /** Define the scissor box */
 static void nv20Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
+        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+       /* There's no scissor enable bit, so adjust the scissor to cover the
+        * maximum draw buffer bounds
+        */
+       if (!ctx->Scissor.Enabled) {
+          x = y = 0;
+          w = h = 4095;
+       } else {
+          x += nmesa->drawX;
+          y += nmesa->drawY;
+       }
+
+        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 2);
+        OUT_RING_CACHE(((x+w-1) << 16) | x);
+        OUT_RING_CACHE(((y+h-1) << 16) | y);
 }
 
 /** Select flat or smooth shading */
@@ -576,22 +614,103 @@ void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
 void (*TexParameter)(GLcontext *ctx, GLenum target,
                struct gl_texture_object *texObj,
                GLenum pname, const GLfloat *params);
-void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
 
-/** Set the viewport */
-static void nv20Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+static void nv20TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat)
 {
-    /* TODO: Where do the VIEWPORT_XFRM_* regs come in? */
-    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-    BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2);
-    OUT_RING_CACHE((w << 16) | x);
-    OUT_RING_CACHE((h << 16) | y);
+        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_TX_MATRIX(unit, 0), 16);
+        /*XXX: This SHOULD work.*/
+        OUT_RING_CACHEp(mat->m, 16);
+}
+
+/* Update anything that depends on the window position/size */
+static void nv20WindowMoved(nouveauContextPtr nmesa)
+{
+       GLcontext *ctx = nmesa->glCtx;
+       GLfloat *v = nmesa->viewport.m;
+       GLuint w = ctx->Viewport.Width;
+       GLuint h = ctx->Viewport.Height;
+       GLuint x = ctx->Viewport.X + nmesa->drawX;
+       GLuint y = ctx->Viewport.Y + nmesa->drawY;
+       int i;
+
+        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2);
+        OUT_RING_CACHE((w << 16) | x);
+        OUT_RING_CACHE((h << 16) | y);
+
+       BEGIN_RING_SIZE(NvSub3D, 0x02b4, 1);
+       OUT_RING(0);
+
+       BEGIN_RING_CACHE(NvSub3D,
+             NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1);
+        OUT_RING_CACHE((4095 << 16) | 0);
+       BEGIN_RING_CACHE(NvSub3D,
+             NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1);
+        OUT_RING_CACHE((4095 << 16) | 0);
+       for (i=1; i<8; i++) {
+               BEGIN_RING_CACHE(NvSub3D,
+                     NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(i), 1);
+               OUT_RING_CACHE(0);
+               BEGIN_RING_CACHE(NvSub3D,
+                     NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(i), 1);
+               OUT_RING_CACHE(0);
+       }
+
+       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                           ctx->Scissor.Width, ctx->Scissor.Height);
+
+       /* TODO: recalc viewport scale coefs */
 }
 
 /* Initialise any card-specific non-GL related state */
 static GLboolean nv20InitCard(nouveauContextPtr nmesa)
 {
-   return GL_TRUE;
+       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
+
+       BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SET_OBJECT1, 2);
+       OUT_RING(NvDmaFB);      /* 184 dma_object1 */
+       OUT_RING(NvDmaFB);      /* 188 dma_object2 */
+       BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SET_OBJECT3, 2);
+       OUT_RING(NvDmaFB);      /* 194 dma_object3 */
+       OUT_RING(NvDmaFB);      /* 198 dma_object4 */
+       BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SET_OBJECT8, 1);
+       OUT_RING(NvDmaFB);      /* 1a8 dma_object8 */
+
+       BEGIN_RING_SIZE(NvSub3D, 0x17e0, 3);
+       OUT_RINGf(0.0);
+       OUT_RINGf(0.0);
+       OUT_RINGf(1.0);
+
+       BEGIN_RING_SIZE(NvSub3D, 0x1e6c, 1);
+       OUT_RING(0x0db6);
+       BEGIN_RING_SIZE(NvSub3D, 0x0290, 1);
+       OUT_RING(0x00100001);
+       BEGIN_RING_SIZE(NvSub3D, 0x09fc, 1);
+       OUT_RING(0);
+       BEGIN_RING_SIZE(NvSub3D, 0x1d80, 1);
+       OUT_RING(1);
+       BEGIN_RING_SIZE(NvSub3D, 0x09f8, 1);
+       OUT_RING(4);
+
+       BEGIN_RING_SIZE(NvSub3D, 0x17ec, 3);
+       OUT_RINGf(0.0);
+       OUT_RINGf(1.0);
+       OUT_RINGf(0.0);
+
+       BEGIN_RING_SIZE(NvSub3D, 0x1d88, 1);
+       OUT_RING(3);
+
+       /* FIXME: More dma objects to setup ? */
+
+       BEGIN_RING_SIZE(NvSub3D, 0x1e98, 1);
+       OUT_RING(0);
+
+       BEGIN_RING_SIZE(NvSub3D, 0x120, 3);
+       OUT_RING(0);
+       OUT_RING(1);
+       OUT_RING(2);
+
+       return GL_TRUE;
 }
 
 /* Update buffer offset/pitch/format */
@@ -599,26 +718,57 @@ static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color,
                                 nouveau_renderbuffer **color,
                                 nouveau_renderbuffer *depth)
 {
-   return GL_TRUE;
-}
+       GLuint x, y, w, h;
+       GLuint pitch, format, depth_pitch;
+
+       w = color[0]->mesa.Width;
+       h = color[0]->mesa.Height;
+       x = nmesa->drawX;
+       y = nmesa->drawY;
+
+       if (num_color != 1)
+               return GL_FALSE;
+
+        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 6);
+        OUT_RING_CACHE((w << 16) | x);
+        OUT_RING_CACHE((h << 16) | y);
+       depth_pitch = (depth ? depth->pitch : color[0]->pitch);
+       pitch = (depth_pitch<<16) | color[0]->pitch;
+       format = 0x128;
+       if (color[0]->mesa._ActualFormat != GL_RGBA8) {
+               format = 0x123; /* R5G6B5 color buffer */
+       }
+       OUT_RING_CACHE(format);
+       OUT_RING_CACHE(pitch);
+       OUT_RING_CACHE(color[0]->offset);
+       OUT_RING_CACHE(depth ? depth->offset : color[0]->offset);
+
+       if (depth) {
+               BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_PITCH, 2);
+               /* TODO: use a different buffer */
+               OUT_RING(depth->pitch);
+               OUT_RING(depth->offset);
+       }
 
-/* Update anything that depends on the window position/size */
-static void nv20WindowMoved(nouveauContextPtr nmesa)
-{
+       /* Always set to bottom left of buffer */
+       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
+       OUT_RING_CACHEf (0.0);
+       OUT_RING_CACHEf ((GLfloat) h);
+       OUT_RING_CACHEf (0.0);
+       OUT_RING_CACHEf (0.0);
+
+       return GL_TRUE;
 }
 
 void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func)
 {
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
 
-       nmesa->hw_func.InitCard         = nv20InitCard;
-       nmesa->hw_func.BindBuffers      = nv20BindBuffers;
-       nmesa->hw_func.WindowMoved      = nv20WindowMoved;
-
        func->AlphaFunc                 = nv20AlphaFunc;
        func->BlendColor                = nv20BlendColor;
        func->BlendEquationSeparate     = nv20BlendEquationSeparate;
        func->BlendFuncSeparate         = nv20BlendFuncSeparate;
+       func->Clear                     = nv20Clear;
        func->ClearColor                = nv20ClearColor;
        func->ClearDepth                = nv20ClearDepth;
        func->ClearStencil              = nv20ClearStencil;
@@ -641,22 +791,21 @@ void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func)
        func->PointParameterfv          = nv20PointParameterfv;
        func->PointSize                 = nv20PointSize;
        func->PolygonMode               = nv20PolygonMode;
-#if 0
        func->PolygonOffset             = nv20PolygonOffset;
        func->PolygonStipple            = nv20PolygonStipple;
-       func->ReadBuffer                = nv20ReadBuffer;
-       func->RenderMode                = nv20RenderMode;
-#endif
+/*     func->ReadBuffer                = nv20ReadBuffer;*/
+/*     func->RenderMode                = nv20RenderMode;*/
        func->Scissor                   = nv20Scissor;
        func->ShadeModel                = nv20ShadeModel;
        func->StencilFuncSeparate       = nv20StencilFuncSeparate;
        func->StencilMaskSeparate       = nv20StencilMaskSeparate;
        func->StencilOpSeparate         = nv20StencilOpSeparate;
-#if 0
-       func->TexGen                    = nv20TexGen;
-       func->TexParameter              = nv20TexParameter;
+/*     func->TexGen                    = nv20TexGen;*/
+/*     func->TexParameter              = nv20TexParameter;*/
        func->TextureMatrix             = nv20TextureMatrix;
-#endif
-       func->Viewport                  = nv20Viewport;
+
+       nmesa->hw_func.InitCard         = nv20InitCard;
+       nmesa->hw_func.BindBuffers      = nv20BindBuffers;
+       nmesa->hw_func.WindowMoved      = nv20WindowMoved;
 }
 
index d03c6bf6f2500cea20d05af8b9a3c47789bd7d48..818e268615c24c4626db006223246f35aa6eba10 100644 (file)
@@ -293,7 +293,11 @@ static void nv50Enable(GLcontext *ctx, GLenum cap, GLboolean state)
 //             case GL_POST_COLOR_MATRIX_COLOR_TABLE:
 //             case GL_POST_CONVOLUTION_COLOR_TABLE:
 //             case GL_RESCALE_NORMAL:
-//             case GL_SCISSOR_TEST:
+               case GL_SCISSOR_TEST:
+                       /* No enable bit, nv50Scissor will adjust to max range */
+                       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                                                ctx->Scissor.Width, ctx->Scissor.Height);
+                       break;
 //             case GL_SEPARABLE_2D:
                case GL_STENCIL_TEST:
                        // TODO BACK and FRONT ?
@@ -416,6 +420,21 @@ void (*RenderMode)(GLcontext *ctx, GLenum mode );
 static void nv50Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
         nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+       /* There's no scissor enable bit, so adjust the scissor to cover the
+        * maximum draw buffer bounds
+        */
+       if (!ctx->Scissor.Enabled) {
+          x = y = 0;
+          w = h = 8191;
+       } else {
+          x += nmesa->drawX;
+          y += nmesa->drawY;
+       }
+
+        BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS, 2);
+        OUT_RING_CACHE(((w) << 16) | x);
+        OUT_RING_CACHE(((h) << 16) | y);
 }
 
 /** Select flat or smooth shading */
@@ -503,10 +522,65 @@ static void nv50TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat)
 
 static void nv50WindowMoved(nouveauContextPtr nmesa)
 {
+       GLcontext *ctx = nmesa->glCtx;
+       GLfloat *v = nmesa->viewport.m;
+       GLuint w = ctx->Viewport.Width;
+       GLuint h = ctx->Viewport.Height;
+       GLuint x = ctx->Viewport.X + nmesa->drawX;
+       GLuint y = ctx->Viewport.Y + nmesa->drawY;
+       int i;
+
+       BEGIN_RING_CACHE(NvSub3D,
+             NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 2);
+        OUT_RING_CACHE((8191 << 16) | 0);
+        OUT_RING_CACHE((8191 << 16) | 0);
+       for (i=1; i<8; i++) {
+               BEGIN_RING_CACHE(NvSub3D,
+                     NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(i), 2);
+               OUT_RING_CACHE(0);
+               OUT_RING_CACHE(0);
+       }
+
+       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                           ctx->Scissor.Width, ctx->Scissor.Height);
 }
 
 static GLboolean nv50InitCard(nouveauContextPtr nmesa)
 {
+       int i,j;
+
+       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
+
+       BEGIN_RING_SIZE(NvSub3D, 0x1558, 1);
+       OUT_RING(1);
+
+       BEGIN_RING_SIZE(NvSub3D, NV50_TCL_PRIMITIVE_3D_SET_OBJECT_1(0), 8);
+       for (i=0; i<8; i++) {
+               OUT_RING(NvDmaFB);
+       }
+
+       BEGIN_RING_SIZE(NvSub3D, NV50_TCL_PRIMITIVE_3D_SET_OBJECT_0(0), 12);
+       for (i=0; i<12; i++) {
+               OUT_RING(NvDmaFB);
+       }
+
+       BEGIN_RING_SIZE(NvSub3D, 0x121c, 1);
+       OUT_RING(1);
+
+       for (i=0; i<8; i++) {
+               BEGIN_RING_SIZE(NvSub3D, 0x0200 + (i*0x20), 5);
+               for (j=0; j<5; j++) {
+                       OUT_RING(0);
+               }
+       }
+
+       BEGIN_RING_SIZE(NvSub3D, 0x0fe0, 5);
+       OUT_RING(0);
+       OUT_RING(0);
+       OUT_RING(0x16);
+       OUT_RING(0);
+       OUT_RING(0);
+
        return GL_FALSE;
 }