X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fi915%2Fintel_tris.c;h=7bcb72f42d0dfe14439fe426c05604149c592e8d;hb=b904321ed018c661271fb1fc3eefd1af0ec61c7f;hp=63c5ae96dc7a62c7a087c17b62798d79a934ad08;hpb=c727fa6dbf5a9fca5fc94de06c309f54402449d1;p=mesa.git diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 63c5ae96dc7..7bcb72f42d0 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -52,34 +52,33 @@ #include "intel_buffers.h" #include "intel_reg.h" #include "intel_span.h" -#include "intel_tex.h" -#include "intel_chipset.h" #include "i830_context.h" #include "i830_reg.h" +#include "i915_context.h" -static void intelRenderPrimitive(GLcontext * ctx, GLenum prim); -static void intelRasterPrimitive(GLcontext * ctx, GLenum rprim, +static void intelRenderPrimitive(struct gl_context * ctx, GLenum prim); +static void intelRasterPrimitive(struct gl_context * ctx, GLenum rprim, GLuint hwprim); static void intel_flush_inline_primitive(struct intel_context *intel) { - GLuint used = intel->batch->ptr - intel->prim.start_ptr; + GLuint used = intel->batch.used - intel->prim.start_ptr; assert(intel->prim.primitive != ~0); -/* _mesa_printf("/\n"); */ +/* printf("/\n"); */ - if (used < 8) + if (used < 2) goto do_discard; - *(int *) intel->prim.start_ptr = (_3DPRIMITIVE | - intel->prim.primitive | (used / 4 - 2)); + intel->batch.map[intel->prim.start_ptr] = + _3DPRIMITIVE | intel->prim.primitive | (used - 2); goto finished; do_discard: - intel->batch->ptr -= used; + intel->batch.used = intel->prim.start_ptr; finished: intel->prim.primitive = ~0; @@ -89,24 +88,20 @@ intel_flush_inline_primitive(struct intel_context *intel) static void intel_start_inline(struct intel_context *intel, uint32_t prim) { - uint32_t batch_flags = LOOP_CLIPRECTS; BATCH_LOCALS; intel->vtbl.emit_state(intel); intel->no_batch_wrap = GL_TRUE; - /*_mesa_printf("%s *", __progname);*/ + /*printf("%s *", __progname);*/ /* Emit a slot which will be filled with the inline primitive * command later. */ - BEGIN_BATCH(2, batch_flags); - OUT_BATCH(0); - - assert((intel->batch->dirty_state & (1<<1)) == 0); + BEGIN_BATCH(1); - intel->prim.start_ptr = intel->batch->ptr; + intel->prim.start_ptr = intel->batch.used; intel->prim.primitive = prim; intel->prim.flush = intel_flush_inline_primitive; @@ -114,7 +109,7 @@ static void intel_start_inline(struct intel_context *intel, uint32_t prim) ADVANCE_BATCH(); intel->no_batch_wrap = GL_FALSE; -/* _mesa_printf(">"); */ +/* printf(">"); */ } static void intel_wrap_inline(struct intel_context *intel) @@ -122,26 +117,25 @@ static void intel_wrap_inline(struct intel_context *intel) GLuint prim = intel->prim.primitive; intel_flush_inline_primitive(intel); - intel_batchbuffer_flush(intel->batch); + intel_batchbuffer_flush(intel); intel_start_inline(intel, prim); /* ??? */ } static GLuint *intel_extend_inline(struct intel_context *intel, GLuint dwords) { - GLuint sz = dwords * sizeof(GLuint); GLuint *ptr; assert(intel->prim.flush == intel_flush_inline_primitive); - if (intel_batchbuffer_space(intel->batch) < sz) + if (intel_batchbuffer_space(intel) < dwords * sizeof(GLuint)) intel_wrap_inline(intel); -/* _mesa_printf("."); */ +/* printf("."); */ intel->vtbl.assert_not_dirty(intel); - ptr = (GLuint *) intel->batch->ptr; - intel->batch->ptr += sz; + ptr = intel->batch.map + intel->batch.used; + intel->batch.used += dwords; return ptr; } @@ -183,8 +177,8 @@ uint32_t *intel_get_prim_space(struct intel_context *intel, unsigned int count) /* Start a new VB */ if (intel->prim.vb == NULL) intel->prim.vb = malloc(INTEL_VB_SIZE); - intel->prim.vb_bo = dri_bo_alloc(intel->bufmgr, "vb", - INTEL_VB_SIZE, 4); + intel->prim.vb_bo = drm_intel_bo_alloc(intel->bufmgr, "vb", + INTEL_VB_SIZE, 4); intel->prim.start_offset = 0; intel->prim.current_offset = 0; } @@ -201,8 +195,8 @@ uint32_t *intel_get_prim_space(struct intel_context *intel, unsigned int count) /** Dispatches the accumulated primitive to the batchbuffer. */ void intel_flush_prim(struct intel_context *intel) { - dri_bo *aper_array[2]; - dri_bo *vb_bo; + drm_intel_bo *aper_array[2]; + drm_intel_bo *vb_bo; unsigned int offset, count; BATCH_LOCALS; @@ -216,21 +210,21 @@ void intel_flush_prim(struct intel_context *intel) * flush triggered by emit_state doesn't loop back to flush_prim again. */ vb_bo = intel->prim.vb_bo; - dri_bo_reference(vb_bo); + drm_intel_bo_reference(vb_bo); count = intel->prim.count; intel->prim.count = 0; offset = intel->prim.start_offset; intel->prim.start_offset = intel->prim.current_offset; - if (!intel->gen >= 3) - intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128); + if (intel->gen < 3) + intel->prim.current_offset = intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128); intel->prim.flush = NULL; intel->vtbl.emit_state(intel); - aper_array[0] = intel->batch->buf; + aper_array[0] = intel->batch.bo; aper_array[1] = vb_bo; if (dri_bufmgr_check_aperture_space(aper_array, 2)) { - intel_batchbuffer_flush(intel->batch); + intel_batchbuffer_flush(intel); intel->vtbl.emit_state(intel); } @@ -240,11 +234,6 @@ void intel_flush_prim(struct intel_context *intel) */ intel->no_batch_wrap = GL_TRUE; - /* Check that we actually emitted the state into this batch, using the - * UPLOAD_CTX bit as the signal. - */ - assert((intel->batch->dirty_state & (1<<1)) == 0); - #if 0 printf("emitting %d..%d=%d vertices size %d\n", offset, intel->prim.current_offset, count, @@ -252,29 +241,48 @@ void intel_flush_prim(struct intel_context *intel) #endif if (intel->gen >= 3) { - BEGIN_BATCH(5, LOOP_CLIPRECTS); - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(0) | I1_LOAD_S(1) | 1); - assert((offset & !S0_VB_OFFSET_MASK) == 0); - OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset); - OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) | - (intel->vertex_size << S1_VERTEX_PITCH_SHIFT)); + struct i915_context *i915 = i915_context(&intel->ctx); + unsigned int cmd = 0, len = 0; + + if (vb_bo != i915->current_vb_bo) { + cmd |= I1_LOAD_S(0); + len++; + } + if (intel->vertex_size != i915->current_vertex_size) { + cmd |= I1_LOAD_S(1); + len++; + } + if (len) + len++; + + BEGIN_BATCH(2+len); + if (cmd) + OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | cmd | (len - 2)); + if (vb_bo != i915->current_vb_bo) { + OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, 0); + i915->current_vb_bo = vb_bo; + } + if (intel->vertex_size != i915->current_vertex_size) { + OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) | + (intel->vertex_size << S1_VERTEX_PITCH_SHIFT)); + i915->current_vertex_size = intel->vertex_size; + } OUT_BATCH(_3DPRIMITIVE | PRIM_INDIRECT | PRIM_INDIRECT_SEQUENTIAL | intel->prim.primitive | count); - OUT_BATCH(0); /* Beginning vertex index */ + OUT_BATCH(offset / (intel->vertex_size * 4)); ADVANCE_BATCH(); } else { struct i830_context *i830 = i830_context(&intel->ctx); - BEGIN_BATCH(5, LOOP_CLIPRECTS); + BEGIN_BATCH(5); OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(0) | I1_LOAD_S(2) | 1); /* S0 */ - assert((offset & !S0_VB_OFFSET_MASK_830) == 0); + assert((offset & ~S0_VB_OFFSET_MASK_830) == 0); OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset | (intel->vertex_size << S0_VB_PITCH_SHIFT_830) | S0_VB_ENABLE_830); @@ -300,7 +308,7 @@ void intel_flush_prim(struct intel_context *intel) intel->no_batch_wrap = GL_FALSE; - dri_bo_unreference(vb_bo); + drm_intel_bo_unreference(vb_bo); } /** @@ -319,9 +327,9 @@ void intel_finish_vb(struct intel_context *intel) if (intel->prim.vb_bo == NULL) return; - dri_bo_subdata(intel->prim.vb_bo, 0, intel->prim.start_offset, - intel->prim.vb); - dri_bo_unreference(intel->prim.vb_bo); + drm_intel_bo_subdata(intel->prim.vb_bo, 0, intel->prim.start_offset, + intel->prim.vb); + drm_intel_bo_unreference(intel->prim.vb_bo); intel->prim.vb_bo = NULL; } @@ -431,7 +439,7 @@ intel_draw_point(struct intel_context *intel, intelVertexPtr v0) static void intel_atten_point(struct intel_context *intel, intelVertexPtr v0) { - GLcontext *ctx = &intel->ctx; + struct gl_context *ctx = &intel->ctx; GLfloat psz[4], col[4], restore_psz, restore_alpha; _tnl_get_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); @@ -482,6 +490,7 @@ static void intel_wpos_triangle(struct intel_context *intel, intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2) { + const struct gl_framebuffer *fb = intel->ctx.DrawBuffer; GLuint offset = intel->wpos_offset; GLuint size = intel->wpos_size; GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset); @@ -492,10 +501,11 @@ intel_wpos_triangle(struct intel_context *intel, __memcpy(v1_wpos, v1, size); __memcpy(v2_wpos, v2, size); - v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; - v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h; - v2_wpos[1] = -v2_wpos[1] + intel->driDrawable->h; - + if (!fb->Name) { + v0_wpos[1] = -v0_wpos[1] + fb->Height; + v1_wpos[1] = -v1_wpos[1] + fb->Height; + v2_wpos[1] = -v2_wpos[1] + fb->Height; + } intel_draw_triangle(intel, v0, v1, v2); } @@ -505,6 +515,7 @@ static void intel_wpos_line(struct intel_context *intel, intelVertexPtr v0, intelVertexPtr v1) { + const struct gl_framebuffer *fb = intel->ctx.DrawBuffer; GLuint offset = intel->wpos_offset; GLuint size = intel->wpos_size; GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset); @@ -513,8 +524,10 @@ intel_wpos_line(struct intel_context *intel, __memcpy(v0_wpos, v0, size); __memcpy(v1_wpos, v1, size); - v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; - v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h; + if (!fb->Name) { + v0_wpos[1] = -v0_wpos[1] + fb->Height; + v1_wpos[1] = -v1_wpos[1] + fb->Height; + } intel_draw_line(intel, v0, v1); } @@ -523,12 +536,15 @@ intel_wpos_line(struct intel_context *intel, static void intel_wpos_point(struct intel_context *intel, intelVertexPtr v0) { + const struct gl_framebuffer *fb = intel->ctx.DrawBuffer; GLuint offset = intel->wpos_offset; GLuint size = intel->wpos_size; GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset); __memcpy(v0_wpos, v0, size); - v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; + + if (!fb->Name) + v0_wpos[1] = -v0_wpos[1] + fb->Height; intel_draw_point(intel, v0); } @@ -607,7 +623,6 @@ static struct #define DO_POINTS 1 #define DO_FULL_QUAD 1 -#define HAVE_RGBA 1 #define HAVE_SPEC 1 #define HAVE_BACK_COLORS 0 #define HAVE_HW_FLATSHADE 1 @@ -789,7 +804,7 @@ static void intel_fallback_tri(struct intel_context *intel, intelVertex * v0, intelVertex * v1, intelVertex * v2) { - GLcontext *ctx = &intel->ctx; + struct gl_context *ctx = &intel->ctx; SWvertex v[3]; if (0) @@ -810,7 +825,7 @@ static void intel_fallback_line(struct intel_context *intel, intelVertex * v0, intelVertex * v1) { - GLcontext *ctx = &intel->ctx; + struct gl_context *ctx = &intel->ctx; SWvertex v[2]; if (0) @@ -829,7 +844,7 @@ static void intel_fallback_point(struct intel_context *intel, intelVertex * v0) { - GLcontext *ctx = &intel->ctx; + struct gl_context *ctx = &intel->ctx; SWvertex v[1]; if (0) @@ -882,7 +897,7 @@ intel_fallback_point(struct intel_context *intel, static void -intelRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) +intelRenderClippedPoly(struct gl_context * ctx, const GLuint * elts, GLuint n) { struct intel_context *intel = intel_context(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -906,7 +921,7 @@ intelRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) } static void -intelRenderClippedLine(GLcontext * ctx, GLuint ii, GLuint jj) +intelRenderClippedLine(struct gl_context * ctx, GLuint ii, GLuint jj) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -914,7 +929,7 @@ intelRenderClippedLine(GLcontext * ctx, GLuint ii, GLuint jj) } static void -intelFastRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) +intelFastRenderClippedPoly(struct gl_context * ctx, const GLuint * elts, GLuint n) { struct intel_context *intel = intel_context(ctx); const GLuint vertsize = intel->vertex_size; @@ -941,7 +956,7 @@ intelFastRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) #define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_TRI_UNFILLED) void -intelChooseRenderState(GLcontext * ctx) +intelChooseRenderState(struct gl_context * ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct intel_context *intel = intel_context(ctx); @@ -1054,7 +1069,7 @@ static const GLenum reduced_prim[GL_POLYGON + 1] = { static void -intelRunPipeline(GLcontext * ctx) +intelRunPipeline(struct gl_context * ctx) { struct intel_context *intel = intel_context(ctx); @@ -1084,7 +1099,7 @@ intelRunPipeline(GLcontext * ctx) } static void -intelRenderStart(GLcontext * ctx) +intelRenderStart(struct gl_context * ctx) { struct intel_context *intel = intel_context(ctx); @@ -1094,7 +1109,7 @@ intelRenderStart(GLcontext * ctx) } static void -intelRenderFinish(GLcontext * ctx) +intelRenderFinish(struct gl_context * ctx) { struct intel_context *intel = intel_context(ctx); @@ -1111,7 +1126,7 @@ intelRenderFinish(GLcontext * ctx) * primitive. */ static void -intelRasterPrimitive(GLcontext * ctx, GLenum rprim, GLuint hwprim) +intelRasterPrimitive(struct gl_context * ctx, GLenum rprim, GLuint hwprim) { struct intel_context *intel = intel_context(ctx); @@ -1134,7 +1149,7 @@ intelRasterPrimitive(GLcontext * ctx, GLenum rprim, GLuint hwprim) /* */ static void -intelRenderPrimitive(GLcontext * ctx, GLenum prim) +intelRenderPrimitive(struct gl_context * ctx, GLenum prim) { struct intel_context *intel = intel_context(ctx); @@ -1181,6 +1196,8 @@ static char *fallbackStrings[] = { [17] = "Logic op", [18] = "Smooth polygon", [19] = "Smooth point", + [20] = "point sprite coord origin", + [21] = "depth/color drawing offset", }; @@ -1204,14 +1221,14 @@ getFallbackString(GLuint bit) void intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode) { - GLcontext *ctx = &intel->ctx; + struct gl_context *ctx = &intel->ctx; TNLcontext *tnl = TNL_CONTEXT(ctx); const GLbitfield oldfallback = intel->Fallback; if (mode) { intel->Fallback |= bit; if (oldfallback == 0) { - intelFlush(ctx); + intel_flush(ctx); if (INTEL_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "ENTER FALLBACK %x: %s\n", bit, getFallbackString(bit)); @@ -1256,7 +1273,7 @@ union fi void -intelInitTriFuncs(GLcontext * ctx) +intelInitTriFuncs(struct gl_context * ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); static int firsttime = 1;