Path: blob/21.2-virgl/src/gallium/drivers/nouveau/nv50/nv50_resource.h
4574 views
1#ifndef __NV50_RESOURCE_H__2#define __NV50_RESOURCE_H__34#include "util/u_transfer.h"5#include "util/list.h"67#include "nouveau_winsys.h"8#include "nouveau_buffer.h"910#ifndef __NVC0_RESOURCE_H__ /* make sure we don't use these in nvc0: */1112void13nv50_init_resource_functions(struct pipe_context *pcontext);1415void16nv50_screen_init_resource_functions(struct pipe_screen *pscreen);1718#define NV50_RESOURCE_FLAG_VIDEO (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 0)19#define NV50_RESOURCE_FLAG_NOALLOC (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 1)2021#define NV50_TILE_SHIFT_X(m) 622#define NV50_TILE_SHIFT_Y(m) ((((m) >> 4) & 0xf) + 2)23#define NV50_TILE_SHIFT_Z(m) ((((m) >> 8) & 0xf) + 0)2425#define NV50_TILE_SIZE_X(m) 6426#define NV50_TILE_SIZE_Y(m) ( 4 << (((m) >> 4) & 0xf))27#define NV50_TILE_SIZE_Z(m) ( 1 << (((m) >> 8) & 0xf))2829#define NV50_TILE_SIZE_2D(m) (NV50_TILE_SIZE_X(m) << NV50_TILE_SHIFT_Y(m))3031#define NV50_TILE_SIZE(m) (NV50_TILE_SIZE_2D(m) << NV50_TILE_SHIFT_Z(m))3233#endif /* __NVC0_RESOURCE_H__ */3435uint32_t36nv50_tex_choose_tile_dims_helper(unsigned nx, unsigned ny, unsigned nz,37bool is_3d);3839struct nv50_miptree_level {40uint32_t offset;41uint32_t pitch;42uint32_t tile_mode;43};4445#define NV50_MAX_TEXTURE_LEVELS 164647struct nv50_miptree {48struct nv04_resource base;49struct nv50_miptree_level level[NV50_MAX_TEXTURE_LEVELS];50uint32_t total_size;51uint32_t layer_stride;52bool layout_3d; /* true if layer count varies with mip level */53uint8_t ms_x; /* log2 of number of samples in x/y dimension */54uint8_t ms_y;55uint8_t ms_mode;56};5758static inline struct nv50_miptree *59nv50_miptree(struct pipe_resource *pt)60{61return (struct nv50_miptree *)pt;62}636465#define NV50_TEXVIEW_SCALED_COORDS (1 << 0)66#define NV50_TEXVIEW_FILTER_MSAA8 (1 << 1)67#define NV50_TEXVIEW_ACCESS_RESOLVE (1 << 2)68#define NV50_TEXVIEW_IMAGE_GM107 (1 << 3)697071/* Internal functions:72*/73bool74nv50_miptree_init_layout_linear(struct nv50_miptree *mt, unsigned pitch_align);7576struct pipe_resource *77nv50_miptree_create(struct pipe_screen *pscreen,78const struct pipe_resource *tmp);7980void81nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt);8283struct pipe_resource *84nv50_miptree_from_handle(struct pipe_screen *pscreen,85const struct pipe_resource *template,86struct winsys_handle *whandle);8788bool89nv50_miptree_get_handle(struct pipe_screen *pscreen,90struct pipe_context *context,91struct pipe_resource *pt,92struct winsys_handle *whandle,93unsigned usage);9495struct nv50_surface {96struct pipe_surface base;97uint32_t offset;98uint32_t width;99uint16_t height;100uint16_t depth;101};102103static inline struct nv50_surface *104nv50_surface(struct pipe_surface *ps)105{106return (struct nv50_surface *)ps;107}108109static inline enum pipe_format110nv50_zs_to_s_format(enum pipe_format format)111{112switch (format) {113case PIPE_FORMAT_Z24_UNORM_S8_UINT: return PIPE_FORMAT_X24S8_UINT;114case PIPE_FORMAT_S8_UINT_Z24_UNORM: return PIPE_FORMAT_S8X24_UINT;115case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: return PIPE_FORMAT_X32_S8X24_UINT;116default:117return format;118}119}120121#ifndef __NVC0_RESOURCE_H__122123unsigned124nv50_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z);125126struct pipe_surface *127nv50_miptree_surface_new(struct pipe_context *,128struct pipe_resource *,129const struct pipe_surface *templ);130131void *132nv50_miptree_transfer_map(struct pipe_context *pctx,133struct pipe_resource *res,134unsigned level,135unsigned usage,136const struct pipe_box *box,137struct pipe_transfer **ptransfer);138void139nv50_miptree_transfer_unmap(struct pipe_context *pcontext,140struct pipe_transfer *ptx);141142#endif /* __NVC0_RESOURCE_H__ */143144struct nv50_surface *145nv50_surface_from_miptree(struct nv50_miptree *mt,146const struct pipe_surface *templ);147148struct pipe_surface *149nv50_surface_from_buffer(struct pipe_context *pipe,150struct pipe_resource *pt,151const struct pipe_surface *templ);152153void154nv50_surface_destroy(struct pipe_context *, struct pipe_surface *);155156void157nv50_invalidate_resource(struct pipe_context *, struct pipe_resource *);158159void160nv50_clear_texture(struct pipe_context *pipe,161struct pipe_resource *res,162unsigned level,163const struct pipe_box *box,164const void *data);165166#endif /* __NV50_RESOURCE_H__ */167168169