19f464c52Smaya/*
29f464c52Smaya * Copyright (c) 2017-2019 Lima Project
39f464c52Smaya *
49f464c52Smaya * Permission is hereby granted, free of charge, to any person obtaining a
59f464c52Smaya * copy of this software and associated documentation files (the "Software"),
69f464c52Smaya * to deal in the Software without restriction, including without limitation
79f464c52Smaya * the rights to use, copy, modify, merge, publish, distribute, sub license,
89f464c52Smaya * and/or sell copies of the Software, and to permit persons to whom the
99f464c52Smaya * Software is furnished to do so, subject to the following conditions:
109f464c52Smaya *
119f464c52Smaya * The above copyright notice and this permission notice (including the
129f464c52Smaya * next paragraph) shall be included in all copies or substantial portions
139f464c52Smaya * of the Software.
149f464c52Smaya *
159f464c52Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
169f464c52Smaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
179f464c52Smaya * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
189f464c52Smaya * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
199f464c52Smaya * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
209f464c52Smaya * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
219f464c52Smaya * DEALINGS IN THE SOFTWARE.
229f464c52Smaya *
239f464c52Smaya */
249f464c52Smaya
259f464c52Smaya#ifndef H_LIMA_RESOURCE
269f464c52Smaya#define H_LIMA_RESOURCE
279f464c52Smaya
289f464c52Smaya#include "pipe/p_state.h"
299f464c52Smaya
309f464c52Smaya/* max texture size is 4096x4096 */
319f464c52Smaya#define LIMA_MAX_MIP_LEVELS 13
327ec681f3Smrg#define LAYOUT_CONVERT_THRESHOLD 8
339f464c52Smaya
349f464c52Smayastruct lima_screen;
357ec681f3Smrgstruct panfrost_minmax_cache;
369f464c52Smaya
379f464c52Smayastruct lima_resource_level {
389f464c52Smaya   uint32_t width;
399f464c52Smaya   uint32_t stride;
409f464c52Smaya   uint32_t offset;
417ec681f3Smrg   uint32_t layer_stride;
427ec681f3Smrg};
437ec681f3Smrg
447ec681f3Smrgstruct lima_damage_region {
457ec681f3Smrg   struct pipe_scissor_state *region;
467ec681f3Smrg   struct pipe_scissor_state bound;
477ec681f3Smrg   unsigned num_region;
487ec681f3Smrg   bool aligned;
499f464c52Smaya};
509f464c52Smaya
519f464c52Smayastruct lima_resource {
529f464c52Smaya   struct pipe_resource base;
539f464c52Smaya
547ec681f3Smrg   struct lima_damage_region damage;
559f464c52Smaya   struct renderonly_scanout *scanout;
569f464c52Smaya   struct lima_bo *bo;
577ec681f3Smrg   struct panfrost_minmax_cache *index_cache;
589f464c52Smaya   bool tiled;
597ec681f3Smrg   bool modifier_constant;
607ec681f3Smrg   unsigned full_updates;
619f464c52Smaya
629f464c52Smaya   struct lima_resource_level levels[LIMA_MAX_MIP_LEVELS];
639f464c52Smaya};
649f464c52Smaya
659f464c52Smayastruct lima_surface {
669f464c52Smaya   struct pipe_surface base;
679f464c52Smaya   int tiled_w, tiled_h;
687ec681f3Smrg   unsigned reload;
699f464c52Smaya};
709f464c52Smaya
719f464c52Smayastruct lima_transfer {
729f464c52Smaya   struct pipe_transfer base;
739f464c52Smaya   void *staging;
749f464c52Smaya};
759f464c52Smaya
769f464c52Smayastatic inline struct lima_resource *
779f464c52Smayalima_resource(struct pipe_resource *res)
789f464c52Smaya{
799f464c52Smaya   return (struct lima_resource *)res;
809f464c52Smaya}
819f464c52Smaya
829f464c52Smayastatic inline struct lima_surface *
839f464c52Smayalima_surface(struct pipe_surface *surf)
849f464c52Smaya{
859f464c52Smaya   return (struct lima_surface *)surf;
869f464c52Smaya}
879f464c52Smaya
889f464c52Smayastatic inline struct lima_transfer *
899f464c52Smayalima_transfer(struct pipe_transfer *trans)
909f464c52Smaya{
919f464c52Smaya   return (struct lima_transfer *)trans;
929f464c52Smaya}
939f464c52Smaya
949f464c52Smayavoid
959f464c52Smayalima_resource_screen_init(struct lima_screen *screen);
969f464c52Smaya
979f464c52Smayavoid
989f464c52Smayalima_resource_context_init(struct lima_context *ctx);
999f464c52Smaya
1009f464c52Smaya#endif
101