From 67094e11e96da75dedd4ea7e0cdaa19f95cef4d8 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 14 Sep 2018 17:21:44 -0500 Subject: [PATCH] anv/query: Add an emit_srm helper Reviewed-by: Lionel Landwerlin --- src/intel/vulkan/genX_query.c | 53 ++++++++++++++--------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c index 4ccbe2975de..7533ec05095 100644 --- a/src/intel/vulkan/genX_query.c +++ b/src/intel/vulkan/genX_query.c @@ -310,6 +310,22 @@ VkResult genX(GetQueryPoolResults)( return status; } +static void +emit_srm32(struct anv_batch *batch, struct anv_address addr, uint32_t reg) +{ + anv_batch_emit(batch, GENX(MI_STORE_REGISTER_MEM), srm) { + srm.MemoryAddress = addr; + srm.RegisterAddress = reg; + } +} + +static void +emit_srm64(struct anv_batch *batch, struct anv_address addr, uint32_t reg) +{ + emit_srm32(batch, anv_address_add(addr, 0), reg + 0); + emit_srm32(batch, anv_address_add(addr, 4), reg + 4); +} + static void emit_ps_depth_count(struct anv_cmd_buffer *cmd_buffer, struct anv_address addr) @@ -394,16 +410,7 @@ emit_pipeline_stat(struct anv_cmd_buffer *cmd_buffer, uint32_t stat, (1 << ARRAY_SIZE(vk_pipeline_stat_to_reg)) - 1); assert(stat < ARRAY_SIZE(vk_pipeline_stat_to_reg)); - uint32_t reg = vk_pipeline_stat_to_reg[stat]; - - anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_REGISTER_MEM), lrm) { - lrm.RegisterAddress = reg; - lrm.MemoryAddress = anv_address_add(addr, 0); - } - anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_REGISTER_MEM), lrm) { - lrm.RegisterAddress = reg + 4; - lrm.MemoryAddress = anv_address_add(addr, 4); - } + emit_srm64(&cmd_buffer->batch, addr, vk_pipeline_stat_to_reg[stat]); } void genX(CmdBeginQuery)( @@ -515,14 +522,7 @@ void genX(CmdWriteTimestamp)( switch (pipelineStage) { case VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT: - anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_REGISTER_MEM), srm) { - srm.RegisterAddress = TIMESTAMP; - srm.MemoryAddress = anv_address_add(query_addr, 8); - } - anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_REGISTER_MEM), srm) { - srm.RegisterAddress = TIMESTAMP + 4; - srm.MemoryAddress = anv_address_add(query_addr, 12); - } + emit_srm64(&cmd_buffer->batch, anv_address_add(query_addr, 8), TIMESTAMP); break; default: @@ -689,21 +689,10 @@ gpu_write_query_result(struct anv_batch *batch, VkQueryResultFlags flags, uint32_t value_index, uint32_t reg) { - if (flags & VK_QUERY_RESULT_64_BIT) - dst_addr = anv_address_add(dst_addr, value_index * 8); - else - dst_addr = anv_address_add(dst_addr, value_index * 4); - - anv_batch_emit(batch, GENX(MI_STORE_REGISTER_MEM), srm) { - srm.RegisterAddress = reg; - srm.MemoryAddress = anv_address_add(dst_addr, 0); - } - if (flags & VK_QUERY_RESULT_64_BIT) { - anv_batch_emit(batch, GENX(MI_STORE_REGISTER_MEM), srm) { - srm.RegisterAddress = reg + 4; - srm.MemoryAddress = anv_address_add(dst_addr, 4); - } + emit_srm64(batch, anv_address_add(dst_addr, value_index * 8), reg); + } else { + emit_srm32(batch, anv_address_add(dst_addr, value_index * 4), reg); } } -- 2.30.2