tu: Simplify device startup CS creation
We have a few different command streams we create at startup. Simplify the initialization by creating a single sub_cs to allocate all of the cs's out of and inlining structures where appropriate. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30544>
This commit is contained in:
@@ -1487,7 +1487,7 @@ tu6_init_hw(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
|
||||
tu_cs_emit(cs, CP_COND_REG_EXEC_0_MODE(THREAD_MODE) |
|
||||
CP_COND_REG_EXEC_0_BR | CP_COND_REG_EXEC_0_LPAC);
|
||||
tu_cs_emit(cs, RENDER_MODE_CP_COND_REG_EXEC_1_DWORDS(4));
|
||||
tu_cs_emit_ib(cs, dev->cmdbuf_start_a725_quirk_entry);
|
||||
tu_cs_emit_ib(cs, &dev->cmdbuf_start_a725_quirk_entry);
|
||||
}
|
||||
|
||||
tu_cs_sanity_check(cs);
|
||||
|
||||
@@ -2132,26 +2132,8 @@ tu_init_dbg_reg_stomper(struct tu_device *device)
|
||||
static VkResult
|
||||
tu_init_cmdbuf_start_a725_quirk(struct tu_device *device)
|
||||
{
|
||||
struct tu_cs *cs;
|
||||
|
||||
if (!(device->cmdbuf_start_a725_quirk_cs =
|
||||
(struct tu_cs *) calloc(1, sizeof(struct tu_cs)))) {
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY,
|
||||
"OOM");
|
||||
}
|
||||
|
||||
if (!(device->cmdbuf_start_a725_quirk_entry =
|
||||
(struct tu_cs_entry *) calloc(1, sizeof(struct tu_cs_entry)))) {
|
||||
free(device->cmdbuf_start_a725_quirk_cs);
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY,
|
||||
"OOM");
|
||||
}
|
||||
|
||||
cs = device->cmdbuf_start_a725_quirk_cs;
|
||||
tu_cs_init(cs, device, TU_CS_MODE_SUB_STREAM, 57, "a725 workaround cs");
|
||||
|
||||
struct tu_cs shader_cs;
|
||||
tu_cs_begin_sub_stream(cs, 10, &shader_cs);
|
||||
tu_cs_begin_sub_stream(&device->sub_cs, 10, &shader_cs);
|
||||
|
||||
uint32_t raw_shader[] = {
|
||||
0x00040000, 0x40600000, // mul.f hr0.x, hr0.x, hr1.x
|
||||
@@ -2162,11 +2144,11 @@ tu_init_cmdbuf_start_a725_quirk(struct tu_device *device)
|
||||
};
|
||||
|
||||
tu_cs_emit_array(&shader_cs, raw_shader, ARRAY_SIZE(raw_shader));
|
||||
struct tu_cs_entry shader_entry = tu_cs_end_sub_stream(cs, &shader_cs);
|
||||
struct tu_cs_entry shader_entry = tu_cs_end_sub_stream(&device->sub_cs, &shader_cs);
|
||||
uint64_t shader_iova = shader_entry.bo->iova + shader_entry.offset;
|
||||
|
||||
struct tu_cs sub_cs;
|
||||
tu_cs_begin_sub_stream(cs, 47, &sub_cs);
|
||||
tu_cs_begin_sub_stream(&device->sub_cs, 47, &sub_cs);
|
||||
|
||||
tu_cs_emit_regs(&sub_cs, HLSQ_INVALIDATE_CMD(A7XX,
|
||||
.vs_state = true, .hs_state = true, .ds_state = true,
|
||||
@@ -2229,7 +2211,8 @@ tu_init_cmdbuf_start_a725_quirk(struct tu_device *device)
|
||||
tu_cs_emit(&sub_cs, CP_EXEC_CS_2_NGROUPS_Y(1));
|
||||
tu_cs_emit(&sub_cs, CP_EXEC_CS_3_NGROUPS_Z(1));
|
||||
|
||||
*device->cmdbuf_start_a725_quirk_entry = tu_cs_end_sub_stream(cs, &sub_cs);
|
||||
device->cmdbuf_start_a725_quirk_entry =
|
||||
tu_cs_end_sub_stream(&device->sub_cs, &sub_cs);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
@@ -2486,19 +2469,13 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||
goto fail_pipeline_cache;
|
||||
}
|
||||
|
||||
tu_cs_init(&device->sub_cs, device, TU_CS_MODE_SUB_STREAM, 1024, "device sub cs");
|
||||
|
||||
if (device->vk.enabled_features.performanceCounterQueryPools) {
|
||||
/* Prepare command streams setting pass index to the PERF_CNTRS_REG
|
||||
* from 0 to 31. One of these will be picked up at cmd submit time
|
||||
* when the perf query is executed.
|
||||
*/
|
||||
struct tu_cs *cs;
|
||||
|
||||
if (!(device->perfcntrs_pass_cs =
|
||||
(struct tu_cs *) calloc(1, sizeof(struct tu_cs)))) {
|
||||
result = vk_startup_errorf(device->instance,
|
||||
VK_ERROR_OUT_OF_HOST_MEMORY, "OOM");
|
||||
goto fail_perfcntrs_pass_alloc;
|
||||
}
|
||||
|
||||
device->perfcntrs_pass_cs_entries =
|
||||
(struct tu_cs_entry *) calloc(32, sizeof(struct tu_cs_entry));
|
||||
@@ -2508,13 +2485,10 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||
goto fail_perfcntrs_pass_entries_alloc;
|
||||
}
|
||||
|
||||
cs = device->perfcntrs_pass_cs;
|
||||
tu_cs_init(cs, device, TU_CS_MODE_SUB_STREAM, 96, "perfcntrs cs");
|
||||
|
||||
for (unsigned i = 0; i < 32; i++) {
|
||||
struct tu_cs sub_cs;
|
||||
|
||||
result = tu_cs_begin_sub_stream(cs, 3, &sub_cs);
|
||||
result = tu_cs_begin_sub_stream(&device->sub_cs, 3, &sub_cs);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_startup_errorf(device->instance, result,
|
||||
"failed to allocate commands streams");
|
||||
@@ -2524,7 +2498,8 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||
tu_cs_emit_regs(&sub_cs, A6XX_CP_SCRATCH_REG(PERF_CNTRS_REG, 1 << i));
|
||||
tu_cs_emit_pkt7(&sub_cs, CP_WAIT_FOR_ME, 0);
|
||||
|
||||
device->perfcntrs_pass_cs_entries[i] = tu_cs_end_sub_stream(cs, &sub_cs);
|
||||
device->perfcntrs_pass_cs_entries[i] =
|
||||
tu_cs_end_sub_stream(&device->sub_cs, &sub_cs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2620,18 +2595,11 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||
return VK_SUCCESS;
|
||||
|
||||
fail_timeline_cond:
|
||||
if (device->cmdbuf_start_a725_quirk_entry) {
|
||||
free(device->cmdbuf_start_a725_quirk_entry);
|
||||
tu_cs_finish(device->cmdbuf_start_a725_quirk_cs);
|
||||
free(device->cmdbuf_start_a725_quirk_cs);
|
||||
}
|
||||
fail_a725_workaround:
|
||||
fail_prepare_perfcntrs_pass_cs:
|
||||
free(device->perfcntrs_pass_cs_entries);
|
||||
tu_cs_finish(device->perfcntrs_pass_cs);
|
||||
fail_perfcntrs_pass_entries_alloc:
|
||||
free(device->perfcntrs_pass_cs);
|
||||
fail_perfcntrs_pass_alloc:
|
||||
tu_cs_finish(&device->sub_cs);
|
||||
vk_pipeline_cache_destroy(device->mem_cache, &device->vk.alloc);
|
||||
fail_pipeline_cache:
|
||||
tu_destroy_dynamic_rendering(device);
|
||||
@@ -2703,10 +2671,10 @@ tu_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator)
|
||||
|
||||
vk_pipeline_cache_destroy(device->mem_cache, &device->vk.alloc);
|
||||
|
||||
if (device->perfcntrs_pass_cs) {
|
||||
tu_cs_finish(&device->sub_cs);
|
||||
|
||||
if (device->perfcntrs_pass_cs_entries) {
|
||||
free(device->perfcntrs_pass_cs_entries);
|
||||
tu_cs_finish(device->perfcntrs_pass_cs);
|
||||
free(device->perfcntrs_pass_cs);
|
||||
}
|
||||
|
||||
if (device->dbg_cmdbuf_stomp_cs) {
|
||||
@@ -2719,12 +2687,6 @@ tu_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator)
|
||||
free(device->dbg_renderpass_stomp_cs);
|
||||
}
|
||||
|
||||
if (device->cmdbuf_start_a725_quirk_entry) {
|
||||
free(device->cmdbuf_start_a725_quirk_entry);
|
||||
tu_cs_finish(device->cmdbuf_start_a725_quirk_cs);
|
||||
free(device->cmdbuf_start_a725_quirk_cs);
|
||||
}
|
||||
|
||||
tu_autotune_fini(&device->autotune, device);
|
||||
|
||||
tu_bo_suballocator_finish(&device->pipeline_suballoc);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "vk_device_memory.h"
|
||||
|
||||
#include "tu_autotune.h"
|
||||
#include "tu_cs.h"
|
||||
#include "tu_pass.h"
|
||||
#include "tu_perfetto.h"
|
||||
#include "tu_suballoc.h"
|
||||
@@ -383,12 +384,12 @@ struct tu_device
|
||||
*/
|
||||
struct u_vector zombie_vmas;
|
||||
|
||||
struct tu_cs sub_cs;
|
||||
|
||||
/* Command streams to set pass index to a scratch reg */
|
||||
struct tu_cs *perfcntrs_pass_cs;
|
||||
struct tu_cs_entry *perfcntrs_pass_cs_entries;
|
||||
|
||||
struct tu_cs *cmdbuf_start_a725_quirk_cs;
|
||||
struct tu_cs_entry *cmdbuf_start_a725_quirk_entry;
|
||||
struct tu_cs_entry cmdbuf_start_a725_quirk_entry;
|
||||
|
||||
struct util_dynarray dynamic_rendering_pending;
|
||||
VkCommandPool dynamic_rendering_pool;
|
||||
|
||||
@@ -1101,7 +1101,7 @@ static VkResult
|
||||
msm_queue_submit(struct tu_queue *queue, struct vk_queue_submit *submit)
|
||||
{
|
||||
MESA_TRACE_FUNC();
|
||||
uint32_t perf_pass_index = queue->device->perfcntrs_pass_cs ?
|
||||
uint32_t perf_pass_index = queue->device->perfcntrs_pass_cs_entries ?
|
||||
submit->perf_pass_index : ~0;
|
||||
struct tu_msm_queue_submit submit_req;
|
||||
|
||||
|
||||
@@ -1199,7 +1199,7 @@ static VkResult
|
||||
virtio_queue_submit(struct tu_queue *queue, struct vk_queue_submit *submit)
|
||||
{
|
||||
MESA_TRACE_FUNC();
|
||||
uint32_t perf_pass_index = queue->device->perfcntrs_pass_cs ?
|
||||
uint32_t perf_pass_index = queue->device->perfcntrs_pass_cs_entries ?
|
||||
submit->perf_pass_index : ~0;
|
||||
struct tu_virtio_queue_submit submit_req;
|
||||
|
||||
|
||||
@@ -1094,7 +1094,7 @@ kgsl_queue_submit(struct tu_queue *queue, struct vk_queue_submit *vk_submit)
|
||||
}
|
||||
|
||||
uint32_t perf_pass_index =
|
||||
queue->device->perfcntrs_pass_cs ? vk_submit->perf_pass_index : ~0;
|
||||
queue->device->perfcntrs_pass_cs_entries ? vk_submit->perf_pass_index : ~0;
|
||||
|
||||
if (TU_DEBUG(LOG_SKIP_GMEM_OPS))
|
||||
tu_dbg_log_gmem_load_store_skips(queue->device);
|
||||
|
||||
Reference in New Issue
Block a user