Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #ifndef __NV50_SCREEN_H__
  2. #define __NV50_SCREEN_H__
  3.  
  4. #include "nouveau/nouveau_screen.h"
  5. #include "nouveau/nouveau_fence.h"
  6. #include "nouveau/nouveau_mm.h"
  7. #include "nouveau/nouveau_heap.h"
  8.  
  9. #include "nv50_winsys.h"
  10. #include "nv50_stateobj.h"
  11.  
  12. #define NV50_TIC_MAX_ENTRIES 2048
  13. #define NV50_TSC_MAX_ENTRIES 2048
  14.  
  15. /* doesn't count reserved slots (for auxiliary constants, immediates, etc.) */
  16. #define NV50_MAX_PIPE_CONSTBUFS 14
  17.  
  18. struct nv50_context;
  19.  
  20. #define NV50_CODE_BO_SIZE_LOG2 19
  21.  
  22. #define NV50_SCREEN_RESIDENT_BO_COUNT 5
  23.  
  24. struct nv50_blitter;
  25.  
  26. struct nv50_screen {
  27.    struct nouveau_screen base;
  28.  
  29.    struct nv50_context *cur_ctx;
  30.  
  31.    struct nouveau_bo *code;
  32.    struct nouveau_bo *uniforms;
  33.    struct nouveau_bo *txc; /* TIC (offset 0) and TSC (65536) */
  34.    struct nouveau_bo *stack_bo;
  35.    struct nouveau_bo *tls_bo;
  36.  
  37.    unsigned TPs;
  38.    unsigned MPsInTP;
  39.    unsigned max_tls_space;
  40.    unsigned cur_tls_space;
  41.  
  42.    struct nouveau_heap *vp_code_heap;
  43.    struct nouveau_heap *gp_code_heap;
  44.    struct nouveau_heap *fp_code_heap;
  45.  
  46.    struct nv50_blitter *blitter;
  47.  
  48.    struct {
  49.       void **entries;
  50.       int next;
  51.       uint32_t lock[NV50_TIC_MAX_ENTRIES / 32];
  52.    } tic;
  53.    
  54.    struct {
  55.       void **entries;
  56.       int next;
  57.       uint32_t lock[NV50_TSC_MAX_ENTRIES / 32];
  58.    } tsc;
  59.  
  60.    struct {
  61.       uint32_t *map;
  62.       struct nouveau_bo *bo;
  63.    } fence;
  64.  
  65.    struct nouveau_object *sync;
  66.  
  67.    struct nouveau_object *tesla;
  68.    struct nouveau_object *eng2d;
  69.    struct nouveau_object *m2mf;
  70. };
  71.  
  72. static INLINE struct nv50_screen *
  73. nv50_screen(struct pipe_screen *screen)
  74. {
  75.    return (struct nv50_screen *)screen;
  76. }
  77.  
  78. boolean nv50_blitter_create(struct nv50_screen *);
  79. void nv50_blitter_destroy(struct nv50_screen *);
  80.  
  81. int nv50_screen_tic_alloc(struct nv50_screen *, void *);
  82. int nv50_screen_tsc_alloc(struct nv50_screen *, void *);
  83.  
  84. static INLINE void
  85. nv50_resource_fence(struct nv04_resource *res, uint32_t flags)
  86. {
  87.    struct nv50_screen *screen = nv50_screen(res->base.screen);
  88.  
  89.    if (res->mm) {
  90.       nouveau_fence_ref(screen->base.fence.current, &res->fence);
  91.       if (flags & NOUVEAU_BO_WR)
  92.          nouveau_fence_ref(screen->base.fence.current, &res->fence_wr);
  93.    }
  94. }
  95.  
  96. static INLINE void
  97. nv50_resource_validate(struct nv04_resource *res, uint32_t flags)
  98. {
  99.    if (likely(res->bo)) {
  100.       if (flags & NOUVEAU_BO_WR)
  101.          res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING |
  102.             NOUVEAU_BUFFER_STATUS_DIRTY;
  103.       if (flags & NOUVEAU_BO_RD)
  104.          res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING;
  105.  
  106.       nv50_resource_fence(res, flags);
  107.    }
  108. }
  109.  
  110. struct nv50_format {
  111.    uint32_t rt;
  112.    uint32_t tic;
  113.    uint32_t vtx;
  114.    uint32_t usage;
  115. };
  116.  
  117. extern const struct nv50_format nv50_format_table[];
  118.  
  119. static INLINE void
  120. nv50_screen_tic_unlock(struct nv50_screen *screen, struct nv50_tic_entry *tic)
  121. {
  122.    if (tic->id >= 0)
  123.       screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
  124. }
  125.  
  126. static INLINE void
  127. nv50_screen_tsc_unlock(struct nv50_screen *screen, struct nv50_tsc_entry *tsc)
  128. {
  129.    if (tsc->id >= 0)
  130.       screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
  131. }
  132.  
  133. static INLINE void
  134. nv50_screen_tic_free(struct nv50_screen *screen, struct nv50_tic_entry *tic)
  135. {
  136.    if (tic->id >= 0) {
  137.       screen->tic.entries[tic->id] = NULL;
  138.       screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
  139.    }
  140. }
  141.  
  142. static INLINE void
  143. nv50_screen_tsc_free(struct nv50_screen *screen, struct nv50_tsc_entry *tsc)
  144. {
  145.    if (tsc->id >= 0) {
  146.       screen->tsc.entries[tsc->id] = NULL;
  147.       screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
  148.    }
  149. }
  150.  
  151. extern int nv50_tls_realloc(struct nv50_screen *screen, unsigned tls_space);
  152.  
  153. #endif
  154.