Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. #ifndef __NV50_RESOURCE_H__
  3. #define __NV50_RESOURCE_H__
  4.  
  5. #include "util/u_transfer.h"
  6. #include "util/u_double_list.h"
  7.  
  8. #include "nouveau/nouveau_winsys.h"
  9. #include "nouveau/nouveau_buffer.h"
  10.  
  11. #ifndef __NVC0_RESOURCE_H__ /* make sure we don't use these in nvc0: */
  12.  
  13. void
  14. nv50_init_resource_functions(struct pipe_context *pcontext);
  15.  
  16. void
  17. nv50_screen_init_resource_functions(struct pipe_screen *pscreen);
  18.  
  19. #define NV50_RESOURCE_FLAG_VIDEO (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 0)
  20.  
  21. #define NV50_TILE_SHIFT_X(m) 6
  22. #define NV50_TILE_SHIFT_Y(m) ((((m) >> 4) & 0xf) + 2)
  23. #define NV50_TILE_SHIFT_Z(m) ((((m) >> 8) & 0xf) + 0)
  24.  
  25. #define NV50_TILE_SIZE_X(m) 64
  26. #define NV50_TILE_SIZE_Y(m) ( 4 << (((m) >> 4) & 0xf))
  27. #define NV50_TILE_SIZE_Z(m) ( 1 << (((m) >> 8) & 0xf))
  28.  
  29. #define NV50_TILE_SIZE_2D(m) (NV50_TILE_SIZE_X(m) << NV50_TILE_SHIFT_Y(m))
  30.  
  31. #define NV50_TILE_SIZE(m) (NV50_TILE_SIZE_2D(m) << NV50_TILE_SHIFT_Z(m))
  32.  
  33. #endif /* __NVC0_RESOURCE_H__ */
  34.  
  35. uint32_t
  36. nv50_tex_choose_tile_dims_helper(unsigned nx, unsigned ny, unsigned nz);
  37.  
  38. struct nv50_miptree_level {
  39.    uint32_t offset;
  40.    uint32_t pitch;
  41.    uint32_t tile_mode;
  42. };
  43.  
  44. #define NV50_MAX_TEXTURE_LEVELS 16
  45.  
  46. struct nv50_miptree {
  47.    struct nv04_resource base;
  48.    struct nv50_miptree_level level[NV50_MAX_TEXTURE_LEVELS];
  49.    uint32_t total_size;
  50.    uint32_t layer_stride;
  51.    boolean layout_3d; /* TRUE if layer count varies with mip level */
  52.    uint8_t ms_x;      /* log2 of number of samples in x/y dimension */
  53.    uint8_t ms_y;
  54.    uint8_t ms_mode;
  55. };
  56.  
  57. static INLINE struct nv50_miptree *
  58. nv50_miptree(struct pipe_resource *pt)
  59. {
  60.    return (struct nv50_miptree *)pt;
  61. }
  62.  
  63.  
  64. #define NV50_TEXVIEW_SCALED_COORDS     (1 << 0)
  65. #define NV50_TEXVIEW_FILTER_MSAA8      (1 << 1)
  66. #define NV50_TEXVIEW_ACCESS_RESOLVE    (1 << 2)
  67.  
  68.  
  69. /* Internal functions:
  70.  */
  71. boolean
  72. nv50_miptree_init_layout_linear(struct nv50_miptree *mt, unsigned pitch_align);
  73.  
  74. struct pipe_resource *
  75. nv50_miptree_create(struct pipe_screen *pscreen,
  76.                     const struct pipe_resource *tmp);
  77.  
  78. void
  79. nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt);
  80.  
  81. struct pipe_resource *
  82. nv50_miptree_from_handle(struct pipe_screen *pscreen,
  83.                          const struct pipe_resource *template,
  84.                          struct winsys_handle *whandle);
  85.  
  86. boolean
  87. nv50_miptree_get_handle(struct pipe_screen *pscreen,
  88.                         struct pipe_resource *pt,
  89.                         struct winsys_handle *whandle);
  90.  
  91. struct nv50_surface {
  92.    struct pipe_surface base;
  93.    uint32_t offset;
  94.    uint32_t width;
  95.    uint16_t height;
  96.    uint16_t depth;
  97. };
  98.  
  99. static INLINE struct nv50_surface *
  100. nv50_surface(struct pipe_surface *ps)
  101. {
  102.    return (struct nv50_surface *)ps;
  103. }
  104.  
  105. static INLINE enum pipe_format
  106. nv50_zs_to_s_format(enum pipe_format format)
  107. {
  108.    switch (format) {
  109.    case PIPE_FORMAT_Z24_UNORM_S8_UINT: return PIPE_FORMAT_X24S8_UINT;
  110.    case PIPE_FORMAT_S8_UINT_Z24_UNORM: return PIPE_FORMAT_S8X24_UINT;
  111.    case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: return PIPE_FORMAT_X32_S8X24_UINT;
  112.    default:
  113.       return format;
  114.    }
  115. }
  116.  
  117. #ifndef __NVC0_RESOURCE_H__
  118.  
  119. unsigned
  120. nv50_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z);
  121.  
  122. struct pipe_surface *
  123. nv50_miptree_surface_new(struct pipe_context *,
  124.                          struct pipe_resource *,
  125.                          const struct pipe_surface *templ);
  126.  
  127. void *
  128. nv50_miptree_transfer_map(struct pipe_context *pctx,
  129.                           struct pipe_resource *res,
  130.                           unsigned level,
  131.                           unsigned usage,
  132.                           const struct pipe_box *box,
  133.                           struct pipe_transfer **ptransfer);
  134. void
  135. nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
  136.                             struct pipe_transfer *ptx);
  137.  
  138. #endif /* __NVC0_RESOURCE_H__ */
  139.  
  140. struct nv50_surface *
  141. nv50_surface_from_miptree(struct nv50_miptree *mt,
  142.                           const struct pipe_surface *templ);
  143.  
  144. struct pipe_surface *
  145. nv50_surface_from_buffer(struct pipe_context *pipe,
  146.                          struct pipe_resource *pt,
  147.                          const struct pipe_surface *templ);
  148.  
  149. void
  150. nv50_surface_destroy(struct pipe_context *, struct pipe_surface *);
  151.  
  152. #endif /* __NV50_RESOURCE_H__ */
  153.