diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/nouveau/Makefile.sources | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 69 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_query.h | 58 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.c | 98 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.h | 61 |
5 files changed, 204 insertions, 84 deletions
diff --git a/src/gallium/drivers/nouveau/Makefile.sources b/src/gallium/drivers/nouveau/Makefile.sources index 350837cd694..0e1cb19bed7 100644 --- a/src/gallium/drivers/nouveau/Makefile.sources +++ b/src/gallium/drivers/nouveau/Makefile.sources @@ -152,6 +152,8 @@ NVC0_C_SOURCES := \ nvc0/nvc0_program.h \ nvc0/nvc0_query.c \ nvc0/nvc0_query.h \ + nvc0/nvc0_query_sw.c \ + nvc0/nvc0_query_sw.h \ nvc0/nvc0_resource.c \ nvc0/nvc0_resource.h \ nvc0/nvc0_screen.c \ diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index 69e9cdb8714..9409bdea81f 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -26,6 +26,7 @@ #include "nvc0/nvc0_context.h" #include "nvc0/nvc0_query.h" +#include "nvc0/nvc0_query_sw.h" #include "nv_object.xml.h" #include "nvc0/nve4_compute.xml.h" @@ -52,16 +53,16 @@ nvc0_query_allocate(struct nvc0_context *nvc0, struct nvc0_query *q, int size) if (q->bo) { nouveau_bo_ref(NULL, &q->bo); - if (q->u.mm) { + if (q->mm) { if (q->state == NVC0_QUERY_STATE_READY) - nouveau_mm_free(q->u.mm); + nouveau_mm_free(q->mm); else nouveau_fence_work(screen->base.fence.current, - nouveau_mm_free_work, q->u.mm); + nouveau_mm_free_work, q->mm); } } if (size) { - q->u.mm = nouveau_mm_allocate(screen->base.mm_GART, size, &q->bo, &q->base); + q->mm = nouveau_mm_allocate(screen->base.mm_GART, size, &q->bo, &q->base); if (!q->bo) return false; q->offset = q->base; @@ -91,6 +92,10 @@ nvc0_query_create(struct pipe_context *pipe, unsigned type, unsigned index) struct nvc0_query *q; unsigned space = NVC0_QUERY_ALLOC_SPACE; + q = nvc0_sw_create_query(nvc0, type, index); + if (q) + return (struct pipe_query *)q; + q = CALLOC_STRUCT(nvc0_query); if (!q) return NULL; @@ -126,14 +131,6 @@ nvc0_query_create(struct pipe_context *pipe, unsigned type, unsigned index) space = 16; break; default: -#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - if (type >= NVC0_QUERY_DRV_STAT(0) && type <= NVC0_QUERY_DRV_STAT_LAST) { - space = 0; - q->is64bit = true; - q->index = type - NVC0_QUERY_DRV_STAT(0); - break; - } else -#endif if (nvc0->screen->base.device->drm_version >= 0x01000101) { if (type >= NVE4_HW_SM_QUERY(0) && type <= NVE4_HW_SM_QUERY_LAST) { /* for each MP: @@ -295,12 +292,9 @@ nvc0_query_begin(struct pipe_context *pipe, struct pipe_query *pq) break; default: #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - if (q->type >= NVC0_QUERY_DRV_STAT(0) && - q->type <= NVC0_QUERY_DRV_STAT_LAST) { - if (q->index >= 5) - q->u.value = nvc0->screen->base.stats.v[q->index]; - else - q->u.value = 0; + if (q->type >= NVC0_SW_QUERY_DRV_STAT(0) && + q->type <= NVC0_SW_QUERY_DRV_STAT_LAST) { + return q->funcs->begin_query(nvc0, q); } else #endif if ((q->type >= NVE4_HW_SM_QUERY(0) && q->type <= NVE4_HW_SM_QUERY_LAST) || @@ -382,9 +376,9 @@ nvc0_query_end(struct pipe_context *pipe, struct pipe_query *pq) break; default: #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - if (q->type >= NVC0_QUERY_DRV_STAT(0) && - q->type <= NVC0_QUERY_DRV_STAT_LAST) { - q->u.value = nvc0->screen->base.stats.v[q->index] - q->u.value; + if (q->type >= NVC0_SW_QUERY_DRV_STAT(0) && + q->type <= NVC0_SW_QUERY_DRV_STAT_LAST) { + q->funcs->end_query(nvc0, q); return; } else #endif @@ -423,10 +417,9 @@ nvc0_query_result(struct pipe_context *pipe, struct pipe_query *pq, unsigned i; #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - if (q->type >= NVC0_QUERY_DRV_STAT(0) && - q->type <= NVC0_QUERY_DRV_STAT_LAST) { - res64[0] = q->u.value; - return true; + if (q->type >= NVC0_SW_QUERY_DRV_STAT(0) && + q->type <= NVC0_SW_QUERY_DRV_STAT_LAST) { + return q->funcs->get_query_result(nvc0, q, wait, result); } else #endif if ((q->type >= NVE4_HW_SM_QUERY(0) && q->type <= NVE4_HW_SM_QUERY_LAST) || @@ -600,7 +593,7 @@ nvc0_query_pushbuf_submit(struct nouveau_pushbuf *push, #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS -static const char *nvc0_drv_stat_names[] = +static const char *nvc0_sw_query_drv_stat_names[] = { "drv-tex_obj_current_count", "drv-tex_obj_current_bytes", @@ -1357,7 +1350,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, struct nvc0_screen *screen = nvc0_screen(pscreen); int count = 0; - count += NVC0_QUERY_DRV_STAT_COUNT; + count += NVC0_SW_QUERY_DRV_STAT_COUNT; if (screen->base.device->drm_version >= 0x01000101) { if (screen->compute) { @@ -1382,29 +1375,29 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, info->group_id = -1; #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - if (id < NVC0_QUERY_DRV_STAT_COUNT) { - info->name = nvc0_drv_stat_names[id]; - info->query_type = NVC0_QUERY_DRV_STAT(id); + if (id < NVC0_SW_QUERY_DRV_STAT_COUNT) { + info->name = nvc0_sw_query_drv_stat_names[id]; + info->query_type = NVC0_SW_QUERY_DRV_STAT(id); info->max_value.u64 = 0; if (strstr(info->name, "bytes")) info->type = PIPE_DRIVER_QUERY_TYPE_BYTES; - info->group_id = NVC0_QUERY_DRV_STAT_GROUP; + info->group_id = NVC0_SW_QUERY_DRV_STAT_GROUP; return 1; } else #endif if (id < count) { if (screen->compute) { if (screen->base.class_3d == NVE4_3D_CLASS) { - info->name = nve4_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; - info->query_type = NVE4_HW_SM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); + info->name = nve4_pm_query_names[id - NVC0_SW_QUERY_DRV_STAT_COUNT]; + info->query_type = NVE4_HW_SM_QUERY(id - NVC0_SW_QUERY_DRV_STAT_COUNT); info->max_value.u64 = (id < NVE4_HW_SM_QUERY_METRIC_MP_OCCUPANCY) ? 0 : 100; info->group_id = NVC0_QUERY_MP_COUNTER_GROUP; return 1; } else if (screen->base.class_3d < NVE4_3D_CLASS) { - info->name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; - info->query_type = NVC0_HW_SM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); + info->name = nvc0_pm_query_names[id - NVC0_SW_QUERY_DRV_STAT_COUNT]; + info->query_type = NVC0_HW_SM_QUERY(id - NVC0_SW_QUERY_DRV_STAT_COUNT); info->group_id = NVC0_QUERY_MP_COUNTER_GROUP; return 1; } @@ -1466,11 +1459,11 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen, } } #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - else if (id == NVC0_QUERY_DRV_STAT_GROUP) { + else if (id == NVC0_SW_QUERY_DRV_STAT_GROUP) { info->name = "Driver statistics"; info->type = PIPE_DRIVER_QUERY_GROUP_TYPE_CPU; - info->max_active_queries = NVC0_QUERY_DRV_STAT_COUNT; - info->num_queries = NVC0_QUERY_DRV_STAT_COUNT; + info->max_active_queries = NVC0_SW_QUERY_DRV_STAT_COUNT; + info->num_queries = NVC0_SW_QUERY_DRV_STAT_COUNT; return 1; } #endif diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.h b/src/gallium/drivers/nouveau/nvc0/nvc0_query.h index 65240a125b7..dfb2fe3c749 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.h @@ -9,8 +9,18 @@ #define NVC0_QUERY_TFB_BUFFER_OFFSET (PIPE_QUERY_TYPES + 0) struct nvc0_context; +struct nvc0_query; + +struct nvc0_query_funcs { + void (*destroy_query)(struct nvc0_context *, struct nvc0_query *); + boolean (*begin_query)(struct nvc0_context *, struct nvc0_query *); + void (*end_query)(struct nvc0_context *, struct nvc0_query *); + boolean (*get_query_result)(struct nvc0_context *, struct nvc0_query *, + boolean, union pipe_query_result *); +}; struct nvc0_query { + const struct nvc0_query_funcs *funcs; uint32_t *data; uint16_t type; uint16_t index; @@ -23,10 +33,7 @@ struct nvc0_query { boolean is64bit; uint8_t rotate; int nesting; /* only used for occlusion queries */ - union { - struct nouveau_mm_allocation *mm; - uint64_t value; - } u; + struct nouveau_mm_allocation *mm; struct nouveau_fence *fence; }; @@ -40,7 +47,7 @@ nvc0_query(struct pipe_query *pipe) * Driver queries groups: */ #define NVC0_QUERY_MP_COUNTER_GROUP 0 -#define NVC0_QUERY_DRV_STAT_GROUP 1 +#define NVC0_SW_QUERY_DRV_STAT_GROUP 1 /* * Performance counter queries: @@ -139,47 +146,6 @@ enum nvc0_pm_queries NVC0_HW_SM_QUERY_COUNT }; -/* - * Driver statistics queries: - */ -#define NVC0_QUERY_DRV_STAT(i) (PIPE_QUERY_DRIVER_SPECIFIC + 1024 + (i)) -#define NVC0_QUERY_DRV_STAT_LAST NVC0_QUERY_DRV_STAT(NVC0_QUERY_DRV_STAT_COUNT - 1) -enum nvc0_drv_stats_queries -{ -#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - NVC0_QUERY_DRV_STAT_TEX_OBJECT_CURRENT_COUNT = 0, - NVC0_QUERY_DRV_STAT_TEX_OBJECT_CURRENT_BYTES, - NVC0_QUERY_DRV_STAT_BUF_OBJECT_CURRENT_COUNT, - NVC0_QUERY_DRV_STAT_BUF_OBJECT_CURRENT_BYTES_VID, - NVC0_QUERY_DRV_STAT_BUF_OBJECT_CURRENT_BYTES_SYS, - NVC0_QUERY_DRV_STAT_TEX_TRANSFERS_READ, - NVC0_QUERY_DRV_STAT_TEX_TRANSFERS_WRITE, - NVC0_QUERY_DRV_STAT_TEX_COPY_COUNT, - NVC0_QUERY_DRV_STAT_TEX_BLIT_COUNT, - NVC0_QUERY_DRV_STAT_TEX_CACHE_FLUSH_COUNT, - NVC0_QUERY_DRV_STAT_BUF_TRANSFERS_READ, - NVC0_QUERY_DRV_STAT_BUF_TRANSFERS_WRITE, - NVC0_QUERY_DRV_STAT_BUF_READ_BYTES_STAGING_VID, - NVC0_QUERY_DRV_STAT_BUF_WRITE_BYTES_DIRECT, - NVC0_QUERY_DRV_STAT_BUF_WRITE_BYTES_STAGING_VID, - NVC0_QUERY_DRV_STAT_BUF_WRITE_BYTES_STAGING_SYS, - NVC0_QUERY_DRV_STAT_BUF_COPY_BYTES, - NVC0_QUERY_DRV_STAT_BUF_NON_KERNEL_FENCE_SYNC_COUNT, - NVC0_QUERY_DRV_STAT_ANY_NON_KERNEL_FENCE_SYNC_COUNT, - NVC0_QUERY_DRV_STAT_QUERY_SYNC_COUNT, - NVC0_QUERY_DRV_STAT_GPU_SERIALIZE_COUNT, - NVC0_QUERY_DRV_STAT_DRAW_CALLS_ARRAY, - NVC0_QUERY_DRV_STAT_DRAW_CALLS_INDEXED, - NVC0_QUERY_DRV_STAT_DRAW_CALLS_FALLBACK_COUNT, - NVC0_QUERY_DRV_STAT_USER_BUFFER_UPLOAD_BYTES, - NVC0_QUERY_DRV_STAT_CONSTBUF_UPLOAD_COUNT, - NVC0_QUERY_DRV_STAT_CONSTBUF_UPLOAD_BYTES, - NVC0_QUERY_DRV_STAT_PUSHBUF_COUNT, - NVC0_QUERY_DRV_STAT_RESOURCE_VALIDATE_COUNT, -#endif - NVC0_QUERY_DRV_STAT_COUNT -}; - void nvc0_init_query_functions(struct nvc0_context *); void nvc0_query_pushbuf_submit(struct nouveau_pushbuf *, struct nvc0_query *, unsigned); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.c new file mode 100644 index 00000000000..5f33b1e019a --- /dev/null +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.c @@ -0,0 +1,98 @@ +/* + * Copyright 2011 Christoph Bumiller + * Copyright 2015 Samuel Pitoiset + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "nvc0/nvc0_context.h" + +#include "nvc0_query_sw.h" + +static void +nvc0_sw_destroy_query(struct nvc0_context *nvc0, struct nvc0_query *q) +{ + struct nvc0_sw_query *sq = nvc0_sw_query(q); + FREE(sq); +} + +static boolean +nvc0_sw_begin_query(struct nvc0_context *nvc0, struct nvc0_query *q) +{ +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + struct nvc0_sw_query *sq = nvc0_sw_query(q); + + if (q->index >= 5) { + sq->value = nvc0->screen->base.stats.v[q->index]; + } else { + sq->value = 0; + } +#endif + return true; +} + +static void +nvc0_sw_end_query(struct nvc0_context *nvc0, struct nvc0_query *q) +{ +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + struct nvc0_sw_query *sq = nvc0_sw_query(q); + sq->value = nvc0->screen->base.stats.v[q->index] - sq->value; +#endif +} + +static boolean +nvc0_sw_get_query_result(struct nvc0_context *nvc0, struct nvc0_query *q, + boolean wait, union pipe_query_result *result) +{ +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + struct nvc0_sw_query *sq = nvc0_sw_query(q); + uint64_t *res64 = (uint64_t *)result; + + res64[0] = sq->value; +#endif + return true; +} + +static const struct nvc0_query_funcs sw_query_funcs = { + .destroy_query = nvc0_sw_destroy_query, + .begin_query = nvc0_sw_begin_query, + .end_query = nvc0_sw_end_query, + .get_query_result = nvc0_sw_get_query_result, +}; + +struct nvc0_query * +nvc0_sw_create_query(struct nvc0_context *nvcO, unsigned type, unsigned index) +{ + struct nvc0_sw_query *sq; + struct nvc0_query *q; + + if (type < NVC0_SW_QUERY_DRV_STAT(0) || type > NVC0_SW_QUERY_DRV_STAT_LAST) + return NULL; + + sq = CALLOC_STRUCT(nvc0_sw_query); + if (!sq) + return NULL; + + q = &sq->base; + q->funcs = &sw_query_funcs; + q->type = type; + q->index = type - NVC0_SW_QUERY_DRV_STAT(0); + + return q; +} diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.h b/src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.h new file mode 100644 index 00000000000..71d23d9b41e --- /dev/null +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.h @@ -0,0 +1,61 @@ +#ifndef __NVC0_QUERY_SW_H__ +#define __NVC0_QUERY_SW_H__ + +#include "nvc0_query.h" + +struct nvc0_sw_query { + struct nvc0_query base; + uint64_t value; +}; + +static inline struct nvc0_sw_query * +nvc0_sw_query(struct nvc0_query *q) +{ + return (struct nvc0_sw_query *)q; +} + +/* + * Driver statistics queries: + */ +#define NVC0_SW_QUERY_DRV_STAT(i) (PIPE_QUERY_DRIVER_SPECIFIC + 1024 + (i)) +#define NVC0_SW_QUERY_DRV_STAT_LAST NVC0_SW_QUERY_DRV_STAT(NVC0_SW_QUERY_DRV_STAT_COUNT - 1) +enum nvc0_sw_query_drv_stat +{ +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + NVC0_SW_QUERY_DRV_STAT_TEX_OBJECT_CURRENT_COUNT = 0, + NVC0_SW_QUERY_DRV_STAT_TEX_OBJECT_CURRENT_BYTES, + NVC0_SW_QUERY_DRV_STAT_BUF_OBJECT_CURRENT_COUNT, + NVC0_SW_QUERY_DRV_STAT_BUF_OBJECT_CURRENT_BYTES_VID, + NVC0_SW_QUERY_DRV_STAT_BUF_OBJECT_CURRENT_BYTES_SYS, + NVC0_SW_QUERY_DRV_STAT_TEX_TRANSFERS_READ, + NVC0_SW_QUERY_DRV_STAT_TEX_TRANSFERS_WRITE, + NVC0_SW_QUERY_DRV_STAT_TEX_COPY_COUNT, + NVC0_SW_QUERY_DRV_STAT_TEX_BLIT_COUNT, + NVC0_SW_QUERY_DRV_STAT_TEX_CACHE_FLUSH_COUNT, + NVC0_SW_QUERY_DRV_STAT_BUF_TRANSFERS_READ, + NVC0_SW_QUERY_DRV_STAT_BUF_TRANSFERS_WRITE, + NVC0_SW_QUERY_DRV_STAT_BUF_READ_BYTES_STAGING_VID, + NVC0_SW_QUERY_DRV_STAT_BUF_WRITE_BYTES_DIRECT, + NVC0_SW_QUERY_DRV_STAT_BUF_WRITE_BYTES_STAGING_VID, + NVC0_SW_QUERY_DRV_STAT_BUF_WRITE_BYTES_STAGING_SYS, + NVC0_SW_QUERY_DRV_STAT_BUF_COPY_BYTES, + NVC0_SW_QUERY_DRV_STAT_BUF_NON_KERNEL_FENCE_SYNC_COUNT, + NVC0_SW_QUERY_DRV_STAT_ANY_NON_KERNEL_FENCE_SYNC_COUNT, + NVC0_SW_QUERY_DRV_STAT_QUERY_SYNC_COUNT, + NVC0_SW_QUERY_DRV_STAT_GPU_SERIALIZE_COUNT, + NVC0_SW_QUERY_DRV_STAT_DRAW_CALLS_ARRAY, + NVC0_SW_QUERY_DRV_STAT_DRAW_CALLS_INDEXED, + NVC0_SW_QUERY_DRV_STAT_DRAW_CALLS_FALLBACK_COUNT, + NVC0_SW_QUERY_DRV_STAT_USER_BUFFER_UPLOAD_BYTES, + NVC0_SW_QUERY_DRV_STAT_CONSTBUF_UPLOAD_COUNT, + NVC0_SW_QUERY_DRV_STAT_CONSTBUF_UPLOAD_BYTES, + NVC0_SW_QUERY_DRV_STAT_PUSHBUF_COUNT, + NVC0_SW_QUERY_DRV_STAT_RESOURCE_VALIDATE_COUNT, +#endif + NVC0_SW_QUERY_DRV_STAT_COUNT +}; + +struct nvc0_query * +nvc0_sw_create_query(struct nvc0_context *, unsigned, unsigned); + +#endif |