diff --git a/src/freedreno/vulkan/tu_autotune.cc b/src/freedreno/vulkan/tu_autotune.cc index 0b90b215822..734c35351e8 100644 --- a/src/freedreno/vulkan/tu_autotune.cc +++ b/src/freedreno/vulkan/tu_autotune.cc @@ -667,8 +667,7 @@ tu_autotune_begin_renderpass(struct tu_cmd_buffer *cmd, &autotune_result->bo); tu_cs_emit_regs(cs, A6XX_RB_SAMPLE_COUNT_CONTROL(.copy = true)); - - if (CHIP >= A7XX) { + if (cmd->device->physical_device->info->a7xx.has_event_write_sample_count) { tu_cs_emit_pkt7(cs, CP_EVENT_WRITE7, 3); tu_cs_emit(cs, CP_EVENT_WRITE7_0(.event = ZPASS_DONE, .write_sample_count = true).value); @@ -693,17 +692,19 @@ void tu_autotune_end_renderpass(struct tu_cmd_buffer *cmd, if (!autotune_result->bo.iova) return; - uint64_t result_iova = autotune_result->bo.iova + - offsetof(struct tu_renderpass_samples, samples_end); + uint64_t result_iova = autotune_result->bo.iova; tu_cs_emit_regs(cs, A6XX_RB_SAMPLE_COUNT_CONTROL(.copy = true)); - if (CHIP >= A7XX) { + if (cmd->device->physical_device->info->a7xx.has_event_write_sample_count) { tu_cs_emit_pkt7(cs, CP_EVENT_WRITE7, 3); tu_cs_emit(cs, CP_EVENT_WRITE7_0(.event = ZPASS_DONE, - .write_sample_count = true).value); + .write_sample_count = true, + .sample_count_end_offset = true).value); tu_cs_emit_qw(cs, result_iova); } else { + result_iova += offsetof(struct tu_renderpass_samples, samples_end); + tu_cs_emit_regs(cs, A6XX_RB_SAMPLE_COUNT_ADDR(.qword = result_iova)); tu_cs_emit_pkt7(cs, CP_EVENT_WRITE, 1); diff --git a/src/freedreno/vulkan/tu_autotune.h b/src/freedreno/vulkan/tu_autotune.h index 137dff6b352..c374e86ab89 100644 --- a/src/freedreno/vulkan/tu_autotune.h +++ b/src/freedreno/vulkan/tu_autotune.h @@ -90,7 +90,7 @@ struct tu_autotune { * Note that we do the math on the CPU to avoid a WFI. But pre-emption * may force us to revisit that. */ -struct tu_renderpass_samples { +struct PACKED tu_renderpass_samples { uint64_t samples_start; /* hw requires the sample start/stop locations to be 128b aligned. */ uint64_t __pad0; @@ -98,6 +98,9 @@ struct tu_renderpass_samples { uint64_t __pad1; }; +/* Necessary when writing sample counts using CP_EVENT_WRITE7::ZPASS_DONE. */ +static_assert(offsetof(struct tu_renderpass_samples, samples_end) == 16); + /** * Tracks the results from an individual renderpass. Initially created * per renderpass, and appended to the tail of at->pending_results. At a later