diff options
author | Eric Anholt <[email protected]> | 2007-09-19 11:05:36 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2007-09-20 09:04:20 -0700 |
commit | 4f1c9f7e510122b32c82ee9adbdb4987dae27afe (patch) | |
tree | 30cb409cf46cd11a6a14178985f7c69468e5b0f9 /src/mesa/drivers/dri/i915tex | |
parent | e3745dac59602a9d21b49d602646de5aef95075f (diff) | |
parent | 45899a494c578d406b29e5ee17c0f1b6bf12c2de (diff) |
Merge branch 'master' into i915-unification
Conflicts:
src/mesa/drivers/dri/common/dri_drmpool.c
src/mesa/drivers/dri/i915tex/i915_vtbl.c
src/mesa/drivers/dri/i915tex/intel_batchbuffer.c
src/mesa/drivers/dri/i915tex/intel_context.c
Diffstat (limited to 'src/mesa/drivers/dri/i915tex')
24 files changed, 1359 insertions, 356 deletions
diff --git a/src/mesa/drivers/dri/i915tex/Makefile b/src/mesa/drivers/dri/i915tex/Makefile index eb704e1538b..d3d0bd570c1 100644 --- a/src/mesa/drivers/dri/i915tex/Makefile +++ b/src/mesa/drivers/dri/i915tex/Makefile @@ -33,17 +33,18 @@ DRIVER_SOURCES = \ intel_pixel_draw.c \ intel_buffers.c \ intel_blit.c \ - i915_disasm.c \ i915_tex.c \ i915_texstate.c \ i915_context.c \ i915_debug.c \ + i915_debug_fp.c \ i915_fragprog.c \ i915_metaops.c \ i915_program.c \ i915_state.c \ i915_vtbl.c \ intel_context.c \ + intel_decode.c \ intel_ioctl.c \ intel_rotate.c \ intel_screen.c \ diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c index dc91af71815..eecff2729fd 100644 --- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c @@ -61,6 +61,11 @@ do { \ #define TEXBIND_SET(n, x) ((x)<<((n)*4)) static void +i830_render_prevalidate(struct intel_context *intel) +{ +} + +static void i830_render_start(struct intel_context *intel) { GLcontext *ctx = &intel->ctx; @@ -516,6 +521,16 @@ i830_emit_state(struct intel_context *intel) static void i830_destroy_context(struct intel_context *intel) { + GLuint i; + struct i830_context *i830 = i830_context(&intel->ctx); + + for (i = 0; i < I830_TEX_UNITS; i++) { + if (i830->state.tex_buffer[i] != NULL) { + dri_bo_unreference(i830->state.tex_buffer[i]); + i830->state.tex_buffer[i] = NULL; + } + } + _tnl_free_vertices(&intel->ctx); } @@ -654,5 +669,6 @@ i830InitVtbl(struct i830_context *i830) i830->intel.vtbl.update_texture_state = i830UpdateTextureState; i830->intel.vtbl.flush_cmd = i830_flush_cmd; i830->intel.vtbl.render_start = i830_render_start; + i830->intel.vtbl.render_prevalidate = i830_render_prevalidate; i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty; } diff --git a/src/mesa/drivers/dri/i915tex/i915_context.h b/src/mesa/drivers/dri/i915tex/i915_context.h index 7915385dca6..0be2b3cc8b0 100644 --- a/src/mesa/drivers/dri/i915tex/i915_context.h +++ b/src/mesa/drivers/dri/i915tex/i915_context.h @@ -309,12 +309,6 @@ extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, /*====================================================================== - * i915_texprog.c - */ -extern void i915ValidateTextureProgram(struct i915_context *i915); - - -/*====================================================================== * i915_debug.c */ extern void i915_disassemble_program(const GLuint * program, GLuint sz); diff --git a/src/mesa/drivers/dri/i915tex/i915_debug.c b/src/mesa/drivers/dri/i915tex/i915_debug.c index 974527e14cc..c0e1242a0ea 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug.c @@ -25,310 +25,819 @@ * **************************************************************************/ +#include "imports.h" + #include "i915_reg.h" #include "i915_context.h" -#include <stdio.h> - - -static const char *opcodes[0x20] = { - "NOP", - "ADD", - "MOV", - "MUL", - "MAD", - "DP2ADD", - "DP3", - "DP4", - "FRC", - "RCP", - "RSQ", - "EXP", - "LOG", - "CMP", - "MIN", - "MAX", - "FLR", - "MOD", - "TRC", - "SGE", - "SLT", - "TEXLD", - "TEXLDP", - "TEXLDB", - "TEXKILL", - "DCL", - "0x1a", - "0x1b", - "0x1c", - "0x1d", - "0x1e", - "0x1f", -}; - - -static const int args[0x20] = { - 0, /* 0 nop */ - 2, /* 1 add */ - 1, /* 2 mov */ - 2, /* 3 m ul */ - 3, /* 4 mad */ - 3, /* 5 dp2add */ - 2, /* 6 dp3 */ - 2, /* 7 dp4 */ - 1, /* 8 frc */ - 1, /* 9 rcp */ - 1, /* a rsq */ - 1, /* b exp */ - 1, /* c log */ - 3, /* d cmp */ - 2, /* e min */ - 2, /* f max */ - 1, /* 10 flr */ - 1, /* 11 mod */ - 1, /* 12 trc */ - 2, /* 13 sge */ - 2, /* 14 slt */ - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -}; - - -static const char *regname[0x8] = { - "R", - "T", - "CONST", - "S", - "OC", - "OD", - "U", - "UNKNOWN", -}; - -static void -print_reg_type_nr(GLuint type, GLuint nr) +#include "i915_debug.h" + +#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) + +static GLboolean debug( struct debug_stream *stream, const char *name, GLuint len ) { - switch (type) { - case REG_TYPE_T: - switch (nr) { - case T_DIFFUSE: - fprintf(stderr, "T_DIFFUSE"); - return; - case T_SPECULAR: - fprintf(stderr, "T_SPECULAR"); - return; - case T_FOG_W: - fprintf(stderr, "T_FOG_W"); - return; - default: - fprintf(stderr, "T_TEX%d", nr); - return; - } - case REG_TYPE_OC: - if (nr == 0) { - fprintf(stderr, "oC"); - return; - } - break; - case REG_TYPE_OD: - if (nr == 0) { - fprintf(stderr, "oD"); - return; - } - break; - default: - break; + GLuint i; + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + + if (len == 0) { + PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + assert(0); + return GL_FALSE; } - fprintf(stderr, "%s[%d]", regname[type], nr); + if (stream->print_addresses) + PRINTF("%08x: ", stream->offset); + + + PRINTF("%s (%d dwords):\n", name, len); + for (i = 0; i < len; i++) + PRINTF("\t0x%08x\n", ptr[i]); + PRINTF("\n"); + + stream->offset += len * sizeof(GLuint); + + return GL_TRUE; +} + + +static const char *get_prim_name( GLuint val ) +{ + switch (val & PRIM3D_MASK) { + case PRIM3D_TRILIST: return "TRILIST"; break; + case PRIM3D_TRISTRIP: return "TRISTRIP"; break; + case PRIM3D_TRISTRIP_RVRSE: return "TRISTRIP_RVRSE"; break; + case PRIM3D_TRIFAN: return "TRIFAN"; break; + case PRIM3D_POLY: return "POLY"; break; + case PRIM3D_LINELIST: return "LINELIST"; break; + case PRIM3D_LINESTRIP: return "LINESTRIP"; break; + case PRIM3D_RECTLIST: return "RECTLIST"; break; + case PRIM3D_POINTLIST: return "POINTLIST"; break; + case PRIM3D_DIB: return "DIB"; break; + case PRIM3D_CLEAR_RECT: return "CLEAR_RECT"; break; + case PRIM3D_ZONE_INIT: return "ZONE_INIT"; break; + default: return "????"; break; + } } -#define REG_SWIZZLE_MASK 0x7777 -#define REG_NEGATE_MASK 0x8888 +static GLboolean debug_prim( struct debug_stream *stream, const char *name, + GLboolean dump_floats, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + const char *prim = get_prim_name( ptr[0] ); + GLuint i; + -#define REG_SWIZZLE_XYZW ((SRC_X << A2_SRC2_CHANNEL_X_SHIFT) | \ - (SRC_Y << A2_SRC2_CHANNEL_Y_SHIFT) | \ - (SRC_Z << A2_SRC2_CHANNEL_Z_SHIFT) | \ - (SRC_W << A2_SRC2_CHANNEL_W_SHIFT)) + + PRINTF("%s %s (%d dwords):\n", name, prim, len); + PRINTF("\t0x%08x\n", ptr[0]); + for (i = 1; i < len; i++) { + if (dump_floats) + PRINTF("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); + else + PRINTF("\t0x%08x\n", ptr[i]); + } + + + PRINTF("\n"); + + stream->offset += len * sizeof(GLuint); + + return GL_TRUE; +} + -static void -print_reg_neg_swizzle(GLuint reg) + +static GLboolean debug_program( struct debug_stream *stream, const char *name, GLuint len ) { - int i; - - if ((reg & REG_SWIZZLE_MASK) == REG_SWIZZLE_XYZW && - (reg & REG_NEGATE_MASK) == 0) - return; - - fprintf(stderr, "."); - - for (i = 3; i >= 0; i--) { - if (reg & (1 << ((i * 4) + 3))) - fprintf(stderr, "-"); - - switch ((reg >> (i * 4)) & 0x7) { - case 0: - fprintf(stderr, "x"); - break; - case 1: - fprintf(stderr, "y"); - break; - case 2: - fprintf(stderr, "z"); - break; - case 3: - fprintf(stderr, "w"); - break; - case 4: - fprintf(stderr, "0"); - break; - case 5: - fprintf(stderr, "1"); - break; - default: - fprintf(stderr, "?"); - break; + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + + if (len == 0) { + PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + assert(0); + return GL_FALSE; + } + + if (stream->print_addresses) + PRINTF("%08x: ", stream->offset); + + PRINTF("%s (%d dwords):\n", name, len); + i915_disassemble_program( ptr, len ); + + stream->offset += len * sizeof(GLuint); + return GL_TRUE; +} + + +static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint old_offset = stream->offset + len * sizeof(GLuint); + GLuint i; + + PRINTF("%s (%d dwords):\n", name, len); + for (i = 0; i < len; i++) + PRINTF("\t0x%08x\n", ptr[i]); + + stream->offset = ptr[1] & ~0x3; + + if (stream->offset < old_offset) + PRINTF("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", + old_offset, stream->offset ); + else + PRINTF("\n... skipping from 0x%x --> 0x%x ...\n\n", + old_offset, stream->offset ); + + + return GL_TRUE; +} + + +static GLboolean debug_variable_length_prim( struct debug_stream *stream ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + const char *prim = get_prim_name( ptr[0] ); + GLuint i, len; + + GLushort *idx = (GLushort *)(ptr+1); + for (i = 0; idx[i] != 0xffff; i++) + ; + + len = 1+(i+2)/2; + + PRINTF("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); + for (i = 0; i < len; i++) + PRINTF("\t0x%08x\n", ptr[i]); + PRINTF("\n"); + + stream->offset += len * sizeof(GLuint); + return GL_TRUE; +} + + +#define BITS( dw, hi, lo, ... ) \ +do { \ + unsigned himask = ~0UL >> (31 - (hi)); \ + PRINTF("\t\t "); \ + PRINTF(__VA_ARGS__); \ + PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \ +} while (0) + +#define MBZ( dw, hi, lo) do { \ + unsigned x = (dw) >> (lo); \ + unsigned lomask = (1 << (lo)) - 1; \ + unsigned himask; \ + himask = (1UL << (hi)) - 1; \ + assert ((x & himask & ~lomask) == 0); \ +} while (0) + +#define FLAG( dw, bit, ... ) \ +do { \ + if (((dw) >> (bit)) & 1) { \ + PRINTF("\t\t "); \ + PRINTF(__VA_ARGS__); \ + PRINTF("\n"); \ + } \ +} while (0) + +static GLboolean debug_load_immediate( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint bits = (ptr[0] >> 4) & 0xff; + GLuint j = 0; + + PRINTF("%s (%d dwords, flags: %x):\n", name, len, bits); + PRINTF("\t0x%08x\n", ptr[j++]); + + if (bits & (1<<0)) { + PRINTF("\t LIS0: 0x%08x\n", ptr[j]); + PRINTF("\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); + BITS(ptr[j], 0, 0, "vb invalidate disable"); + j++; + } + if (bits & (1<<1)) { + PRINTF("\t LIS1: 0x%08x\n", ptr[j]); + BITS(ptr[j], 29, 24, "vb dword width"); + BITS(ptr[j], 21, 16, "vb dword pitch"); + BITS(ptr[j], 15, 0, "vb max index"); + j++; + } + if (bits & (1<<2)) { + int i; + PRINTF("\t LIS2: 0x%08x\n", ptr[j]); + for (i = 0; i < 8; i++) { + unsigned tc = (ptr[j] >> (i * 4)) & 0xf; + if (tc != 0xf) + BITS(tc, 3, 0, "tex coord %d", i); + } + j++; + } + if (bits & (1<<3)) { + PRINTF("\t LIS3: 0x%08x\n", ptr[j]); + j++; + } + if (bits & (1<<4)) { + PRINTF("\t LIS4: 0x%08x\n", ptr[j]); + BITS(ptr[j], 31, 23, "point width"); + BITS(ptr[j], 22, 19, "line width"); + FLAG(ptr[j], 18, "alpha flatshade"); + FLAG(ptr[j], 17, "fog flatshade"); + FLAG(ptr[j], 16, "spec flatshade"); + FLAG(ptr[j], 15, "rgb flatshade"); + BITS(ptr[j], 14, 13, "cull mode"); + FLAG(ptr[j], 12, "vfmt: point width"); + FLAG(ptr[j], 11, "vfmt: specular/fog"); + FLAG(ptr[j], 10, "vfmt: rgba"); + FLAG(ptr[j], 9, "vfmt: depth offset"); + BITS(ptr[j], 8, 6, "vfmt: position (2==xyzw)"); + FLAG(ptr[j], 5, "force dflt diffuse"); + FLAG(ptr[j], 4, "force dflt specular"); + FLAG(ptr[j], 3, "local depth offset enable"); + FLAG(ptr[j], 2, "vfmt: fp32 fog coord"); + FLAG(ptr[j], 1, "sprite point"); + FLAG(ptr[j], 0, "antialiasing"); + j++; + } + if (bits & (1<<5)) { + PRINTF("\t LIS5: 0x%08x\n", ptr[j]); + BITS(ptr[j], 31, 28, "rgba write disables"); + FLAG(ptr[j], 27, "force dflt point width"); + FLAG(ptr[j], 26, "last pixel enable"); + FLAG(ptr[j], 25, "global z offset enable"); + FLAG(ptr[j], 24, "fog enable"); + BITS(ptr[j], 23, 16, "stencil ref"); + BITS(ptr[j], 15, 13, "stencil test"); + BITS(ptr[j], 12, 10, "stencil fail op"); + BITS(ptr[j], 9, 7, "stencil pass z fail op"); + BITS(ptr[j], 6, 4, "stencil pass z pass op"); + FLAG(ptr[j], 3, "stencil write enable"); + FLAG(ptr[j], 2, "stencil test enable"); + FLAG(ptr[j], 1, "color dither enable"); + FLAG(ptr[j], 0, "logiop enable"); + j++; + } + if (bits & (1<<6)) { + PRINTF("\t LIS6: 0x%08x\n", ptr[j]); + FLAG(ptr[j], 31, "alpha test enable"); + BITS(ptr[j], 30, 28, "alpha func"); + BITS(ptr[j], 27, 20, "alpha ref"); + FLAG(ptr[j], 19, "depth test enable"); + BITS(ptr[j], 18, 16, "depth func"); + FLAG(ptr[j], 15, "blend enable"); + BITS(ptr[j], 14, 12, "blend func"); + BITS(ptr[j], 11, 8, "blend src factor"); + BITS(ptr[j], 7, 4, "blend dst factor"); + FLAG(ptr[j], 3, "depth write enable"); + FLAG(ptr[j], 2, "color write enable"); + BITS(ptr[j], 1, 0, "provoking vertex"); + j++; + } + + + PRINTF("\n"); + + assert(j == len); + + stream->offset += len * sizeof(GLuint); + + return GL_TRUE; +} + + + +static GLboolean debug_load_indirect( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint bits = (ptr[0] >> 8) & 0x3f; + GLuint i, j = 0; + + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); + + for (i = 0; i < 6; i++) { + if (bits & (1<<i)) { + switch (1<<(8+i)) { + case LI0_STATE_STATIC_INDIRECT: + PRINTF(" STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(" 0x%08x\n", ptr[j++]); + break; + case LI0_STATE_DYNAMIC_INDIRECT: + PRINTF(" DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + break; + case LI0_STATE_SAMPLER: + PRINTF(" SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(" 0x%08x\n", ptr[j++]); + break; + case LI0_STATE_MAP: + PRINTF(" MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(" 0x%08x\n", ptr[j++]); + break; + case LI0_STATE_PROGRAM: + PRINTF(" PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(" 0x%08x\n", ptr[j++]); + break; + case LI0_STATE_CONSTANTS: + PRINTF(" CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(" 0x%08x\n", ptr[j++]); + break; + default: + assert(0); + break; + } } } + + if (bits == 0) { + PRINTF("\t DUMMY: 0x%08x\n", ptr[j++]); + } + + PRINTF("\n"); + + + assert(j == len); + + stream->offset += len * sizeof(GLuint); + + return GL_TRUE; +} + +static void BR13( struct debug_stream *stream, + GLuint val ) +{ + PRINTF("\t0x%08x\n", val); + FLAG(val, 30, "clipping enable"); + BITS(val, 25, 24, "color depth (3==32bpp)"); + BITS(val, 23, 16, "raster op"); + BITS(val, 15, 0, "dest pitch"); } -static void -print_src_reg(GLuint dword) +static void BR22( struct debug_stream *stream, + GLuint val ) { - GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK; - GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr(type, nr); - print_reg_neg_swizzle(dword); + PRINTF("\t0x%08x\n", val); + BITS(val, 31, 16, "dest y1"); + BITS(val, 15, 0, "dest x1"); } -void -i915_print_ureg(const char *msg, GLuint ureg) +static void BR23( struct debug_stream *stream, + GLuint val ) +{ + PRINTF("\t0x%08x\n", val); + BITS(val, 31, 16, "dest y2"); + BITS(val, 15, 0, "dest x2"); +} + +static void BR09( struct debug_stream *stream, + GLuint val ) { - fprintf(stderr, "%s: ", msg); - print_src_reg(ureg >> 8); - fprintf(stderr, "\n"); + PRINTF("\t0x%08x -- dest address\n", val); } -static void -print_dest_reg(GLuint dword) +static void BR26( struct debug_stream *stream, + GLuint val ) { - GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK; - GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr(type, nr); - if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) - return; - fprintf(stderr, "."); - if (dword & A0_DEST_CHANNEL_X) - fprintf(stderr, "x"); - if (dword & A0_DEST_CHANNEL_Y) - fprintf(stderr, "y"); - if (dword & A0_DEST_CHANNEL_Z) - fprintf(stderr, "z"); - if (dword & A0_DEST_CHANNEL_W) - fprintf(stderr, "w"); + PRINTF("\t0x%08x\n", val); + BITS(val, 31, 16, "src y1"); + BITS(val, 15, 0, "src x1"); } +static void BR11( struct debug_stream *stream, + GLuint val ) +{ + PRINTF("\t0x%08x\n", val); + BITS(val, 15, 0, "src pitch"); +} -#define GET_SRC0_REG(r0, r1) ((r0<<14)|(r1>>A1_SRC0_CHANNEL_W_SHIFT)) -#define GET_SRC1_REG(r0, r1) ((r0<<8)|(r1>>A2_SRC1_CHANNEL_W_SHIFT)) -#define GET_SRC2_REG(r) (r) +static void BR12( struct debug_stream *stream, + GLuint val ) +{ + PRINTF("\t0x%08x -- src address\n", val); +} +static void BR16( struct debug_stream *stream, + GLuint val ) +{ + PRINTF("\t0x%08x -- color\n", val); +} + +static GLboolean debug_copy_blit( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); + + BR13(stream, ptr[j++]); + BR22(stream, ptr[j++]); + BR23(stream, ptr[j++]); + BR09(stream, ptr[j++]); + BR26(stream, ptr[j++]); + BR11(stream, ptr[j++]); + BR12(stream, ptr[j++]); + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} -static void -print_arith_op(GLuint opcode, const GLuint * program) +static GLboolean debug_color_blit( struct debug_stream *stream, + const char *name, + GLuint len ) { - if (opcode != A0_NOP) { - print_dest_reg(program[0]); - if (program[0] & A0_DEST_SATURATE) - fprintf(stderr, " = SATURATE "); - else - fprintf(stderr, " = "); - } + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; - fprintf(stderr, "%s ", opcodes[opcode]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); - print_src_reg(GET_SRC0_REG(program[0], program[1])); - if (args[opcode] == 1) { - fprintf(stderr, "\n"); - return; + BR13(stream, ptr[j++]); + BR22(stream, ptr[j++]); + BR23(stream, ptr[j++]); + BR09(stream, ptr[j++]); + BR16(stream, ptr[j++]); + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_modes4( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j]); + BITS(ptr[j], 21, 18, "logicop func"); + FLAG(ptr[j], 17, "stencil test mask modify-enable"); + FLAG(ptr[j], 16, "stencil write mask modify-enable"); + BITS(ptr[j], 15, 8, "stencil test mask"); + BITS(ptr[j], 7, 0, "stencil write mask"); + j++; + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_map_state( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); + + { + PRINTF("\t0x%08x\n", ptr[j]); + BITS(ptr[j], 15, 0, "map mask"); + j++; } - fprintf(stderr, ", "); - print_src_reg(GET_SRC1_REG(program[1], program[2])); - if (args[opcode] == 2) { - fprintf(stderr, "\n"); - return; + while (j < len) { + { + PRINTF("\t TMn.0: 0x%08x\n", ptr[j]); + PRINTF("\t map address: 0x%08x\n", (ptr[j] & ~0x3)); + FLAG(ptr[j], 1, "vertical line stride"); + FLAG(ptr[j], 0, "vertical line stride offset"); + j++; + } + + { + PRINTF("\t TMn.1: 0x%08x\n", ptr[j]); + BITS(ptr[j], 31, 21, "height"); + BITS(ptr[j], 20, 10, "width"); + BITS(ptr[j], 9, 7, "surface format"); + BITS(ptr[j], 6, 3, "texel format"); + FLAG(ptr[j], 2, "use fence regs"); + FLAG(ptr[j], 1, "tiled surface"); + FLAG(ptr[j], 0, "tile walk ymajor"); + j++; + } + { + PRINTF("\t TMn.2: 0x%08x\n", ptr[j]); + BITS(ptr[j], 31, 21, "dword pitch"); + BITS(ptr[j], 20, 15, "cube face enables"); + BITS(ptr[j], 14, 9, "max lod"); + FLAG(ptr[j], 8, "mip layout right"); + BITS(ptr[j], 7, 0, "depth"); + j++; + } } - fprintf(stderr, ", "); - print_src_reg(GET_SRC2_REG(program[2])); - fprintf(stderr, "\n"); - return; + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; } - -static void -print_tex_op(GLuint opcode, const GLuint * program) +static GLboolean debug_sampler_state( struct debug_stream *stream, + const char *name, + GLuint len ) { - print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - fprintf(stderr, " = "); + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); + + { + PRINTF("\t0x%08x\n", ptr[j]); + BITS(ptr[j], 15, 0, "sampler mask"); + j++; + } - fprintf(stderr, "%s ", opcodes[opcode]); + while (j < len) { + { + PRINTF("\t TSn.0: 0x%08x\n", ptr[j]); + FLAG(ptr[j], 31, "reverse gamma"); + FLAG(ptr[j], 30, "planar to packed"); + FLAG(ptr[j], 29, "yuv->rgb"); + BITS(ptr[j], 28, 27, "chromakey index"); + BITS(ptr[j], 26, 22, "base mip level"); + BITS(ptr[j], 21, 20, "mip mode filter"); + BITS(ptr[j], 19, 17, "mag mode filter"); + BITS(ptr[j], 16, 14, "min mode filter"); + BITS(ptr[j], 13, 5, "lod bias (s4.4)"); + FLAG(ptr[j], 4, "shadow enable"); + FLAG(ptr[j], 3, "max-aniso-4"); + BITS(ptr[j], 2, 0, "shadow func"); + j++; + } - fprintf(stderr, "S[%d],", program[0] & T0_SAMPLER_NR_MASK); + { + PRINTF("\t TSn.1: 0x%08x\n", ptr[j]); + BITS(ptr[j], 31, 24, "min lod"); + MBZ( ptr[j], 23, 18 ); + FLAG(ptr[j], 17, "kill pixel enable"); + FLAG(ptr[j], 16, "keyed tex filter mode"); + FLAG(ptr[j], 15, "chromakey enable"); + BITS(ptr[j], 14, 12, "tcx wrap mode"); + BITS(ptr[j], 11, 9, "tcy wrap mode"); + BITS(ptr[j], 8, 6, "tcz wrap mode"); + FLAG(ptr[j], 5, "normalized coords"); + BITS(ptr[j], 4, 1, "map (surface) index"); + FLAG(ptr[j], 0, "EAST deinterlacer enable"); + j++; + } + { + PRINTF("\t TSn.2: 0x%08x (default color)\n", ptr[j]); + j++; + } + } - print_reg_type_nr((program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & - REG_TYPE_MASK, - (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); - fprintf(stderr, "\n"); + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; } -static void -print_dcl_op(GLuint opcode, const GLuint * program) +static GLboolean debug_dest_vars( struct debug_stream *stream, + const char *name, + GLuint len ) { - fprintf(stderr, "%s ", opcodes[opcode]); - print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - fprintf(stderr, "\n"); + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); + + { + PRINTF("\t0x%08x\n", ptr[j]); + FLAG(ptr[j], 31, "early classic ztest"); + FLAG(ptr[j], 30, "opengl tex default color"); + FLAG(ptr[j], 29, "bypass iz"); + FLAG(ptr[j], 28, "lod preclamp"); + BITS(ptr[j], 27, 26, "dither pattern"); + FLAG(ptr[j], 25, "linear gamma blend"); + FLAG(ptr[j], 24, "debug dither"); + BITS(ptr[j], 23, 20, "dstorg x"); + BITS(ptr[j], 19, 16, "dstorg y"); + MBZ (ptr[j], 15, 15 ); + BITS(ptr[j], 14, 12, "422 write select"); + BITS(ptr[j], 11, 8, "cbuf format"); + BITS(ptr[j], 3, 2, "zbuf format"); + FLAG(ptr[j], 1, "vert line stride"); + FLAG(ptr[j], 1, "vert line stride offset"); + j++; + } + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; } +static GLboolean debug_buf_info( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); + + { + PRINTF("\t0x%08x\n", ptr[j]); + BITS(ptr[j], 28, 28, "aux buffer id"); + BITS(ptr[j], 27, 24, "buffer id (7=depth, 3=back)"); + FLAG(ptr[j], 23, "use fence regs"); + FLAG(ptr[j], 22, "tiled surface"); + FLAG(ptr[j], 21, "tile walk ymajor"); + MBZ (ptr[j], 20, 14); + BITS(ptr[j], 13, 2, "dword pitch"); + MBZ (ptr[j], 2, 0); + j++; + } + + PRINTF("\t0x%08x -- buffer base address\n", ptr[j++]); + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean i915_debug_packet( struct debug_stream *stream ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint cmd = *ptr; + + switch (((cmd >> 29) & 0x7)) { + case 0x0: + switch ((cmd >> 23) & 0x3f) { + case 0x0: + return debug(stream, "MI_NOOP", 1); + case 0x3: + return debug(stream, "MI_WAIT_FOR_EVENT", 1); + case 0x4: + return debug(stream, "MI_FLUSH", 1); + case 0xA: + debug(stream, "MI_BATCH_BUFFER_END", 1); + return GL_FALSE; + case 0x22: + return debug(stream, "MI_LOAD_REGISTER_IMM", 3); + case 0x31: + return debug_chain(stream, "MI_BATCH_BUFFER_START", 2); + default: + break; + } + break; + case 0x1: + break; + case 0x2: + switch ((cmd >> 22) & 0xff) { + case 0x50: + return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2); + case 0x53: + return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2); + default: + return debug(stream, "blit command", (cmd & 0xff) + 2); + } + break; + case 0x3: + switch ((cmd >> 24) & 0x1f) { + case 0x6: + return debug(stream, "3DSTATE_ANTI_ALIASING", 1); + case 0x7: + return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1); + case 0x8: + return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 2); + case 0x9: + return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1); + case 0xb: + return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1); + case 0xc: + return debug(stream, "3DSTATE_MODES5", 1); + case 0xd: + return debug_modes4(stream, "3DSTATE_MODES4", 1); + case 0x15: + return debug(stream, "3DSTATE_FOG_COLOR", 1); + case 0x16: + return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1); + case 0x1c: + /* 3DState16NP */ + switch((cmd >> 19) & 0x1f) { + case 0x10: + return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1); + case 0x11: + return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1); + default: + break; + } + break; + case 0x1d: + /* 3DStateMW */ + switch ((cmd >> 16) & 0xff) { + case 0x0: + return debug_map_state(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2); + case 0x1: + return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2); + case 0x4: + return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2); + case 0x5: + return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd & 0x1ff) + 2); + case 0x6: + return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd & 0xff) + 2); + case 0x7: + return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT", (cmd & 0xff) + 2); + case 0x80: + return debug(stream, "3DSTATE_DRAWING_RECTANGLE", (cmd & 0xffff) + 2); + case 0x81: + return debug(stream, "3DSTATE_SCISSOR_RECTANGLE", (cmd & 0xffff) + 2); + case 0x83: + return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2); + case 0x85: + return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2); + case 0x88: + return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2); + case 0x89: + return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2); + case 0x8e: + return debug_buf_info(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2); + case 0x97: + return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2); + case 0x98: + return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2); + case 0x99: + return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2); + case 0x9a: + return debug(stream, "3DSTATE_DEFAULT_SPECULAR", (cmd & 0xffff) + 2); + case 0x9c: + return debug(stream, "3DSTATE_CLEAR_PARAMETERS", (cmd & 0xffff) + 2); + default: + assert(0); + return 0; + } + break; + case 0x1e: + if (cmd & (1 << 23)) + return debug(stream, "???", (cmd & 0xffff) + 1); + else + return debug(stream, "", 1); + break; + case 0x1f: + if ((cmd & (1 << 23)) == 0) + return debug_prim(stream, "3DPRIM (inline)", 1, (cmd & 0x1ffff) + 2); + else if (cmd & (1 << 17)) + { + if ((cmd & 0xffff) == 0) + return debug_variable_length_prim(stream); + else + return debug_prim(stream, "3DPRIM (indexed)", 0, (((cmd & 0xffff) + 1) / 2) + 1); + } + else + return debug_prim(stream, "3DPRIM (indirect sequential)", 0, 2); + break; + default: + return debug(stream, "", 0); + } + default: + assert(0); + return 0; + } + + assert(0); + return 0; +} + + void -i915_disassemble_program(const GLuint * program, GLuint sz) +i915_dump_batchbuffer( GLuint *start, + GLuint *end ) { - GLuint size = program[0] & 0x1ff; - GLint i; + struct debug_stream stream; + GLuint bytes = (end - start) * 4; + GLboolean done = GL_FALSE; - fprintf(stderr, "BEGIN\n"); + PRINTF("\n\nBATCH: (%d)\n", bytes / 4); - if (size + 2 != sz) { - fprintf(stderr, "%s: program size mismatch %d/%d\n", __FUNCTION__, - size + 2, sz); - exit(1); - } + stream.offset = 0; + stream.ptr = (char *)start; + stream.print_addresses = 0; - program++; - for (i = 1; i < sz; i += 3, program += 3) { - GLuint opcode = program[0] & (0x1f << 24); + while (!done && + stream.offset < bytes && + stream.offset >= 0) + { + if (!i915_debug_packet( &stream )) + break; - if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) - print_arith_op(opcode >> 24, program); - else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL) - print_tex_op(opcode >> 24, program); - else if (opcode == D0_DCL) - print_dcl_op(opcode >> 24, program); - else - fprintf(stderr, "Unknown opcode 0x%x\n", opcode); + assert(stream.offset <= bytes && + stream.offset >= 0); } - fprintf(stderr, "END\n\n"); + PRINTF("END-BATCH\n\n\n"); } + + diff --git a/src/mesa/drivers/dri/i915tex/i915_debug.h b/src/mesa/drivers/dri/i915tex/i915_debug.h new file mode 100644 index 00000000000..0643a8c631c --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/i915_debug.h @@ -0,0 +1,55 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Authors: Keith Whitwell <[email protected]> + */ + +#ifndef I915_DEBUG_H +#define I915_DEBUG_H + +struct i915_context; + +struct debug_stream +{ + unsigned offset; /* current gtt offset */ + char *ptr; /* pointer to gtt offset zero */ + char *end; /* pointer to gtt offset zero */ + unsigned print_addresses; +}; + + + +extern void i915_disassemble_program(const unsigned *program, unsigned sz); +extern void i915_print_ureg(const char *msg, unsigned ureg); + + +void +i915_dump_batchbuffer( unsigned *start, + unsigned *end ); + + +#endif diff --git a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c new file mode 100644 index 00000000000..84347a01efe --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c @@ -0,0 +1,333 @@ +/************************************************************************** + * + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include <stdio.h> + +#include "i915_reg.h" +#include "i915_debug.h" +#include "main/imports.h" +#include "shader/program.h" +#include "shader/prog_instruction.h" +#include "shader/prog_print.h" + +#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) + +static const char *opcodes[0x20] = { + "NOP", + "ADD", + "MOV", + "MUL", + "MAD", + "DP2ADD", + "DP3", + "DP4", + "FRC", + "RCP", + "RSQ", + "EXP", + "LOG", + "CMP", + "MIN", + "MAX", + "FLR", + "MOD", + "TRC", + "SGE", + "SLT", + "TEXLD", + "TEXLDP", + "TEXLDB", + "TEXKILL", + "DCL", + "0x1a", + "0x1b", + "0x1c", + "0x1d", + "0x1e", + "0x1f", +}; + + +static const int args[0x20] = { + 0, /* 0 nop */ + 2, /* 1 add */ + 1, /* 2 mov */ + 2, /* 3 m ul */ + 3, /* 4 mad */ + 3, /* 5 dp2add */ + 2, /* 6 dp3 */ + 2, /* 7 dp4 */ + 1, /* 8 frc */ + 1, /* 9 rcp */ + 1, /* a rsq */ + 1, /* b exp */ + 1, /* c log */ + 3, /* d cmp */ + 2, /* e min */ + 2, /* f max */ + 1, /* 10 flr */ + 1, /* 11 mod */ + 1, /* 12 trc */ + 2, /* 13 sge */ + 2, /* 14 slt */ + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +}; + + +static const char *regname[0x8] = { + "R", + "T", + "CONST", + "S", + "OC", + "OD", + "U", + "UNKNOWN", +}; + +static void +print_reg_type_nr(GLuint type, GLuint nr) +{ + switch (type) { + case REG_TYPE_T: + switch (nr) { + case T_DIFFUSE: + PRINTF("T_DIFFUSE"); + return; + case T_SPECULAR: + PRINTF("T_SPECULAR"); + return; + case T_FOG_W: + PRINTF("T_FOG_W"); + return; + default: + PRINTF("T_TEX%d", nr); + return; + } + case REG_TYPE_OC: + if (nr == 0) { + PRINTF("oC"); + return; + } + break; + case REG_TYPE_OD: + if (nr == 0) { + PRINTF("oD"); + return; + } + break; + default: + break; + } + + PRINTF("%s[%d]", regname[type], nr); +} + +#define REG_SWIZZLE_MASK 0x7777 +#define REG_NEGATE_MASK 0x8888 + +#define REG_SWIZZLE_XYZW ((SRC_X << A2_SRC2_CHANNEL_X_SHIFT) | \ + (SRC_Y << A2_SRC2_CHANNEL_Y_SHIFT) | \ + (SRC_Z << A2_SRC2_CHANNEL_Z_SHIFT) | \ + (SRC_W << A2_SRC2_CHANNEL_W_SHIFT)) + + +static void +print_reg_neg_swizzle(GLuint reg) +{ + int i; + + if ((reg & REG_SWIZZLE_MASK) == REG_SWIZZLE_XYZW && + (reg & REG_NEGATE_MASK) == 0) + return; + + PRINTF("."); + + for (i = 3; i >= 0; i--) { + if (reg & (1 << ((i * 4) + 3))) + PRINTF("-"); + + switch ((reg >> (i * 4)) & 0x7) { + case 0: + PRINTF("x"); + break; + case 1: + PRINTF("y"); + break; + case 2: + PRINTF("z"); + break; + case 3: + PRINTF("w"); + break; + case 4: + PRINTF("0"); + break; + case 5: + PRINTF("1"); + break; + default: + PRINTF("?"); + break; + } + } +} + + +static void +print_src_reg(GLuint dword) +{ + GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK; + GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK; + print_reg_type_nr(type, nr); + print_reg_neg_swizzle(dword); +} + + +static void +print_dest_reg(GLuint dword) +{ + GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK; + GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK; + print_reg_type_nr(type, nr); + if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) + return; + PRINTF("."); + if (dword & A0_DEST_CHANNEL_X) + PRINTF("x"); + if (dword & A0_DEST_CHANNEL_Y) + PRINTF("y"); + if (dword & A0_DEST_CHANNEL_Z) + PRINTF("z"); + if (dword & A0_DEST_CHANNEL_W) + PRINTF("w"); +} + + +#define GET_SRC0_REG(r0, r1) ((r0<<14)|(r1>>A1_SRC0_CHANNEL_W_SHIFT)) +#define GET_SRC1_REG(r0, r1) ((r0<<8)|(r1>>A2_SRC1_CHANNEL_W_SHIFT)) +#define GET_SRC2_REG(r) (r) + + +static void +print_arith_op(GLuint opcode, const GLuint * program) +{ + if (opcode != A0_NOP) { + print_dest_reg(program[0]); + if (program[0] & A0_DEST_SATURATE) + PRINTF(" = SATURATE "); + else + PRINTF(" = "); + } + + PRINTF("%s ", opcodes[opcode]); + + print_src_reg(GET_SRC0_REG(program[0], program[1])); + if (args[opcode] == 1) { + PRINTF("\n"); + return; + } + + PRINTF(", "); + print_src_reg(GET_SRC1_REG(program[1], program[2])); + if (args[opcode] == 2) { + PRINTF("\n"); + return; + } + + PRINTF(", "); + print_src_reg(GET_SRC2_REG(program[2])); + PRINTF("\n"); + return; +} + + +static void +print_tex_op(GLuint opcode, const GLuint * program) +{ + print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); + PRINTF(" = "); + + PRINTF("%s ", opcodes[opcode]); + + PRINTF("S[%d],", program[0] & T0_SAMPLER_NR_MASK); + + print_reg_type_nr((program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & + REG_TYPE_MASK, + (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); + PRINTF("\n"); +} + +static void +print_dcl_op(GLuint opcode, const GLuint * program) +{ + PRINTF("%s ", opcodes[opcode]); + print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); + PRINTF("\n"); +} + + +void +i915_disassemble_program(const GLuint * program, GLuint sz) +{ + GLuint size = program[0] & 0x1ff; + GLint i; + + PRINTF("\t\tBEGIN\n"); + + assert(size + 2 == sz); + + program++; + for (i = 1; i < sz; i += 3, program += 3) { + GLuint opcode = program[0] & (0x1f << 24); + + PRINTF("\t\t"); + + if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) + print_arith_op(opcode >> 24, program); + else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL) + print_tex_op(opcode >> 24, program); + else if (opcode == D0_DCL) + print_dcl_op(opcode >> 24, program); + else + PRINTF("Unknown opcode 0x%x\n", opcode); + } + + PRINTF("\t\tEND\n\n"); +} + + diff --git a/src/mesa/drivers/dri/i915tex/i915_fragprog.c b/src/mesa/drivers/dri/i915tex/i915_fragprog.c index a4b22a0c32c..4c3f2236e5e 100644 --- a/src/mesa/drivers/dri/i915tex/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915tex/i915_fragprog.c @@ -29,19 +29,20 @@ #include "macros.h" #include "enums.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/program.h" +#include "shader/programopt.h" + #include "tnl/tnl.h" #include "tnl/t_context.h" + #include "intel_batchbuffer.h" #include "i915_reg.h" #include "i915_context.h" #include "i915_program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "program.h" -#include "programopt.h" - /* 1, -1/3!, 1/5!, -1/7! */ @@ -320,7 +321,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + src0, i915_emit_const1f(p, 1.0 / (M_PI)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -329,7 +330,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, (M_PI)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 @@ -642,7 +643,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + src0, i915_emit_const1f(p, 1.0 / (M_PI)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -651,7 +652,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, (M_PI)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 diff --git a/src/mesa/drivers/dri/i915tex/i915_metaops.c b/src/mesa/drivers/dri/i915tex/i915_metaops.c index 128f86e21b6..a739bd65811 100644 --- a/src/mesa/drivers/dri/i915tex/i915_metaops.c +++ b/src/mesa/drivers/dri/i915tex/i915_metaops.c @@ -95,7 +95,7 @@ meta_depth_replace(struct intel_context *intel) i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE | S6_DEPTH_WRITE_ENABLE); - /* ctx->Driver.DepthFunc( ctx, GL_REPLACE ) + /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS ) */ i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK; i915->meta.Ctx[I915_CTXREG_LIS6] |= diff --git a/src/mesa/drivers/dri/i915tex/i915_reg.h b/src/mesa/drivers/dri/i915tex/i915_reg.h index 34c68214056..a9fa56e8a60 100644 --- a/src/mesa/drivers/dri/i915tex/i915_reg.h +++ b/src/mesa/drivers/dri/i915tex/i915_reg.h @@ -112,6 +112,20 @@ /* 3DSTATE_CHROMA_KEY */ /* 3DSTATE_CLEAR_PARAMETERS, p150 */ +/* + * Sets the color, depth and stencil clear values used by the + * CLEAR_RECT and ZONE_INIT primitive types, respectively. These + * primitives set override most 3d state and only take a minimal x/y + * vertex. The color/z/stencil information is supplied here and + * therefore cannot vary per vertex. + */ +#define _3DSTATE_CLEAR_PARAMETERS (CMD_3D | (0x1d<<24) | (0x9c<<16) | 5) +/* Dword 1 */ +#define CLEARPARAM_CLEAR_RECT (1 << 16) +#define CLEARPARAM_ZONE_INIT (0 << 16) +#define CLEARPARAM_WRITE_COLOR (1 << 2) +#define CLEARPARAM_WRITE_DEPTH (1 << 1) +#define CLEARPARAM_WRITE_STENCIL (1 << 0) /* 3DSTATE_CONSTANT_BLEND_COLOR, p153 */ #define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16)) @@ -424,6 +438,17 @@ #define S7_DEPTH_OFFSET_CONST_MASK ~0 + +/* Helper macros for blend factors + */ +#define DST_BLND_FACT(f) ((f)<<S6_CBUF_DST_BLEND_FACT_SHIFT) +#define SRC_BLND_FACT(f) ((f)<<S6_CBUF_SRC_BLEND_FACT_SHIFT) +#define DST_ABLND_FACT(f) ((f)<<IAB_DST_FACTOR_SHIFT) +#define SRC_ABLND_FACT(f) ((f)<<IAB_SRC_FACTOR_SHIFT) + + + + /* 3DSTATE_MAP_DEINTERLACER_PARAMETERS */ /* 3DSTATE_MAP_PALETTE_LOAD_32, p206 */ diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c index 5d6ad8d86cf..35757e17eb9 100644 --- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c @@ -44,13 +44,18 @@ #include "i915_context.h" static void -i915_render_start(struct intel_context *intel) +i915_render_prevalidate(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); i915ValidateFragmentProgram(i915); } +static void +i915_render_start(struct intel_context *intel) +{ +} + static void i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim) @@ -61,6 +66,7 @@ i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim) st1 &= ~ST1_ENABLE; switch (rprim) { + case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */ case GL_TRIANGLES: if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple) st1 |= ST1_ENABLE; @@ -197,7 +203,7 @@ i915_emit_invarient_state(struct intel_context *intel) /* Need to initialize this to zero. */ - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 0); + OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (0)); OUT_BATCH(0); /* XXX: Use this */ @@ -215,6 +221,7 @@ i915_emit_invarient_state(struct intel_context *intel) /* Don't support twosided stencil yet */ OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0); + OUT_BATCH(0); ADVANCE_BATCH(); } @@ -246,6 +253,9 @@ get_state_size(struct i915_hw_state *state) GLuint i; GLuint sz = 0; + if (dirty & I915_UPLOAD_INVARIENT) + sz += 30 * 4; + if (dirty & I915_UPLOAD_CTX) sz += sizeof(state->Ctx); @@ -301,6 +311,7 @@ i915_emit_state(struct intel_context *intel) * causing more state to be dirty! */ dirty = get_dirty(state); + state->emitted |= dirty; if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "%s dirty: %x\n", __FUNCTION__, dirty); @@ -420,12 +431,22 @@ i915_emit_state(struct intel_context *intel) i915_disassemble_program(state->Program, state->ProgramSize); } - state->emitted |= dirty; + assert(get_dirty(state) == 0); } static void i915_destroy_context(struct intel_context *intel) { + GLuint i; + struct i915_context *i915 = i915_context(&intel->ctx); + + for (i = 0; i < I915_TEX_UNITS; i++) { + if (i915->state.tex_buffer[i] != NULL) { + dri_bo_unreference(i915->state.tex_buffer[i]); + i915->state.tex_buffer[i] = NULL; + } + } + _tnl_free_vertices(&intel->ctx); } @@ -542,6 +563,7 @@ i915InitVtbl(struct i915_context *i915) i915->intel.vtbl.lost_hardware = i915_lost_hardware; i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state; i915->intel.vtbl.render_start = i915_render_start; + i915->intel.vtbl.render_prevalidate = i915_render_prevalidate; i915->intel.vtbl.set_draw_region = i915_set_draw_region; i915->intel.vtbl.update_texture_state = i915UpdateTextureState; i915->intel.vtbl.flush_cmd = i915_flush_cmd; diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index 5aabef96aea..5515d6c235a 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c @@ -27,7 +27,8 @@ #include "intel_batchbuffer.h" #include "intel_ioctl.h" -#include "i915_disasm.h" +#include "intel_decode.h" +#include "i915_debug.h" /* Relocations in kernel space: * - pass dma buffer seperately @@ -67,9 +68,6 @@ * modifying cliprects ??? */ -/*====================================================================== - * Public functions - */ void intel_batchbuffer_reset(struct intel_batchbuffer *batch) { @@ -197,7 +195,7 @@ do_flush_locked(struct intel_batchbuffer *batch, if (INTEL_DEBUG & DEBUG_BATCH) { dri_bo_map(batch->buf, GL_FALSE); - i915_disasm(ptr, used / 4, batch->buf->offset); + intel_decode(ptr, used / 4, batch->buf->offset); dri_bo_unmap(batch->buf); } } diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h index 82a3d49fcac..850a91e1c91 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h @@ -9,7 +9,7 @@ struct intel_context; #define BATCH_SZ 16384 #define BATCH_RESERVED 16 -#define MAX_RELOCS 400 +#define MAX_RELOCS 4096 #define INTEL_BATCH_NO_CLIPRECTS 0x1 #define INTEL_BATCH_CLIPRECTS 0x2 diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 62ff54b0075..cb151ab94d8 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -50,7 +50,7 @@ #define DRM_VBLANK_FLIP 0x8000000 typedef struct drm_i915_flip { - int pipes; + int planes; } drm_i915_flip_t; #undef DRM_IOCTL_I915_FLIP @@ -235,34 +235,34 @@ intelWindowMoved(struct intel_context *intel) drmI830Sarea *sarea = intel->sarea; drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w, .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h }; - drm_clip_rect_t pipeA_rect = { .x1 = sarea->pipeA_x, .y1 = sarea->pipeA_y, - .x2 = sarea->pipeA_x + sarea->pipeA_w, - .y2 = sarea->pipeA_y + sarea->pipeA_h }; - drm_clip_rect_t pipeB_rect = { .x1 = sarea->pipeB_x, .y1 = sarea->pipeB_y, - .x2 = sarea->pipeB_x + sarea->pipeB_w, - .y2 = sarea->pipeB_y + sarea->pipeB_h }; - GLint areaA = driIntersectArea( drw_rect, pipeA_rect ); - GLint areaB = driIntersectArea( drw_rect, pipeB_rect ); + drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, .y1 = sarea->planeA_y, + .x2 = sarea->planeA_x + sarea->planeA_w, + .y2 = sarea->planeA_y + sarea->planeA_h }; + drm_clip_rect_t planeB_rect = { .x1 = sarea->planeB_x, .y1 = sarea->planeB_y, + .x2 = sarea->planeB_x + sarea->planeB_w, + .y2 = sarea->planeB_y + sarea->planeB_h }; + GLint areaA = driIntersectArea( drw_rect, planeA_rect ); + GLint areaB = driIntersectArea( drw_rect, planeB_rect ); GLuint flags = intel_fb->vblank_flags; GLboolean pf_active; - GLint pf_pipes; + GLint pf_planes; /* Update page flipping info */ - pf_pipes = 0; + pf_planes = 0; if (areaA > 0) - pf_pipes |= 1; + pf_planes |= 1; if (areaB > 0) - pf_pipes |= 2; + pf_planes |= 2; intel_fb->pf_current_page = (intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3; + (intel_fb->pf_planes & 0x2)) & 0x3; intel_fb->pf_num_pages = intel->intelScreen->third.handle ? 3 : 2; - pf_active = pf_pipes && (pf_pipes & intel->sarea->pf_active) == pf_pipes; + pf_active = pf_planes && (pf_planes & intel->sarea->pf_active) == pf_planes; if (INTEL_DEBUG & DEBUG_LOCK) if (pf_active != intel_fb->pf_active) @@ -270,8 +270,8 @@ intelWindowMoved(struct intel_context *intel) pf_active ? "" : "in"); if (pf_active) { - /* Sync pages between pipes if we're flipping on both at the same time */ - if (pf_pipes == 0x3 && pf_pipes != intel_fb->pf_pipes && + /* Sync pages between planes if flipping on both at the same time */ + if (pf_planes == 0x3 && pf_planes != intel_fb->pf_planes && (intel->sarea->pf_current_page & 0x3) != (((intel->sarea->pf_current_page) >> 2) & 0x3)) { drm_i915_flip_t flip; @@ -287,7 +287,7 @@ intelWindowMoved(struct intel_context *intel) ((intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) % intel_fb->pf_num_pages) << 2; - flip.pipes = 0x2; + flip.planes = 0x2; } else { intel->sarea->pf_current_page = intel->sarea->pf_current_page & (0x3 << 2); @@ -295,13 +295,13 @@ intelWindowMoved(struct intel_context *intel) (intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) % intel_fb->pf_num_pages; - flip.pipes = 0x1; + flip.planes = 0x1; } drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip)); } - intel_fb->pf_pipes = pf_pipes; + intel_fb->pf_planes = pf_planes; } intel_fb->pf_active = pf_active; @@ -316,7 +316,8 @@ intelWindowMoved(struct intel_context *intel) flags = intel_fb->vblank_flags & ~VBLANK_FLAG_SECONDARY; } - if (flags != intel_fb->vblank_flags) { + if (flags != intel_fb->vblank_flags && intel_fb->vblank_flags && + !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ)) { drmVBlank vbl; int i; @@ -327,7 +328,9 @@ intelWindowMoved(struct intel_context *intel) } for (i = 0; i < intel_fb->pf_num_pages; i++) { - if (!intel_fb->color_rb[i]) + if (!intel_fb->color_rb[i] || + (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <= + (1<<23)) continue; vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending; @@ -712,14 +715,14 @@ intel_wait_flips(struct intel_context *intel, GLuint batch_flags) BUFFER_BACK_LEFT); if (intel_fb->Base.Name == 0 && intel_rb->pf_pending == intel_fb->pf_seq) { - GLint pf_pipes = intel_fb->pf_pipes; + GLint pf_planes = intel_fb->pf_planes; BATCH_LOCALS; /* Wait for pending flips to take effect */ BEGIN_BATCH(2, batch_flags); - OUT_BATCH(pf_pipes & 0x1 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP) + OUT_BATCH(pf_planes & 0x1 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP) : 0); - OUT_BATCH(pf_pipes & 0x2 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_B_FLIP) + OUT_BATCH(pf_planes & 0x2 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_B_FLIP) : 0); ADVANCE_BATCH(); @@ -758,7 +761,7 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv) if (dPriv->numClipRects && intel_fb->pf_active) { drm_i915_flip_t flip; - flip.pipes = intel_fb->pf_pipes; + flip.planes = intel_fb->pf_planes; ret = drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip)); } @@ -773,7 +776,7 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv) } intel_fb->pf_current_page = (intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3; + (intel_fb->pf_planes & 0x2)) & 0x3; if (dPriv->numClipRects != 0) { intel_get_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT)->pf_pending = @@ -828,7 +831,8 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) drm_i915_vblank_swap_t swap; GLboolean ret; - if ((intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) || + if (!intel_fb->vblank_flags || + (intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) || intelScreen->current_rotation != 0 || intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6)) return GL_FALSE; @@ -856,7 +860,7 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) swap.seqtype |= DRM_VBLANK_FLIP; intel_fb->pf_current_page = (((intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3) + 1) % + (intel_fb->pf_planes & 0x2)) & 0x3) + 1) % intel_fb->pf_num_pages; } @@ -880,7 +884,7 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) } else { if (swap.seqtype & DRM_VBLANK_FLIP) { intel_fb->pf_current_page = ((intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3) % + (intel_fb->pf_planes & 0x2)) & 0x3) % intel_fb->pf_num_pages; } @@ -1120,6 +1124,15 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled); } + /* + * Update depth test state + */ + if (ctx->Depth.Test && fb->Visual.depthBits > 0) { + ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_TRUE); + } + else { + ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_FALSE); + } /** ** Release old regions, reference new regions diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 3eb58bdd9ce..16fbe38e647 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -59,7 +59,7 @@ #include "intel_regions.h" #include "intel_buffer_objects.h" #include "intel_fbo.h" -#include "i915_disasm.h" +#include "intel_decode.h" #include "drirenderbuffer.h" #include "vblank.h" @@ -617,12 +617,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, if (intel->ctx.DrawBuffer == &intel_fb->Base) { if (intel->driDrawable != driDrawPriv) { - intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0) - ? driGetDefaultVBlankFlags(&intel->optionCache) - : VBLANK_FLAG_NO_IRQ; - (*dri_interface->getUST) (&intel_fb->swap_ust); - driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags, - &intel_fb->vbl_seq); + if (driDrawPriv->pdraw->swap_interval == (unsigned)-1) { + int i; + + intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0) + ? driGetDefaultVBlankFlags(&intel->optionCache) + : VBLANK_FLAG_NO_IRQ; + + (*dri_interface->getUST) (&intel_fb->swap_ust); + driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags, + &intel_fb->vbl_seq); + intel_fb->vbl_waited = intel_fb->vbl_seq; + + for (i = 0; i < (intel->intelScreen->third.handle ? 3 : 2); i++) { + if (intel_fb->color_rb[i]) + intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_seq; + } + } intel->driDrawable = driDrawPriv; intelWindowMoved(intel); } @@ -667,7 +678,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags) sarea->texAge = intel->hHWContext; dri_bufmgr_fake_contended_lock_take(intel->intelScreen->bufmgr); if (INTEL_DEBUG & DEBUG_BATCH) - i915_disasm_context_reset(); + intel_decode_context_reset(); } if (sarea->width != intelScreen->width || @@ -680,37 +691,27 @@ intelContendedLock(struct intel_context *intel, GLuint flags) if (sarea->width != intel->width || sarea->height != intel->height || sarea->rotation != intel->current_rotation) { - - void *batchMap = intel->batch->map; - + int numClipRects = intel->numClipRects; + /* * FIXME: Really only need to do this when drawing to a * common back- or front buffer. */ /* - * This will drop the outstanding batchbuffer on the floor + * This will essentially drop the outstanding batchbuffer on the floor. */ + intel->numClipRects = 0; - if (batchMap != NULL) { - dri_bo_unmap(intel->batch->buf); - intel->batch->map = NULL; - } - - intel_batchbuffer_reset(intel->batch); + if (intel->Fallback) + _swrast_flush(&intel->ctx); - if (batchMap == NULL) { - dri_bo_unmap(intel->batch->buf); - intel->batch->map = NULL; - } + INTEL_FIREVERTICES(intel); - /* lose all primitives */ - intel->prim.primitive = ~0; - intel->prim.start_ptr = 0; - intel->prim.flush = 0; + if (intel->batch->map != intel->batch->ptr) + intel_batchbuffer_flush(intel->batch); - /* re-emit all state */ - intel->vtbl.lost_hardware(intel); + intel->numClipRects = numClipRects; /* force window update */ intel->lastStamp = 0; @@ -751,7 +752,9 @@ void LOCK_HARDWARE( struct intel_context *intel ) BUFFER_BACK_LEFT); } - if (intel_rb && (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) { + if (intel_rb && intel_fb->vblank_flags && + !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) && + (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) { drmVBlank vbl; vbl.request.type = DRM_VBLANK_ABSOLUTE; diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 8755f5703dc..1e9ccd5cdc0 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -130,6 +130,7 @@ struct intel_context void (*update_texture_state) (struct intel_context * intel); void (*render_start) (struct intel_context * intel); + void (*render_prevalidate) (struct intel_context * intel); void (*set_draw_region) (struct intel_context * intel, struct intel_region * draw_region, struct intel_region * depth_region); diff --git a/src/mesa/drivers/dri/i915tex/i915_disasm.c b/src/mesa/drivers/dri/i915tex/intel_decode.c index 292b6e3a3b3..bf3387b28e6 100644 --- a/src/mesa/drivers/dri/i915tex/i915_disasm.c +++ b/src/mesa/drivers/dri/i915tex/intel_decode.c @@ -26,11 +26,20 @@ * */ +/** @file intel_decode.c + * This file contains code to print out batchbuffer contents in a + * human-readable format. + * + * The current version only supports i915 packets, and only pretty-prints a + * subset of them. The intention is for it to make just a best attempt to + * decode, but never crash in the process. + */ + #include <stdio.h> #include <stdarg.h> #include <inttypes.h> -#include "i915_disasm.h" +#include "intel_decode.h" #include "i915_reg.h" #define BUFFER_FAIL(_count, _len, _name) do { \ @@ -782,7 +791,7 @@ decode_3d(uint32_t *data, int count, uint32_t hw_offset, int *failures) * \param hw_offset hardware address for the buffer */ int -i915_disasm(uint32_t *data, int count, uint32_t hw_offset) +intel_decode(uint32_t *data, int count, uint32_t hw_offset) { int index = 0; int failures = 0; @@ -815,7 +824,7 @@ i915_disasm(uint32_t *data, int count, uint32_t hw_offset) return failures; } -void i915_disasm_context_reset() +void intel_decode_context_reset() { saved_s2_set = 0; saved_s4_set = 1; diff --git a/src/mesa/drivers/dri/i915tex/i915_disasm.h b/src/mesa/drivers/dri/i915tex/intel_decode.h index 5eb620f9a4e..ef0cba153c7 100644 --- a/src/mesa/drivers/dri/i915tex/i915_disasm.h +++ b/src/mesa/drivers/dri/i915tex/intel_decode.h @@ -25,5 +25,5 @@ * */ -int i915_disasm(uint32_t *data, int count, uint32_t hw_offset); -void i915_disasm_context_reset(); +int intel_decode(uint32_t *data, int count, uint32_t hw_offset); +void intel_decode_context_reset(); diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index 349912ffecd..6f99f401c7c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -488,7 +488,7 @@ intel_new_renderbuffer(GLcontext * ctx, GLuint name) */ static void intel_bind_framebuffer(GLcontext * ctx, GLenum target, - struct gl_framebuffer *fb) + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { intel_draw_buffer(ctx, fb); diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.h b/src/mesa/drivers/dri/i915tex/intel_fbo.h index 963f5e706f4..411d6342317 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.h +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.h @@ -44,7 +44,7 @@ struct intel_framebuffer /* Drawable page flipping state */ GLboolean pf_active; GLuint pf_seq; - GLint pf_pipes; + GLint pf_planes; GLint pf_current_page; GLint pf_num_pages; diff --git a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c index 843a78eb82b..74f6b2d8515 100644 --- a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c @@ -97,9 +97,19 @@ intel_miptree_create(struct intel_context *intel, break; } - if (ok) + if (ok) { + if (!mt->compressed) { + /* XXX: Align pitch to multiple of 64 bytes for now to allow + * render-to-texture to work in all cases. This should probably be + * replaced at some point by some scheme to only do this when really + * necessary. + */ + mt->pitch = ((mt->pitch * cpp + 63) & ~63) / cpp; + } + mt->region = intel_region_alloc(intel->intelScreen, mt->cpp, mt->pitch, mt->total_height); + } if (!mt->region) { free(mt); @@ -325,6 +335,7 @@ intel_miptree_image_data(struct intel_context *intel, } } +extern GLuint intel_compressed_alignment(GLenum); /* Copy mipmap image between trees */ void @@ -342,8 +353,12 @@ intel_miptree_image_copy(struct intel_context *intel, const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level); GLuint i; - if (dst->compressed) - height /= 4; + if (dst->compressed) { + GLuint alignment = intel_compressed_alignment(dst->internal_format); + height = (height + 3) / 4; + width = ((width + alignment - 1) & ~(alignment - 1)); + } + for (i = 0; i < depth; i++) { intel_region_copy(intel->intelScreen, dst->region, dst_offset + dst_depth_offset[i], diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index 6d9fc6144a2..afb586b4a33 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -370,10 +370,16 @@ intelDrawPixels(GLcontext * ctx, * wise happily run the fragment program on each pixel in the image). */ struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current; + /* can't just set current frag prog to 0 here as on buffer resize + we'll get new state checks which will segfault. Remains a hack. */ ctx->FragmentProgram._Current = NULL; + ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE; + ctx->FragmentProgram._Active = GL_FALSE; _swrast_DrawPixels( ctx, x, y, width, height, format, type, unpack, pixels ); ctx->FragmentProgram._Current = fpSave; + ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; + ctx->FragmentProgram._Active = GL_TRUE; } else { _swrast_DrawPixels( ctx, x, y, width, height, format, type, diff --git a/src/mesa/drivers/dri/i915tex/intel_render.c b/src/mesa/drivers/dri/i915tex/intel_render.c index f9fa55051ea..c8b6d308d96 100644 --- a/src/mesa/drivers/dri/i915tex/intel_render.c +++ b/src/mesa/drivers/dri/i915tex/intel_render.c @@ -202,6 +202,8 @@ intel_run_render(GLcontext * ctx, struct tnl_pipeline_stage *stage) struct vertex_buffer *VB = &tnl->vb; GLuint i; + intel->vtbl.render_prevalidate( intel ); + /* Don't handle clipping or indexed vertices. */ if (intel->RenderIndex != 0 || diff --git a/src/mesa/drivers/dri/i915tex/intel_span.c b/src/mesa/drivers/dri/i915tex/intel_span.c index ab0874e4fd6..d1f8ef06beb 100644 --- a/src/mesa/drivers/dri/i915tex/intel_span.c +++ b/src/mesa/drivers/dri/i915tex/intel_span.c @@ -198,9 +198,9 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) intel_region_map(intel->intelScreen, irb->region); else intel_region_unmap(intel->intelScreen, irb->region); + irb->pfMap = irb->region->map; + irb->pfPitch = irb->region->pitch; } - irb->pfMap = irb->region->map; - irb->pfPitch = irb->region->pitch; } } } diff --git a/src/mesa/drivers/dri/i915tex/server/i830_common.h b/src/mesa/drivers/dri/i915tex/server/i830_common.h index bd2bec3eaea..a877f3c2f40 100644 --- a/src/mesa/drivers/dri/i915tex/server/i830_common.h +++ b/src/mesa/drivers/dri/i915tex/server/i830_common.h @@ -122,14 +122,14 @@ typedef struct { unsigned int rotated_tiled; unsigned int rotated2_tiled; - int pipeA_x; - int pipeA_y; - int pipeA_w; - int pipeA_h; - int pipeB_x; - int pipeB_y; - int pipeB_w; - int pipeB_h; + int planeA_x; + int planeA_y; + int planeA_w; + int planeA_h; + int planeB_x; + int planeB_y; + int planeB_w; + int planeB_h; /* Triple buffering */ drm_handle_t third_handle; |