X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fi915%2Fintel_render.c;h=6afd7388e1e51b33b586bfcce6d73f04b9741b65;hb=4df1b986d3e44dc035227054000a1d0e1846ef07;hp=d9438ba0fd898a5e3de890db8ec73e7b8a9eb9af;hpb=e3358dea660f5dec53a8be9e38d725f4fd829e14;p=mesa.git diff --git a/src/mesa/drivers/dri/i915/intel_render.c b/src/mesa/drivers/dri/i915/intel_render.c index d9438ba0fd8..6afd7388e1e 100644 --- a/src/mesa/drivers/dri/i915/intel_render.c +++ b/src/mesa/drivers/dri/i915/intel_render.c @@ -30,15 +30,18 @@ * dma buffers. Use strip/fan hardware acceleration where possible. * */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" -#include "enums.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" +#include "main/enums.h" + +#include "math/m_xform.h" #include "tnl/t_context.h" #include "tnl/t_vertex.h" +#include "tnl/t_pipeline.h" #include "intel_screen.h" #include "intel_context.h" @@ -51,14 +54,14 @@ * dma buffers. Use strip/fan hardware primitives where possible. * Try to simulate missing primitives with indexed vertices. */ -#define HAVE_POINTS 0 /* Has it, but can't use because subpixel has to - * be adjusted for points on the INTEL/I845G - */ +#define HAVE_POINTS 0 /* Has it, but can't use because subpixel has to + * be adjusted for points on the INTEL/I845G + */ #define HAVE_LINES 1 #define HAVE_LINE_STRIPS 1 #define HAVE_TRIANGLES 1 #define HAVE_TRI_STRIPS 1 -#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */ +#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */ #define HAVE_TRI_FANS 1 #define HAVE_POLYGONS 1 #define HAVE_QUADS 0 @@ -66,7 +69,7 @@ #define HAVE_ELTS 0 -static GLuint hw_prim[GL_POLYGON+1] = { +static uint32_t hw_prim[GL_POLYGON + 1] = { 0, PRIM3D_LINELIST, PRIM3D_LINESTRIP, @@ -79,7 +82,7 @@ static GLuint hw_prim[GL_POLYGON+1] = { PRIM3D_POLY }; -static const GLenum reduced_prim[GL_POLYGON+1] = { +static const GLenum reduced_prim[GL_POLYGON + 1] = { GL_POINTS, GL_LINES, GL_LINES, @@ -92,58 +95,85 @@ static const GLenum reduced_prim[GL_POLYGON+1] = { GL_TRIANGLES }; -static const int scale_prim[GL_POLYGON+1] = { - 0, /* fallback case */ +static const int scale_prim[GL_POLYGON + 1] = { + 0, /* fallback case */ 1, 2, 2, 1, 3, 3, - 0, /* fallback case */ - 0, /* fallback case */ + 0, /* fallback case */ + 0, /* fallback case */ 3 }; -static void intelDmaPrimitive( intelContextPtr intel, GLenum prim ) +static void +intelDmaPrimitive(struct intel_context *intel, GLenum prim) { - if (0) fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim)); + if (0) + fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim)); INTEL_FIREVERTICES(intel); - intel->vtbl.reduced_primitive_state( intel, reduced_prim[prim] ); - intelStartInlinePrimitive( intel, hw_prim[prim] ); + intel->vtbl.reduced_primitive_state(intel, reduced_prim[prim]); + intel_set_prim(intel, hw_prim[prim]); } +#define INTEL_NO_VBO_STATE_RESERVED 1500 + +static INLINE GLuint intel_get_vb_max(struct intel_context *intel) +{ + GLuint ret; + + if (intel->intelScreen->no_vbo) { + ret = intel->batch.bo->size - INTEL_NO_VBO_STATE_RESERVED; + } else + ret = INTEL_VB_SIZE; + ret /= (intel->vertex_size * 4); + return ret; +} + +static INLINE GLuint intel_get_current_max(struct intel_context *intel) +{ + GLuint ret; -#define LOCAL_VARS intelContextPtr intel = INTEL_CONTEXT(ctx) + if (intel->intelScreen->no_vbo) { + ret = intel_batchbuffer_space(intel); + ret = ret <= INTEL_NO_VBO_STATE_RESERVED ? 0 : ret - INTEL_NO_VBO_STATE_RESERVED; + } else + ret = (INTEL_VB_SIZE - intel->prim.current_offset); + + return ret / (intel->vertex_size * 4); +} + +#define LOCAL_VARS struct intel_context *intel = intel_context(ctx) #define INIT( prim ) \ do { \ intelDmaPrimitive( intel, prim ); \ } while (0) -#define FLUSH() INTEL_FIREVERTICES( intel ) -#define GET_SUBSEQUENT_VB_MAX_VERTS() \ - (((intel->alloc.size / 2) - 1500) / (intel->vertex_size*4)) -#define GET_CURRENT_VB_MAX_VERTS() GET_SUBSEQUENT_VB_MAX_VERTS() +#define FLUSH() INTEL_FIREVERTICES(intel) + +#define GET_SUBSEQUENT_VB_MAX_VERTS() intel_get_vb_max(intel) +#define GET_CURRENT_VB_MAX_VERTS() intel_get_current_max(intel) + +#define ALLOC_VERTS(nr) intel_get_prim_space(intel, nr) -#define ALLOC_VERTS( nr ) \ - intelExtendInlinePrimitive( intel, (nr) * intel->vertex_size ) - #define EMIT_VERTS( ctx, j, nr, buf ) \ - _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf ) + _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf ) #define TAG(x) intel_##x #include "tnl_dd/t_dd_dmatmp.h" - - + + /**********************************************************************/ /* Render pipeline stage */ /**********************************************************************/ /* Heuristic to choose between the two render paths: */ -static GLboolean choose_render( intelContextPtr intel, - struct vertex_buffer *VB ) +static bool +choose_render(struct intel_context *intel, struct vertex_buffer *VB) { int vertsz = intel->vertex_size; int cost_render = 0; @@ -153,20 +183,20 @@ static GLboolean choose_render( intelContextPtr intel, int nr_rverts = 0; int rprim = intel->reduced_primitive; int i = 0; - - for (i = 0 ; i < VB->PrimitiveCount ; i++) { + + for (i = 0; i < VB->PrimitiveCount; i++) { GLuint prim = VB->Primitive[i].mode; GLuint length = VB->Primitive[i].count; if (!length) - continue; + continue; nr_prims++; nr_rverts += length * scale_prim[prim & PRIM_MODE_MASK]; if (reduced_prim[prim & PRIM_MODE_MASK] != rprim) { - nr_rprims++; - rprim = reduced_prim[prim & PRIM_MODE_MASK]; + nr_rprims++; + rprim = reduced_prim[prim & PRIM_MODE_MASK]; } } @@ -177,64 +207,81 @@ static GLboolean choose_render( intelContextPtr intel, /* One point for every 1024 dwords (4k) of dma: */ - cost_render += (vertsz * i) / 1024; - cost_fallback += (vertsz * nr_rverts) / 1024; + cost_render += (vertsz * i) / 1024; + cost_fallback += (vertsz * nr_rverts) / 1024; if (0) fprintf(stderr, "cost render: %d fallback: %d\n", - cost_render, cost_fallback); + cost_render, cost_fallback); - if (cost_render > cost_fallback) - return GL_FALSE; + if (cost_render > cost_fallback) + return false; - return GL_TRUE; + return true; } -static GLboolean intel_run_render( GLcontext *ctx, - struct tnl_pipeline_stage *stage ) +static GLboolean +intel_run_render(struct gl_context * ctx, struct tnl_pipeline_stage *stage) { - intelContextPtr intel = INTEL_CONTEXT(ctx); + struct intel_context *intel = intel_context(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; GLuint i; + intel->vtbl.render_prevalidate( intel ); + /* Don't handle clipping or indexed vertices. */ - if (intel->RenderIndex != 0 || - !intel_validate_render( ctx, VB ) || - !choose_render( intel, VB )) { - return GL_TRUE; + if (intel->RenderIndex != 0 || + !intel_validate_render(ctx, VB) || !choose_render(intel, VB)) { + return true; } tnl->clipspace.new_inputs |= VERT_BIT_POS; - tnl->Driver.Render.Start( ctx ); - - for (i = 0 ; i < VB->PrimitiveCount ; i++) - { - GLuint prim = VB->Primitive[i].mode; + tnl->Driver.Render.Start(ctx); + + for (i = 0; i < VB->PrimitiveCount; i++) { + GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); GLuint start = VB->Primitive[i].start; GLuint length = VB->Primitive[i].count; if (!length) - continue; + continue; - intel_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length, - prim ); + intel_render_tab_verts[prim & PRIM_MODE_MASK] (ctx, start, + start + length, prim); } - - tnl->Driver.Render.Finish( ctx ); - return GL_FALSE; /* finished the pipe */ + tnl->Driver.Render.Finish(ctx); + + INTEL_FIREVERTICES(intel); + + return false; /* finished the pipe */ } -const struct tnl_pipeline_stage _intel_render_stage = -{ +static const struct tnl_pipeline_stage _intel_render_stage = { "intel render", NULL, NULL, NULL, NULL, - intel_run_render /* run */ + intel_run_render /* run */ +}; + +const struct tnl_pipeline_stage *intel_pipeline[] = { + &_tnl_vertex_transform_stage, + &_tnl_normal_transform_stage, + &_tnl_lighting_stage, + &_tnl_fog_coordinate_stage, + &_tnl_texgen_stage, + &_tnl_texture_transform_stage, + &_tnl_point_attenuation_stage, + &_tnl_vertex_program_stage, +#if 1 + &_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */ +#endif + &_tnl_render_stage, + 0, };