summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorVladimir Dergachev <volodya@freedesktop.org>2004-12-30 06:06:54 +0000
committerVladimir Dergachev <volodya@freedesktop.org>2004-12-30 06:06:54 +0000
commit74bf43051c5a0abbe83f431ca8e1d8d4d2b068c4 (patch)
treedf567d3c5f0324f346a06ae4b7f570209839a288 /src/mesa/drivers
parent5be14fd59a24612afd09da13688d611a1711d6da (diff)
Port viewport setting code from R200.
Take it outside R300ResetHwState.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h11
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c81
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.h13
3 files changed, 85 insertions, 20 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index be27659259..5863ee52f2 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -308,7 +308,13 @@ struct r300_cmdbuf {
/**
* State cache
*/
+
+struct r300_depthbuffer_state {
+ GLfloat scale;
+};
+
struct r300_state {
+ struct r300_depthbuffer_state depth;
};
@@ -321,6 +327,11 @@ struct r300_context {
struct r300_hw_state hw;
struct r300_cmdbuf cmdbuf;
struct r300_state state;
+
+ /* Vertex buffers */
+ int elt_count; /* size of the buffer for vertices */
+ int attrib_count; /* size of the buffer for vertex attributes.. Somehow it can be different ? */
+
};
#define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 86b457bf82..d080ae5bf7 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -225,6 +225,58 @@ static void r300ColorMask(GLcontext* ctx,
}
}
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+/*
+ * To correctly position primitives:
+ */
+#define SUBPIXEL_X 0.125
+#define SUBPIXEL_Y 0.125
+
+void r300UpdateWindow(GLcontext * ctx)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
+ GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
+ GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+ GLfloat sy = -v[MAT_SY];
+ GLfloat ty = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+ GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale;
+ GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale;
+
+ R300_FIREVERTICES(rmesa);
+ R300_STATECHANGE(rmesa, vpt);
+
+ rmesa->hw.vpt.cmd[R300_VPT_XSCALE] = r300PackFloat32(sx);
+ rmesa->hw.vpt.cmd[R300_VPT_XOFFSET] = r300PackFloat32(tx);
+ rmesa->hw.vpt.cmd[R300_VPT_YSCALE] = r300PackFloat32(sy);
+ rmesa->hw.vpt.cmd[R300_VPT_YOFFSET] = r300PackFloat32(ty);
+ rmesa->hw.vpt.cmd[R300_VPT_ZSCALE] = r300PackFloat32(sz);
+ rmesa->hw.vpt.cmd[R300_VPT_ZOFFSET] = r300PackFloat32(tz);
+}
+
+static void r300Viewport(GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ /* Don't pipeline viewport changes, conflict with window offset
+ * setting below. Could apply deltas to rescue pipelined viewport
+ * values, or keep the originals hanging around.
+ */
+ R200_FIREVERTICES(R200_CONTEXT(ctx));
+ r300UpdateWindow(ctx);
+}
+
+static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
+{
+ r300UpdateWindow(ctx);
+}
+
/**
* Called by Mesa after an internal state update.
@@ -255,26 +307,8 @@ void r300ResetHwState(r300ContextPtr r300)
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s\n", __FUNCTION__);
- {
- __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
- GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
- GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
- const GLfloat *v = ctx->Viewport._WindowMap.m;
-
- r300->hw.vpt.cmd[R300_VPT_XSCALE] =
- r300PackFloat32(v[MAT_SX]);
- r300->hw.vpt.cmd[R300_VPT_XOFFSET] =
- r300PackFloat32(v[MAT_TX] + xoffset);
- r300->hw.vpt.cmd[R300_VPT_YSCALE] =
- r300PackFloat32(-v[MAT_SY]);
- r300->hw.vpt.cmd[R300_VPT_YOFFSET] =
- r300PackFloat32(-v[MAT_TY] + yoffset);
- r300->hw.vpt.cmd[R300_VPT_ZSCALE] =
- r300PackFloat32(v[MAT_SZ]);
- r300->hw.vpt.cmd[R300_VPT_ZOFFSET] =
- r300PackFloat32(v[MAT_TZ]);
- }
-
+ r300UpdateWindow(ctx);
+
r300ColorMask(ctx,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
@@ -504,11 +538,14 @@ void r300ResetHwState(r300ContextPtr r300)
void r300InitState(r300ContextPtr r300)
{
radeonInitState(&r300->radeon);
+
+ r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
r300ResetHwState(r300);
}
+
/**
* Initialize driver's state callback functions
*/
@@ -523,5 +560,9 @@ void r300InitStateFuncs(struct dd_function_table* functions)
functions->DepthMask = r300DepthMask;
functions->CullFace = r300CullFace;
functions->FrontFace = r300FrontFace;
+
+ /* Viewport related */
+ functions->Viewport = r300Viewport;
+ functions->DepthRange = r300DepthRange;
}
diff --git a/src/mesa/drivers/dri/r300/r300_state.h b/src/mesa/drivers/dri/r300/r300_state.h
index 9c945c4cdd..a04835c79d 100644
--- a/src/mesa/drivers/dri/r300/r300_state.h
+++ b/src/mesa/drivers/dri/r300/r300_state.h
@@ -43,6 +43,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
r300->hw.is_dirty = GL_TRUE; \
} while(0)
+/* Fire the buffered vertices no matter what.
+ TODO: This has not been implemented yet
+ */
+#define R300_FIREVERTICES( r300 ) \
+do { \
+ /* \
+ if ( (r300)->store.cmd_used || (r300)->dma.flush ) { \
+ radeonFlush( (r300)->radeon.glCtx ); \
+ } \
+ */ \
+} while (0)
+
+
extern void r300ResetHwState(r300ContextPtr r300);
extern void r300InitState(r300ContextPtr r300);