Path: blob/21.2-virgl/src/vulkan/util/vk_format.h
7136 views
/*1* Copyright © 2016 Intel Corporation2* Copyright © 2019 Google LLC3*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 OTHER21* DEALINGS IN THE SOFTWARE.22*/2324#ifndef U_FORMAT_VK_H25#define U_FORMAT_VK_H2627#include <vulkan/vulkan_core.h>28#include "util/format/u_format.h"2930enum pipe_format31vk_format_to_pipe_format(enum VkFormat vkformat);3233VkImageAspectFlags34vk_format_aspects(VkFormat format);3536static inline bool37vk_format_is_color(VkFormat format)38{39return vk_format_aspects(format) == VK_IMAGE_ASPECT_COLOR_BIT;40}4142static inline bool43vk_format_is_depth_or_stencil(VkFormat format)44{45const VkImageAspectFlags aspects = vk_format_aspects(format);46return aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);47}4849static inline bool50vk_format_has_depth(VkFormat format)51{52const VkImageAspectFlags aspects = vk_format_aspects(format);53return aspects & VK_IMAGE_ASPECT_DEPTH_BIT;54}5556static inline bool57vk_format_has_stencil(VkFormat format)58{59const VkImageAspectFlags aspects = vk_format_aspects(format);60return aspects & VK_IMAGE_ASPECT_STENCIL_BIT;61}6263#endif646566