*/
svga->swc->flush(svga->swc, &fence);
+ svga->hud.num_flushes++;
+
svga_screen_cache_flush(svgascreen, fence);
/* To force the re-emission of rendertargets and texture sampler bindings on
/** Non-GPU queries for gallium HUD */
-#define SVGA_QUERY_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0)
-#define SVGA_QUERY_FALLBACKS (PIPE_QUERY_DRIVER_SPECIFIC + 1)
-#define SVGA_QUERY_MEMORY_USED (PIPE_QUERY_DRIVER_SPECIFIC + 2)
-#define SVGA_QUERY_MAX (PIPE_QUERY_DRIVER_SPECIFIC + 3)
+/* per-frame counters */
+#define SVGA_QUERY_NUM_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0)
+#define SVGA_QUERY_NUM_FALLBACKS (PIPE_QUERY_DRIVER_SPECIFIC + 1)
+#define SVGA_QUERY_NUM_FLUSHES (PIPE_QUERY_DRIVER_SPECIFIC + 2)
+#define SVGA_QUERY_NUM_VALIDATIONS (PIPE_QUERY_DRIVER_SPECIFIC + 3)
+#define SVGA_QUERY_MAP_BUFFER_TIME (PIPE_QUERY_DRIVER_SPECIFIC + 4)
+#define SVGA_QUERY_NUM_RESOURCES_MAPPED (PIPE_QUERY_DRIVER_SPECIFIC + 5)
+/* running total counters */
+#define SVGA_QUERY_MEMORY_USED (PIPE_QUERY_DRIVER_SPECIFIC + 6)
+#define SVGA_QUERY_NUM_SHADERS (PIPE_QUERY_DRIVER_SPECIFIC + 7)
+#define SVGA_QUERY_NUM_RESOURCES (PIPE_QUERY_DRIVER_SPECIFIC + 8)
+#define SVGA_QUERY_NUM_STATE_OBJECTS (PIPE_QUERY_DRIVER_SPECIFIC + 9)
+#define SVGA_QUERY_NUM_SURFACE_VIEWS (PIPE_QUERY_DRIVER_SPECIFIC + 10)
+/*SVGA_QUERY_MAX has to be last because it is size of an array*/
+#define SVGA_QUERY_MAX (PIPE_QUERY_DRIVER_SPECIFIC + 11)
/**
* Maximum supported number of constant buffers per shader
/** List of buffers with queued transfers */
struct list_head dirty_buffers;
- /** performance / info queries */
- uint64_t num_draw_calls; /**< SVGA_QUERY_DRAW_CALLS */
- uint64_t num_fallbacks; /**< SVGA_QUERY_FALLBACKS */
+ /** performance / info queries for HUD */
+ struct {
+ uint64_t num_draw_calls; /**< SVGA_QUERY_DRAW_CALLS */
+ uint64_t num_fallbacks; /**< SVGA_QUERY_NUM_FALLBACKS */
+ uint64_t num_flushes; /**< SVGA_QUERY_NUM_FLUSHES */
+ uint64_t num_validations; /**< SVGA_QUERY_NUM_VALIDATIONS */
+ uint64_t map_buffer_time; /**< SVGA_QUERY_MAP_BUFFER_TIME */
+ uint64_t num_resources_mapped; /**< SVGA_QUERY_NUM_RESOURCES_MAPPED */
+ uint64_t num_shaders; /**< SVGA_QUERY_NUM_SHADERS */
+ uint64_t num_state_objects; /**< SVGA_QUERY_NUM_STATE_OBJECTS */
+ uint64_t num_surface_views; /**< SVGA_QUERY_NUM_SURFACE_VIEWS */
+ } hud;
/** The currently bound stream output targets */
unsigned num_so_targets;
define_blend_state_object(svga, blend);
}
+ svga->hud.num_state_objects++;
+
return blend;
}
}
FREE(blend);
+ svga->hud.num_state_objects--;
}
static void svga_set_blend_color( struct pipe_context *pipe,
define_depth_stencil_state_object(svga, ds);
}
+ svga->hud.num_state_objects++;
+
return ds;
}
}
FREE(depth_stencil);
+ svga->hud.num_state_objects--;
}
enum pipe_error ret = 0;
boolean needed_swtnl;
- svga->num_draw_calls++; /* for SVGA_QUERY_DRAW_CALLS */
+ svga->hud.num_draw_calls++; /* for SVGA_QUERY_NUM_DRAW_CALLS */
if (u_reduced_prim(info->mode) == PIPE_PRIM_TRIANGLES &&
svga->curr.rast->templ.cull_face == PIPE_FACE_FRONT_AND_BACK)
#endif
if (svga->state.sw.need_swtnl) {
- svga->num_fallbacks++; /* for SVGA_QUERY_FALLBACKS */
+ svga->hud.num_fallbacks++; /* for SVGA_QUERY_NUM_FALLBACKS */
if (!needed_swtnl) {
/*
* We're switching from HW to SW TNL. SW TNL will require mapping all
define_query_vgpu10(svga, sq,
sizeof(SVGADXTimestampQueryResult));
break;
- case SVGA_QUERY_DRAW_CALLS:
- case SVGA_QUERY_FALLBACKS:
+ case SVGA_QUERY_NUM_DRAW_CALLS:
+ case SVGA_QUERY_NUM_FALLBACKS:
+ case SVGA_QUERY_NUM_FLUSHES:
case SVGA_QUERY_MEMORY_USED:
+ case SVGA_QUERY_NUM_SHADERS:
+ case SVGA_QUERY_NUM_RESOURCES:
+ case SVGA_QUERY_NUM_STATE_OBJECTS:
+ case SVGA_QUERY_NUM_VALIDATIONS:
+ case SVGA_QUERY_MAP_BUFFER_TIME:
+ case SVGA_QUERY_NUM_SURFACE_VIEWS:
+ case SVGA_QUERY_NUM_RESOURCES_MAPPED:
break;
default:
assert(!"unexpected query type in svga_create_query()");
destroy_query_vgpu10(svga, sq);
sws->fence_reference(sws, &sq->fence, NULL);
break;
- case SVGA_QUERY_DRAW_CALLS:
- case SVGA_QUERY_FALLBACKS:
+ case SVGA_QUERY_NUM_DRAW_CALLS:
+ case SVGA_QUERY_NUM_FALLBACKS:
+ case SVGA_QUERY_NUM_FLUSHES:
case SVGA_QUERY_MEMORY_USED:
+ case SVGA_QUERY_NUM_SHADERS:
+ case SVGA_QUERY_NUM_RESOURCES:
+ case SVGA_QUERY_NUM_STATE_OBJECTS:
+ case SVGA_QUERY_NUM_VALIDATIONS:
+ case SVGA_QUERY_MAP_BUFFER_TIME:
+ case SVGA_QUERY_NUM_SURFACE_VIEWS:
+ case SVGA_QUERY_NUM_RESOURCES_MAPPED:
/* nothing */
break;
default:
ret = begin_query_vgpu10(svga, sq);
assert(ret == PIPE_OK);
break;
- case SVGA_QUERY_DRAW_CALLS:
- sq->begin_count = svga->num_draw_calls;
+ case SVGA_QUERY_NUM_DRAW_CALLS:
+ sq->begin_count = svga->hud.num_draw_calls;
break;
- case SVGA_QUERY_FALLBACKS:
- sq->begin_count = svga->num_fallbacks;
+ case SVGA_QUERY_NUM_FALLBACKS:
+ sq->begin_count = svga->hud.num_fallbacks;
+ break;
+ case SVGA_QUERY_NUM_FLUSHES:
+ sq->begin_count = svga->hud.num_flushes;
+ break;
+ case SVGA_QUERY_NUM_VALIDATIONS:
+ sq->begin_count = svga->hud.num_validations;
+ break;
+ case SVGA_QUERY_MAP_BUFFER_TIME:
+ sq->begin_count = svga->hud.map_buffer_time;
+ break;
+ case SVGA_QUERY_NUM_RESOURCES_MAPPED:
+ sq->begin_count = svga->hud.num_resources_mapped;
break;
case SVGA_QUERY_MEMORY_USED:
+ case SVGA_QUERY_NUM_SHADERS:
+ case SVGA_QUERY_NUM_RESOURCES:
+ case SVGA_QUERY_NUM_STATE_OBJECTS:
+ case SVGA_QUERY_NUM_SURFACE_VIEWS:
/* nothing */
break;
default:
ret = end_query_vgpu10(svga, sq);
assert(ret == PIPE_OK);
break;
- case SVGA_QUERY_DRAW_CALLS:
- sq->end_count = svga->num_draw_calls;
+ case SVGA_QUERY_NUM_DRAW_CALLS:
+ sq->end_count = svga->hud.num_draw_calls;
+ break;
+ case SVGA_QUERY_NUM_FALLBACKS:
+ sq->end_count = svga->hud.num_fallbacks;
+ break;
+ case SVGA_QUERY_NUM_FLUSHES:
+ sq->end_count = svga->hud.num_flushes;
break;
- case SVGA_QUERY_FALLBACKS:
- sq->end_count = svga->num_fallbacks;
+ case SVGA_QUERY_NUM_VALIDATIONS:
+ sq->end_count = svga->hud.num_validations;
+ break;
+ case SVGA_QUERY_MAP_BUFFER_TIME:
+ sq->end_count = svga->hud.map_buffer_time;
+ break;
+ case SVGA_QUERY_NUM_RESOURCES_MAPPED:
+ sq->end_count = svga->hud.num_resources_mapped;
break;
case SVGA_QUERY_MEMORY_USED:
+ case SVGA_QUERY_NUM_SHADERS:
+ case SVGA_QUERY_NUM_RESOURCES:
+ case SVGA_QUERY_NUM_STATE_OBJECTS:
+ case SVGA_QUERY_NUM_SURFACE_VIEWS:
/* nothing */
break;
default:
*result = (uint64_t)sResult.numPrimitivesWritten;
break;
}
- case SVGA_QUERY_DRAW_CALLS:
- /* fall-through */
- case SVGA_QUERY_FALLBACKS:
+ /* These are per-frame counters */
+ case SVGA_QUERY_NUM_DRAW_CALLS:
+ case SVGA_QUERY_NUM_FALLBACKS:
+ case SVGA_QUERY_NUM_FLUSHES:
+ case SVGA_QUERY_NUM_VALIDATIONS:
+ case SVGA_QUERY_NUM_RESOURCES_MAPPED:
+ case SVGA_QUERY_MAP_BUFFER_TIME:
vresult->u64 = sq->end_count - sq->begin_count;
break;
+ /* These are running total counters */
case SVGA_QUERY_MEMORY_USED:
- vresult->u64 = svgascreen->total_resource_bytes;
+ vresult->u64 = svgascreen->hud.total_resource_bytes;
+ break;
+ case SVGA_QUERY_NUM_SHADERS:
+ vresult->u64 = svga->hud.num_shaders;
+ break;
+ case SVGA_QUERY_NUM_RESOURCES:
+ vresult->u64 = svgascreen->hud.num_resources;
+ break;
+ case SVGA_QUERY_NUM_STATE_OBJECTS:
+ vresult->u64 = svga->hud.num_state_objects;
+ break;
+ case SVGA_QUERY_NUM_SURFACE_VIEWS:
+ vresult->u64 = svga->hud.num_surface_views;
break;
default:
assert(!"unexpected query type in svga_get_query_result");
define_rasterizer_object(svga, rast);
}
+ svga->hud.num_state_objects++;
+
return rast;
}
}
FREE(state);
+ svga->hud.num_state_objects--;
}
cso->min_lod, cso->view_min_lod, cso->view_max_lod,
cso->mipfilter == SVGA3D_TEX_FILTER_NONE ? "SVGA3D_TEX_FILTER_NONE" : "SOMETHING");
+ svga->hud.num_state_objects++;
+
return cso;
}
}
FREE(sampler);
+ svga->hud.num_state_objects--;
}
translate_vertex_decls(svga, velems);
}
}
+
+ svga->hud.num_state_objects++;
+
return velems;
}
}
FREE(velems);
+ svga->hud.num_state_objects--;
}
void svga_cleanup_vertex_state( struct svga_context *svga )
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "os/os_thread.h"
+#include "os/os_time.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_resource.h"
struct svga_buffer *sbuf = svga_buffer(resource);
struct pipe_transfer *transfer;
uint8_t *map;
+ int64_t begin = os_time_get();
transfer = CALLOC_STRUCT(pipe_transfer);
if (transfer == NULL) {
FREE(transfer);
}
+ svga->hud.map_buffer_time += (os_time_get() - begin);
+ svga->hud.num_resources_mapped++;
+
return map;
}
if (sbuf->swbuf && !sbuf->user)
align_free(sbuf->swbuf);
- ss->total_resource_bytes -= sbuf->size;
+ ss->hud.total_resource_bytes -= sbuf->size;
+ assert(ss->hud.num_resources > 0);
+ if (ss->hud.num_resources > 0)
+ ss->hud.num_resources--;
FREE(sbuf);
}
(debug_reference_descriptor)debug_describe_resource, 0);
sbuf->size = util_resource_size(&sbuf->b.b);
- ss->total_resource_bytes += sbuf->size;
+ ss->hud.total_resource_bytes += sbuf->size;
+
+ ss->hud.num_resources++;
return &sbuf->b.b;
unsigned bind)
{
struct svga_buffer *sbuf;
+ struct svga_screen *ss = svga_screen(screen);
sbuf = CALLOC_STRUCT(svga_buffer);
if (!sbuf)
debug_reference(&sbuf->b.b.reference,
(debug_reference_descriptor)debug_describe_resource, 0);
+ ss->hud.num_resources++;
+
return &sbuf->b.b;
no_sbuf:
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "os/os_thread.h"
+#include "os/os_time.h"
#include "util/u_format.h"
#include "util/u_inlines.h"
#include "util/u_math.h"
SVGA_DBG(DEBUG_DMA, "unref sid %p (texture)\n", tex->handle);
svga_screen_surface_destroy(ss, &tex->key, &tex->handle);
- ss->total_resource_bytes -= tex->size;
+ ss->hud.total_resource_bytes -= tex->size;
FREE(tex->defined);
FREE(tex->rendered_to);
FREE(tex);
+
+ assert(ss->hud.num_resources > 0);
+ if (ss->hud.num_resources > 0)
+ ss->hud.num_resources--;
}
boolean use_direct_map = svga_have_gb_objects(svga) &&
!svga_have_gb_dma(svga);
unsigned d;
+ void *returnVal;
+ int64_t begin = os_time_get();
/* We can't map texture storage directly unless we have GB objects */
if (usage & PIPE_TRANSFER_MAP_DIRECTLY) {
* Begin mapping code
*/
if (st->swbuf) {
- return st->swbuf;
+ returnVal = st->swbuf;
}
else if (!st->use_direct_map) {
- return sws->buffer_map(sws, st->hwbuf, usage);
+ returnVal = sws->buffer_map(sws, st->hwbuf, usage);
}
else {
SVGA3dSize baseLevelSize;
offset += svga3dsurface_get_pixel_offset(tex->key.format,
mip_width, mip_height,
xoffset, yoffset, zoffset);
-
- return (void *) (map + offset);
+ returnVal = (void *) (map + offset);
}
+
+ svga->hud.map_buffer_time += (os_time_get() - begin);
+ svga->hud.num_resources_mapped++;
+
+ return returnVal;
}
(debug_reference_descriptor)debug_describe_resource, 0);
tex->size = util_resource_size(template);
- svgascreen->total_resource_bytes += tex->size;
+ svgascreen->hud.total_resource_bytes += tex->size;
+ svgascreen->hud.num_resources++;
return &tex->b.b;
}
struct winsys_handle *whandle)
{
struct svga_winsys_screen *sws = svga_winsys_screen(screen);
+ struct svga_screen *ss = svga_screen(screen);
struct svga_winsys_surface *srf;
struct svga_texture *tex;
enum SVGA3dSurfaceFormat format = 0;
tex->rendered_to = CALLOC(1, sizeof(tex->rendered_to[0]));
tex->imported = TRUE;
+ ss->hud.num_resources++;
+
return &tex->b.b;
}
struct pipe_driver_query_info *info)
{
static const struct pipe_driver_query_info queries[] = {
- {"draw-calls", SVGA_QUERY_DRAW_CALLS, {0}},
- {"fallbacks", SVGA_QUERY_FALLBACKS, {0}},
- {"memory-used", SVGA_QUERY_MEMORY_USED, {0}, PIPE_DRIVER_QUERY_TYPE_BYTES}
+ /* per-frame counters */
+ {"num-draw-calls", SVGA_QUERY_NUM_DRAW_CALLS, {0}},
+ {"num-fallbacks", SVGA_QUERY_NUM_FALLBACKS, {0}},
+ {"num-flushes", SVGA_QUERY_NUM_FLUSHES, {0}},
+ {"num-validations", SVGA_QUERY_NUM_VALIDATIONS, {0}},
+ {"map-buffer-time", SVGA_QUERY_MAP_BUFFER_TIME, {0},
+ PIPE_DRIVER_QUERY_TYPE_MICROSECONDS},
+ {"num-resources-mapped", SVGA_QUERY_NUM_RESOURCES_MAPPED, {0}},
+
+ /* running total counters */
+ {"memory-used", SVGA_QUERY_MEMORY_USED, {0},
+ PIPE_DRIVER_QUERY_TYPE_BYTES},
+ {"num-shaders", SVGA_QUERY_NUM_SHADERS, {0}},
+ {"num-resources", SVGA_QUERY_NUM_RESOURCES, {0}},
+ {"num-state-objects", SVGA_QUERY_NUM_STATE_OBJECTS, {0}},
+ {"num-surface-views", SVGA_QUERY_NUM_SURFACE_VIEWS, {0}},
};
if (!info)
struct svga_host_surface_cache cache;
- /** Memory used by all resources (buffers and surfaces) */
- uint64_t total_resource_bytes;
+ /** HUD counters */
+ struct {
+ /** Memory used by all resources (buffers and surfaces) */
+ uint64_t total_resource_bytes;
+ uint64_t num_resources;
+ } hud;
};
#ifndef DEBUG
struct svga_shader_variant *
svga_new_shader_variant(struct svga_context *svga)
{
+ svga->hud.num_shaders++;
return CALLOC_STRUCT(svga_shader_variant);
}
FREE((unsigned *)variant->tokens);
FREE(variant);
+ svga->hud.num_shaders--;
+
return ret;
}
svga->state.dirty[i] |= svga->dirty;
svga->dirty = 0;
+
+ svga->hud.num_validations++;
+
return PIPE_OK;
}
s->real_level = surf_tmpl->u.tex.level;
}
+ svga->hud.num_surface_views++;
+
return &s->base;
}
pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
+
+ svga->hud.num_surface_views--;
}