Path: blob/21.2-virgl/src/gallium/drivers/vc4/vc4_resource.h
4570 views
/*1* Copyright © 2014 Broadcom2* Copyright (C) 2012 Rob Clark <[email protected]>3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS21* IN THE SOFTWARE.22*/2324#ifndef VC4_RESOURCE_H25#define VC4_RESOURCE_H2627#include "vc4_screen.h"28#include "kernel/vc4_packet.h"29#include "util/u_transfer.h"3031struct vc4_transfer {32struct pipe_transfer base;33void *map;34};3536struct vc4_resource_slice {37uint32_t offset;38uint32_t stride;39uint32_t size;40/** One of VC4_TILING_FORMAT_* */41uint8_t tiling;42};4344struct vc4_surface {45struct pipe_surface base;46uint32_t offset;47uint8_t tiling;48};4950struct vc4_resource {51struct pipe_resource base;52struct vc4_bo *bo;53struct renderonly_scanout *scanout;54struct vc4_resource_slice slices[VC4_MAX_MIP_LEVELS];55uint32_t cube_map_stride;56int cpp;57bool tiled;58/** One of VC4_TEXTURE_TYPE_* */59enum vc4_texture_data_type vc4_format;6061/**62* Number of times the resource has been written to.63*64* This is used to track when we need to update this shadow resource65* from its parent in the case of GL_TEXTURE_BASE_LEVEL (which we66* can't support in hardware) or GL_UNSIGNED_INTEGER index buffers.67*/68uint64_t writes;6970/**71* Bitmask of PIPE_CLEAR_COLOR0, PIPE_CLEAR_DEPTH, PIPE_CLEAR_STENCIL72* for which parts of the resource are defined.73*74* Used for avoiding fallback to quad clears for clearing just depth,75* when the stencil contents have never been initialized. Note that76* we're lazy and fields not present in the buffer (DEPTH in a color77* buffer) may get marked.78*/79uint32_t initialized_buffers;80};8182static inline struct vc4_resource *83vc4_resource(struct pipe_resource *prsc)84{85return (struct vc4_resource *)prsc;86}8788static inline struct vc4_surface *89vc4_surface(struct pipe_surface *psurf)90{91return (struct vc4_surface *)psurf;92}9394static inline struct vc4_transfer *95vc4_transfer(struct pipe_transfer *ptrans)96{97return (struct vc4_transfer *)ptrans;98}99100void vc4_resource_screen_init(struct pipe_screen *pscreen);101void vc4_resource_context_init(struct pipe_context *pctx);102struct pipe_resource *vc4_resource_create(struct pipe_screen *pscreen,103const struct pipe_resource *tmpl);104void vc4_update_shadow_baselevel_texture(struct pipe_context *pctx,105struct pipe_sampler_view *view);106struct pipe_resource *vc4_get_shadow_index_buffer(struct pipe_context *pctx,107const struct pipe_draw_info *info,108uint32_t offset,109uint32_t count,110uint32_t *shadow_offset);111void vc4_dump_surface(struct pipe_surface *psurf);112113#endif /* VC4_RESOURCE_H */114115116