diff options
author | Christoph Bumiller <[email protected]> | 2013-03-29 16:30:58 +0100 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2013-04-03 12:54:43 +0200 |
commit | 198f514aa6f08bc43a3002519843b0fe94f340bd (patch) | |
tree | 1f9a3038e554dceadcd27ddc1b829815206f7432 /src/gallium/drivers/nouveau | |
parent | 7628cc247feecfb31aff97f47f039ebe476f0ca8 (diff) |
nvc0: add some driver statistics queries
Diffstat (limited to 'src/gallium/drivers/nouveau')
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_buffer.c | 30 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_fence.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_screen.h | 55 |
3 files changed, 87 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c index e3cbaf60a25..5c9a44e368a 100644 --- a/src/gallium/drivers/nouveau/nouveau_buffer.c +++ b/src/gallium/drivers/nouveau/nouveau_buffer.c @@ -51,12 +51,14 @@ nouveau_buffer_allocate(struct nouveau_screen *screen, &buf->bo, &buf->offset); if (!buf->bo) return nouveau_buffer_allocate(screen, buf, NOUVEAU_BO_GART); + NOUVEAU_DRV_STAT(screen, buf_obj_current_bytes_vid, buf->base.width0); } else if (domain == NOUVEAU_BO_GART) { buf->mm = nouveau_mm_allocate(screen->mm_GART, size, &buf->bo, &buf->offset); if (!buf->bo) return FALSE; + NOUVEAU_DRV_STAT(screen, buf_obj_current_bytes_sys, buf->base.width0); } else { assert(domain == 0); if (!nouveau_buffer_malloc(buf)) @@ -85,6 +87,11 @@ nouveau_buffer_release_gpu_storage(struct nv04_resource *buf) if (buf->mm) release_allocation(&buf->mm, buf->fence); + if (buf->domain == NOUVEAU_BO_VRAM) + NOUVEAU_DRV_STAT_RES(buf, buf_obj_current_bytes_vid, -(uint64_t)buf->base.width0); + if (buf->domain == NOUVEAU_BO_GART) + NOUVEAU_DRV_STAT_RES(buf, buf_obj_current_bytes_sys, -(uint64_t)buf->base.width0); + buf->domain = 0; } @@ -117,6 +124,8 @@ nouveau_buffer_destroy(struct pipe_screen *pscreen, nouveau_fence_ref(NULL, &res->fence_wr); FREE(res); + + NOUVEAU_DRV_STAT(nouveau_screen(pscreen), buf_obj_current_count, -1); } static uint8_t * @@ -153,6 +162,8 @@ nouveau_transfer_read(struct nouveau_context *nv, struct nouveau_transfer *tx) const unsigned base = tx->base.box.x; const unsigned size = tx->base.box.width; + NOUVEAU_DRV_STAT(nv->screen, buf_read_bytes_staging_vid, size); + nv->copy_data(nv, tx->bo, tx->offset, NOUVEAU_BO_GART, buf->bo, buf->offset + base, buf->domain, size); @@ -179,6 +190,11 @@ nouveau_transfer_write(struct nouveau_context *nv, struct nouveau_transfer *tx, else buf->status |= NOUVEAU_BUFFER_STATUS_DIRTY; + if (buf->domain == NOUVEAU_BO_VRAM) + NOUVEAU_DRV_STAT(nv->screen, buf_write_bytes_staging_vid, size); + if (buf->domain == NOUVEAU_BO_GART) + NOUVEAU_DRV_STAT(nv->screen, buf_write_bytes_staging_sys, size); + if (tx->bo) nv->copy_data(nv, buf->bo, buf->offset + base, buf->domain, tx->bo, tx->offset + offset, NOUVEAU_BO_GART, size); @@ -197,11 +213,15 @@ nouveau_buffer_sync(struct nv04_resource *buf, unsigned rw) if (rw == PIPE_TRANSFER_READ) { if (!buf->fence_wr) return TRUE; + NOUVEAU_DRV_STAT_RES(buf, buf_non_kernel_fence_sync_count, + !nouveau_fence_signalled(buf->fence_wr)); if (!nouveau_fence_wait(buf->fence_wr)) return FALSE; } else { if (!buf->fence) return TRUE; + NOUVEAU_DRV_STAT_RES(buf, buf_non_kernel_fence_sync_count, + !nouveau_fence_signalled(buf->fence)); if (!nouveau_fence_wait(buf->fence)) return FALSE; @@ -320,6 +340,11 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe, nouveau_buffer_transfer_init(tx, resource, box, usage); *ptransfer = &tx->base; + if (usage & PIPE_TRANSFER_READ) + NOUVEAU_DRV_STAT(nv->screen, buf_transfers_rd, 1); + if (usage & PIPE_TRANSFER_WRITE) + NOUVEAU_DRV_STAT(nv->screen, buf_transfers_wr, 1); + if (buf->domain == NOUVEAU_BO_VRAM) { if (usage & NOUVEAU_TRANSFER_DISCARD) { if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) @@ -427,6 +452,9 @@ nouveau_buffer_transfer_unmap(struct pipe_context *pipe, } } + if (!tx->bo && (tx->base.usage & PIPE_TRANSFER_WRITE)) + NOUVEAU_DRV_STAT(nv->screen, buf_write_bytes_direct, tx->base.box.width); + nouveau_buffer_transfer_del(nv, tx); FREE(tx); } @@ -525,6 +553,8 @@ nouveau_buffer_create(struct pipe_screen *pscreen, if (buffer->domain == NOUVEAU_BO_VRAM && screen->hint_buf_keep_sysmem_copy) nouveau_buffer_cache(NULL, buffer); + NOUVEAU_DRV_STAT(screen, buf_obj_current_count, 1); + return &buffer->base; fail: diff --git a/src/gallium/drivers/nouveau/nouveau_fence.c b/src/gallium/drivers/nouveau/nouveau_fence.c index 669aced7815..2a483b09568 100644 --- a/src/gallium/drivers/nouveau/nouveau_fence.c +++ b/src/gallium/drivers/nouveau/nouveau_fence.c @@ -205,6 +205,8 @@ nouveau_fence_wait(struct nouveau_fence *fence) if (fence->state == NOUVEAU_FENCE_STATE_SIGNALLED) return TRUE; + if (!spins) + NOUVEAU_DRV_STAT(screen, any_non_kernel_fence_sync_count, 1); spins++; #ifdef PIPE_OS_UNIX if (!(spins % 8)) /* donate a few cycles */ diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index d5bc8171bb5..7f15d10e11c 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -4,6 +4,10 @@ #include "pipe/p_screen.h" #include "util/u_memory.h" +#ifdef DEBUG +# define NOUVEAU_ENABLE_DRIVER_STATISTICS +#endif + typedef uint32_t u32; typedef uint16_t u16; @@ -44,8 +48,59 @@ struct nouveau_screen { int64_t cpu_gpu_time_delta; boolean hint_buf_keep_sysmem_copy; + +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + union { + uint64_t v[29]; + struct { + uint64_t tex_obj_current_count; + uint64_t tex_obj_current_bytes; + uint64_t buf_obj_current_count; + uint64_t buf_obj_current_bytes_vid; + uint64_t buf_obj_current_bytes_sys; + uint64_t tex_transfers_rd; + uint64_t tex_transfers_wr; + uint64_t tex_copy_count; + uint64_t tex_blit_count; + uint64_t tex_cache_flush_count; + uint64_t buf_transfers_rd; + uint64_t buf_transfers_wr; + uint64_t buf_read_bytes_staging_vid; + uint64_t buf_write_bytes_direct; + uint64_t buf_write_bytes_staging_vid; + uint64_t buf_write_bytes_staging_sys; + uint64_t buf_copy_bytes; + uint64_t buf_non_kernel_fence_sync_count; + uint64_t any_non_kernel_fence_sync_count; + uint64_t query_sync_count; + uint64_t gpu_serialize_count; + uint64_t draw_calls_array; + uint64_t draw_calls_indexed; + uint64_t draw_calls_fallback_count; + uint64_t user_buffer_upload_bytes; + uint64_t constbuf_upload_count; + uint64_t constbuf_upload_bytes; + uint64_t pushbuf_count; + uint64_t resource_validate_count; + } named; + } stats; +#endif }; +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS +# define NOUVEAU_DRV_STAT(s, n, v) do { \ + (s)->stats.named.n += (v); \ + } while(0) +# define NOUVEAU_DRV_STAT_RES(r, n, v) do { \ + nouveau_screen((r)->base.screen)->stats.named.n += (v); \ + } while(0) +# define NOUVEAU_DRV_STAT_IFD(x) x +#else +# define NOUVEAU_DRV_STAT(s, n, v) do { } while(0) +# define NOUVEAU_DRV_STAT_RES(r, n, v) do { } while(0) +# define NOUVEAU_DRV_STAT_IFD(x) +#endif + static INLINE struct nouveau_screen * nouveau_screen(struct pipe_screen *pscreen) { |