ilo: add functions for Gen8 relocs
authorChia-I Wu <olvaffe@gmail.com>
Sun, 25 Jan 2015 10:04:25 +0000 (18:04 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Wed, 11 Feb 2015 23:56:11 +0000 (07:56 +0800)
Extend ilo_builder_writer_reloc() for Gen8 memory addressing.  Add new
wrappers, ilo_builder_surface_reloc64(() and ilo_builder_batch_reloc64().

src/gallium/drivers/ilo/ilo_builder.h

index c11dba2d616292471a28b2254b766909d7e7d1aa..0de7b5dedc68d28a8bc25120e4bb6d93694be10e 100644 (file)
@@ -244,12 +244,18 @@ static inline void
 ilo_builder_writer_reloc(struct ilo_builder *builder,
                          enum ilo_builder_writer_type which,
                          unsigned offset, struct intel_bo *bo,
-                         unsigned bo_offset, unsigned reloc_flags)
+                         unsigned bo_offset, unsigned reloc_flags,
+                         bool write_presumed_offset_hi)
 {
    struct ilo_builder_writer *writer = &builder->writers[which];
    uint64_t presumed_offset;
    int err;
 
+   if (write_presumed_offset_hi)
+      ILO_DEV_ASSERT(builder->dev, 8, 8);
+   else
+      ILO_DEV_ASSERT(builder->dev, 6, 7.5);
+
    assert(offset + sizeof(uint32_t) <= writer->used ||
           (offset >= writer->size - writer->stolen &&
            offset + sizeof(uint32_t) <= writer->size));
@@ -259,9 +265,13 @@ ilo_builder_writer_reloc(struct ilo_builder *builder,
    if (unlikely(err))
       builder->unrecoverable_error = true;
 
-   /* 32-bit addressing */
-   assert(presumed_offset == (uint64_t) ((uint32_t) presumed_offset));
-   *((uint32_t *) ((char *) writer->ptr + offset)) = presumed_offset;
+   if (write_presumed_offset_hi) {
+      *((uint64_t *) ((char *) writer->ptr + offset)) = presumed_offset;
+   } else {
+      /* 32-bit addressing */
+      assert(presumed_offset == (uint64_t) ((uint32_t) presumed_offset));
+      *((uint32_t *) ((char *) writer->ptr + offset)) = presumed_offset;
+   }
 }
 
 /**
@@ -369,7 +379,19 @@ ilo_builder_surface_reloc(struct ilo_builder *builder,
    const enum ilo_builder_writer_type which = ILO_BUILDER_WRITER_BATCH;
 
    ilo_builder_writer_reloc(builder, which, offset + (dw_index << 2),
-         bo, bo_offset, reloc_flags);
+         bo, bo_offset, reloc_flags, false);
+}
+
+static inline void
+ilo_builder_surface_reloc64(struct ilo_builder *builder,
+                            uint32_t offset, unsigned dw_index,
+                            struct intel_bo *bo, unsigned bo_offset,
+                            unsigned reloc_flags)
+{
+   const enum ilo_builder_writer_type which = ILO_BUILDER_WRITER_BATCH;
+
+   ilo_builder_writer_reloc(builder, which, offset + (dw_index << 2),
+         bo, bo_offset, reloc_flags, true);
 }
 
 static inline unsigned
@@ -470,7 +492,18 @@ ilo_builder_batch_reloc(struct ilo_builder *builder, unsigned pos,
    const enum ilo_builder_writer_type which = ILO_BUILDER_WRITER_BATCH;
 
    ilo_builder_writer_reloc(builder, which, pos << 2,
-         bo, bo_offset, reloc_flags);
+         bo, bo_offset, reloc_flags, false);
+}
+
+static inline void
+ilo_builder_batch_reloc64(struct ilo_builder *builder, unsigned pos,
+                          struct intel_bo *bo, unsigned bo_offset,
+                          unsigned reloc_flags)
+{
+   const enum ilo_builder_writer_type which = ILO_BUILDER_WRITER_BATCH;
+
+   ilo_builder_writer_reloc(builder, which, pos << 2,
+         bo, bo_offset, reloc_flags, true);
 }
 
 static inline unsigned