diff options
author | Patrice Mandin <[email protected]> | 2007-08-22 11:01:59 +0200 |
---|---|---|
committer | Patrice Mandin <[email protected]> | 2007-08-22 11:01:59 +0200 |
commit | a3750c989b7330cc08942c9e0959ebfcdfcb9306 (patch) | |
tree | 9024897f68108dcd66bdce4c4ad2f20d1a4cc4a3 /src | |
parent | 24746d0e3219b333fdbbb0026191fc735036ac8c (diff) |
nouveau: nv10: set projection matrix from viewport size
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_state.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 1d2994e5105..5d512b13c41 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -37,29 +37,43 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. static void nv10ViewportScale(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; - GLuint w = ctx->Viewport.Width; - GLuint h = ctx->Viewport.Height; - + GLuint w = ((GLfloat) ctx->Viewport.Width) * 0.5; + GLuint h = ((GLfloat) ctx->Viewport.Height) * 0.5; GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; -/* if (ctx->DrawBuffer) { - switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) { - case 16: - max_depth *= 32767.0; - break; - case 24: - max_depth *= 16777215.0; - break; - } - } else {*/ - /* Default to 24 bits range */ - max_depth *= 16777215.0; -/* }*/ + GLfloat projection[16]; + int i; + + if (!ctx->DrawBuffer) { + return; + } + if (!ctx->DrawBuffer->_DepthBuffer) { + return; + } + + 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 (w - 2048.0); + OUT_RING_CACHEf (h - 2048.0); OUT_RING_CACHEf (max_depth); OUT_RING_CACHEf (0.0); + + memset(projection, 0, sizeof(projection)); + projection[0*4+0] = w; + projection[1*4+1] = h; + projection[2*4+2] = max_depth; + projection[3*4+3] = 1.0; + BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); + for (i=0; i<16; i++) { + OUT_RING_CACHEf (projection[i]); + } } static void nv10AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) @@ -774,6 +788,7 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) /* Set state for stuff not initialized in nouveau_state.c */ BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_TX_ENABLE(0), 2); OUT_RING (0); + OUT_RING (0); BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_RC_IN_ALPHA(0), 12); OUT_RING (0x30141010); OUT_RING (0); |