1bf215546Sopenharmony_ci#ifndef __NV50_SCREEN_H__ 2bf215546Sopenharmony_ci#define __NV50_SCREEN_H__ 3bf215546Sopenharmony_ci 4bf215546Sopenharmony_ci#include "nouveau_screen.h" 5bf215546Sopenharmony_ci#include "nouveau_fence.h" 6bf215546Sopenharmony_ci#include "nouveau_mm.h" 7bf215546Sopenharmony_ci#include "nouveau_heap.h" 8bf215546Sopenharmony_ci 9bf215546Sopenharmony_ci#include "nv50/nv50_winsys.h" 10bf215546Sopenharmony_ci#include "nv50/nv50_stateobj.h" 11bf215546Sopenharmony_ci 12bf215546Sopenharmony_ci#define NV50_TIC_MAX_ENTRIES 2048 13bf215546Sopenharmony_ci#define NV50_TSC_MAX_ENTRIES 2048 14bf215546Sopenharmony_ci 15bf215546Sopenharmony_ci/* doesn't count reserved slots (for auxiliary constants, immediates, etc.) */ 16bf215546Sopenharmony_ci#define NV50_MAX_PIPE_CONSTBUFS 14 17bf215546Sopenharmony_ci 18bf215546Sopenharmony_cistruct nv50_context; 19bf215546Sopenharmony_ci 20bf215546Sopenharmony_ci#define NV50_CODE_BO_SIZE_LOG2 19 21bf215546Sopenharmony_ci 22bf215546Sopenharmony_ci#define NV50_SCREEN_RESIDENT_BO_COUNT 5 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#define NV50_MAX_VIEWPORTS 16 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#define NV50_MAX_WINDOW_RECTANGLES 8 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#define NV50_MAX_GLOBALS 16 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#define ONE_TEMP_SIZE (4/*vector*/ * sizeof(float)) 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_cistruct nv50_blitter; 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_cistruct nv50_graph_state { 35bf215546Sopenharmony_ci uint32_t instance_elts; /* bitmask of per-instance elements */ 36bf215546Sopenharmony_ci uint32_t instance_base; 37bf215546Sopenharmony_ci uint32_t interpolant_ctrl; 38bf215546Sopenharmony_ci uint32_t semantic_color; 39bf215546Sopenharmony_ci uint32_t semantic_psize; 40bf215546Sopenharmony_ci int32_t index_bias; 41bf215546Sopenharmony_ci uint32_t clip_mode; 42bf215546Sopenharmony_ci bool uniform_buffer_bound[4]; 43bf215546Sopenharmony_ci bool prim_restart; 44bf215546Sopenharmony_ci bool point_sprite; 45bf215546Sopenharmony_ci bool rt_serialize; 46bf215546Sopenharmony_ci bool flushed; 47bf215546Sopenharmony_ci bool rasterizer_discard; 48bf215546Sopenharmony_ci uint8_t tls_required; 49bf215546Sopenharmony_ci bool new_tls_space; 50bf215546Sopenharmony_ci uint8_t num_vtxbufs; 51bf215546Sopenharmony_ci uint8_t num_vtxelts; 52bf215546Sopenharmony_ci uint8_t num_textures[4]; 53bf215546Sopenharmony_ci uint8_t num_samplers[4]; 54bf215546Sopenharmony_ci uint8_t prim_size; 55bf215546Sopenharmony_ci uint16_t scissor; 56bf215546Sopenharmony_ci bool seamless_cube_map; 57bf215546Sopenharmony_ci bool mul_zero_wins; 58bf215546Sopenharmony_ci}; 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_cistruct nv50_screen { 61bf215546Sopenharmony_ci struct nouveau_screen base; 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci struct nv50_context *cur_ctx; 64bf215546Sopenharmony_ci struct nv50_graph_state save_state; 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci int num_occlusion_queries_active; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci struct nouveau_bo *code; 69bf215546Sopenharmony_ci struct nouveau_bo *uniforms; 70bf215546Sopenharmony_ci struct nouveau_bo *txc; /* TIC (offset 0) and TSC (65536) */ 71bf215546Sopenharmony_ci struct nouveau_bo *stack_bo; 72bf215546Sopenharmony_ci struct nouveau_bo *tls_bo; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci unsigned TPs; 75bf215546Sopenharmony_ci unsigned MPsInTP; 76bf215546Sopenharmony_ci unsigned max_tls_space; 77bf215546Sopenharmony_ci unsigned cur_tls_space; 78bf215546Sopenharmony_ci unsigned mp_count; 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci struct nouveau_heap *vp_code_heap; 81bf215546Sopenharmony_ci struct nouveau_heap *gp_code_heap; 82bf215546Sopenharmony_ci struct nouveau_heap *fp_code_heap; 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci struct nv50_blitter *blitter; 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci struct { 87bf215546Sopenharmony_ci void **entries; 88bf215546Sopenharmony_ci int next; 89bf215546Sopenharmony_ci uint32_t lock[NV50_TIC_MAX_ENTRIES / 32]; 90bf215546Sopenharmony_ci } tic; 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_ci struct { 93bf215546Sopenharmony_ci void **entries; 94bf215546Sopenharmony_ci int next; 95bf215546Sopenharmony_ci uint32_t lock[NV50_TSC_MAX_ENTRIES / 32]; 96bf215546Sopenharmony_ci } tsc; 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci struct { 99bf215546Sopenharmony_ci uint32_t *map; 100bf215546Sopenharmony_ci struct nouveau_bo *bo; 101bf215546Sopenharmony_ci } fence; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci struct { 104bf215546Sopenharmony_ci struct nv50_program *prog; /* compute state object to read MP counters */ 105bf215546Sopenharmony_ci struct nv50_hw_sm_query *mp_counter[4]; /* counter to query allocation */ 106bf215546Sopenharmony_ci uint8_t num_hw_sm_active; 107bf215546Sopenharmony_ci } pm; 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci struct nouveau_object *sync; 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ci struct nouveau_object *tesla; 112bf215546Sopenharmony_ci struct nouveau_object *compute; 113bf215546Sopenharmony_ci struct nouveau_object *eng2d; 114bf215546Sopenharmony_ci struct nouveau_object *m2mf; 115bf215546Sopenharmony_ci}; 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_cistatic inline struct nv50_screen * 118bf215546Sopenharmony_cinv50_screen(struct pipe_screen *screen) 119bf215546Sopenharmony_ci{ 120bf215546Sopenharmony_ci return (struct nv50_screen *)screen; 121bf215546Sopenharmony_ci} 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_ciint nv50_screen_get_driver_query_info(struct pipe_screen *, unsigned, 124bf215546Sopenharmony_ci struct pipe_driver_query_info *); 125bf215546Sopenharmony_ciint nv50_screen_get_driver_query_group_info(struct pipe_screen *, unsigned, 126bf215546Sopenharmony_ci struct pipe_driver_query_group_info *); 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_cibool nv50_blitter_create(struct nv50_screen *); 129bf215546Sopenharmony_civoid nv50_blitter_destroy(struct nv50_screen *); 130bf215546Sopenharmony_ci 131bf215546Sopenharmony_ciint nv50_screen_tic_alloc(struct nv50_screen *, void *); 132bf215546Sopenharmony_ciint nv50_screen_tsc_alloc(struct nv50_screen *, void *); 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_ciint nv50_screen_compute_setup(struct nv50_screen *, struct nouveau_pushbuf *); 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_cistatic inline void 137bf215546Sopenharmony_cinv50_resource_fence(struct nv04_resource *res, uint32_t flags) 138bf215546Sopenharmony_ci{ 139bf215546Sopenharmony_ci struct nv50_screen *screen = nv50_screen(res->base.screen); 140bf215546Sopenharmony_ci 141bf215546Sopenharmony_ci if (res->mm) { 142bf215546Sopenharmony_ci nouveau_fence_ref(screen->base.fence.current, &res->fence); 143bf215546Sopenharmony_ci if (flags & NOUVEAU_BO_WR) 144bf215546Sopenharmony_ci nouveau_fence_ref(screen->base.fence.current, &res->fence_wr); 145bf215546Sopenharmony_ci } 146bf215546Sopenharmony_ci} 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_cistatic inline void 149bf215546Sopenharmony_cinv50_resource_validate(struct nv04_resource *res, uint32_t flags) 150bf215546Sopenharmony_ci{ 151bf215546Sopenharmony_ci if (likely(res->bo)) { 152bf215546Sopenharmony_ci if (flags & NOUVEAU_BO_WR) 153bf215546Sopenharmony_ci res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING | 154bf215546Sopenharmony_ci NOUVEAU_BUFFER_STATUS_DIRTY; 155bf215546Sopenharmony_ci if (flags & NOUVEAU_BO_RD) 156bf215546Sopenharmony_ci res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_ci nv50_resource_fence(res, flags); 159bf215546Sopenharmony_ci } 160bf215546Sopenharmony_ci} 161bf215546Sopenharmony_ci 162bf215546Sopenharmony_cistruct nv50_format { 163bf215546Sopenharmony_ci uint32_t rt; 164bf215546Sopenharmony_ci struct { 165bf215546Sopenharmony_ci unsigned format:6; 166bf215546Sopenharmony_ci unsigned type_r:3; 167bf215546Sopenharmony_ci unsigned type_g:3; 168bf215546Sopenharmony_ci unsigned type_b:3; 169bf215546Sopenharmony_ci unsigned type_a:3; 170bf215546Sopenharmony_ci unsigned src_x:3; 171bf215546Sopenharmony_ci unsigned src_y:3; 172bf215546Sopenharmony_ci unsigned src_z:3; 173bf215546Sopenharmony_ci unsigned src_w:3; 174bf215546Sopenharmony_ci } tic; 175bf215546Sopenharmony_ci uint32_t usage; 176bf215546Sopenharmony_ci}; 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_cistruct nv50_vertex_format { 179bf215546Sopenharmony_ci uint32_t vtx; 180bf215546Sopenharmony_ci uint32_t usage; 181bf215546Sopenharmony_ci}; 182bf215546Sopenharmony_ci 183bf215546Sopenharmony_ciextern const struct nv50_format nv50_format_table[]; 184bf215546Sopenharmony_ciextern const struct nv50_vertex_format nv50_vertex_format[]; 185bf215546Sopenharmony_ci 186bf215546Sopenharmony_cistatic inline void 187bf215546Sopenharmony_cinv50_screen_tic_unlock(struct nv50_screen *screen, struct nv50_tic_entry *tic) 188bf215546Sopenharmony_ci{ 189bf215546Sopenharmony_ci if (tic->id >= 0) 190bf215546Sopenharmony_ci screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32)); 191bf215546Sopenharmony_ci} 192bf215546Sopenharmony_ci 193bf215546Sopenharmony_cistatic inline void 194bf215546Sopenharmony_cinv50_screen_tsc_unlock(struct nv50_screen *screen, struct nv50_tsc_entry *tsc) 195bf215546Sopenharmony_ci{ 196bf215546Sopenharmony_ci if (tsc->id >= 0) 197bf215546Sopenharmony_ci screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32)); 198bf215546Sopenharmony_ci} 199bf215546Sopenharmony_ci 200bf215546Sopenharmony_cistatic inline void 201bf215546Sopenharmony_cinv50_screen_tic_free(struct nv50_screen *screen, struct nv50_tic_entry *tic) 202bf215546Sopenharmony_ci{ 203bf215546Sopenharmony_ci if (tic->id >= 0) { 204bf215546Sopenharmony_ci screen->tic.entries[tic->id] = NULL; 205bf215546Sopenharmony_ci screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32)); 206bf215546Sopenharmony_ci } 207bf215546Sopenharmony_ci} 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_cistatic inline void 210bf215546Sopenharmony_cinv50_screen_tsc_free(struct nv50_screen *screen, struct nv50_tsc_entry *tsc) 211bf215546Sopenharmony_ci{ 212bf215546Sopenharmony_ci if (tsc->id >= 0) { 213bf215546Sopenharmony_ci screen->tsc.entries[tsc->id] = NULL; 214bf215546Sopenharmony_ci screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32)); 215bf215546Sopenharmony_ci } 216bf215546Sopenharmony_ci} 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_ciextern int nv50_tls_realloc(struct nv50_screen *screen, unsigned tls_space); 219bf215546Sopenharmony_ci 220bf215546Sopenharmony_ci#endif 221