intel: move some driver functions around
authorBrian Paul <brianp@vmware.com>
Mon, 26 Jan 2009 23:33:45 +0000 (16:33 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 26 Jan 2009 23:33:45 +0000 (16:33 -0700)
A step toward consolidating i915/intel_state.c and i965/intel_state.c

src/mesa/drivers/dri/i915/i915_state.c
src/mesa/drivers/dri/i915/intel_state.c
src/mesa/drivers/dri/i965/intel_state.c
src/mesa/drivers/dri/intel/intel_context.h

index a53f120a817371f085db42590fc1f737e80cc46a..f94de41a57b7cf2c953a4994c29352e429ef88d4 100644 (file)
@@ -301,6 +301,74 @@ i915DepthMask(GLcontext * ctx, GLboolean flag)
       i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_WRITE_ENABLE;
 }
 
+
+
+/**
+ * Update the viewport transformation matrix.  Depends on:
+ *  - viewport pos/size
+ *  - depthrange
+ *  - window pos/size or FBO size
+ */
+static void
+intelCalcViewport(GLcontext * ctx)
+{
+   struct intel_context *intel = intel_context(ctx);
+   const GLfloat *v = ctx->Viewport._WindowMap.m;
+   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+   GLfloat *m = intel->ViewportMatrix.m;
+   GLfloat yScale, yBias;
+
+   if (ctx->DrawBuffer->Name) {
+      /* User created FBO */
+      struct intel_renderbuffer *irb
+         = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
+      if (irb && !irb->RenderToTexture) {
+         /* y=0=top */
+         yScale = -1.0;
+         yBias = irb->Base.Height;
+      }
+      else {
+         /* y=0=bottom */
+         yScale = 1.0;
+         yBias = 0.0;
+      }
+   }
+   else {
+      /* window buffer, y=0=top */
+      yScale = -1.0;
+      yBias = (intel->driDrawable) ? intel->driDrawable->h : 0.0F;
+   }
+
+   m[MAT_SX] = v[MAT_SX];
+   m[MAT_TX] = v[MAT_TX];
+
+   m[MAT_SY] = v[MAT_SY] * yScale;
+   m[MAT_TY] = v[MAT_TY] * yScale + yBias;
+
+   m[MAT_SZ] = v[MAT_SZ] * depthScale;
+   m[MAT_TZ] = v[MAT_TZ] * depthScale;
+}
+
+
+/** Called from ctx->Driver.Viewport() */
+static void
+intelViewport(GLcontext * ctx,
+              GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   intelCalcViewport(ctx);
+
+   intel_viewport(ctx, x, y, width, height);
+}
+
+
+/** Called from ctx->Driver.DepthRange() */
+static void
+intelDepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
+{
+   intelCalcViewport(ctx);
+}
+
+
 /* =============================================================
  * Polygon stipple
  *
@@ -964,6 +1032,8 @@ i915InitStateFunctions(struct dd_function_table *functions)
    functions->StencilFuncSeparate = i915StencilFuncSeparate;
    functions->StencilMaskSeparate = i915StencilMaskSeparate;
    functions->StencilOpSeparate = i915StencilOpSeparate;
+   functions->DepthRange = intelDepthRange;
+   functions->Viewport = intelViewport;
 }
 
 
index 4aa43e5f3abd20670e62ce743072b0470d7f9098..8d96e9baec16d4f489c4ce07c5160b5d3dc5492c 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "intel_screen.h"
 #include "intel_context.h"
-#include "intel_fbo.h"
 #include "intel_regions.h"
 #include "swrast/swrast.h"
 
@@ -216,67 +215,6 @@ intelClearColor(GLcontext * ctx, const GLfloat color[4])
 }
 
 
-/**
- * Update the viewport transformation matrix.  Depends on:
- *  - viewport pos/size
- *  - depthrange
- *  - window pos/size or FBO size
- */
-static void
-intelCalcViewport(GLcontext * ctx)
-{
-   struct intel_context *intel = intel_context(ctx);
-   const GLfloat *v = ctx->Viewport._WindowMap.m;
-   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
-   GLfloat *m = intel->ViewportMatrix.m;
-   GLfloat yScale, yBias;
-
-   if (ctx->DrawBuffer->Name) {
-      /* User created FBO */
-      struct intel_renderbuffer *irb
-         = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
-      if (irb && !irb->RenderToTexture) {
-         /* y=0=top */
-         yScale = -1.0;
-         yBias = irb->Base.Height;
-      }
-      else {
-         /* y=0=bottom */
-         yScale = 1.0;
-         yBias = 0.0;
-      }
-   }
-   else {
-      /* window buffer, y=0=top */
-      yScale = -1.0;
-      yBias = (intel->driDrawable) ? intel->driDrawable->h : 0.0F;
-   }
-
-   m[MAT_SX] = v[MAT_SX];
-   m[MAT_TX] = v[MAT_TX];
-
-   m[MAT_SY] = v[MAT_SY] * yScale;
-   m[MAT_TY] = v[MAT_TY] * yScale + yBias;
-
-   m[MAT_SZ] = v[MAT_SZ] * depthScale;
-   m[MAT_TZ] = v[MAT_TZ] * depthScale;
-}
-
-static void
-intelViewport(GLcontext * ctx,
-              GLint x, GLint y, GLsizei width, GLsizei height)
-{
-   intelCalcViewport(ctx);
-
-   intel_viewport(ctx, x, y, width, height);
-}
-
-static void
-intelDepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
-{
-   intelCalcViewport(ctx);
-}
-
 /* Fallback to swrast for select and feedback.
  */
 static void
