intel: allocate a separate surface state bo
authorChia-I Wu <olv@lunarg.com>
Mon, 9 Feb 2015 20:07:40 +0000 (04:07 +0800)
committerMike Stroyan <mike@LunarG.com>
Thu, 12 Feb 2015 17:42:15 +0000 (10:42 -0700)
Add INTEL_CMD_WRITER_SURFACE to intel_cmd, and write BINDING_TABLE_STATEs and
SURFACE_STATEs to the new writer.  Fix cmd_batch_state_base_address() up for
the separation.

icd/intel/cmd.c
icd/intel/cmd.h
icd/intel/cmd_decode.c
icd/intel/cmd_pipeline.c
icd/intel/cmd_priv.h

index 4d38da3..47f8629 100644 (file)
@@ -82,6 +82,8 @@ static struct intel_bo *alloc_writer_bo(struct intel_winsys *winsys,
 {
     static const char *writer_names[INTEL_CMD_WRITER_COUNT] = {
         [INTEL_CMD_WRITER_BATCH] = "batch",
+        [INTEL_CMD_WRITER_SURFACE] = "surface",
+        [INTEL_CMD_WRITER_STATE] = "state",
         [INTEL_CMD_WRITER_INSTRUCTION] = "instruction",
     };
 
@@ -350,7 +352,8 @@ XGL_RESULT intel_cmd_begin(struct intel_cmd *cmd, const XGL_CMD_BUFFER_BEGIN_INF
             divider *= 4;
 
         cmd->writers[INTEL_CMD_WRITER_BATCH].size = size / divider;
-        cmd->writers[INTEL_CMD_WRITER_STATE].size = size / divider;
+        cmd->writers[INTEL_CMD_WRITER_SURFACE].size = size / divider / 2;
+        cmd->writers[INTEL_CMD_WRITER_STATE].size = size / divider / 2;
         cmd->writers[INTEL_CMD_WRITER_INSTRUCTION].size = 16384 / divider;
     }
 
index a1a076d..dcb1965 100644 (file)
@@ -122,6 +122,7 @@ enum intel_cmd_wa_flags {
 
 enum intel_cmd_writer_type {
     INTEL_CMD_WRITER_BATCH,
+    INTEL_CMD_WRITER_SURFACE,
     INTEL_CMD_WRITER_STATE,
     INTEL_CMD_WRITER_INSTRUCTION,
 
index 362efc3..0a6c502 100644 (file)
@@ -569,8 +569,13 @@ static void cmd_writer_decode(struct intel_cmd *cmd,
                     writer->bo, writer->used);
         }
         break;
+    case INTEL_CMD_WRITER_SURFACE:
+        fprintf(stderr, "decoding surface state buffer: %d states\n",
+                writer->item_used);
+        cmd_writer_decode_items(cmd, which);
+        break;
     case INTEL_CMD_WRITER_STATE:
-        fprintf(stderr, "decoding state buffer: %d states\n",
+        fprintf(stderr, "decoding dynamic state buffer: %d states\n",
                 writer->item_used);
         cmd_writer_decode_items(cmd, which);
         break;
index d600a0a..55947ad 100644 (file)
@@ -1200,7 +1200,7 @@ void cmd_batch_state_base_address(struct intel_cmd *cmd)
     dw[9] = 1;
 
     cmd_reserve_reloc(cmd, 3);
-    cmd_batch_reloc_writer(cmd, pos + 2, INTEL_CMD_WRITER_STATE, 1);
+    cmd_batch_reloc_writer(cmd, pos + 2, INTEL_CMD_WRITER_SURFACE, 1);
     cmd_batch_reloc_writer(cmd, pos + 3, INTEL_CMD_WRITER_STATE, 1);
     cmd_batch_reloc_writer(cmd, pos + 5, INTEL_CMD_WRITER_INSTRUCTION, 1);
 }
index dda45e1..9349b10 100644 (file)
@@ -286,10 +286,27 @@ static inline uint32_t cmd_surface_write(struct intel_cmd *cmd,
                                          size_t alignment, uint32_t len,
                                          const uint32_t *dw)
 {
+    const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_SURFACE;
+    const XGL_SIZE size = len << 2;
+    const uint32_t offset = cmd_writer_reserve(cmd, which, alignment, size);
+    struct intel_cmd_writer *writer = &cmd->writers[which];
+    uint32_t *dst;
+
     assert(item == INTEL_CMD_ITEM_SURFACE ||
            item == INTEL_CMD_ITEM_BINDING_TABLE);
 
-    return cmd_state_write(cmd, item, alignment, len, dw);
+    /* all states are at least aligned to 32-bytes */
+    assert(alignment % 32 == 0);
+
+    writer->used = offset + size;
+
+    if (intel_debug & INTEL_DEBUG_BATCH)
+        cmd_writer_record(cmd, which, item, offset, size);
+
+    dst = (uint32_t *) ((char *) writer->ptr + offset);
+    memcpy(dst, dw, size);
+
+    return offset;
 }
 
 /**
@@ -300,7 +317,7 @@ static inline void cmd_surface_reloc(struct intel_cmd *cmd,
                                      struct intel_bo *bo,
                                      uint32_t bo_offset, uint32_t reloc_flags)
 {
-    const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_STATE;
+    const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_SURFACE;
 
     cmd_writer_reloc(cmd, which, offset + (dw_index << 2),
             (intptr_t) bo, bo_offset, reloc_flags);
@@ -311,7 +328,7 @@ static inline void cmd_surface_reloc_writer(struct intel_cmd *cmd,
                                             enum intel_cmd_writer_type writer,
                                             uint32_t writer_offset)
 {
-    const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_STATE;
+    const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_SURFACE;
 
     cmd_writer_reloc(cmd, which, offset + (dw_index << 2),
             (intptr_t) writer, writer_offset,