From fef3dcbee60b041df64a12511c8aa3c304a04652 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 20:38:10 +1000 Subject: nouveau: Always render offscreen, emulate front buffer rendering. --- src/mesa/drivers/dri/nouveau/nv20_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/nouveau/nv20_state.c') diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index ccf2f6148b..6b583980a4 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -728,8 +728,8 @@ static GLboolean nv20InitCard(nouveauContextPtr nmesa) /* Update buffer offset/pitch/format */ static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color, - nouveau_renderbuffer **color, - nouveau_renderbuffer *depth) + nouveau_renderbuffer_t **color, + nouveau_renderbuffer_t *depth) { GLuint x, y, w, h; GLuint pitch, format, depth_pitch; -- cgit v1.2.3 From b0a1e81887a831f72ffbec4fe005e1837c81018c Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Fri, 31 Aug 2007 19:43:16 +0200 Subject: nouveau: add hw-dependent function to update modelview*projection matrix --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_context.h | 6 ++++ src/mesa/drivers/dri/nouveau/nouveau_state.c | 17 ++++++++++ src/mesa/drivers/dri/nouveau/nv10_state.c | 46 ++++++++++++++++++++++++++ src/mesa/drivers/dri/nouveau/nv20_state.c | 5 +++ src/mesa/drivers/dri/nouveau/nv30_state.c | 5 +++ src/mesa/drivers/dri/nouveau/nv50_state.c | 5 +++ 7 files changed, 85 insertions(+) (limited to 'src/mesa/drivers/dri/nouveau/nv20_state.c') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 1e13324b98..ae0a6d5c9e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -210,6 +210,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, _swsetup_CreateContext( ctx ); _math_matrix_ctr(&nmesa->viewport); + _math_matrix_ctr(&nmesa->model_proj); nouveauDDInitStateFuncs( ctx ); nouveauSpanInitFunctions( ctx ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 778c4401e4..94d729daef 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -86,6 +86,9 @@ typedef struct nouveau_hw_func_t { nouveau_renderbuffer_t *depth); /* Update anything that depends on the window position/size */ void (*WindowMoved)(struct nouveau_context *); + + /* Update projection matrix */ + void (*UpdateModelProjMatrix)(struct nouveau_context *); } nouveau_hw_func; typedef struct nouveau_context { @@ -117,6 +120,9 @@ typedef struct nouveau_context { GLuint color_offset; GLuint specular_offset; + /* Projection*modelview matrix */ + GLmatrix model_proj; + /* Vertex state */ GLuint vertex_size; GLubyte *verts; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index f618dcfc99..6c63b12c46 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -100,6 +100,16 @@ static void nouveauDepthRange(GLcontext *ctx, GLclampd near, GLclampd far) nouveauCalcViewport(ctx); } +static void nouveauUpdateModelProjMatrix(GLcontext *ctx) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + + _math_matrix_mul_matrix(&(nmesa->model_proj), &(ctx->_ModelProjectMatrix), + ctx->ModelviewMatrixStack.Top); + + nmesa->hw_func.UpdateModelProjMatrix(nmesa); +} + static void nouveauDDUpdateHWState(GLcontext *ctx) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); @@ -141,6 +151,13 @@ static void nouveauDDUpdateHWState(GLcontext *ctx) static void nouveauDDInvalidateState(GLcontext *ctx, GLuint new_state) { + if ( new_state & _NEW_PROJECTION ) { + nouveauUpdateModelProjMatrix(ctx); + } + if ( new_state & _NEW_MODELVIEW ) { + nouveauUpdateModelProjMatrix(ctx); + } + _swrast_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state ); _vbo_InvalidateState( ctx, new_state ); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 79d567b25d..9c63bd118a 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -750,6 +750,51 @@ static void nv10TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } +static void nv10UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ + GLcontext *ctx = nmesa->glCtx; + GLfloat w = ((GLfloat) ctx->Viewport.Width) * 0.5; + GLfloat h = ((GLfloat) ctx->Viewport.Height) * 0.5; + GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; + GLfloat projection[16]; + int i; + + if (ctx->DrawBuffer) { + if (ctx->DrawBuffer->_DepthBuffer) { + switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) { + case 16: + max_depth *= 32767.0; + break; + case 24: + max_depth *= 16777215.0; + break; + } + } + } + + /* Rescale for viewport */ + for (i=0; i<4; i++) { + projection[i] = w * nmesa->model_proj.m[i]; + } + for (i=0; i<4; i++) { + projection[i+4] = -h * nmesa->model_proj.m[i+4]; + } + for (i=0; i<4; i++) { + projection[i+8] = max_depth * nmesa->model_proj.m[i+8]; + } + for (i=0; i<4; i++) { + projection[i+12] = nmesa->model_proj.m[i+12]; + } + + for (i=0; i<16; i++) { + printf("%d\t%.3f\t%.3f\n", i, + nmesa->model_proj.m[i], projection[i]); + } + + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); + OUT_RINGp(projection, 16); +} + /* Update anything that depends on the window position/size */ static void nv10WindowMoved(nouveauContextPtr nmesa) { @@ -1011,4 +1056,5 @@ void nv10InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv10InitCard; nmesa->hw_func.BindBuffers = nv10BindBuffers; nmesa->hw_func.WindowMoved = nv10WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv10UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index 6b583980a4..c6efa6b72c 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -636,6 +636,10 @@ static void nv20TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } +static void nv20UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ +} + /* Update anything that depends on the window position/size */ static void nv20WindowMoved(nouveauContextPtr nmesa) { @@ -820,5 +824,6 @@ void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv20InitCard; nmesa->hw_func.BindBuffers = nv20BindBuffers; nmesa->hw_func.WindowMoved = nv20WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv20UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index cd3ee98688..ebd9e1c514 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -767,6 +767,10 @@ static void nv30TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) } } +static void nv30UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ +} + static void nv30WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -998,5 +1002,6 @@ void nv30InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv30InitCard; nmesa->hw_func.BindBuffers = nv30BindBuffers; nmesa->hw_func.WindowMoved = nv30WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv30UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv50_state.c b/src/mesa/drivers/dri/nouveau/nv50_state.c index a9236f093c..66a18c4a15 100644 --- a/src/mesa/drivers/dri/nouveau/nv50_state.c +++ b/src/mesa/drivers/dri/nouveau/nv50_state.c @@ -520,6 +520,10 @@ static void nv50TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) /* Only with shaders */ } +static void nv50UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ +} + static void nv50WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -638,4 +642,5 @@ void nv50InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv50InitCard; nmesa->hw_func.BindBuffers = nv50BindBuffers; nmesa->hw_func.WindowMoved = nv50WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv50UpdateModelProjMatrix; } -- cgit v1.2.3 From c45bb05b3c0b65981b6ddeaf1bb043b9a6f7f3fc Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Mon, 3 Sep 2007 23:08:57 +0200 Subject: nouveau: separate modelview and projection matrix updates --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_context.h | 9 ++++++--- src/mesa/drivers/dri/nouveau/nouveau_state.c | 22 ++++++++++++++-------- src/mesa/drivers/dri/nouveau/nv10_state.c | 18 +++++++++++------- src/mesa/drivers/dri/nouveau/nv20_state.c | 5 ----- src/mesa/drivers/dri/nouveau/nv30_state.c | 5 ----- src/mesa/drivers/dri/nouveau/nv50_state.c | 5 ----- 7 files changed, 32 insertions(+), 34 deletions(-) (limited to 'src/mesa/drivers/dri/nouveau/nv20_state.c') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index ae0a6d5c9e..0f7bd4aa07 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -210,7 +210,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, _swsetup_CreateContext( ctx ); _math_matrix_ctr(&nmesa->viewport); - _math_matrix_ctr(&nmesa->model_proj); + _math_matrix_ctr(&nmesa->projection); nouveauDDInitStateFuncs( ctx ); nouveauSpanInitFunctions( ctx ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 94d729daef..51666ef91c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -88,7 +88,10 @@ typedef struct nouveau_hw_func_t { void (*WindowMoved)(struct nouveau_context *); /* Update projection matrix */ - void (*UpdateModelProjMatrix)(struct nouveau_context *); + void (*UpdateProjectionMatrix)(GLcontext *); + + /* Update modelview matrix (used for lighting and vertex weight) */ + void (*UpdateModelviewMatrix)(GLcontext *); } nouveau_hw_func; typedef struct nouveau_context { @@ -120,8 +123,8 @@ typedef struct nouveau_context { GLuint color_offset; GLuint specular_offset; - /* Projection*modelview matrix */ - GLmatrix model_proj; + /* Projection matrix */ + GLmatrix projection; /* Vertex state */ GLuint vertex_size; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 6c63b12c46..9e64a7010e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -100,14 +100,12 @@ static void nouveauDepthRange(GLcontext *ctx, GLclampd near, GLclampd far) nouveauCalcViewport(ctx); } -static void nouveauUpdateModelProjMatrix(GLcontext *ctx) +static void nouveauUpdateProjectionMatrix(GLcontext *ctx) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - - _math_matrix_mul_matrix(&(nmesa->model_proj), &(ctx->_ModelProjectMatrix), - ctx->ModelviewMatrixStack.Top); +} - nmesa->hw_func.UpdateModelProjMatrix(nmesa); +static void nouveauUpdateModelviewMatrix(GLcontext *ctx) +{ } static void nouveauDDUpdateHWState(GLcontext *ctx) @@ -151,11 +149,13 @@ static void nouveauDDUpdateHWState(GLcontext *ctx) static void nouveauDDInvalidateState(GLcontext *ctx, GLuint new_state) { + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + if ( new_state & _NEW_PROJECTION ) { - nouveauUpdateModelProjMatrix(ctx); + nmesa->hw_func.UpdateProjectionMatrix(ctx); } if ( new_state & _NEW_MODELVIEW ) { - nouveauUpdateModelProjMatrix(ctx); + nmesa->hw_func.UpdateModelviewMatrix(ctx); } _swrast_InvalidateState( ctx, new_state ); @@ -203,6 +203,8 @@ void nouveauDDInitState(nouveauContextPtr nmesa) /* Initialize the driver's state functions */ void nouveauDDInitStateFuncs(GLcontext *ctx) { + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + ctx->Driver.UpdateState = nouveauDDInvalidateState; ctx->Driver.ClearIndex = NULL; @@ -253,6 +255,10 @@ void nouveauDDInitStateFuncs(GLcontext *ctx) ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable; ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; + + /* Matrix updates */ + nmesa->hw_func.UpdateProjectionMatrix = nouveauUpdateProjectionMatrix; + nmesa->hw_func.UpdateModelviewMatrix = nouveauUpdateModelviewMatrix; } #define STATE_INIT(a) if (ctx->Driver.a) ctx->Driver.a diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index bdfc75b875..f9a8356772 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -736,9 +736,9 @@ static void nv10TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } -static void nv10UpdateModelProjMatrix(nouveauContextPtr nmesa) +static void nv10UpdateProjectionMatrix(GLcontext *ctx) { - GLcontext *ctx = nmesa->glCtx; + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); GLfloat w = ((GLfloat) ctx->Viewport.Width) * 0.5; GLfloat h = ((GLfloat) ctx->Viewport.Height) * 0.5; GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; @@ -758,18 +758,22 @@ static void nv10UpdateModelProjMatrix(nouveauContextPtr nmesa) } } + /* Calc projection * modelview */ + _math_matrix_mul_matrix(&(nmesa->projection), &(ctx->_ModelProjectMatrix), + ctx->ModelviewMatrixStack.Top); + /* Rescale for viewport */ for (i=0; i<4; i++) { - projection[i] = w * nmesa->model_proj.m[i]; + projection[i] = w * nmesa->projection.m[i]; } for (i=0; i<4; i++) { - projection[i+4] = -h * nmesa->model_proj.m[i+4]; + projection[i+4] = -h * nmesa->projection.m[i+4]; } for (i=0; i<4; i++) { - projection[i+8] = max_depth * nmesa->model_proj.m[i+8]; + projection[i+8] = max_depth * nmesa->projection.m[i+8]; } for (i=0; i<4; i++) { - projection[i+12] = nmesa->model_proj.m[i+12]; + projection[i+12] = nmesa->projection.m[i+12]; } BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); @@ -1037,5 +1041,5 @@ void nv10InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv10InitCard; nmesa->hw_func.BindBuffers = nv10BindBuffers; nmesa->hw_func.WindowMoved = nv10WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv10UpdateModelProjMatrix; + nmesa->hw_func.UpdateProjectionMatrix = nv10UpdateProjectionMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index c6efa6b72c..6b583980a4 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -636,10 +636,6 @@ static void nv20TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } -static void nv20UpdateModelProjMatrix(nouveauContextPtr nmesa) -{ -} - /* Update anything that depends on the window position/size */ static void nv20WindowMoved(nouveauContextPtr nmesa) { @@ -824,6 +820,5 @@ void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv20InitCard; nmesa->hw_func.BindBuffers = nv20BindBuffers; nmesa->hw_func.WindowMoved = nv20WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv20UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index ebd9e1c514..cd3ee98688 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -767,10 +767,6 @@ static void nv30TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) } } -static void nv30UpdateModelProjMatrix(nouveauContextPtr nmesa) -{ -} - static void nv30WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -1002,6 +998,5 @@ void nv30InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv30InitCard; nmesa->hw_func.BindBuffers = nv30BindBuffers; nmesa->hw_func.WindowMoved = nv30WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv30UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv50_state.c b/src/mesa/drivers/dri/nouveau/nv50_state.c index 66a18c4a15..a9236f093c 100644 --- a/src/mesa/drivers/dri/nouveau/nv50_state.c +++ b/src/mesa/drivers/dri/nouveau/nv50_state.c @@ -520,10 +520,6 @@ static void nv50TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) /* Only with shaders */ } -static void nv50UpdateModelProjMatrix(nouveauContextPtr nmesa) -{ -} - static void nv50WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -642,5 +638,4 @@ void nv50InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv50InitCard; nmesa->hw_func.BindBuffers = nv50BindBuffers; nmesa->hw_func.WindowMoved = nv50WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv50UpdateModelProjMatrix; } -- cgit v1.2.3