Home | History | Annotate | Download | only in nv50
      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 
     20 #define NV50_TILE_SHIFT_X(m) 6
     21 #define NV50_TILE_SHIFT_Y(m) ((((m) >> 4) & 0xf) + 2)
     22 #define NV50_TILE_SHIFT_Z(m) ((((m) >> 8) & 0xf) + 0)
     23 
     24 #define NV50_TILE_SIZE_X(m) 64
     25 #define NV50_TILE_SIZE_Y(m) ( 4 << (((m) >> 4) & 0xf))
     26 #define NV50_TILE_SIZE_Z(m) ( 1 << (((m) >> 8) & 0xf))
     27 
     28 #define NV50_TILE_SIZE_2D(m) (NV50_TILE_SIZE_X(m) << NV50_TILE_SHIFT_Y(m))
     29 
     30 #define NV50_TILE_SIZE(m) (NV50_TILE_SIZE_2D(m) << NV50_TILE_SHIFT_Z(m))
     31 
     32 #endif /* __NVC0_RESOURCE_H__ */
     33 
     34 uint32_t
     35 nvc0_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz);
     36 
     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 /* Internal functions:
     64  */
     65 boolean
     66 nv50_miptree_init_layout_linear(struct nv50_miptree *mt);
     67 
     68 struct pipe_resource *
     69 nv50_miptree_create(struct pipe_screen *pscreen,
     70                     const struct pipe_resource *tmp);
     71 
     72 void
     73 nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt);
     74 
     75 struct pipe_resource *
     76 nv50_miptree_from_handle(struct pipe_screen *pscreen,
     77                          const struct pipe_resource *template,
     78                          struct winsys_handle *whandle);
     79 
     80 boolean
     81 nv50_miptree_get_handle(struct pipe_screen *pscreen,
     82                         struct pipe_resource *pt,
     83                         struct winsys_handle *whandle);
     84 
     85 struct nv50_surface {
     86    struct pipe_surface base;
     87    uint32_t offset;
     88    uint32_t width;
     89    uint16_t height;
     90    uint16_t depth;
     91 };
     92 
     93 static INLINE struct nv50_surface *
     94 nv50_surface(struct pipe_surface *ps)
     95 {
     96    return (struct nv50_surface *)ps;
     97 }
     98 
     99 static INLINE enum pipe_format
    100 nv50_zs_to_s_format(enum pipe_format format)
    101 {
    102    switch (format) {
    103    case PIPE_FORMAT_Z24_UNORM_S8_UINT: return PIPE_FORMAT_X24S8_UINT;
    104    case PIPE_FORMAT_S8_UINT_Z24_UNORM: return PIPE_FORMAT_S8X24_UINT;
    105    case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: return PIPE_FORMAT_X32_S8X24_UINT;
    106    default:
    107       return format;
    108    }
    109 }
    110 
    111 #ifndef __NVC0_RESOURCE_H__
    112 
    113 unsigned
    114 nv50_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z);
    115 
    116 struct pipe_surface *
    117 nv50_miptree_surface_new(struct pipe_context *,
    118                          struct pipe_resource *,
    119                          const struct pipe_surface *templ);
    120 
    121 struct pipe_transfer *
    122 nv50_miptree_transfer_new(struct pipe_context *pcontext,
    123                           struct pipe_resource *pt,
    124                           unsigned level,
    125                           unsigned usage,
    126                           const struct pipe_box *box);
    127 void
    128 nv50_miptree_transfer_del(struct pipe_context *pcontext,
    129                           struct pipe_transfer *ptx);
    130 void *
    131 nv50_miptree_transfer_map(struct pipe_context *pcontext,
    132                           struct pipe_transfer *ptx);
    133 void
    134 nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
    135                             struct pipe_transfer *ptx);
    136 
    137 #endif /* __NVC0_RESOURCE_H__ */
    138 
    139 struct nv50_surface *
    140 nv50_surface_from_miptree(struct nv50_miptree *mt,
    141                           const struct pipe_surface *templ);
    142 
    143 struct pipe_surface *
    144 nv50_surface_from_buffer(struct pipe_context *pipe,
    145                          struct pipe_resource *pt,
    146                          const struct pipe_surface *templ);
    147 
    148 void
    149 nv50_surface_destroy(struct pipe_context *, struct pipe_surface *);
    150 
    151 #endif /* __NV50_RESOURCE_H__ */
    152