@@ -291,7 +229,5 @@ void
 intelInitStateFuncs(struct dd_function_table *functions)
 {
    functions->RenderMode = intelRenderMode;
-   functions->Viewport = intelViewport;
-   functions->DepthRange = intelDepthRange;
    functions->ClearColor = intelClearColor;
 }
index 67ef5f78c1aa32df0324ca8579ed867f8a8312e6..0c9c6707f9da797f56df441fc5b95fa91097b2c9 100644 (file)
@@ -38,7 +38,8 @@
 #include "intel_regions.h"
 #include "swrast/swrast.h"
 
-int intel_translate_shadow_compare_func( GLenum func )
+int
+intel_translate_shadow_compare_func( GLenum func )
 {
    switch(func) {
    case GL_NEVER: 
@@ -63,7 +64,8 @@ int intel_translate_shadow_compare_func( GLenum func )
    return COMPAREFUNC_NEVER; 
 }
 
-int intel_translate_compare_func( GLenum func )
+int
+intel_translate_compare_func( GLenum func )
 {
    switch(func) {
    case GL_NEVER: 
@@ -88,7 +90,8 @@ int intel_translate_compare_func( GLenum func )
    return COMPAREFUNC_ALWAYS; 
 }
 
-int intel_translate_stencil_op( GLenum op )
+int
+intel_translate_stencil_op( GLenum op )
 {
    switch(op) {
    case GL_KEEP: 
@@ -112,7 +115,8 @@ int intel_translate_stencil_op( GLenum op )
    }
 }
 
-int intel_translate_blend_factor( GLenum factor )
+int
+intel_translate_blend_factor( GLenum factor )
 {
    switch(factor) {
    case GL_ZERO: 
@@ -151,7 +155,8 @@ int intel_translate_blend_factor( GLenum factor )
    return BLENDFACT_ZERO;
 }
 
-int intel_translate_logic_op( GLenum opcode )
+int
+intel_translate_logic_op( GLenum opcode )
 {
    switch(opcode) {
    case GL_CLEAR: 
@@ -192,33 +197,36 @@ int intel_translate_logic_op( GLenum opcode )
 }
 
 
-static void intelClearColor(GLcontext *ctx, const GLfloat color[4])
+static void
+intelClearColor(GLcontext *ctx, const GLfloat color[4])
 {
    struct intel_context *intel = intel_context(ctx);
+   GLubyte clear[4];
 
-   UNCLAMPED_FLOAT_TO_RGBA_CHAN(intel->clear_chan, color);
+   CLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]);
+   CLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]);
+   CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
+   CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
 
-   intel->ClearColor8888 = INTEL_PACKCOLOR8888(intel->clear_chan[0],
-                                              intel->clear_chan[1],
-                                              intel->clear_chan[2],
-                                              intel->clear_chan[3]);
-   intel->ClearColor565 = INTEL_PACKCOLOR565(intel->clear_chan[0],
-                                            intel->clear_chan[1],
-                                            intel->clear_chan[2]);
+   /* compute both 32 and 16-bit clear values */
+   intel->ClearColor8888 = INTEL_PACKCOLOR8888(clear[0], clear[1],
+                                               clear[2], clear[3]);
+   intel->ClearColor565 = INTEL_PACKCOLOR565(clear[0], clear[1], clear[2]);
 }
 
 
-
 /* Fallback to swrast for select and feedback.
  */
-static void intelRenderMode( GLcontext *ctx, GLenum mode )
+static void
+intelRenderMode( GLcontext *ctx, GLenum mode )
 {
    struct intel_context *intel = intel_context(ctx);
    FALLBACK( intel, INTEL_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
 }
 
 
-void intelInitStateFuncs( struct dd_function_table *functions )
+void
+intelInitStateFuncs( struct dd_function_table *functions )
 {
    functions->RenderMode = intelRenderMode;
    functions->ClearColor = intelClearColor;
index 9a84451e7cb870f3345805b79e233ae983f0827b..18dc43c4a42b6ee5e8c054a2960efa85ced9b1b8 100644 (file)
@@ -210,7 +210,6 @@ struct intel_context
    char *prevLockFile;
    int prevLockLine;
 
-   GLubyte clear_chan[4];
    GLuint ClearColor565;
    GLuint ClearColor8888;