summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/nouveau/nouveau_state.c
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/mesa/drivers/dri/nouveau/nouveau_state.c
parentb0c4cfed608f21f255b8637ec5ff499fc36ee302 (diff)
State changes.
Diffstat (limited to 'src/mesa/drivers/dri/nouveau/nouveau_state.c')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_state.c89
1 files changed, 86 insertions, 3 deletions
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;