1bf215546Sopenharmony_ci 2bf215546Sopenharmony_ci#ifndef __NV50_RESOURCE_H__ 3bf215546Sopenharmony_ci#define __NV50_RESOURCE_H__ 4bf215546Sopenharmony_ci 5bf215546Sopenharmony_ci#include "util/u_transfer.h" 6bf215546Sopenharmony_ci#include "util/list.h" 7bf215546Sopenharmony_ci 8bf215546Sopenharmony_ci#include "nouveau_winsys.h" 9bf215546Sopenharmony_ci#include "nouveau_buffer.h" 10bf215546Sopenharmony_ci 11bf215546Sopenharmony_ci#ifndef __NVC0_RESOURCE_H__ /* make sure we don't use these in nvc0: */ 12bf215546Sopenharmony_ci 13bf215546Sopenharmony_civoid 14bf215546Sopenharmony_cinv50_init_resource_functions(struct pipe_context *pcontext); 15bf215546Sopenharmony_ci 16bf215546Sopenharmony_civoid 17bf215546Sopenharmony_cinv50_screen_init_resource_functions(struct pipe_screen *pscreen); 18bf215546Sopenharmony_ci 19bf215546Sopenharmony_ci#define NV50_RESOURCE_FLAG_VIDEO (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 0) 20bf215546Sopenharmony_ci#define NV50_RESOURCE_FLAG_NOALLOC (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 1) 21bf215546Sopenharmony_ci 22bf215546Sopenharmony_ci#define NV50_TILE_SHIFT_X(m) 6 23bf215546Sopenharmony_ci#define NV50_TILE_SHIFT_Y(m) ((((m) >> 4) & 0xf) + 2) 24bf215546Sopenharmony_ci#define NV50_TILE_SHIFT_Z(m) ((((m) >> 8) & 0xf) + 0) 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#define NV50_TILE_SIZE_X(m) 64 27bf215546Sopenharmony_ci#define NV50_TILE_SIZE_Y(m) ( 4 << (((m) >> 4) & 0xf)) 28bf215546Sopenharmony_ci#define NV50_TILE_SIZE_Z(m) ( 1 << (((m) >> 8) & 0xf)) 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#define NV50_TILE_SIZE_2D(m) (NV50_TILE_SIZE_X(m) << NV50_TILE_SHIFT_Y(m)) 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#define NV50_TILE_SIZE(m) (NV50_TILE_SIZE_2D(m) << NV50_TILE_SHIFT_Z(m)) 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#endif /* __NVC0_RESOURCE_H__ */ 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ciuint32_t 37bf215546Sopenharmony_cinv50_tex_choose_tile_dims_helper(unsigned nx, unsigned ny, unsigned nz, 38bf215546Sopenharmony_ci bool is_3d); 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cistruct nv50_miptree_level { 41bf215546Sopenharmony_ci uint32_t offset; 42bf215546Sopenharmony_ci uint32_t pitch; 43bf215546Sopenharmony_ci uint32_t tile_mode; 44bf215546Sopenharmony_ci}; 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci#define NV50_MAX_TEXTURE_LEVELS 16 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_cistruct nv50_miptree { 49bf215546Sopenharmony_ci struct nv04_resource base; 50bf215546Sopenharmony_ci struct nv50_miptree_level level[NV50_MAX_TEXTURE_LEVELS]; 51bf215546Sopenharmony_ci uint32_t total_size; 52bf215546Sopenharmony_ci uint32_t layer_stride; 53bf215546Sopenharmony_ci bool layout_3d; /* true if layer count varies with mip level */ 54bf215546Sopenharmony_ci uint8_t ms_x; /* log2 of number of samples in x/y dimension */ 55bf215546Sopenharmony_ci uint8_t ms_y; 56bf215546Sopenharmony_ci uint8_t ms_mode; 57bf215546Sopenharmony_ci}; 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_cistatic inline struct nv50_miptree * 60bf215546Sopenharmony_cinv50_miptree(struct pipe_resource *pt) 61bf215546Sopenharmony_ci{ 62bf215546Sopenharmony_ci return (struct nv50_miptree *)pt; 63bf215546Sopenharmony_ci} 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci#define NV50_TEXVIEW_SCALED_COORDS (1 << 0) 67bf215546Sopenharmony_ci#define NV50_TEXVIEW_FILTER_MSAA8 (1 << 1) 68bf215546Sopenharmony_ci#define NV50_TEXVIEW_ACCESS_RESOLVE (1 << 2) 69bf215546Sopenharmony_ci#define NV50_TEXVIEW_IMAGE_GM107 (1 << 3) 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ci/* Internal functions: 73bf215546Sopenharmony_ci */ 74bf215546Sopenharmony_cibool 75bf215546Sopenharmony_cinv50_miptree_init_layout_linear(struct nv50_miptree *mt, unsigned pitch_align); 76bf215546Sopenharmony_ci 77bf215546Sopenharmony_cistruct pipe_resource * 78bf215546Sopenharmony_cinv50_miptree_create(struct pipe_screen *pscreen, 79bf215546Sopenharmony_ci const struct pipe_resource *tmp); 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_civoid 82bf215546Sopenharmony_cinv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt); 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_cistruct pipe_resource * 85bf215546Sopenharmony_cinv50_miptree_from_handle(struct pipe_screen *pscreen, 86bf215546Sopenharmony_ci const struct pipe_resource *template, 87bf215546Sopenharmony_ci struct winsys_handle *whandle); 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_cibool 90bf215546Sopenharmony_cinv50_miptree_get_handle(struct pipe_screen *pscreen, 91bf215546Sopenharmony_ci struct pipe_context *context, 92bf215546Sopenharmony_ci struct pipe_resource *pt, 93bf215546Sopenharmony_ci struct winsys_handle *whandle, 94bf215546Sopenharmony_ci unsigned usage); 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_cistruct nv50_surface { 97bf215546Sopenharmony_ci struct pipe_surface base; 98bf215546Sopenharmony_ci uint32_t offset; 99bf215546Sopenharmony_ci uint32_t width; 100bf215546Sopenharmony_ci uint16_t height; 101bf215546Sopenharmony_ci uint16_t depth; 102bf215546Sopenharmony_ci}; 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_cistatic inline struct nv50_surface * 105bf215546Sopenharmony_cinv50_surface(struct pipe_surface *ps) 106bf215546Sopenharmony_ci{ 107bf215546Sopenharmony_ci return (struct nv50_surface *)ps; 108bf215546Sopenharmony_ci} 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_cistatic inline enum pipe_format 111bf215546Sopenharmony_cinv50_zs_to_s_format(enum pipe_format format) 112bf215546Sopenharmony_ci{ 113bf215546Sopenharmony_ci switch (format) { 114bf215546Sopenharmony_ci case PIPE_FORMAT_Z24_UNORM_S8_UINT: return PIPE_FORMAT_X24S8_UINT; 115bf215546Sopenharmony_ci case PIPE_FORMAT_S8_UINT_Z24_UNORM: return PIPE_FORMAT_S8X24_UINT; 116bf215546Sopenharmony_ci case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: return PIPE_FORMAT_X32_S8X24_UINT; 117bf215546Sopenharmony_ci default: 118bf215546Sopenharmony_ci return format; 119bf215546Sopenharmony_ci } 120bf215546Sopenharmony_ci} 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_ci#ifndef __NVC0_RESOURCE_H__ 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_ciunsigned 125bf215546Sopenharmony_cinv50_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z); 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_cistruct pipe_surface * 128bf215546Sopenharmony_cinv50_miptree_surface_new(struct pipe_context *, 129bf215546Sopenharmony_ci struct pipe_resource *, 130bf215546Sopenharmony_ci const struct pipe_surface *templ); 131bf215546Sopenharmony_ci 132bf215546Sopenharmony_civoid * 133bf215546Sopenharmony_cinv50_miptree_transfer_map(struct pipe_context *pctx, 134bf215546Sopenharmony_ci struct pipe_resource *res, 135bf215546Sopenharmony_ci unsigned level, 136bf215546Sopenharmony_ci unsigned usage, 137bf215546Sopenharmony_ci const struct pipe_box *box, 138bf215546Sopenharmony_ci struct pipe_transfer **ptransfer); 139bf215546Sopenharmony_civoid 140bf215546Sopenharmony_cinv50_miptree_transfer_unmap(struct pipe_context *pcontext, 141bf215546Sopenharmony_ci struct pipe_transfer *ptx); 142bf215546Sopenharmony_ci 143bf215546Sopenharmony_ci#endif /* __NVC0_RESOURCE_H__ */ 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_cistruct nv50_surface * 146bf215546Sopenharmony_cinv50_surface_from_miptree(struct nv50_miptree *mt, 147bf215546Sopenharmony_ci const struct pipe_surface *templ); 148bf215546Sopenharmony_ci 149bf215546Sopenharmony_cistruct pipe_surface * 150bf215546Sopenharmony_cinv50_surface_from_buffer(struct pipe_context *pipe, 151bf215546Sopenharmony_ci struct pipe_resource *pt, 152bf215546Sopenharmony_ci const struct pipe_surface *templ); 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_civoid 155bf215546Sopenharmony_cinv50_surface_destroy(struct pipe_context *, struct pipe_surface *); 156bf215546Sopenharmony_ci 157bf215546Sopenharmony_civoid 158bf215546Sopenharmony_cinv50_invalidate_resource(struct pipe_context *, struct pipe_resource *); 159bf215546Sopenharmony_ci 160bf215546Sopenharmony_civoid 161bf215546Sopenharmony_cinv50_clear_texture(struct pipe_context *pipe, 162bf215546Sopenharmony_ci struct pipe_resource *res, 163bf215546Sopenharmony_ci unsigned level, 164bf215546Sopenharmony_ci const struct pipe_box *box, 165bf215546Sopenharmony_ci const void *data); 166bf215546Sopenharmony_ci 167bf215546Sopenharmony_ci#endif /* __NV50_RESOURCE_H__ */ 168