svga: add num-commands-per-draw HUD query
authorBrian Paul <brianp@vmware.com>
Thu, 11 Jan 2018 18:17:45 +0000 (11:17 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 17 Jan 2018 18:17:56 +0000 (11:17 -0700)
This query shows the ratio of total commands vs. drawing commands sent
to the vgpu device.  This gives some idea of how many state changes
are sent per draw call.  The closer the ratio is to 1.0, the better.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Neha Bhende <bhenden@vmware.com>
src/gallium/drivers/svga/svga_cmd.c
src/gallium/drivers/svga/svga_cmd_vgpu10.c
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_query.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/svga/svga_winsys.h

index 7b78cb735472ccf94a2ceb38c4f12980233390ad..2bd1cc21a75276e051f55b4a05ae7b10c083437e 100644 (file)
@@ -121,6 +121,8 @@ SVGA3D_FIFOReserve(struct svga_winsys_context *swc,
 
    swc->last_command = cmd;
 
+   swc->num_commands++;
+
    return &header[1];
 }
 
@@ -1022,6 +1024,8 @@ SVGA3D_BeginDrawPrimitives(struct svga_winsys_context *swc,
 
    swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
 
+   swc->num_draw_commands++;
+
    return PIPE_OK;
 }
 
index 55465f530302ec3714fc96295bd66c85030024b3..bed1403ac1b8e0ee2e7379ed23b99ded11312b72 100644 (file)
@@ -537,6 +537,7 @@ SVGA3D_vgpu10_Draw(struct svga_winsys_context *swc,
 
    swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
    swc->commit(swc);
+   swc->num_draw_commands++;
    return PIPE_OK;
 }
 
@@ -553,6 +554,7 @@ SVGA3D_vgpu10_DrawIndexed(struct svga_winsys_context *swc,
 
    swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
    swc->commit(swc);
+   swc->num_draw_commands++;
    return PIPE_OK;
 }
 
@@ -570,6 +572,7 @@ SVGA3D_vgpu10_DrawInstanced(struct svga_winsys_context *swc,
 
    swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
    swc->commit(swc);
+   swc->num_draw_commands++;
    return PIPE_OK;
 }
 
@@ -590,6 +593,7 @@ SVGA3D_vgpu10_DrawIndexedInstanced(struct svga_winsys_context *swc,
 
    swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
    swc->commit(swc);
+   swc->num_draw_commands++;
    return PIPE_OK;
 }
 
@@ -600,6 +604,7 @@ SVGA3D_vgpu10_DrawAuto(struct svga_winsys_context *swc)
 
    swc->hints |= SVGA_HINT_FLAG_CAN_PRE_FLUSH;
    swc->commit(swc);
+   swc->num_draw_commands++;
    return PIPE_OK;
 }
 
index fd0c31222e634bd93a0d57f6d2798b71d86f2645..bc881c943d68a8a7b2e85691a4e2bcd7547c3ac7 100644 (file)
@@ -73,6 +73,7 @@ enum svga_hud {
    SVGA_QUERY_NUM_SURFACE_VIEWS,
    SVGA_QUERY_NUM_GENERATE_MIPMAP,
    SVGA_QUERY_NUM_FAILED_ALLOCATIONS,
+   SVGA_QUERY_NUM_COMMANDS_PER_DRAW,
 
 /*SVGA_QUERY_MAX has to be last because it is size of an array*/
    SVGA_QUERY_MAX
index 269245243723f72bfd8beeeab562bd570279e5fc..cec95ed3b6f550c4ba1d5757fb411ad4737e477c 100644 (file)
@@ -751,6 +751,7 @@ svga_create_query(struct pipe_context *pipe,
    case SVGA_QUERY_NUM_CONST_BUF_UPDATES:
    case SVGA_QUERY_NUM_CONST_UPDATES:
    case SVGA_QUERY_NUM_FAILED_ALLOCATIONS:
+   case SVGA_QUERY_NUM_COMMANDS_PER_DRAW:
       break;
    case SVGA_QUERY_FLUSH_TIME:
    case SVGA_QUERY_MAP_BUFFER_TIME:
@@ -832,6 +833,7 @@ svga_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
    case SVGA_QUERY_NUM_CONST_BUF_UPDATES:
    case SVGA_QUERY_NUM_CONST_UPDATES:
    case SVGA_QUERY_NUM_FAILED_ALLOCATIONS:
+   case SVGA_QUERY_NUM_COMMANDS_PER_DRAW:
       /* nothing */
       break;
    default:
@@ -945,6 +947,7 @@ svga_begin_query(struct pipe_context *pipe, struct pipe_query *q)
    case SVGA_QUERY_NUM_SURFACE_VIEWS:
    case SVGA_QUERY_NUM_GENERATE_MIPMAP:
    case SVGA_QUERY_NUM_FAILED_ALLOCATIONS:
+   case SVGA_QUERY_NUM_COMMANDS_PER_DRAW:
       /* nothing */
       break;
    default:
@@ -1059,6 +1062,7 @@ svga_end_query(struct pipe_context *pipe, struct pipe_query *q)
    case SVGA_QUERY_NUM_SURFACE_VIEWS:
    case SVGA_QUERY_NUM_GENERATE_MIPMAP:
    case SVGA_QUERY_NUM_FAILED_ALLOCATIONS:
+   case SVGA_QUERY_NUM_COMMANDS_PER_DRAW:
       /* nothing */
       break;
    default:
@@ -1196,6 +1200,10 @@ svga_get_query_result(struct pipe_context *pipe,
    case SVGA_QUERY_NUM_FAILED_ALLOCATIONS:
       vresult->u64 = svgascreen->hud.num_failed_allocations;
       break;
+   case SVGA_QUERY_NUM_COMMANDS_PER_DRAW:
+      vresult->f = (float) svga->swc->num_commands
+         / (float) svga->swc->num_draw_commands;
+      break;
    default:
       assert(!"unexpected query type in svga_get_query_result");
    }
index 534e94ab22bd13662596acfe61af0141f6dd02a3..5d9d024e7686e25edf1a4872effc50b9e22b169f 100644 (file)
@@ -845,6 +845,8 @@ svga_get_driver_query_info(struct pipe_screen *screen,
             PIPE_DRIVER_QUERY_TYPE_UINT64),
       QUERY("num-failed-allocations", SVGA_QUERY_NUM_FAILED_ALLOCATIONS,
             PIPE_DRIVER_QUERY_TYPE_UINT64),
+      QUERY("num-commands-per-draw", SVGA_QUERY_NUM_COMMANDS_PER_DRAW,
+            PIPE_DRIVER_QUERY_TYPE_FLOAT),
    };
 #undef QUERY
 
index e74d1ca4d72b679c6519e91b973e55101f85f20b..f0db3e97cc08019a1dcb5440828ac98a82de8469 100644 (file)
@@ -453,6 +453,10 @@ struct svga_winsys_context
 
    /** The more recent command issued to command buffer */
    SVGAFifo3dCmdId last_command;
+
+   /** For HUD queries */
+   uint64_t num_commands;
+   uint64_t num_draw_commands;
 };