Path: blob/21.2-virgl/src/gallium/drivers/panfrost/pan_resource.h
4570 views
/*1* © Copyright2018-2019 Alyssa Rosenzweig2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22*/232425#ifndef PAN_RESOURCE_H26#define PAN_RESOURCE_H2728#include "pan_screen.h"29#include "pan_minmax_cache.h"30#include "pan_texture.h"31#include "drm-uapi/drm.h"32#include "util/u_range.h"3334#define LAYOUT_CONVERT_THRESHOLD 835#define PAN_MAX_BATCHES 323637struct panfrost_resource {38struct pipe_resource base;39struct {40struct pipe_scissor_state extent;41struct {42bool enable;43unsigned stride;44unsigned size;45BITSET_WORD *data;46} tile_map;47} damage;4849struct {50struct panfrost_batch *writer;51BITSET_DECLARE(users, PAN_MAX_BATCHES);52} track;5354struct renderonly_scanout *scanout;5556struct panfrost_resource *separate_stencil;5758struct util_range valid_buffer_range;5960/* Description of the resource layout */61struct pan_image image;6263struct {64/* Is the checksum for this image valid? Implicitly refers to65* the first slice; we only checksum non-mipmapped 2D images */66bool crc;6768/* Has anything been written to this slice? */69BITSET_DECLARE(data, MAX_MIP_LEVELS);70} valid;7172/* Whether the modifier can be changed */73bool modifier_constant;7475/* Used to decide when to convert to another modifier */76uint16_t modifier_updates;7778/* Cached min/max values for index buffers */79struct panfrost_minmax_cache *index_cache;80};8182static inline struct panfrost_resource *83pan_resource(struct pipe_resource *p)84{85return (struct panfrost_resource *)p;86}8788struct panfrost_transfer {89struct pipe_transfer base;90void *map;91struct {92struct pipe_resource *rsrc;93struct pipe_box box;94} staging;95};9697static inline struct panfrost_transfer *98pan_transfer(struct pipe_transfer *p)99{100return (struct panfrost_transfer *)p;101}102103mali_ptr104panfrost_get_texture_address(struct panfrost_resource *rsrc,105unsigned level, unsigned layer,106unsigned sample);107108void109panfrost_get_afbc_pointers(struct panfrost_resource *rsrc,110unsigned level, unsigned layer,111mali_ptr *header, mali_ptr *body);112113void panfrost_resource_screen_init(struct pipe_screen *screen);114115void panfrost_resource_context_init(struct pipe_context *pctx);116117/* Blitting */118119void120panfrost_blit(struct pipe_context *pipe,121const struct pipe_blit_info *info);122123void124panfrost_resource_set_damage_region(struct pipe_screen *screen,125struct pipe_resource *res,126unsigned int nrects,127const struct pipe_box *rects);128129static inline enum mali_texture_dimension130panfrost_translate_texture_dimension(enum pipe_texture_target t) {131switch (t)132{133case PIPE_BUFFER:134case PIPE_TEXTURE_1D:135case PIPE_TEXTURE_1D_ARRAY:136return MALI_TEXTURE_DIMENSION_1D;137138case PIPE_TEXTURE_2D:139case PIPE_TEXTURE_2D_ARRAY:140case PIPE_TEXTURE_RECT:141return MALI_TEXTURE_DIMENSION_2D;142143case PIPE_TEXTURE_3D:144return MALI_TEXTURE_DIMENSION_3D;145146case PIPE_TEXTURE_CUBE:147case PIPE_TEXTURE_CUBE_ARRAY:148return MALI_TEXTURE_DIMENSION_CUBE;149150default:151unreachable("Unknown target");152}153}154155void156pan_resource_modifier_convert(struct panfrost_context *ctx,157struct panfrost_resource *rsrc,158uint64_t modifier);159160#endif /* PAN_RESOURCE_H */161162163