turnip: run sed and clang-format on tu_cs
authorChia-I Wu <olvaffe@gmail.com>
Wed, 16 Jan 2019 18:03:02 +0000 (10:03 -0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 11 Mar 2019 17:01:41 +0000 (10:01 -0700)
src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_cs.c
src/freedreno/vulkan/tu_cs.h
src/freedreno/vulkan/tu_device.c
src/freedreno/vulkan/tu_private.h

index 9efcd9264a8f98a36ad4878f8b05ebff00396d89..d29f07b27ec447f5704e655302c08d6b79daab6a 100644 (file)
@@ -247,7 +247,7 @@ tu_create_cmd_buffer(struct tu_device *device,
    }
 
    tu_bo_list_init(&cmd_buffer->bo_list);
-   tu_cmd_stream_init(&cmd_buffer->cs);
+   tu_cs_init(&cmd_buffer->cs);
 
    *pCommandBuffer = tu_cmd_buffer_to_handle(cmd_buffer);
 
@@ -264,7 +264,7 @@ tu_cmd_buffer_destroy(struct tu_cmd_buffer *cmd_buffer)
    for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++)
       free(cmd_buffer->descriptors[i].push_set.set.mapped_ptr);
 
-   tu_cmd_stream_finish(cmd_buffer->device, &cmd_buffer->cs);
+   tu_cs_finish(cmd_buffer->device, &cmd_buffer->cs);
    tu_bo_list_destroy(&cmd_buffer->bo_list);
    vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
 }
@@ -275,7 +275,7 @@ tu_reset_cmd_buffer(struct tu_cmd_buffer *cmd_buffer)
    cmd_buffer->record_result = VK_SUCCESS;
 
    tu_bo_list_reset(&cmd_buffer->bo_list);
