1/* 2 * Copyright (c) 2017-2019 Lima Project 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sub license, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the 12 * next paragraph) shall be included in all copies or substantial portions 13 * of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 * 23 */ 24 25#ifndef H_LIMA_RESOURCE 26#define H_LIMA_RESOURCE 27 28#include "pipe/p_state.h" 29 30/* max texture size is 4096x4096 */ 31#define LIMA_MAX_MIP_LEVELS 13 32#define LAYOUT_CONVERT_THRESHOLD 8 33 34struct lima_screen; 35struct panfrost_minmax_cache; 36 37struct lima_resource_level { 38 uint32_t width; 39 uint32_t stride; 40 uint32_t offset; 41 uint32_t layer_stride; 42}; 43 44struct lima_damage_region { 45 struct pipe_scissor_state *region; 46 struct pipe_scissor_state bound; 47 unsigned num_region; 48 bool aligned; 49}; 50 51struct lima_resource { 52 struct pipe_resource base; 53 54 struct lima_damage_region damage; 55 struct renderonly_scanout *scanout; 56 struct lima_bo *bo; 57 struct panfrost_minmax_cache *index_cache; 58 uint32_t mrt_pitch; 59 bool tiled; 60 bool modifier_constant; 61 unsigned full_updates; 62 63 struct lima_resource_level levels[LIMA_MAX_MIP_LEVELS]; 64}; 65 66struct lima_surface { 67 struct pipe_surface base; 68 int tiled_w, tiled_h; 69 unsigned reload; 70}; 71 72struct lima_transfer { 73 struct pipe_transfer base; 74 void *staging; 75}; 76 77static inline struct lima_resource * 78lima_resource(struct pipe_resource *res) 79{ 80 return (struct lima_resource *)res; 81} 82 83static inline struct lima_surface * 84lima_surface(struct pipe_surface *surf) 85{ 86 return (struct lima_surface *)surf; 87} 88 89static inline struct lima_transfer * 90lima_transfer(struct pipe_transfer *trans) 91{ 92 return (struct lima_transfer *)trans; 93} 94 95void 96lima_resource_screen_init(struct lima_screen *screen); 97 98void 99lima_resource_context_init(struct lima_context *ctx); 100 101#endif 102