Path: blob/21.2-virgl/src/gallium/drivers/zink/zink_clear.h
4570 views
/*1* Copyright © 2020 Mike Blumenkrantz2*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*22* Authors:23* Mike Blumenkrantz <[email protected]>24*/2526#include "util/u_dynarray.h"27#include "pipe/p_state.h"28#include <vulkan/vulkan.h>29#include "util/u_rect.h"3031struct zink_context;32struct zink_resource;3334struct zink_framebuffer_clear_data {35union {36struct {37union pipe_color_union color;38bool srgb;39} color;40struct {41float depth;42unsigned stencil;43uint8_t bits : 2; // PIPE_CLEAR_DEPTH, PIPE_CLEAR_STENCIL44} zs;45};46struct pipe_scissor_state scissor;47bool has_scissor;48bool conditional;49};5051struct zink_framebuffer_clear {52struct util_dynarray clears;53};5455void56zink_clear(struct pipe_context *pctx,57unsigned buffers,58const struct pipe_scissor_state *scissor_state,59const union pipe_color_union *pcolor,60double depth, unsigned stencil);61void62zink_clear_texture(struct pipe_context *ctx,63struct pipe_resource *p_res,64unsigned level,65const struct pipe_box *box,66const void *data);67void68zink_clear_buffer(struct pipe_context *pctx,69struct pipe_resource *pres,70unsigned offset,71unsigned size,72const void *clear_value,73int clear_value_size);7475void76zink_clear_render_target(struct pipe_context *ctx, struct pipe_surface *dst,77const union pipe_color_union *color, unsigned dstx,78unsigned dsty, unsigned width, unsigned height,79bool render_condition_enabled);8081void82zink_clear_depth_stencil(struct pipe_context *ctx, struct pipe_surface *dst,83unsigned clear_flags, double depth, unsigned stencil,84unsigned dstx, unsigned dsty, unsigned width, unsigned height,85bool render_condition_enabled);8687bool88zink_fb_clear_needs_explicit(struct zink_framebuffer_clear *fb_clear);8990bool91zink_fb_clear_first_needs_explicit(struct zink_framebuffer_clear *fb_clear);9293void94zink_clear_framebuffer(struct zink_context *ctx, unsigned clear_buffers);9596static inline struct zink_framebuffer_clear_data *97zink_fb_clear_element(struct zink_framebuffer_clear *fb_clear, int idx)98{99return util_dynarray_element(&fb_clear->clears, struct zink_framebuffer_clear_data, idx);100}101102static inline unsigned103zink_fb_clear_count(struct zink_framebuffer_clear *fb_clear)104{105return fb_clear ? util_dynarray_num_elements(&fb_clear->clears, struct zink_framebuffer_clear_data) : 0;106}107108void109zink_fb_clear_reset(struct zink_context *ctx, unsigned idx);110111static inline bool112zink_fb_clear_element_needs_explicit(struct zink_framebuffer_clear_data *clear)113{114return clear->has_scissor || clear->conditional;115}116117void118zink_clear_apply_conditionals(struct zink_context *ctx);119120void121zink_fb_clears_apply(struct zink_context *ctx, struct pipe_resource *pres);122123void124zink_fb_clears_discard(struct zink_context *ctx, struct pipe_resource *pres);125126void127zink_fb_clears_apply_or_discard(struct zink_context *ctx, struct pipe_resource *pres, struct u_rect region, bool discard_only);128129void130zink_fb_clears_apply_region(struct zink_context *ctx, struct pipe_resource *pres, struct u_rect region);131132void133zink_fb_clear_util_unpack_clear_color(struct zink_framebuffer_clear_data *clear, enum pipe_format format, union pipe_color_union *color);134135136