i965g: update disassembler code from classic.
authorDave Airlie <airlied@gmail.com>
Fri, 31 Dec 2010 02:24:35 +0000 (12:24 +1000)
committerDave Airlie <airlied@gmail.com>
Sun, 9 Jan 2011 07:21:10 +0000 (17:21 +1000)
still a bit of work to do, the winsys gen setting is a bit of a hack.

src/gallium/drivers/i965/brw_disasm.c
src/gallium/drivers/i965/brw_disasm.h
src/gallium/drivers/i965/brw_eu_emit.c
src/gallium/drivers/i965/brw_screen.c
src/gallium/drivers/i965/brw_vs_emit.c
src/gallium/drivers/i965/brw_winsys.h
src/gallium/drivers/i965/brw_winsys_debug.c
src/gallium/drivers/i965/brw_wm_emit.c
src/gallium/winsys/i965/drm/i965_drm_buffer.c

index 3c27d9ebd765aa2883c569d7fdc65a5166026838..b093569f0cf4aa6c568b5be23edb0e3d5b0eb1d6 100644 (file)
@@ -813,7 +813,7 @@ static int src1 (FILE *file, struct brw_instruction *inst)
     }
 }
 
-int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
+int brw_disasm_insn (FILE *file, struct brw_instruction *inst, int gen)
 {
     int        err = 0;
     int space = 0;
@@ -863,7 +863,8 @@ int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
        err |= src1 (file, inst);
     }
 
-    if (inst->header.opcode == BRW_OPCODE_SEND) {
+    if (inst->header.opcode == BRW_OPCODE_SEND ||
+        inst->header.opcode == BRW_OPCODE_SENDC) {
        newline (file);
        pad (file, 16);
        space = 0;
@@ -883,24 +884,70 @@ int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
                            inst->bits3.math.precision, &space);
            break;
        case BRW_MESSAGE_TARGET_SAMPLER:
-           format (file, " (%d, %d, ",
-                   inst->bits3.sampler.binding_table_index,
-                   inst->bits3.sampler.sampler);
-           err |= control (file, "sampler target format", sampler_target_format,
-                           inst->bits3.sampler.return_format, NULL);
-           string (file, ")");
+           if (gen >= 5) {
+               format (file, " (%d, %d, %d, %d)",
+                       inst->bits3.sampler_gen5.binding_table_index,
+                       inst->bits3.sampler_gen5.sampler,
+                       inst->bits3.sampler_gen5.msg_type,
+                       inst->bits3.sampler_gen5.simd_mode);
+           } else if (0 /* FINISHME: is_g4x */) {
+             format (file, " (%d, %d)",
+                       inst->bits3.sampler_g4x.binding_table_index,
+                       inst->bits3.sampler_g4x.sampler);
+           } else {
+               format (file, " (%d, %d, ",
+                       inst->bits3.sampler.binding_table_index,
+                       inst->bits3.sampler.sampler);
+               err |= control (file, "sampler target format", sampler_target_format,
+                               inst->bits3.sampler.return_format, NULL);
+               string (file, ")");
+           }
+           break;
+       case BRW_MESSAGE_TARGET_DATAPORT_READ:
+           if (gen >= 6) {
+               format (file, " (%d, %d, %d, %d, %d, %d)",
+                       inst->bits3.dp_render_cache.binding_table_index,
+                       inst->bits3.dp_render_cache.msg_control,
+                       inst->bits3.dp_render_cache.msg_type,
+                       inst->bits3.dp_render_cache.send_commit_msg,
+                       inst->bits3.dp_render_cache.msg_length,
+                       inst->bits3.dp_render_cache.response_length);
+           } else if (gen >= 5 /* FINISHME: || is_g4x */) {
+               format (file, " (%d, %d, %d)",
+                       inst->bits3.dp_read_gen5.binding_table_index,
+                       inst->bits3.dp_read_gen5.msg_control,
+                       inst->bits3.dp_read_gen5.msg_type);
+           } else {
+               format (file, " (%d, %d, %d)",
+                       inst->bits3.dp_read.binding_table_index,
+                       inst->bits3.dp_read.msg_control,
+                       inst->bits3.dp_read.msg_type);
+           }
            break;
        case BRW_MESSAGE_TARGET_DATAPORT_WRITE:
-           format (file, " (%d, %d, %d, %d)",
-                   inst->bits3.dp_write.binding_table_index,
-                   (inst->bits3.dp_write.pixel_scoreboard_clear << 3) |
-                   inst->bits3.dp_write.msg_control,
-                   inst->bits3.dp_write.msg_type,
-                   inst->bits3.dp_write.send_commit_msg);
+           if (gen >= 6) {
+               format (file, " (%d, %d, %d, %d, %d, %d)",
+                       inst->bits3.dp_render_cache.binding_table_index,
+                       inst->bits3.dp_render_cache.msg_control,
+                       inst->bits3.dp_render_cache.msg_type,
+                       inst->bits3.dp_render_cache.send_commit_msg,
+                       inst->bits3.dp_render_cache.msg_length,
+                       inst->bits3.dp_render_cache.response_length);
+           } else {
+               format (file, " (%d, %d, %d, %d)",
+                       inst->bits3.dp_write.binding_table_index,
+                       (inst->bits3.dp_write.pixel_scoreboard_clear << 3) |
+                       inst->bits3.dp_write.msg_control,
+                       inst->bits3.dp_write.msg_type,
+                       inst->bits3.dp_write.send_commit_msg);
+           }
            break;
        case BRW_MESSAGE_TARGET_URB:
-           format (file, " %d", inst->bits3.urb.offset);
-           space = 1;
+           if (gen >= 5) {
+               format (file, " %d", inst->bits3.urb_gen5.offset);
+           } else {
+               format (file, " %d", inst->bits3.urb.offset);
+           }
            err |= control (file, "urb swizzle", urb_swizzle,
                            inst->bits3.urb.swizzle_control, &space);
            err |= control (file, "urb allocate", urb_allocate,
@@ -909,6 +956,11 @@ int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
                            inst->bits3.urb.used, &space);
            err |= control (file, "urb complete", urb_complete,
                            inst->bits3.urb.complete, &space);
+           if (gen >= 5) {
+               format (file, " mlen %d, rlen %d\n",
+                       inst->bits3.urb_gen5.msg_length,
+                       inst->bits3.urb_gen5.response_length);
+           }
            break;
        case BRW_MESSAGE_TARGET_THREAD_SPAWNER:
            break;
@@ -918,10 +970,17 @@ int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
        }
        if (space)
            string (file, " ");
