1#ifndef __NVC0_SCREEN_H__ 2#define __NVC0_SCREEN_H__ 3 4#include "nouveau/nouveau_screen.h" 5#include "nouveau/nouveau_mm.h" 6#include "nouveau/nouveau_fence.h" 7#include "nouveau/nouveau_heap.h" 8 9#include "nouveau/nv_object.xml.h" 10 11#include "nvc0_winsys.h" 12#include "nvc0_stateobj.h" 13 14#define NVC0_TIC_MAX_ENTRIES 2048 15#define NVC0_TSC_MAX_ENTRIES 2048 16 17/* doesn't count reserved slots (for auxiliary constants, immediates, etc.) */ 18#define NVC0_MAX_PIPE_CONSTBUFS 14 19 20struct nvc0_context; 21 22struct nvc0_blitctx; 23 24struct nvc0_screen { 25 struct nouveau_screen base; 26 27 struct nvc0_context *cur_ctx; 28 29 int num_occlusion_queries_active; 30 31 struct nouveau_bo *text; 32 struct nouveau_bo *uniform_bo; 33 struct nouveau_bo *tls; 34 struct nouveau_bo *txc; /* TIC (offset 0) and TSC (65536) */ 35 struct nouveau_bo *poly_cache; 36 37 uint64_t tls_size; 38 39 struct nouveau_heap *text_heap; 40 struct nouveau_heap *lib_code; /* allocated from text_heap */ 41 42 struct nvc0_blitctx *blitctx; 43 44 struct { 45 void **entries; 46 int next; 47 uint32_t lock[NVC0_TIC_MAX_ENTRIES / 32]; 48 } tic; 49 50 struct { 51 void **entries; 52 int next; 53 uint32_t lock[NVC0_TSC_MAX_ENTRIES / 32]; 54 } tsc; 55 56 struct { 57 struct nouveau_bo *bo; 58 uint32_t *map; 59 } fence; 60 61 struct nouveau_mman *mm_VRAM_fe0; 62 63 struct nouveau_object *eng3d; /* sqrt(1/2)|kepler> + sqrt(1/2)|fermi> */ 64 struct nouveau_object *eng2d; 65 struct nouveau_object *m2mf; 66 struct nouveau_object *dijkstra; 67}; 68 69static INLINE struct nvc0_screen * 70nvc0_screen(struct pipe_screen *screen) 71{ 72 return (struct nvc0_screen *)screen; 73} 74 75boolean nvc0_blitctx_create(struct nvc0_screen *); 76 77void nvc0_screen_make_buffers_resident(struct nvc0_screen *); 78 79int nvc0_screen_tic_alloc(struct nvc0_screen *, void *); 80int nvc0_screen_tsc_alloc(struct nvc0_screen *, void *); 81 82static INLINE void 83nvc0_resource_fence(struct nv04_resource *res, uint32_t flags) 84{ 85 struct nvc0_screen *screen = nvc0_screen(res->base.screen); 86 87 if (res->mm) { 88 nouveau_fence_ref(screen->base.fence.current, &res->fence); 89 if (flags & NOUVEAU_BO_WR) 90 nouveau_fence_ref(screen->base.fence.current, &res->fence_wr); 91 } 92} 93 94static INLINE void 95nvc0_resource_validate(struct nv04_resource *res, uint32_t flags) 96{ 97 if (likely(res->bo)) { 98 if (flags & NOUVEAU_BO_WR) 99 res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING; 100 if (flags & NOUVEAU_BO_RD) 101 res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; 102 103 nvc0_resource_fence(res, flags); 104 } 105} 106 107struct nvc0_format { 108 uint32_t rt; 109 uint32_t tic; 110 uint32_t vtx; 111 uint32_t usage; 112}; 113 114extern const struct nvc0_format nvc0_format_table[]; 115 116static INLINE void 117nvc0_screen_tic_unlock(struct nvc0_screen *screen, struct nv50_tic_entry *tic) 118{ 119 if (tic->id >= 0) 120 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32)); 121} 122 123static INLINE void 124nvc0_screen_tsc_unlock(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc) 125{ 126 if (tsc->id >= 0) 127 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32)); 128} 129 130static INLINE void 131nvc0_screen_tic_free(struct nvc0_screen *screen, struct nv50_tic_entry *tic) 132{ 133 if (tic->id >= 0) { 134 screen->tic.entries[tic->id] = NULL; 135 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32)); 136 } 137} 138 139static INLINE void 140nvc0_screen_tsc_free(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc) 141{ 142 if (tsc->id >= 0) { 143 screen->tsc.entries[tsc->id] = NULL; 144 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32)); 145 } 146} 147 148#endif 149