Path: blob/21.2-virgl/src/gallium/drivers/swr/swr_resource.h
4570 views
/****************************************************************************1* Copyright (C) 2015 Intel Corporation. All Rights Reserved.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21***************************************************************************/2223#ifndef SWR_RESOURCE_H24#define SWR_RESOURCE_H2526#include "memory/SurfaceState.h"27#include "pipe/p_state.h"28#include "api.h"2930struct sw_displaytarget;3132enum swr_resource_status {33SWR_RESOURCE_UNUSED = 0x0,34SWR_RESOURCE_READ = 0x1,35SWR_RESOURCE_WRITE = 0x2,36};3738struct swr_resource {39struct pipe_resource base;4041bool has_depth;42bool has_stencil;4344SWR_SURFACE_STATE swr;45SWR_SURFACE_STATE secondary; /* for faking depth/stencil merged formats */4647struct sw_displaytarget *display_target;4849/* If resource is multisample, then this points to a alternate resource50* containing the resolved multisample surface, otherwise null */51struct pipe_resource *resolve_target;5253size_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS];54size_t secondary_mip_offsets[PIPE_MAX_TEXTURE_LEVELS];5556enum swr_resource_status status;5758/* last pipe that used (validated) this resource */59struct pipe_context *curr_pipe;60};616263static INLINE struct swr_resource *64swr_resource(struct pipe_resource *resource)65{66return (struct swr_resource *)resource;67}6869static INLINE bool70swr_resource_is_texture(const struct pipe_resource *resource)71{72switch (resource->target) {73case PIPE_BUFFER:74return false;75case PIPE_TEXTURE_1D:76case PIPE_TEXTURE_1D_ARRAY:77case PIPE_TEXTURE_2D:78case PIPE_TEXTURE_2D_ARRAY:79case PIPE_TEXTURE_RECT:80case PIPE_TEXTURE_3D:81case PIPE_TEXTURE_CUBE:82case PIPE_TEXTURE_CUBE_ARRAY:83return true;84default:85assert(0);86return false;87}88}899091static INLINE uint8_t *92swr_resource_data(struct pipe_resource *resource)93{94struct swr_resource *swr_r = swr_resource(resource);9596assert(!swr_resource_is_texture(resource));9798return (uint8_t*)(swr_r->swr.xpBaseAddress);99}100101102void swr_invalidate_render_target(struct pipe_context *pipe,103uint32_t attachment,104uint16_t width, uint16_t height);105106void swr_store_render_target(struct pipe_context *pipe,107uint32_t attachment,108enum SWR_TILE_STATE post_tile_state);109110void swr_store_dirty_resource(struct pipe_context *pipe,111struct pipe_resource *resource,112enum SWR_TILE_STATE post_tile_state);113114void swr_update_resource_status(struct pipe_context *,115const struct pipe_draw_info *);116117/*118* Functions to indicate a resource's in-use status.119*/120static INLINE enum121swr_resource_status & operator|=(enum swr_resource_status & a,122enum swr_resource_status b) {123return (enum swr_resource_status &)((int&)a |= (int)b);124}125126static INLINE void127swr_resource_read(struct pipe_resource *resource)128{129swr_resource(resource)->status |= SWR_RESOURCE_READ;130}131132static INLINE void133swr_resource_write(struct pipe_resource *resource)134{135swr_resource(resource)->status |= SWR_RESOURCE_WRITE;136}137138static INLINE void139swr_resource_unused(struct pipe_resource *resource)140{141swr_resource(resource)->status = SWR_RESOURCE_UNUSED;142}143144#endif145146147