1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2014 Broadcom 3bf215546Sopenharmony_ci * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org> 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22bf215546Sopenharmony_ci * IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci#ifndef VC4_RESOURCE_H 26bf215546Sopenharmony_ci#define VC4_RESOURCE_H 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#include "vc4_screen.h" 29bf215546Sopenharmony_ci#include "kernel/vc4_packet.h" 30bf215546Sopenharmony_ci#include "util/u_transfer.h" 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_cistruct vc4_transfer { 33bf215546Sopenharmony_ci struct pipe_transfer base; 34bf215546Sopenharmony_ci void *map; 35bf215546Sopenharmony_ci}; 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_cistruct vc4_resource_slice { 38bf215546Sopenharmony_ci uint32_t offset; 39bf215546Sopenharmony_ci uint32_t stride; 40bf215546Sopenharmony_ci uint32_t size; 41bf215546Sopenharmony_ci /** One of VC4_TILING_FORMAT_* */ 42bf215546Sopenharmony_ci uint8_t tiling; 43bf215546Sopenharmony_ci}; 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_cistruct vc4_surface { 46bf215546Sopenharmony_ci struct pipe_surface base; 47bf215546Sopenharmony_ci uint32_t offset; 48bf215546Sopenharmony_ci uint8_t tiling; 49bf215546Sopenharmony_ci}; 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_cistruct vc4_resource { 52bf215546Sopenharmony_ci struct pipe_resource base; 53bf215546Sopenharmony_ci struct vc4_bo *bo; 54bf215546Sopenharmony_ci struct renderonly_scanout *scanout; 55bf215546Sopenharmony_ci struct vc4_resource_slice slices[VC4_MAX_MIP_LEVELS]; 56bf215546Sopenharmony_ci uint32_t cube_map_stride; 57bf215546Sopenharmony_ci int cpp; 58bf215546Sopenharmony_ci bool tiled; 59bf215546Sopenharmony_ci /** One of VC4_TEXTURE_TYPE_* */ 60bf215546Sopenharmony_ci enum vc4_texture_data_type vc4_format; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci /** 63bf215546Sopenharmony_ci * Number of times the resource has been written to. 64bf215546Sopenharmony_ci * 65bf215546Sopenharmony_ci * This is used to track when we need to update this shadow resource 66bf215546Sopenharmony_ci * from its parent in the case of GL_TEXTURE_BASE_LEVEL (which we 67bf215546Sopenharmony_ci * can't support in hardware) or GL_UNSIGNED_INTEGER index buffers. 68bf215546Sopenharmony_ci */ 69bf215546Sopenharmony_ci uint64_t writes; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /** 72bf215546Sopenharmony_ci * Bitmask of PIPE_CLEAR_COLOR0, PIPE_CLEAR_DEPTH, PIPE_CLEAR_STENCIL 73bf215546Sopenharmony_ci * for which parts of the resource are defined. 74bf215546Sopenharmony_ci * 75bf215546Sopenharmony_ci * Used for avoiding fallback to quad clears for clearing just depth, 76bf215546Sopenharmony_ci * when the stencil contents have never been initialized. Note that 77bf215546Sopenharmony_ci * we're lazy and fields not present in the buffer (DEPTH in a color 78bf215546Sopenharmony_ci * buffer) may get marked. 79bf215546Sopenharmony_ci */ 80bf215546Sopenharmony_ci uint32_t initialized_buffers; 81bf215546Sopenharmony_ci}; 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_cistatic inline struct vc4_resource * 84bf215546Sopenharmony_civc4_resource(struct pipe_resource *prsc) 85bf215546Sopenharmony_ci{ 86bf215546Sopenharmony_ci return (struct vc4_resource *)prsc; 87bf215546Sopenharmony_ci} 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_cistatic inline struct vc4_surface * 90bf215546Sopenharmony_civc4_surface(struct pipe_surface *psurf) 91bf215546Sopenharmony_ci{ 92bf215546Sopenharmony_ci return (struct vc4_surface *)psurf; 93bf215546Sopenharmony_ci} 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_cistatic inline struct vc4_transfer * 96bf215546Sopenharmony_civc4_transfer(struct pipe_transfer *ptrans) 97bf215546Sopenharmony_ci{ 98bf215546Sopenharmony_ci return (struct vc4_transfer *)ptrans; 99bf215546Sopenharmony_ci} 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_civoid vc4_resource_screen_init(struct pipe_screen *pscreen); 102bf215546Sopenharmony_civoid vc4_resource_context_init(struct pipe_context *pctx); 103bf215546Sopenharmony_cistruct pipe_resource *vc4_resource_create(struct pipe_screen *pscreen, 104bf215546Sopenharmony_ci const struct pipe_resource *tmpl); 105bf215546Sopenharmony_civoid vc4_update_shadow_baselevel_texture(struct pipe_context *pctx, 106bf215546Sopenharmony_ci struct pipe_sampler_view *view); 107bf215546Sopenharmony_cistruct pipe_resource *vc4_get_shadow_index_buffer(struct pipe_context *pctx, 108bf215546Sopenharmony_ci const struct pipe_draw_info *info, 109bf215546Sopenharmony_ci uint32_t offset, 110bf215546Sopenharmony_ci uint32_t count, 111bf215546Sopenharmony_ci uint32_t *shadow_offset); 112bf215546Sopenharmony_civoid vc4_dump_surface(struct pipe_surface *psurf); 113bf215546Sopenharmony_ci 114bf215546Sopenharmony_ci#endif /* VC4_RESOURCE_H */ 115