-   tu_cmd_stream_reset(cmd_buffer->device, &cmd_buffer->cs);
+   tu_cs_reset(cmd_buffer->device, &cmd_buffer->cs);
 
    for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++) {
       cmd_buffer->descriptors[i].dirty = 0;
@@ -401,8 +401,7 @@ tu_BeginCommandBuffer(VkCommandBuffer commandBuffer,
 
    cmd_buffer->status = TU_CMD_BUFFER_STATUS_RECORDING;
 
-   result = tu_cmd_stream_begin(cmd_buffer->device,
-                                &cmd_buffer->cs, 4096);
+   result = tu_cs_begin(cmd_buffer->device, &cmd_buffer->cs, 4096);
 
    /* Put some stuff in so we do not have empty command buffers. */
    tu_cs_emit_pkt7(&cmd_buffer->cs, CP_NOP, 4);
@@ -458,7 +457,7 @@ tu_EndCommandBuffer(VkCommandBuffer commandBuffer)
 {
    TU_FROM_HANDLE(tu_cmd_buffer, cmd_buffer, commandBuffer);
 
-   tu_cmd_stream_end(&cmd_buffer->cs);
+   tu_cs_end(&cmd_buffer->cs);
    cmd_buffer->status = TU_CMD_BUFFER_STATUS_EXECUTABLE;
 
    return cmd_buffer->record_result;
index 16957dd26825c89bcf0651931c950ef92c85a9d2..55e7d3528e08b089ae8708fcfb9363197e3fbdb2 100644 (file)
 #include "tu_cs.h"
 
 void
-tu_cmd_stream_init(struct tu_cmd_stream *stream)
+tu_cs_init(struct tu_cs *cs)
 {
-   stream->start = stream->cur = stream->end = NULL;
+   cs->start = cs->cur = cs->end = NULL;
 
-   stream->entry_count = stream->entry_capacity = 0;
-   stream->entries = NULL;
+   cs->entry_count = cs->entry_capacity = 0;
+   cs->entries = NULL;
 
-   stream->bo_count = stream->bo_capacity = 0;
-   stream->bos = NULL;
+   cs->bo_count = cs->bo_capacity = 0;
+   cs->bos = NULL;
 }
 
 void
-tu_cmd_stream_finish(struct tu_device *dev, struct tu_cmd_stream *stream)
+tu_cs_finish(struct tu_device *dev, struct tu_cs *cs)
 {
-   for (uint32_t i = 0; i < stream->bo_count; ++i) {
-      tu_bo_finish(dev, stream->bos[i]);
-      free(stream->bos[i]);
+   for (uint32_t i = 0; i < cs->bo_count; ++i) {
+      tu_bo_finish(dev, cs->bos[i]);
+      free(cs->bos[i]);
    }
 
-   free(stream->entries);
-   free(stream->bos);
+   free(cs->entries);
+   free(cs->bos);
 }
 
 VkResult
-tu_cmd_stream_begin(struct tu_device *dev,
-                    struct tu_cmd_stream *stream,
-                    uint32_t reserve_size)
+tu_cs_begin(struct tu_device *dev, struct tu_cs *cs, uint32_t reserve_size)
 {
    assert(reserve_size);
 
-   if (stream->end - stream->cur < reserve_size) {
-      if (stream->bo_count == stream->bo_capacity) {
-         uint32_t new_capacity = MAX2(4, 2 * stream->bo_capacity);
+   if (cs->end - cs->cur < reserve_size) {
+      if (cs->bo_count == cs->bo_capacity) {
+         uint32_t new_capacity = MAX2(4, 2 * cs->bo_capacity);
          struct tu_bo **new_bos =
-            realloc(stream->bos, new_capacity * sizeof(struct tu_bo *));
+            realloc(cs->bos, new_capacity * sizeof(struct tu_bo *));
          if (!new_bos)
             abort();
 
-         stream->bo_capacity = new_capacity;
-         stream->bos = new_bos;
+         cs->bo_capacity = new_capacity;
+         cs->bos = new_bos;
       }
 
       uint32_t new_size = MAX2(16384, reserve_size * sizeof(uint32_t));
-      if (stream->bo_count)
-         new_size =
-            MAX2(new_size, stream->bos[stream->bo_count - 1]->size * 2);
+      if (cs->bo_count)
+         new_size = MAX2(new_size, cs->bos[cs->bo_count - 1]->size * 2);
 
       struct tu_bo *new_bo = malloc(sizeof(struct tu_bo));
       if (!new_bo)
@@ -88,78 +85,75 @@ tu_cmd_stream_begin(struct tu_device *dev,
          return result;
       }
 
-      stream->bos[stream->bo_count] = new_bo;
-      ++stream->bo_count;
+      cs->bos[cs->bo_count] = new_bo;
+      ++cs->bo_count;
 
-      stream->start = stream->cur = (uint32_t *) new_bo->map;
-      stream->end = stream->start + new_bo->size / sizeof(uint32_t);
+      cs->start = cs->cur = (uint32_t *) new_bo->map;
+      cs->end = cs->start + new_bo->size / sizeof(uint32_t);
    }
-   stream->start = stream->cur;
+   cs->start = cs->cur;
 
    return VK_SUCCESS;
 }
 
 VkResult
-tu_cmd_stream_end(struct tu_cmd_stream *stream)
+tu_cs_end(struct tu_cs *cs)
 {
-   if (stream->start == stream->cur)
+   if (cs->start == cs->cur)
       return VK_SUCCESS;
 
-   if (stream->entry_capacity == stream->entry_count) {
-      uint32_t new_capacity = MAX2(stream->entry_capacity * 2, 4);
-      struct tu_cmd_stream_entry *new_entries = realloc(
-         stream->entries, new_capacity * sizeof(struct tu_cmd_stream_entry));
+   if (cs->entry_capacity == cs->entry_count) {
+      uint32_t new_capacity = MAX2(cs->entry_capacity * 2, 4);
+      struct tu_cs_entry *new_entries =
+         realloc(cs->entries, new_capacity * sizeof(struct tu_cs_entry));
       if (!new_entries)
          abort(); /* TODO */
 
-      stream->entries = new_entries;
-      stream->entry_capacity = new_capacity;
+      cs->entries = new_entries;
+      cs->entry_capacity = new_capacity;
    }
 
-   assert(stream->bo_count);
+   assert(cs->bo_count);
 
-   struct tu_cmd_stream_entry entry;
-   entry.bo = stream->bos[stream->bo_count - 1];
-   entry.size = (stream->cur - stream->start) * sizeof(uint32_t);
-   entry.offset =
-      (stream->start - (uint32_t *) entry.bo->map) * sizeof(uint32_t);
+   struct tu_cs_entry entry;
+   entry.bo = cs->bos[cs->bo_count - 1];
+   entry.size = (cs->cur - cs->start) * sizeof(uint32_t);
+   entry.offset = (cs->start - (uint32_t *) entry.bo->map) * sizeof(uint32_t);
 
-   stream->entries[stream->entry_count] = entry;
-   ++stream->entry_count;
+   cs->entries[cs->entry_count] = entry;
+   ++cs->entry_count;
 
    return VK_SUCCESS;
 }
 
 void
-tu_cmd_stream_reset(struct tu_device *dev, struct tu_cmd_stream *stream)
+tu_cs_reset(struct tu_device *dev, struct tu_cs *cs)
 {
-   for (uint32_t i = 0; i + 1 < stream->bo_count; ++i) {
-      tu_bo_finish(dev, stream->bos[i]);
-      free(stream->bos[i]);
+   for (uint32_t i = 0; i + 1 < cs->bo_count; ++i) {
+      tu_bo_finish(dev, cs->bos[i]);
+      free(cs->bos[i]);
    }
 
-   if (stream->bo_count) {
-      stream->bos[0] = stream->bos[stream->bo_count - 1];
-      stream->bo_count = 1;
+   if (cs->bo_count) {
+      cs->bos[0] = cs->bos[cs->bo_count - 1];
+      cs->bo_count = 1;
 
-      stream->start = stream->cur = (uint32_t *) stream->bos[0]->map;
-      stream->end = stream->start + stream->bos[0]->size / sizeof(uint32_t);
+      cs->start = cs->cur = (uint32_t *) cs->bos[0]->map;
+      cs->end = cs->start + cs->bos[0]->size / sizeof(uint32_t);
    }
 
-   stream->entry_count = 0;
+   cs->entry_count = 0;
 }
 
 VkResult
-tu_cs_check_space(struct tu_device *dev,
-                  struct tu_cmd_stream *stream,
-                  size_t size)
+tu_cs_check_space(struct tu_device *dev, struct tu_cs *cs, size_t size)
 {
-   if (stream->end - stream->cur >= size)
+   if (cs->end - cs->cur >= size)
       return VK_SUCCESS;
 
-   VkResult result = tu_cmd_stream_end(stream);
+   VkResult result = tu_cs_end(cs);
    if (result != VK_SUCCESS)
       return result;
 
-   return tu_cmd_stream_begin(dev, stream, size);
+   return tu_cs_begin(dev, cs, size);
 }
index e865c738ddeef5ec6422950c147f1b3e082ec7d5..952d0262d6a8da2548983dceafe123eff7b8f658 100644 (file)
 #include "adreno_pm4.xml.h"
 
 void
-tu_cmd_stream_init(struct tu_cmd_stream *stream);
+tu_cs_init(struct tu_cs *cs);
 void
-tu_cmd_stream_finish(struct tu_device *dev, struct tu_cmd_stream *stream);
+tu_cs_finish(struct tu_device *dev, struct tu_cs *cs);
 VkResult
-tu_cmd_stream_begin(struct tu_device *dev,
-                    struct tu_cmd_stream *stream,
-                    uint32_t reserve_size);
+tu_cs_begin(struct tu_device *dev, struct tu_cs *cs, uint32_t reserve_size);
 VkResult
-tu_cmd_stream_end(struct tu_cmd_stream *stream);
+tu_cs_end(struct tu_cs *cs);
 void
-tu_cmd_stream_reset(struct tu_device *dev, struct tu_cmd_stream *stream);
+tu_cs_reset(struct tu_device *dev, struct tu_cs *cs);
 VkResult
-tu_cs_check_space(struct tu_device *dev,
-                  struct tu_cmd_stream *stream,
-                  size_t size);
+tu_cs_check_space(struct tu_device *dev, struct tu_cs *cs, size_t size);
 
 static inline void
-tu_cs_emit(struct tu_cmd_stream *stream, uint32_t value)
+tu_cs_emit(struct tu_cs *cs, uint32_t value)
 {
-   assert(stream->cur < stream->end);
-   *stream->cur = value;
-   ++stream->cur;
+   assert(cs->cur < cs->end);
+   *cs->cur = value;
+   ++cs->cur;
 }
 
 static inline unsigned
@@ -66,25 +62,25 @@ tu_odd_parity_bit(unsigned val)
 }
 
 static inline void
-tu_cs_emit_pkt4(struct tu_cmd_stream *stream, uint16_t regindx, uint16_t cnt)
+tu_cs_emit_pkt4(struct tu_cs *cs, uint16_t regindx, uint16_t cnt)
 {
-   tu_cs_emit(stream, CP_TYPE4_PKT | cnt | (tu_odd_parity_bit(cnt) << 7) |
-                         ((regindx & 0x3ffff) << 8) |
-                         ((tu_odd_parity_bit(regindx) << 27)));
+   tu_cs_emit(cs, CP_TYPE4_PKT | cnt | (tu_odd_parity_bit(cnt) << 7) |
+                     ((regindx & 0x3ffff) << 8) |
+                     ((tu_odd_parity_bit(regindx) << 27)));
 }
 
 static inline void
-tu_cs_emit_pkt7(struct tu_cmd_stream *stream, uint8_t opcode, uint16_t cnt)
+tu_cs_emit_pkt7(struct tu_cs *cs, uint8_t opcode, uint16_t cnt)
 {
-   tu_cs_emit(stream, CP_TYPE7_PKT | cnt | (tu_odd_parity_bit(cnt) << 15) |
-                         ((opcode & 0x7f) << 16) |
-                         ((tu_odd_parity_bit(opcode) << 23)));
+   tu_cs_emit(cs, CP_TYPE7_PKT | cnt | (tu_odd_parity_bit(cnt) << 15) |
+                     ((opcode & 0x7f) << 16) |
+                     ((tu_odd_parity_bit(opcode) << 23)));
 }
 
 static inline void
-tu_cs_emit_wfi5(struct tu_cmd_stream *stream)
+tu_cs_emit_wfi5(struct tu_cs *cs)
 {
-   tu_cs_emit_pkt7(stream, CP_WAIT_FOR_IDLE, 0);
+   tu_cs_emit_pkt7(cs, CP_WAIT_FOR_IDLE, 0);
 }
 
 #endif /* TU_CS_H */
index 7ff1e5a4f6271fb197ca3cf81b3b8c6e0de59f3d..d5533028a6216095c4414b40a7ac276647404eee 100644 (file)
@@ -1166,25 +1166,25 @@ tu_QueueSubmit(VkQueue _queue,
       tu_bo_list_init(&bo_list);
 
       uint32_t entry_count = 0;
-      for(uint32_t j = 0; j < submit->commandBufferCount; ++j) {
+      for (uint32_t j = 0; j < submit->commandBufferCount; ++j) {
          TU_FROM_HANDLE(tu_cmd_buffer, cmdbuf, submit->pCommandBuffers[j]);
          entry_count += cmdbuf->cs.entry_count;
       }
 
       struct drm_msm_gem_submit_cmd cmds[entry_count];
       uint32_t entry_idx = 0;
-      for(uint32_t j = 0; j < submit->commandBufferCount; ++j) {
+      for (uint32_t j = 0; j < submit->commandBufferCount; ++j) {
          TU_FROM_HANDLE(tu_cmd_buffer, cmdbuf, submit->pCommandBuffers[j]);
-         struct tu_cmd_stream *stream = &cmdbuf->cs;
-         for (unsigned i = 0; i < stream->entry_count; ++i, ++entry_idx) {
+         struct tu_cs *cs = &cmdbuf->cs;
+         for (unsigned i = 0; i < cs->entry_count; ++i, ++entry_idx) {
             cmds[entry_idx].type = MSM_SUBMIT_CMD_BUF;
-            cmds[entry_idx].submit_idx = tu_bo_list_add(&bo_list, stream->entries[i].bo);
-            cmds[entry_idx].submit_offset = stream->entries[i].offset;
-            cmds[entry_idx].size = stream->entries[i].size;
+            cmds[entry_idx].submit_idx =
+               tu_bo_list_add(&bo_list, cs->entries[i].bo);
+            cmds[entry_idx].submit_offset = cs->entries[i].offset;
+            cmds[entry_idx].size = cs->entries[i].size;
             cmds[entry_idx].pad = 0;
             cmds[entry_idx].nr_relocs = 0;
             cmds[entry_idx].relocs = 0;
-
          }
       }
 
index a112bbcb7817c2b7b87a46c44799c0bfc03a28fc..7a65bc385858ea42413ec5d75470def94177f425 100644 (file)
@@ -717,22 +717,22 @@ void tu_bo_list_reset(struct tu_bo_list *list);
 uint32_t tu_bo_list_add(struct tu_bo_list *list,
                         const struct tu_bo *bo);
 
-struct tu_cmd_stream_entry
+struct tu_cs_entry
 {
-    /* No ownership */
+   /* No ownership */
    struct tu_bo *bo;
 
    uint32_t size;
    uint64_t offset;
 };
 
-struct tu_cmd_stream
+struct tu_cs
 {
    uint32_t *start;
    uint32_t *cur;
    uint32_t *end;
 
-   struct tu_cmd_stream_entry *entries;
+   struct tu_cs_entry *entries;
    uint32_t entry_count;
    uint32_t entry_capacity;
 
@@ -767,7 +767,7 @@ struct tu_cmd_buffer
    struct tu_cmd_buffer_upload upload;
 
    struct tu_bo_list bo_list;
-   struct tu_cmd_stream cs;
+   struct tu_cs cs;
 
    VkResult record_result;
 };