-       format (file, "mlen %d",
-               inst->bits3.generic.msg_length);
-       format (file, " rlen %d",
-               inst->bits3.generic.response_length);
+       if (gen >= 5) {
+          format (file, "mlen %d",
+                  inst->bits3.generic_gen5.msg_length);
+          format (file, " rlen %d",
+                  inst->bits3.generic_gen5.response_length);
+       } else {
+           format (file, "mlen %d",
+                   inst->bits3.generic.msg_length);
+           format (file, " rlen %d",
+                   inst->bits3.generic.response_length);
+       }
     }
     pad (file, 64);
     if (inst->header.opcode != BRW_OPCODE_NOP) {
@@ -932,7 +991,8 @@ int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
        err |= control (file, "dependency control", dep_ctrl, inst->header.dependency_control, &space);
        err |= control (file, "compression control", compr_ctrl, inst->header.compression_control, &space);
        err |= control (file, "thread control", thread_ctrl, inst->header.thread_control, &space);
-       if (inst->header.opcode == BRW_OPCODE_SEND)
+       if (inst->header.opcode == BRW_OPCODE_SEND ||
+            inst->header.opcode == BRW_OPCODE_SENDC)
            err |= control (file, "end of thread", end_of_thread,
                            inst->bits3.generic.end_of_thread, &space);
        if (space)
@@ -946,13 +1006,13 @@ int brw_disasm_insn (FILE *file, const struct brw_instruction *inst)
 
 
 int brw_disasm (FILE *file, 
-                const struct brw_instruction *inst,
-                unsigned count)
+                struct brw_instruction *inst,
+                unsigned count, int gen)
 {
    int i, err;
 
    for (i = 0; i < count; i++) {
-      err = brw_disasm_insn(stderr, &inst[i]);
+      err = brw_disasm_insn(stderr, &inst[i], gen);
       if (err)
          return err;
    }
index ba5b109c483668cae403091fbaa7782c1137799e..ce451ed5a06611d3c7b2053b014fd9649b181a65 100644 (file)
 
 struct brw_instruction;
 
-int brw_disasm_insn (FILE *file, const struct brw_instruction *inst);
+int brw_disasm_insn (FILE *file, struct brw_instruction *inst, int gen);
 int brw_disasm (FILE *file, 
-                const struct brw_instruction *inst,
-                unsigned count);
+                struct brw_instruction *inst,
+                unsigned count, int gen);
 
 #endif
 
