Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. #ifndef __NV50_SCREEN_H__
  2. #define __NV50_SCREEN_H__
  3.  
  4. #include "nouveau_screen.h"
  5. #include "nouveau_fence.h"
  6. #include "nouveau_mm.h"
  7. #include "nouveau_heap.h"
  8.  
  9. #include "nv50/nv50_winsys.h"
  10. #include "nv50/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. #define NV50_MAX_VIEWPORTS 16
  25.  
  26. struct nv50_blitter;
  27.  
  28. struct nv50_graph_state {
  29.    uint32_t instance_elts; /* bitmask of per-instance elements */
  30.    uint32_t instance_base;
  31.    uint32_t interpolant_ctrl;
  32.    uint32_t semantic_color;
  33.    uint32_t semantic_psize;
  34.    int32_t index_bias;
  35.    boolean uniform_buffer_bound[3];
  36.    boolean prim_restart;
  37.    boolean point_sprite;
  38.    boolean rt_serialize;
  39.    boolean flushed;
  40.    boolean rasterizer_discard;
  41.    uint8_t tls_required;
  42.    boolean new_tls_space;
  43.    uint8_t num_vtxbufs;
  44.    uint8_t num_vtxelts;
  45.    uint8_t num_textures[3];
  46.    uint8_t num_samplers[3];
  47.    uint8_t prim_size;
  48.    uint16_t scissor;
  49. };
  50.  
  51. struct nv50_screen {
  52.    struct nouveau_screen base;
  53.  
  54.    struct nv50_context *cur_ctx;
  55.    struct nv50_graph_state save_state;
  56.  
  57.    struct nouveau_bo *code;
  58.    struct nouveau_bo *uniforms;
  59.    struct nouveau_bo *txc; /* TIC (offset 0) and TSC (65536) */
  60.    struct nouveau_bo *stack_bo;
  61.    struct nouveau_bo *tls_bo;
  62.  
  63.    unsigned TPs;
  64.    unsigned MPsInTP;
  65.    unsigned max_tls_space;
  66.    unsigned cur_tls_space;
  67.  
  68.    struct nouveau_heap *vp_code_heap;
  69.    struct nouveau_heap *gp_code_heap;
  70.    struct nouveau_heap *fp_code_heap;
  71.  
  72.    struct nv50_blitter *blitter;
  73.  
  74.    struct {
  75.       void **entries;
  76.       int next;
  77.       uint32_t lock[NV50_TIC_MAX_ENTRIES / 32];
  78.    } tic;
  79.  
  80.    struct {
  81.       void **entries;
  82.       int next;
  83.       uint32_t lock[NV50_TSC_MAX_ENTRIES / 32];
  84.    } tsc;
  85.  
  86.    struct {
  87.       uint32_t *map;
  88.       struct nouveau_bo *bo;
  89.    } fence;
  90.  
  91.    struct nouveau_object *sync;
  92.  
  93.    struct nouveau_object *tesla;
  94.    struct nouveau_object *eng2d;
  95.    struct nouveau_object *m2mf;
  96. };
  97.  
  98. static INLINE struct nv50_screen *
  99. nv50_screen(struct pipe_screen *screen)
  100. {
  101.    return (struct nv50_screen *)screen;
  102. }
  103.  
  104. boolean nv50_blitter_create(struct nv50_screen *);
  105. void nv50_blitter_destroy(struct nv50_screen *);
  106.  
  107. int nv50_screen_tic_alloc(struct nv50_screen *, void *);
  108. int nv50_screen_tsc_alloc(struct nv50_screen *, void *);
  109.  
  110. static INLINE void
  111. nv50_resource_fence(struct nv04_resource *res, uint32_t flags)
  112. {
  113.    struct nv50_screen *screen = nv50_screen(res->base.screen);
  114.  
  115.    if (res->mm) {
  116.       nouveau_fence_ref(screen->base.fence.current, &res->fence);
  117.       if (flags & NOUVEAU_BO_WR)
  118.          nouveau_fence_ref(screen->base.fence.current, &res->fence_wr);
  119.    }
  120. }
  121.  
  122. static INLINE void
  123. nv50_resource_validate(struct nv04_resource *res, uint32_t flags)
  124. {
  125.    if (likely(res->bo)) {
  126.       if (flags & NOUVEAU_BO_WR)
  127.          res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING |
  128.             NOUVEAU_BUFFER_STATUS_DIRTY;
  129.       if (flags & NOUVEAU_BO_RD)
  130.          res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING;
  131.  
  132.       nv50_resource_fence(res, flags);
  133.    }
  134. }
  135.  
  136. struct nv50_format {
  137.    uint32_t rt;
  138.    uint32_t tic;
  139.    uint32_t vtx;
  140.    uint32_t usage;
  141. };
  142.  
  143. extern const struct nv50_format nv50_format_table[];
  144.  
  145. static INLINE void
  146. nv50_screen_tic_unlock(struct nv50_screen *screen, struct nv50_tic_entry *tic)
  147. {
  148.    if (tic->id >= 0)
  149.       screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
  150. }
  151.  
  152. static INLINE void
  153. nv50_screen_tsc_unlock(struct nv50_screen *screen, struct nv50_tsc_entry *tsc)
  154. {
  155.    if (tsc->id >= 0)
  156.       screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
  157. }
  158.  
  159. static INLINE void
  160. nv50_screen_tic_free(struct nv50_screen *screen, struct nv50_tic_entry *tic)
  161. {
  162.    if (tic->id >= 0) {
  163.       screen->tic.entries[tic->id] = NULL;
  164.       screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
  165.    }
  166. }
  167.  
  168. static INLINE void
  169. nv50_screen_tsc_free(struct nv50_screen *screen, struct nv50_tsc_entry *tsc)
  170. {
  171.    if (tsc->id >= 0) {
  172.       screen->tsc.entries[tsc->id] = NULL;
  173.       screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
  174.    }
  175. }
  176.  
  177. extern int nv50_tls_realloc(struct nv50_screen *screen, unsigned tls_space);
  178.  
  179. #endif
  180.