[Mesa-dev] [PATCH v2 10/16] anv/query: Break GPU query calculation into a helper
Jason Ekstrand
jason at jlekstrand.net
Thu Mar 16 21:34:05 UTC 2017
Reviewed-By: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/vulkan/genX_query.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
index b8d4c55..6c26e6a 100644
--- a/src/intel/vulkan/genX_query.c
+++ b/src/intel/vulkan/genX_query.c
@@ -416,6 +416,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,
@@ -444,18 +460,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:
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list