index fa624ab0fc4e9c113f270529c47afe0394a289e2..ba1159e4c32d1101664b0f59f3ac016a87704d7e 100644 (file)
@@ -478,7 +478,7 @@ static struct brw_instruction *next_insn( struct brw_compile *p,
    if (0 && (BRW_DEBUG & DEBUG_DISASSEM))
    {
       if (p->nr_insn) 
-         brw_disasm_insn(stderr, &p->store[p->nr_insn-1]);
+         brw_disasm_insn(stderr, &p->store[p->nr_insn-1], p->brw->gen);
    }
 
    assert(p->nr_insn + 1 < BRW_EU_MAX_INSN);
index 6ab9075e13ac937357dfd789fa59b3d64a3b042b..7842218593e4d95a0fc0e7ef7c016713584d5486 100644 (file)
@@ -437,6 +437,7 @@ brw_screen_create(struct brw_winsys_screen *sws)
       return NULL;
    }
 
+   sws->gen = bscreen->gen;
    bscreen->sws = sws;
    bscreen->base.winsys = NULL;
    bscreen->base.destroy = brw_destroy_screen;
index a53553d0986106a3e2a201ccdcf0d2d4d75af7e9..559f0c61d8dd0a9e3a95d90872ea7f40550c697b 100644 (file)
@@ -1655,6 +1655,6 @@ void brw_vs_emit(struct brw_vs_compile *c)
 
    if (BRW_DEBUG & DEBUG_VS) {
       debug_printf("vs-native:\n");
-      brw_disasm(stderr, p->store, p->nr_insn);
+      brw_disasm(stderr, p->store, p->nr_insn, p->brw->gen);
    }
 }
index a06f8bb7d6140d9e1d61111d4ea927d752355143..038f6f788a039698515b84f1be55cee54bbcd5f3 100644 (file)
@@ -148,7 +148,7 @@ static INLINE void make_reloc(struct brw_winsys_reloc *reloc,
 struct brw_winsys_screen {
 
    unsigned pci_id;
-
+   int gen;
    /**
     * Buffer functions.
     */
@@ -282,7 +282,7 @@ void brw_dump_data( unsigned pci_id,
                    enum brw_buffer_data_type data_type,
                    unsigned offset,
                    const void *data,
-                   size_t size );
+                   size_t size, int gen );
 
 
 #endif
index f8f6a539bc9d4e8efdcd6530ffc9ebd582f5ea81..b7888b9b4d6be3ef8fb3244b181ec53a6641de4b 100644 (file)
@@ -9,7 +9,7 @@ void brw_dump_data( unsigned pci_id,
                    enum brw_buffer_data_type data_type,
                    unsigned offset,
                    const void *data,
-                   size_t size )
+                   size_t size, int gen )
 {
    if (BRW_DUMP & DUMP_ASM) {
       switch (data_type) {
@@ -18,7 +18,7 @@ void brw_dump_data( unsigned pci_id,
       case BRW_DATA_GS_VS_PROG:
       case BRW_DATA_GS_GS_PROG:
       case BRW_DATA_GS_CLIP_PROG:
-         brw_disasm( stderr, data, size / sizeof(struct brw_instruction) );
+         brw_disasm( stderr, data, size / sizeof(struct brw_instruction), gen );
          break;
       default:
          break;
index 0bae9388dd9d7baf5b01a07eefe15d42f7c90d59..6301062fd79015e4197fa7d0c49d02572cc5802b 100644 (file)
@@ -1516,6 +1516,6 @@ void brw_wm_emit( struct brw_wm_compile *c )
 
    if (BRW_DEBUG & DEBUG_WM) {
       debug_printf("wm-native:\n");
-      brw_disasm(stderr, p->store, p->nr_insn);
+      brw_disasm(stderr, p->store, p->nr_insn, p->brw->gen);
    }
 }
index ed62db60bbb9cc5912a29afc731b210467835dda..a904179eeb9281a800fe89ceac363c4655b6be9b 100644 (file)
@@ -325,7 +325,7 @@ i965_libdrm_bo_subdata(struct brw_winsys_buffer *buffer,
       brw_dump_data( idws->base.pci_id,
                     data_type,
                     buf->bo->offset + offset, 
-                    data, size );
+                    data, size, buffer->sws->gen );
 
    /* XXX: use bo_map_gtt/memcpy/unmap_gtt under some circumstances???
     */
@@ -464,7 +464,7 @@ i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer,
                     buf->data_type,
                     buf->bo->offset + offset, 
                     (char*)buf->bo->virtual + offset, 
-                    length );
+                    length, buffer->sws->gen );
 }
 
 static void