summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Kolb <jkolb@freedesktop.org>2006-04-15 00:21:44 +0000
committerJeremy Kolb <jkolb@freedesktop.org>2006-04-15 00:21:44 +0000
commita7d88857680d3d4d2a0788f18c49149dd2118b6f (patch)
tree153a519f0f2badd60aefee9ef67fd6d90bb48109 /src
parentb0c4cfed608f21f255b8637ec5ff499fc36ee302 (diff)
State changes.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.h17
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.h2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_state.c89
3 files changed, 105 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index c23b633bb9..7405bb4145 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -96,6 +96,9 @@ typedef struct nouveau_context {
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
+ /* Color state */
+ GLuint clear_color;
+
/* The drawing fallbacks */
GLuint Fallback;
nouveau_tri_func* draw_tri;
@@ -134,8 +137,22 @@ typedef struct nouveau_context {
}nouveauContextRec, *nouveauContextPtr;
+
#define NOUVEAU_CONTEXT(ctx) ((nouveauContextPtr)(ctx->DriverCtx))
+/* Flags for what context state needs to be updated: */
+#define NOUVEAU_NEW_ALPHA 0x0001
+#define NOUVEAU_NEW_DEPTH 0x0002
+#define NOUVEAU_NEW_FOG 0x0004
+#define NOUVEAU_NEW_CLIP 0x0008
+#define NOUVEAU_NEW_CULL 0x0010
+#define NOUVEAU_NEW_MASKS 0x0020
+#define NOUVEAU_NEW_RENDER_NOT 0x0040
+#define NOUVEAU_NEW_WINDOW 0x0080
+#define NOUVEAU_NEW_CONTEXT 0x0100
+#define NOUVEAU_NEW_ALL 0x01ff
+
+/* Flags for software fallback cases: */
#define NOUVEAU_FALLBACK_TEXTURE 0x0001
#define NOUVEAU_FALLBACK_DRAW_BUFFER 0x0002
#define NOUVEAU_FALLBACK_READ_BUFFER 0x0004
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.h b/src/mesa/drivers/dri/nouveau/nouveau_screen.h
index 997b05fecd..f6959419c5 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.h
@@ -35,6 +35,8 @@ typedef struct {
u_int32_t bus_type;
u_int32_t agp_mode;
+ GLint fbFormat;
+
GLuint frontOffset;
GLuint frontPitch;
GLuint backOffset;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index 5d12d1ca9f..b7f53ff957 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -28,6 +28,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "nouveau_state.h"
#include "nouveau_ioctl.h"
#include "nouveau_tris.h"
+#include "nouveau_fifo.h"
#include "swrast/swrast.h"
#include "array_cache/acache.h"
@@ -36,6 +37,38 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "tnl/t_pipeline.h"
+#include "mtypes.h"
+#include "colormac.h"
+
+static __inline__ GLuint nouveauPackColor(GLuint format,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+ switch (format) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( r, g, b, a);
+ default:
+ fprintf(stderr, "unknown format %d\n", (int)format);
+ return 0;
+ }
+}
+
+static void nouveauDDClearColor(GLcontext *ctx, const GLfloat color[4])
+{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ GLubyte c[4];
+
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+
+ nmesa->clear_color = nouveauPackColor( nmesa->screen->fbFormat,
+ c[0], c[1], c[2], c[3] );
+}
+
static void nouveauCalcViewport(GLcontext *ctx)
{
/* Calculate the Viewport Matrix */
@@ -57,7 +90,7 @@ static void nouveauCalcViewport(GLcontext *ctx)
}
-static nouveauViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+static void nouveauViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/*
* Need to send (at least on an nv35 the following:
@@ -78,11 +111,61 @@ static nouveauViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
nouveauCalcViewport(ctx);
}
-void nouveauDepthRange(GLcontext *ctx)
+static void nouveauDepthRange(GLcontext *ctx)
{
nouveauCalcViewport(ctx);
}
+static void nouveauDDUpdateHWState(GLcontext *ctx)
+{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ int new_state = nmesa->new_state;
+
+ if ( new_state || nmesa->new_render_state & _NEW_TEXTURE )
+ {
+ FINISH_RING_PRIM();
+
+ nmesa->new_state = 0;
+
+ /* Update the various parts of the context's state.
+ */
+ /*
+ if ( new_state & NOUVEAU_NEW_ALPHA )
+ nouveauUpdateAlphaMode( ctx );
+
+ if ( new_state & NOUVEAU_NEW_DEPTH )
+ nouveauUpdateZMode( ctx );
+
+ if ( new_state & NOUVEAU_NEW_FOG )
+ nouveauUpdateFogAttrib( ctx );
+
+ if ( new_state & NOUVEAU_NEW_CLIP )
+ nouveauUpdateClipping( ctx );
+
+ if ( new_state & NOUVEAU_NEW_CULL )
+ nouveauUpdateCull( ctx );
+
+ if ( new_state & NOUVEAU_NEW_MASKS )
+ nouveauUpdateMasks( ctx );
+
+ if ( new_state & NOUVEAU_NEW_WINDOW )
+ nouveauUpdateWindow( ctx );
+
+ if ( nmesa->new_render_state & _NEW_TEXTURE ) {
+ nouveauUpdateTextureState( ctx );
+ }*/
+ }
+}
+
+static void nouveauDDInvalidateState(GLcontext *ctx, GLuint new_state)
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ NOUVEAU_CONTEXT(ctx)->new_render_state |= new_state;
+}
+
/* Initialize the context's hardware state. */
void nouveauDDInitState(nouveauContextPtr nmesa)
{
@@ -92,7 +175,7 @@ void nouveauDDInitState(nouveauContextPtr nmesa)
/* Initialize the driver's state functions */
void nouveauDDInitStateFuncs(GLcontext *ctx)
{
- ctx->Driver.UpdateState = NULL; //nouveauDDInvalidateState;
+ ctx->Driver.UpdateState = nouveauDDInvalidateState;
ctx->Driver.ClearIndex = NULL;
ctx->Driver.ClearColor = NULL; //nouveauDDClearColor;