Path: blob/21.2-virgl/src/gallium/drivers/v3d/v3d_resource.h
4570 views
/*1* Copyright © 2014-2017 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 V3D_RESOURCE_H25#define V3D_RESOURCE_H2627#include "v3d_screen.h"28#include "util/u_transfer.h"2930#include "broadcom/common/v3d_tiling.h"3132struct v3d_transfer {33struct pipe_transfer base;34void *map;35};3637struct v3d_resource_slice {38uint32_t offset;39uint32_t stride;40uint32_t padded_height;41/* Size of a single pane of the slice. For 3D textures, there will be42* a number of panes equal to the minified, power-of-two-aligned43* depth.44*/45uint32_t size;46uint8_t ub_pad;47enum v3d_tiling_mode tiling;48};4950struct v3d_surface {51struct pipe_surface base;52uint32_t offset;53enum v3d_tiling_mode tiling;54/**55* Output image format for TILE_RENDERING_MODE_CONFIGURATION56*/57uint8_t format;5859/**60* Internal format of the tile buffer for61* TILE_RENDERING_MODE_CONFIGURATION.62*/63uint8_t internal_type;6465/**66* internal bpp value (0=32bpp, 2=128bpp) for color buffers in67* TILE_RENDERING_MODE_CONFIGURATION.68*/69uint8_t internal_bpp;7071/**72* If the R and B channels should be swapped. On V3D 3.x, we do it in73* the shader and the blend equation. On V3D 4.1+, we can use the new74* TLB load/store flags instead of recompiling.75*/76bool swap_rb;7778uint32_t padded_height_of_output_image_in_uif_blocks;7980/* If the resource being referenced is separate stencil, then this is81* the surface to use when reading/writing stencil.82*/83struct pipe_surface *separate_stencil;84};8586struct v3d_resource {87struct pipe_resource base;88struct v3d_bo *bo;89struct renderonly_scanout *scanout;90struct v3d_resource_slice slices[V3D_MAX_MIP_LEVELS];91uint32_t cube_map_stride;92uint32_t sand_col128_stride;93uint32_t size;94int cpp;95bool tiled;9697/**98* Indicates if the CS has written the resource99*/100bool compute_written;101102/**103* Number of times the resource has been written to.104*105* This is used to track whether we need to load the surface on first106* rendering.107*/108uint64_t writes;109110/**111* Bitmask of PIPE_CLEAR_COLOR0, PIPE_CLEAR_DEPTH, PIPE_CLEAR_STENCIL112* for which parts of the resource are defined.113*114* Used for avoiding fallback to quad clears for clearing just depth,115* when the stencil contents have never been initialized. Note that116* we're lazy and fields not present in the buffer (DEPTH in a color117* buffer) may get marked.118*/119uint32_t initialized_buffers;120121enum pipe_format internal_format;122123/* Resource storing the S8 part of a Z32F_S8 resource, or NULL. */124struct v3d_resource *separate_stencil;125};126127static inline struct v3d_resource *128v3d_resource(struct pipe_resource *prsc)129{130return (struct v3d_resource *)prsc;131}132133static inline struct v3d_surface *134v3d_surface(struct pipe_surface *psurf)135{136return (struct v3d_surface *)psurf;137}138139static inline struct v3d_transfer *140v3d_transfer(struct pipe_transfer *ptrans)141{142return (struct v3d_transfer *)ptrans;143}144145void v3d_resource_screen_init(struct pipe_screen *pscreen);146void v3d_resource_context_init(struct pipe_context *pctx);147struct pipe_resource *v3d_resource_create(struct pipe_screen *pscreen,148const struct pipe_resource *tmpl);149void v3d_update_shadow_texture(struct pipe_context *pctx,150struct pipe_sampler_view *view);151uint32_t v3d_layer_offset(struct pipe_resource *prsc, uint32_t level,152uint32_t layer);153154155#endif /* V3D_RESOURCE_H */156157158