_swsetup_CreateContext( ctx );
_math_matrix_ctr(&nmesa->viewport);
- _math_matrix_ctr(&nmesa->model_proj);
+ _math_matrix_ctr(&nmesa->projection);
nouveauDDInitStateFuncs( ctx );
nouveauSpanInitFunctions( ctx );
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 {
GLuint color_offset;
GLuint specular_offset;
- /* Projection*modelview matrix */
- GLmatrix model_proj;
+ /* Projection matrix */
+ GLmatrix projection;
/* Vertex state */
GLuint vertex_size;
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)
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 );
/* Initialize the driver's state functions */
void nouveauDDInitStateFuncs(GLcontext *ctx)
{
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
ctx->Driver.UpdateState = nouveauDDInvalidateState;
ctx->Driver.ClearIndex = NULL;
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
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;
}
}
+ /* 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);
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;
}
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)
{
nmesa->hw_func.InitCard = nv20InitCard;
nmesa->hw_func.BindBuffers = nv20BindBuffers;
nmesa->hw_func.WindowMoved = nv20WindowMoved;
- nmesa->hw_func.UpdateModelProjMatrix = nv20UpdateModelProjMatrix;
}
}
}
-static void nv30UpdateModelProjMatrix(nouveauContextPtr nmesa)
-{
-}
-
static void nv30WindowMoved(nouveauContextPtr nmesa)
{
GLcontext *ctx = nmesa->glCtx;
nmesa->hw_func.InitCard = nv30InitCard;
nmesa->hw_func.BindBuffers = nv30BindBuffers;
nmesa->hw_func.WindowMoved = nv30WindowMoved;
- nmesa->hw_func.UpdateModelProjMatrix = nv30UpdateModelProjMatrix;
}
/* Only with shaders */
}
-static void nv50UpdateModelProjMatrix(nouveauContextPtr nmesa)
-{
-}
-
static void nv50WindowMoved(nouveauContextPtr nmesa)
{
GLcontext *ctx = nmesa->glCtx;
nmesa->hw_func.InitCard = nv50InitCard;
nmesa->hw_func.BindBuffers = nv50BindBuffers;
nmesa->hw_func.WindowMoved = nv50WindowMoved;
- nmesa->hw_func.UpdateModelProjMatrix = nv50UpdateModelProjMatrix;
}