diff options
Diffstat (limited to 'src/freedreno')
-rw-r--r-- | src/freedreno/vulkan/tu_cmd_buffer.c | 11 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_cs.c | 116 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_cs.h | 44 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_device.c | 16 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 10 |
5 files changed, 93 insertions, 104 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 9efcd9264a8..d29f07b27ec 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -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; diff --git a/src/freedreno/vulkan/tu_cs.c b/src/freedreno/vulkan/tu_cs.c index 16957dd2682..55e7d3528e0 100644 --- a/src/freedreno/vulkan/tu_cs.c +++ b/src/freedreno/vulkan/tu_cs.c @@ -24,52 +24,49 @@ #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); } diff --git a/src/freedreno/vulkan/tu_cs.h b/src/freedreno/vulkan/tu_cs.h index e865c738dde..952d0262d6a 100644 --- a/src/freedreno/vulkan/tu_cs.h +++ b/src/freedreno/vulkan/tu_cs.h @@ -28,28 +28,24 @@ #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 */ diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 7ff1e5a4f62..d5533028a62 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -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; - } } diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index a112bbcb781..7a65bc38585 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -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; }; |