|
|
|
@@ -41,7 +41,7 @@
|
|
|
|
|
#include "tnl/t_pipeline.h"
|
|
|
|
|
|
|
|
|
|
#include "nouveau_tris.h"
|
|
|
|
|
#include "nv20_swtcl.h"
|
|
|
|
|
#include "nv10_swtcl.h"
|
|
|
|
|
#include "nouveau_context.h"
|
|
|
|
|
#include "nouveau_span.h"
|
|
|
|
|
#include "nouveau_ioctl.h"
|
|
|
|
@@ -52,8 +52,8 @@
|
|
|
|
|
/* XXX hack for now */
|
|
|
|
|
#define channel 1
|
|
|
|
|
|
|
|
|
|
static void nv20RenderPrimitive( GLcontext *ctx, GLenum prim );
|
|
|
|
|
static void nv20RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
|
|
|
|
|
static void nv10RenderPrimitive( GLcontext *ctx, GLenum prim );
|
|
|
|
|
static void nv10RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
@@ -71,7 +71,7 @@ static void nv20RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
|
|
|
|
|
/* the size above which we fire the ring. this is a performance-tunable */
|
|
|
|
|
#define NOUVEAU_FIRE_SIZE (2048/4)
|
|
|
|
|
|
|
|
|
|
static inline void nv20StartPrimitive(struct nouveau_context* nmesa)
|
|
|
|
|
static inline void nv10StartPrimitive(struct nouveau_context* nmesa)
|
|
|
|
|
{
|
|
|
|
|
if (nmesa->screen->card_type==NV_10)
|
|
|
|
|
BEGIN_RING_SIZE(channel,NV10_PRIMITIVE,1);
|
|
|
|
@@ -87,7 +87,7 @@ static inline void nv20StartPrimitive(struct nouveau_context* nmesa)
|
|
|
|
|
BEGIN_RING_PRIM(channel,NV20_BEGIN_VERTICES,NOUVEAU_MIN_PRIM_SIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void nv20FinishPrimitive(struct nouveau_context *nmesa)
|
|
|
|
|
static inline void nv10FinishPrimitive(struct nouveau_context *nmesa)
|
|
|
|
|
{
|
|
|
|
|
FINISH_RING_PRIM();
|
|
|
|
|
if (nmesa->screen->card_type==NV_10)
|
|
|
|
@@ -101,13 +101,13 @@ static inline void nv20FinishPrimitive(struct nouveau_context *nmesa)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline void nv20ExtendPrimitive(struct nouveau_context* nmesa, int size)
|
|
|
|
|
static inline void nv10ExtendPrimitive(struct nouveau_context* nmesa, int size)
|
|
|
|
|
{
|
|
|
|
|
/* when the fifo has enough stuff (2048 bytes) or there is not enough room, fire */
|
|
|
|
|
if ((RING_AHEAD()>=NOUVEAU_FIRE_SIZE)||(RING_AVAILABLE()<size/4))
|
|
|
|
|
{
|
|
|
|
|
nv20FinishPrimitive(nmesa);
|
|
|
|
|
nv20StartPrimitive(nmesa);
|
|
|
|
|
nv10FinishPrimitive(nmesa);
|
|
|
|
|
nv10StartPrimitive(nmesa);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* make sure there's enough room. if not, wait */
|
|
|
|
@@ -117,14 +117,14 @@ static inline void nv20ExtendPrimitive(struct nouveau_context* nmesa, int size)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void nv20_draw_quad(nouveauContextPtr nmesa,
|
|
|
|
|
static inline void nv10_draw_quad(nouveauContextPtr nmesa,
|
|
|
|
|
nouveauVertexPtr v0,
|
|
|
|
|
nouveauVertexPtr v1,
|
|
|
|
|
nouveauVertexPtr v2,
|
|
|
|
|
nouveauVertexPtr v3)
|
|
|
|
|
{
|
|
|
|
|
GLuint vertsize = nmesa->vertex_size;
|
|
|
|
|
nv20ExtendPrimitive(nmesa, 4 * 4 * vertsize);
|
|
|
|
|
nv10ExtendPrimitive(nmesa, 4 * 4 * vertsize);
|
|
|
|
|
|
|
|
|
|
OUT_RINGp(v0,vertsize);
|
|
|
|
|
OUT_RINGp(v1,vertsize);
|
|
|
|
@@ -132,34 +132,34 @@ static inline void nv20_draw_quad(nouveauContextPtr nmesa,
|
|
|
|
|
OUT_RINGp(v3,vertsize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void nv20_draw_triangle(nouveauContextPtr nmesa,
|
|
|
|
|
static inline void nv10_draw_triangle(nouveauContextPtr nmesa,
|
|
|
|
|
nouveauVertexPtr v0,
|
|
|
|
|
nouveauVertexPtr v1,
|
|
|
|
|
nouveauVertexPtr v2)
|
|
|
|
|
{
|
|
|
|
|
GLuint vertsize = nmesa->vertex_size;
|
|
|
|
|
nv20ExtendPrimitive(nmesa, 3 * 4 * vertsize);
|
|
|
|
|
nv10ExtendPrimitive(nmesa, 3 * 4 * vertsize);
|
|
|
|
|
|
|
|
|
|
OUT_RINGp(v0,vertsize);
|
|
|
|
|
OUT_RINGp(v1,vertsize);
|
|
|
|
|
OUT_RINGp(v2,vertsize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void nv20_draw_line(nouveauContextPtr nmesa,
|
|
|
|
|
static inline void nv10_draw_line(nouveauContextPtr nmesa,
|
|
|
|
|
nouveauVertexPtr v0,
|
|
|
|
|
nouveauVertexPtr v1)
|
|
|
|
|
{
|
|
|
|
|
GLuint vertsize = nmesa->vertex_size;
|
|
|
|
|
nv20ExtendPrimitive(nmesa, 2 * 4 * vertsize);
|
|
|
|
|
nv10ExtendPrimitive(nmesa, 2 * 4 * vertsize);
|
|
|
|
|
OUT_RINGp(v0,vertsize);
|
|
|
|
|
OUT_RINGp(v1,vertsize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void nv20_draw_point(nouveauContextPtr nmesa,
|
|
|
|
|
static inline void nv10_draw_point(nouveauContextPtr nmesa,
|
|
|
|
|
nouveauVertexPtr v0)
|
|
|
|
|
{
|
|
|
|
|
GLuint vertsize = nmesa->vertex_size;
|
|
|
|
|
nv20ExtendPrimitive(nmesa, 1 * 4 * vertsize);
|
|
|
|
|
nv10ExtendPrimitive(nmesa, 1 * 4 * vertsize);
|
|
|
|
|
OUT_RINGp(v0,vertsize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -174,7 +174,7 @@ static inline void nv20_draw_point(nouveauContextPtr nmesa,
|
|
|
|
|
if (DO_FALLBACK) \
|
|
|
|
|
nmesa->draw_tri(nmesa, a, b, c); \
|
|
|
|
|
else \
|
|
|
|
|
nv20_draw_triangle(nmesa, a, b, c); \
|
|
|
|
|
nv10_draw_triangle(nmesa, a, b, c); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define QUAD(a, b, c, d) \
|
|
|
|
@@ -184,7 +184,7 @@ static inline void nv20_draw_point(nouveauContextPtr nmesa,
|
|
|
|
|
nmesa->draw_tri(nmesa, b, c, d); \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
nv20_draw_quad(nmesa, a, b, c, d); \
|
|
|
|
|
nv10_draw_quad(nmesa, a, b, c, d); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define LINE(v0, v1) \
|
|
|
|
@@ -192,7 +192,7 @@ static inline void nv20_draw_point(nouveauContextPtr nmesa,
|
|
|
|
|
if (DO_FALLBACK) \
|
|
|
|
|
nmesa->draw_line(nmesa, v0, v1); \
|
|
|
|
|
else \
|
|
|
|
|
nv20_draw_line(nmesa, v0, v1); \
|
|
|
|
|
nv10_draw_line(nmesa, v0, v1); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define POINT(v0) \
|
|
|
|
@@ -200,7 +200,7 @@ static inline void nv20_draw_point(nouveauContextPtr nmesa,
|
|
|
|
|
if (DO_FALLBACK) \
|
|
|
|
|
nmesa->draw_point(nmesa, v0); \
|
|
|
|
|
else \
|
|
|
|
|
nv20_draw_point(nmesa, v0); \
|
|
|
|
|
nv10_draw_point(nmesa, v0); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -320,7 +320,7 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
|
|
|
|
|
GL_TRIANGLES+1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define RASTERIZE(x) nv20RasterPrimitive( ctx, x, hw_prim[x] )
|
|
|
|
|
#define RASTERIZE(x) nv10RasterPrimitive( ctx, x, hw_prim[x] )
|
|
|
|
|
#define RENDER_PRIMITIVE nmesa->renderPrimitive
|
|
|
|
|
#define TAG(x) x
|
|
|
|
|
#define IND NOUVEAU_FALLBACK_BIT
|
|
|
|
@@ -448,7 +448,7 @@ static void init_rast_tab(void)
|
|
|
|
|
#define RENDER_LINE(v0, v1) LINE(V(v0), V(v1))
|
|
|
|
|
#define RENDER_TRI( v0, v1, v2) TRI( V(v0), V(v1), V(v2))
|
|
|
|
|
#define RENDER_QUAD(v0, v1, v2, v3) QUAD(V(v0), V(v1), V(v2), V(v3))
|
|
|
|
|
#define INIT(x) nv20RasterPrimitive(ctx, x, hw_prim[x])
|
|
|
|
|
#define INIT(x) nv10RasterPrimitive(ctx, x, hw_prim[x])
|
|
|
|
|
#undef LOCAL_VARS
|
|
|
|
|
#define LOCAL_VARS \
|
|
|
|
|
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); \
|
|
|
|
@@ -517,7 +517,7 @@ static void nouveauFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
|
|
|
|
|
{
|
|
|
|
|
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
|
|
|
|
|
GLuint vertsize = nmesa->vertex_size;
|
|
|
|
|
nv20ExtendPrimitive(nmesa, (n - 2) * 3 * 4 * vertsize);
|
|
|
|
|
nv10ExtendPrimitive(nmesa, (n - 2) * 3 * 4 * vertsize);
|
|
|
|
|
GLubyte *vertptr = (GLubyte *)nmesa->verts;
|
|
|
|
|
const GLuint *start = (const GLuint *)V(elts[0]);
|
|
|
|
|
int i;
|
|
|
|
@@ -557,16 +557,16 @@ do { \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void nv20ChooseRenderState(GLcontext *ctx)
|
|
|
|
|
static void nv10ChooseRenderState(GLcontext *ctx)
|
|
|
|
|
{
|
|
|
|
|
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
|
|
|
|
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
|
|
|
|
|
GLuint flags = ctx->_TriangleCaps;
|
|
|
|
|
GLuint index = 0;
|
|
|
|
|
|
|
|
|
|
nmesa->draw_point = nv20_draw_point;
|
|
|
|
|
nmesa->draw_line = nv20_draw_line;
|
|
|
|
|
nmesa->draw_tri = nv20_draw_triangle;
|
|
|
|
|
nmesa->draw_point = nv10_draw_point;
|
|
|
|
|
nmesa->draw_line = nv10_draw_line;
|
|
|
|
|
nmesa->draw_tri = nv10_draw_triangle;
|
|
|
|
|
|
|
|
|
|
if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
|
|
|
|
|
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= NOUVEAU_TWOSIDE_BIT;
|
|
|
|
@@ -617,7 +617,7 @@ static void nv20ChooseRenderState(GLcontext *ctx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline void nv20OutputVertexFormat(struct nouveau_context* nmesa, GLuint index)
|
|
|
|
|
static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa, GLuint index)
|
|
|
|
|
{
|
|
|
|
|
GLcontext* ctx=nmesa->glCtx;
|
|
|
|
|
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
|
|
|
@@ -715,7 +715,7 @@ static inline void nv20OutputVertexFormat(struct nouveau_context* nmesa, GLuint
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void nv20ChooseVertexState( GLcontext *ctx )
|
|
|
|
|
static void nv10ChooseVertexState( GLcontext *ctx )
|
|
|
|
|
{
|
|
|
|
|
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
|
|
|
|
|
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
|
|
|
@@ -724,7 +724,7 @@ static void nv20ChooseVertexState( GLcontext *ctx )
|
|
|
|
|
if (index!=nmesa->render_inputs)
|
|
|
|
|
{
|
|
|
|
|
nmesa->render_inputs=index;
|
|
|
|
|
nv20OutputVertexFormat(nmesa,index);
|
|
|
|
|
nv10OutputVertexFormat(nmesa,index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -734,13 +734,12 @@ static void nv20ChooseVertexState( GLcontext *ctx )
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void nv20RenderStart(GLcontext *ctx)
|
|
|
|
|
static void nv10RenderStart(GLcontext *ctx)
|
|
|
|
|
{
|
|
|
|
|
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
|
|
|
|
|
|
|
|
|
|
if (nmesa->newState) {
|
|
|
|
|
nmesa->newRenderState |= nmesa->newState;
|
|
|
|
|
nouveauValidateState( ctx );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nmesa->Fallback) {
|
|
|
|
@@ -749,23 +748,23 @@ static void nv20RenderStart(GLcontext *ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nmesa->newRenderState) {
|
|
|
|
|
nv20ChooseVertexState(ctx);
|
|
|
|
|
nv20ChooseRenderState(ctx);
|
|
|
|
|
nv10ChooseVertexState(ctx);
|
|
|
|
|
nv10ChooseRenderState(ctx);
|
|
|
|
|
nmesa->newRenderState = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void nv20RenderFinish(GLcontext *ctx)
|
|
|
|
|
static void nv10RenderFinish(GLcontext *ctx)
|
|
|
|
|
{
|
|
|
|
|
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
|
|
|
|
|
nv20FinishPrimitive(nmesa);
|
|
|
|
|
nv10FinishPrimitive(nmesa);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* System to flush dma and emit state changes based on the rasterized
|
|
|
|
|
* primitive.
|
|
|
|
|
*/
|
|
|
|
|
void nv20RasterPrimitive(GLcontext *ctx,
|
|
|
|
|
void nv10RasterPrimitive(GLcontext *ctx,
|
|
|
|
|
GLenum glprim,
|
|
|
|
|
GLuint hwprim)
|
|
|
|
|
{
|
|
|
|
@@ -782,9 +781,9 @@ void nv20RasterPrimitive(GLcontext *ctx,
|
|
|
|
|
|
|
|
|
|
/* Callback for mesa:
|
|
|
|
|
*/
|
|
|
|
|
static void nv20RenderPrimitive( GLcontext *ctx, GLuint prim )
|
|
|
|
|
static void nv10RenderPrimitive( GLcontext *ctx, GLuint prim )
|
|
|
|
|
{
|
|
|
|
|
nv20RasterPrimitive( ctx, prim, hw_prim[prim] );
|
|
|
|
|
nv10RasterPrimitive( ctx, prim, hw_prim[prim] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -806,9 +805,9 @@ void nouveauInitTriFuncs(GLcontext *ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tnl->Driver.RunPipeline = nouveauRunPipeline;
|
|
|
|
|
tnl->Driver.Render.Start = nv20RenderStart;
|
|
|
|
|
tnl->Driver.Render.Finish = nv20RenderFinish;
|
|
|
|
|
tnl->Driver.Render.PrimitiveNotify = nv20RenderPrimitive;
|
|
|
|
|
tnl->Driver.Render.Start = nv10RenderStart;
|
|
|
|
|
tnl->Driver.Render.Finish = nv10RenderFinish;
|
|
|
|
|
tnl->Driver.Render.PrimitiveNotify = nv10RenderPrimitive;
|
|
|
|
|
tnl->Driver.Render.ResetLineStipple = nouveauResetLineStipple;
|
|
|
|
|
tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
|
|
|
|
|
tnl->Driver.Render.CopyPV = _tnl_copy_pv;
|