Path: blob/21.2-virgl/src/gallium/drivers/zink/zink_framebuffer.h
4570 views
/*1* Copyright 2018 Collabora Ltd.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* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the 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 NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/2223#ifndef ZINK_FRAMEBUFFER_H24#define ZINK_FRAMEBUFFER_H2526#include "pipe/p_state.h"27#include <vulkan/vulkan.h>2829#include "util/hash_table.h"30#include "util/u_inlines.h"3132struct zink_context;33struct zink_screen;34struct zink_render_pass;3536struct zink_framebuffer_state {37uint32_t width;38uint16_t height, layers;39uint8_t samples;40uint8_t num_attachments;41VkImageView attachments[PIPE_MAX_COLOR_BUFS + 1];42};4344struct zink_framebuffer {45struct pipe_reference reference;4647/* current objects */48VkFramebuffer fb;49struct zink_render_pass *rp;5051struct pipe_surface *surfaces[PIPE_MAX_COLOR_BUFS + 1];52struct pipe_surface *null_surface; /* for use with unbound attachments */53struct zink_framebuffer_state state;54struct hash_table objects;55};5657struct zink_framebuffer *58zink_create_framebuffer(struct zink_context *ctx,59struct zink_framebuffer_state *fb,60struct pipe_surface **attachments);6162void63zink_init_framebuffer(struct zink_screen *screen, struct zink_framebuffer *fb, struct zink_render_pass *rp);6465void66zink_destroy_framebuffer(struct zink_screen *screen,67struct zink_framebuffer *fbuf);6869void70debug_describe_zink_framebuffer(char* buf, const struct zink_framebuffer *ptr);7172static inline bool73zink_framebuffer_reference(struct zink_screen *screen,74struct zink_framebuffer **dst,75struct zink_framebuffer *src)76{77struct zink_framebuffer *old_dst = *dst;78bool ret = false;7980if (pipe_reference_described(&old_dst->reference, src ? &src->reference : NULL,81(debug_reference_descriptor)debug_describe_zink_framebuffer)) {82zink_destroy_framebuffer(screen, old_dst);83ret = true;84}85*dst = src;86return ret;87}8889#endif909192