From: Jason Ekstrand Date: Wed, 15 Mar 2017 22:24:48 +0000 (-0700) Subject: anv/query: Break GPU query calculation into a helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c773ae88dfbf206dbcbe656e0c8697fc7dea38fc;p=mesa.git anv/query: Break GPU query calculation into a helper Reviewed-By: Lionel Landwerlin --- diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c index ecd6a7a695b..48058ce9d71 100644 --- a/src/intel/vulkan/genX_query.c +++ b/src/intel/vulkan/genX_query.c @@ -417,6 +417,22 @@ store_query_result(struct anv_batch *batch, uint32_t reg, } } +static void +compute_query_result(struct anv_batch *batch, uint32_t dst_reg, + struct anv_bo *bo, uint32_t offset) +{ + emit_load_alu_reg_u64(batch, CS_GPR(0), bo, offset); + emit_load_alu_reg_u64(batch, CS_GPR(1), bo, offset + 8); + + /* FIXME: We need to clamp the result for 32 bit. */ + + uint32_t *dw = anv_batch_emitn(batch, 5, GENX(MI_MATH)); + dw[1] = alu(OPCODE_LOAD, OPERAND_SRCA, OPERAND_R1); + dw[2] = alu(OPCODE_LOAD, OPERAND_SRCB, OPERAND_R0); + dw[3] = alu(OPCODE_SUB, 0, 0); + dw[4] = alu(OPCODE_STORE, dst_reg, OPERAND_ACCU); +} + void genX(CmdCopyQueryPoolResults)( VkCommandBuffer commandBuffer, VkQueryPool queryPool, @@ -445,18 +461,8 @@ void genX(CmdCopyQueryPoolResults)( slot_offset = (firstQuery + i) * pool->stride; switch (pool->type) { case VK_QUERY_TYPE_OCCLUSION: - emit_load_alu_reg_u64(&cmd_buffer->batch, - CS_GPR(0), &pool->bo, slot_offset + 8); - emit_load_alu_reg_u64(&cmd_buffer->batch, - CS_GPR(1), &pool->bo, slot_offset + 16); - - /* FIXME: We need to clamp the result for 32 bit. */ - - uint32_t *dw = anv_batch_emitn(&cmd_buffer->batch, 5, GENX(MI_MATH)); - dw[1] = alu(OPCODE_LOAD, OPERAND_SRCA, OPERAND_R1); - dw[2] = alu(OPCODE_LOAD, OPERAND_SRCB, OPERAND_R0); - dw[3] = alu(OPCODE_SUB, 0, 0); - dw[4] = alu(OPCODE_STORE, OPERAND_R2, OPERAND_ACCU); + compute_query_result(&cmd_buffer->batch, OPERAND_R2, + &pool->bo, slot_offset + 8); break; case VK_QUERY_TYPE_TIMESTAMP: