1857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs/* 2f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller * Copyright 2011 Nouveau Project 3857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * 4857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 5857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * copy of this software and associated documentation files (the "Software"), 6857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * to deal in the Software without restriction, including without limitation 7857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 9857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * Software is furnished to do so, subject to the following conditions: 10857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * 11857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * The above copyright notice and this permission notice shall be included in 12857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * all copies or substantial portions of the Software. 13857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * 14857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 173d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 183d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 193d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 203d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER DEALINGS IN THE SOFTWARE. 21f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller * 22f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller * Authors: Christoph Bumiller 23857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs */ 24857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs 256d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller#define NV50_PUSH_EXPLICIT_SPACE_CHECKING 266d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller 275eb7ff1175a644ffe3b0f1a75cb235400355f9fbJohannes Obermayr#include "nv50/nv50_context.h" 282e3fe0379edd4c0c2c6e87a53b077d77e5fff24eSamuel Pitoiset#include "nv50/nv50_query.h" 295f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset#include "nv50/nv50_query_hw.h" 30aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset#include "nv50/nv50_query_hw_metric.h" 31aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset#include "nv50/nv50_query_hw_sm.h" 32918fc55e5f5cbedd3ab8fb3e02b225106c059fa6Ben Skeggs 3379bca7dd884da33c06ecd3dabb893f9cfed1aaedBen Skeggsstatic struct pipe_query * 345f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoisetnv50_create_query(struct pipe_context *pipe, unsigned type, unsigned index) 3579bca7dd884da33c06ecd3dabb893f9cfed1aaedBen Skeggs{ 36f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller struct nv50_context *nv50 = nv50_context(pipe); 37f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller struct nv50_query *q; 38f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller 395f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset q = nv50_hw_create_query(nv50, type, index); 40f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller return (struct pipe_query *)q; 4179bca7dd884da33c06ecd3dabb893f9cfed1aaedBen Skeggs} 4279bca7dd884da33c06ecd3dabb893f9cfed1aaedBen Skeggs 43b8965bee404cb36ccd97ac089fbd3ffc63268080Ben Skeggsstatic void 445f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoisetnv50_destroy_query(struct pipe_context *pipe, struct pipe_query *pq) 4547b418b8fa5fd242e9021503d6ec329ac3d56fb0Ben Skeggs{ 465f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset struct nv50_query *q = nv50_query(pq); 475f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset q->funcs->destroy_query(nv50_context(pipe), q); 4847b418b8fa5fd242e9021503d6ec329ac3d56fb0Ben Skeggs} 4947b418b8fa5fd242e9021503d6ec329ac3d56fb0Ben Skeggs 5096f164f6f047833091eb98a73aa80c31dc94f962Samuel Pitoisetstatic boolean 515f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoisetnv50_begin_query(struct pipe_context *pipe, struct pipe_query *pq) 5247b418b8fa5fd242e9021503d6ec329ac3d56fb0Ben Skeggs{ 53f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller struct nv50_query *q = nv50_query(pq); 545f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset return q->funcs->begin_query(nv50_context(pipe), q); 5547b418b8fa5fd242e9021503d6ec329ac3d56fb0Ben Skeggs} 5647b418b8fa5fd242e9021503d6ec329ac3d56fb0Ben Skeggs 5732214e0c6837a24ad82152e9971baa3926992498Nicolai Hähnlestatic bool 585f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoisetnv50_end_query(struct pipe_context *pipe, struct pipe_query *pq) 5979bca7dd884da33c06ecd3dabb893f9cfed1aaedBen Skeggs{ 60f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller struct nv50_query *q = nv50_query(pq); 615f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset q->funcs->end_query(nv50_context(pipe), q); 6232214e0c6837a24ad82152e9971baa3926992498Nicolai Hähnle return true; 63f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller} 64f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller 6579bca7dd884da33c06ecd3dabb893f9cfed1aaedBen Skeggsstatic boolean 665f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoisetnv50_get_query_result(struct pipe_context *pipe, struct pipe_query *pq, 675f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset boolean wait, union pipe_query_result *result) 6847b418b8fa5fd242e9021503d6ec329ac3d56fb0Ben Skeggs{ 69f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller struct nv50_query *q = nv50_query(pq); 705f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset return q->funcs->get_query_result(nv50_context(pipe), q, wait, result); 7102fac2930581b9bea9f6d221eb6d6b471fc3b9c6Christoph Bumiller} 7202fac2930581b9bea9f6d221eb6d6b471fc3b9c6Christoph Bumiller 73d6fd31a8d47b6cc70b5e64757e1272ccc6594350Christoph Bumillerstatic void 74d6fd31a8d47b6cc70b5e64757e1272ccc6594350Christoph Bumillernv50_render_condition(struct pipe_context *pipe, 75793e8e3d7ed816cc9a066245dde798afdcf8b581Roland Scheidegger struct pipe_query *pq, 76793e8e3d7ed816cc9a066245dde798afdcf8b581Roland Scheidegger boolean condition, uint mode) 77d6fd31a8d47b6cc70b5e64757e1272ccc6594350Christoph Bumiller{ 78f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller struct nv50_context *nv50 = nv50_context(pipe); 796d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller struct nouveau_pushbuf *push = nv50->base.pushbuf; 805f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset struct nv50_query *q = nv50_query(pq); 815f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset struct nv50_hw_query *hq = nv50_hw_query(q); 821a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann uint32_t cond; 83cd0dec0d9dfab642c51774c3f5788cbdf00b8c9bSamuel Pitoiset bool wait = 841a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann mode != PIPE_RENDER_COND_NO_WAIT && 851a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann mode != PIPE_RENDER_COND_BY_REGION_NO_WAIT; 861a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann 871a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann if (!pq) { 881a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann cond = NV50_3D_COND_MODE_ALWAYS; 891a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann } 901a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann else { 911a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann /* NOTE: comparison of 2 queries only works if both have completed */ 921a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann switch (q->type) { 931a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann case PIPE_QUERY_SO_OVERFLOW_PREDICATE: 941a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann cond = condition ? NV50_3D_COND_MODE_EQUAL : 951a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann NV50_3D_COND_MODE_NOT_EQUAL; 96cd0dec0d9dfab642c51774c3f5788cbdf00b8c9bSamuel Pitoiset wait = true; 971a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann break; 981a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann case PIPE_QUERY_OCCLUSION_COUNTER: 991a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann case PIPE_QUERY_OCCLUSION_PREDICATE: 1001a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann if (likely(!condition)) { 1015f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset if (unlikely(hq->nesting)) 1021a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann cond = wait ? NV50_3D_COND_MODE_NOT_EQUAL : 1031a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann NV50_3D_COND_MODE_ALWAYS; 1041a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann else 1051a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann cond = NV50_3D_COND_MODE_RES_NON_ZERO; 1061a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann } else { 1071a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann cond = wait ? NV50_3D_COND_MODE_EQUAL : NV50_3D_COND_MODE_ALWAYS; 1081a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann } 1091a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann break; 1101a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann default: 1111a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann assert(!"render condition query not a predicate"); 1121a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann cond = NV50_3D_COND_MODE_ALWAYS; 1131a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann break; 1141a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann } 1151a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann } 116f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller 11736ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller nv50->cond_query = pq; 118793e8e3d7ed816cc9a066245dde798afdcf8b581Roland Scheidegger nv50->cond_cond = condition; 1191a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann nv50->cond_condmode = cond; 12036ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller nv50->cond_mode = mode; 12136ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller 122f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller if (!pq) { 1231a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann PUSH_SPACE(push, 2); 1246d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller BEGIN_NV04(push, NV50_3D(COND_MODE), 1); 1251a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann PUSH_DATA (push, cond); 126f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller return; 127f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller } 128f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller 1291a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann PUSH_SPACE(push, 9); 1301a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann 1311a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann if (wait) { 1326d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller BEGIN_NV04(push, SUBC_3D(NV50_GRAPH_SERIALIZE), 1); 1336d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller PUSH_DATA (push, 0); 134f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller } 135f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller 1365f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset PUSH_REFN (push, hq->bo, NOUVEAU_BO_GART | NOUVEAU_BO_RD); 1376d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller BEGIN_NV04(push, NV50_3D(COND_ADDRESS_HIGH), 3); 1385f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset PUSH_DATAh(push, hq->bo->offset + hq->offset); 1395f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset PUSH_DATA (push, hq->bo->offset + hq->offset); 1401a170980a09d82201b88e3fe20684a0df2cfea80Tobias Klausmann PUSH_DATA (push, cond); 1414467c0c9fbf2c13b6c73a002e8247448ee12d4c4Ilia Mirkin 1424467c0c9fbf2c13b6c73a002e8247448ee12d4c4Ilia Mirkin BEGIN_NV04(push, NV50_2D(COND_ADDRESS_HIGH), 2); 1435f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset PUSH_DATAh(push, hq->bo->offset + hq->offset); 1445f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset PUSH_DATA (push, hq->bo->offset + hq->offset); 14502fac2930581b9bea9f6d221eb6d6b471fc3b9c6Christoph Bumiller} 14602fac2930581b9bea9f6d221eb6d6b471fc3b9c6Christoph Bumiller 14726171bd67e47cf25857cbce767ad048c8d99d1b0Marek Olšákstatic void 14826171bd67e47cf25857cbce767ad048c8d99d1b0Marek Olšáknv50_set_active_query_state(struct pipe_context *pipe, boolean enable) 14926171bd67e47cf25857cbce767ad048c8d99d1b0Marek Olšák{ 15026171bd67e47cf25857cbce767ad048c8d99d1b0Marek Olšák} 15126171bd67e47cf25857cbce767ad048c8d99d1b0Marek Olšák 15202fac2930581b9bea9f6d221eb6d6b471fc3b9c6Christoph Bumillervoid 153b8965bee404cb36ccd97ac089fbd3ffc63268080Ben Skeggsnv50_init_query_functions(struct nv50_context *nv50) 154b8965bee404cb36ccd97ac089fbd3ffc63268080Ben Skeggs{ 1551ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs struct pipe_context *pipe = &nv50->base.pipe; 1561ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs 1575f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset pipe->create_query = nv50_create_query; 1585f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset pipe->destroy_query = nv50_destroy_query; 1595f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset pipe->begin_query = nv50_begin_query; 1605f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset pipe->end_query = nv50_end_query; 1615f1eeb799bd9bcdb32382961e57ef74253701ed2Samuel Pitoiset pipe->get_query_result = nv50_get_query_result; 16226171bd67e47cf25857cbce767ad048c8d99d1b0Marek Olšák pipe->set_active_query_state = nv50_set_active_query_state; 1631ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs pipe->render_condition = nv50_render_condition; 164ff17b3ccf4f8d9f989cc975cd0e11716ff48bc1dIlia Mirkin nv50->cond_condmode = NV50_3D_COND_MODE_ALWAYS; 165b8965bee404cb36ccd97ac089fbd3ffc63268080Ben Skeggs} 1666a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset 1676a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoisetint 1686a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoisetnv50_screen_get_driver_query_info(struct pipe_screen *pscreen, 1696a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset unsigned id, 1706a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset struct pipe_driver_query_info *info) 1716a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset{ 1726a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset struct nv50_screen *screen = nv50_screen(pscreen); 1736a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset int num_hw_queries = 0; 1746a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset 1756a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset num_hw_queries = nv50_hw_get_driver_query_info(screen, 0, NULL); 1766a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset 1776a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset if (!info) 1786a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset return num_hw_queries; 1796a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset 1806a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset /* Init default values. */ 1816a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset info->name = "this_is_not_the_query_you_are_looking_for"; 1826a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset info->query_type = 0xdeadd01d; 1836a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset info->max_value.u64 = 0; 1846a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset info->type = PIPE_DRIVER_QUERY_TYPE_UINT64; 1856a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset info->group_id = -1; 186d61d4df02e568d314c4e763ba9b5bdd57aef98c5Nicolai Hähnle info->flags = 0; 1876a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset 1886a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset return nv50_hw_get_driver_query_info(screen, id, info); 1896a9c151dbb87a10b6d51c451a5a277d646d08857Samuel Pitoiset} 190aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset 191aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoisetint 192aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoisetnv50_screen_get_driver_query_group_info(struct pipe_screen *pscreen, 193aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset unsigned id, 194aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset struct pipe_driver_query_group_info *info) 195aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset{ 196aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset struct nv50_screen *screen = nv50_screen(pscreen); 197aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset int count = 0; 198aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset 199aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (screen->compute) 200aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (screen->base.class_3d >= NV84_3D_CLASS) 201aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset count += 2; 202aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset 203aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (!info) 204aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset return count; 205aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset 206aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (id == NV50_HW_SM_QUERY_GROUP) { 207aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (screen->compute) { 208aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (screen->base.class_3d >= NV84_3D_CLASS) { 209aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset info->name = "MP counters"; 210aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset 211548b5fee6b4a71d1b7b52b2268ef809a2cb90149Samuel Pitoiset /* Expose the maximum number of hardware counters available, 212548b5fee6b4a71d1b7b52b2268ef809a2cb90149Samuel Pitoiset * although some queries use more than one counter. Expect failures 213548b5fee6b4a71d1b7b52b2268ef809a2cb90149Samuel Pitoiset * in that case but as performance counters are for developers, 214548b5fee6b4a71d1b7b52b2268ef809a2cb90149Samuel Pitoiset * this should not have a real impact. */ 215548b5fee6b4a71d1b7b52b2268ef809a2cb90149Samuel Pitoiset info->max_active_queries = 4; 216aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset info->num_queries = NV50_HW_SM_QUERY_COUNT; 217aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset return 1; 218aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset } 219aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset } 220aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset } else 221aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (id == NV50_HW_METRIC_QUERY_GROUP) { 222aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (screen->compute) { 223aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset if (screen->base.class_3d >= NV84_3D_CLASS) { 224aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset info->name = "Performance metrics"; 225548b5fee6b4a71d1b7b52b2268ef809a2cb90149Samuel Pitoiset info->max_active_queries = 2; /* A metric uses at least 2 queries */ 226aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset info->num_queries = NV50_HW_METRIC_QUERY_COUNT; 227aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset return 1; 228aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset } 229aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset } 230aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset } 231aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset 232aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset /* user asked for info about non-existing query group */ 233aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset info->name = "this_is_not_the_query_group_you_are_looking_for"; 234aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset info->max_active_queries = 0; 235aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset info->num_queries = 0; 236aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset return 0; 237aede8ca9a79cafa7d019a16d38e6ee6bfc557100Samuel Pitoiset} 238