anv: Move vk_format helpers to common code
The Android ones we put in anv_android.c. Maybe one day we'll want a vk_android.h to put some common Android stuff but, for now, let's keep it contained to ANV's android code. Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8857>
This commit is contained in:
parent
c7345bd1fb
commit
4fb6c051c9
|
@ -3281,7 +3281,7 @@ radv_image_is_pipe_misaligned(const struct radv_device *device,
|
|||
if (rad_info->chip_class >= GFX10_3) {
|
||||
log2_bpp_and_samples = log2_bpp + log2_samples;
|
||||
} else {
|
||||
if (vk_format_is_depth(image->vk_format) &&
|
||||
if (vk_format_has_depth(image->vk_format) &&
|
||||
image->info.array_size >= 8) {
|
||||
log2_bpp = 2;
|
||||
}
|
||||
|
@ -3292,7 +3292,7 @@ radv_image_is_pipe_misaligned(const struct radv_device *device,
|
|||
unsigned num_pipes = G_0098F8_NUM_PIPES(rad_info->gb_addr_config);
|
||||
int overlap = MAX2(0, log2_bpp_and_samples + num_pipes - 8);
|
||||
|
||||
if (vk_format_is_depth(image->vk_format)) {
|
||||
if (vk_format_has_depth(image->vk_format)) {
|
||||
if (radv_image_is_tc_compat_htile(image) && overlap) {
|
||||
return true;
|
||||
}
|
||||
|
@ -3325,7 +3325,7 @@ radv_image_is_l2_coherent(const struct radv_device *device, const struct radv_im
|
|||
if (image->info.samples == 1 &&
|
||||
(image->usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) &&
|
||||
!vk_format_is_stencil(image->vk_format)) {
|
||||
!vk_format_has_stencil(image->vk_format)) {
|
||||
/* Single-sample color and single-sample depth
|
||||
* (not stencil) are coherent with shaders on
|
||||
* GFX9.
|
||||
|
@ -6128,7 +6128,7 @@ static void radv_initialize_htile(struct radv_cmd_buffer *cmd_buffer,
|
|||
|
||||
state->flush_bits |= radv_clear_htile(cmd_buffer, image, range, htile_value);
|
||||
|
||||
if (vk_format_is_stencil(image->vk_format))
|
||||
if (vk_format_has_stencil(image->vk_format))
|
||||
aspects |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
radv_set_ds_clear_metadata(cmd_buffer, image, range, value, aspects);
|
||||
|
@ -6444,7 +6444,7 @@ static void radv_handle_image_transition(struct radv_cmd_buffer *cmd_buffer,
|
|||
radv_image_queue_family_mask(image, dst_family,
|
||||
cmd_buffer->queue_family_index);
|
||||
|
||||
if (vk_format_is_depth(image->vk_format)) {
|
||||
if (vk_format_has_depth(image->vk_format)) {
|
||||
radv_handle_depth_image_transition(cmd_buffer, image,
|
||||
src_layout, src_render_loop,
|
||||
dst_layout, dst_render_loop,
|
||||
|
|
|
@ -718,11 +718,11 @@ radv_physical_device_get_format_properties(struct radv_physical_device *physical
|
|||
if (radv_is_filter_minmax_format_supported(format))
|
||||
tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT;
|
||||
|
||||
if (vk_format_is_depth(format))
|
||||
if (vk_format_has_depth(format))
|
||||
tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
|
||||
/* Don't support blitting surfaces with depth/stencil. */
|
||||
if (vk_format_is_depth(format) && vk_format_is_stencil(format))
|
||||
if (vk_format_has_depth(format) && vk_format_has_stencil(format))
|
||||
tiled &= ~VK_FORMAT_FEATURE_BLIT_DST_BIT;
|
||||
|
||||
/* Don't support linear depth surfaces */
|
||||
|
|
|
@ -1008,7 +1008,7 @@ radv_pipeline_out_of_order_rast(struct radv_pipeline *pipeline,
|
|||
if (vkds) {
|
||||
struct radv_render_pass_attachment *attachment =
|
||||
pass->attachments + subpass->depth_stencil_attachment->attachment;
|
||||
bool has_stencil = vk_format_is_stencil(attachment->format);
|
||||
bool has_stencil = vk_format_has_stencil(attachment->format);
|
||||
struct radv_dsa_order_invariance order_invariance[2];
|
||||
struct radv_shader_variant *ps =
|
||||
pipeline->shaders[MESA_SHADER_FRAGMENT];
|
||||
|
@ -1825,8 +1825,8 @@ radv_pipeline_init_depth_stencil_state(struct radv_pipeline *pipeline,
|
|||
if (subpass->depth_stencil_attachment)
|
||||
attachment = pass->attachments + subpass->depth_stencil_attachment->attachment;
|
||||
|
||||
bool has_depth_attachment = attachment && vk_format_is_depth(attachment->format);
|
||||
bool has_stencil_attachment = attachment && vk_format_is_stencil(attachment->format);
|
||||
bool has_depth_attachment = attachment && vk_format_has_depth(attachment->format);
|
||||
bool has_stencil_attachment = attachment && vk_format_has_stencil(attachment->format);
|
||||
|
||||
if (ds_info) {
|
||||
if (has_depth_attachment) {
|
||||
|
@ -3914,8 +3914,8 @@ radv_gfx9_compute_bin_size(const struct radv_pipeline *pipeline, const VkGraphic
|
|||
struct radv_render_pass_attachment *attachment = pass->attachments + subpass->depth_stencil_attachment->attachment;
|
||||
|
||||
/* Coefficients taken from AMDVLK */
|
||||
unsigned depth_coeff = vk_format_is_depth(attachment->format) ? 5 : 0;
|
||||
unsigned stencil_coeff = vk_format_is_stencil(attachment->format) ? 1 : 0;
|
||||
unsigned depth_coeff = vk_format_has_depth(attachment->format) ? 5 : 0;
|
||||
unsigned stencil_coeff = vk_format_has_stencil(attachment->format) ? 1 : 0;
|
||||
unsigned ds_bytes_per_pixel = 4 * (depth_coeff + stencil_coeff) * total_samples;
|
||||
|
||||
const struct radv_bin_size_entry *ds_entry = ds_size_table[log_num_rb_per_se][log_num_se];
|
||||
|
@ -4000,8 +4000,8 @@ radv_gfx10_compute_bin_size(const struct radv_pipeline *pipeline, const VkGraphi
|
|||
struct radv_render_pass_attachment *attachment = pass->attachments + subpass->depth_stencil_attachment->attachment;
|
||||
|
||||
/* Coefficients taken from AMDVLK */
|
||||
unsigned depth_coeff = vk_format_is_depth(attachment->format) ? 5 : 0;
|
||||
unsigned stencil_coeff = vk_format_is_stencil(attachment->format) ? 1 : 0;
|
||||
unsigned depth_coeff = vk_format_has_depth(attachment->format) ? 5 : 0;
|
||||
unsigned stencil_coeff = vk_format_has_stencil(attachment->format) ? 1 : 0;
|
||||
unsigned db_bytes_per_pixel = (depth_coeff + stencil_coeff) * total_samples;
|
||||
|
||||
const unsigned db_pixel_count_log = util_logbase2(db_tag_part / db_bytes_per_pixel);
|
||||
|
@ -4161,7 +4161,7 @@ radv_pipeline_generate_depth_stencil_state(struct radeon_cmdbuf *ctx_cs,
|
|||
if (subpass->depth_stencil_attachment)
|
||||
attachment = pass->attachments + subpass->depth_stencil_attachment->attachment;
|
||||
|
||||
bool has_depth_attachment = attachment && vk_format_is_depth(attachment->format);
|
||||
bool has_depth_attachment = attachment && vk_format_has_depth(attachment->format);
|
||||
|
||||
if (vkds && has_depth_attachment) {
|
||||
/* from amdvlk: For 4xAA and 8xAA need to decompress on flush for better performance */
|
||||
|
|
|
@ -2015,12 +2015,12 @@ radv_image_tile_stencil_disabled(const struct radv_device *device,
|
|||
const struct radv_image *image)
|
||||
{
|
||||
if (device->physical_device->rad_info.chip_class >= GFX9) {
|
||||
return !vk_format_is_stencil(image->vk_format);
|
||||
return !vk_format_has_stencil(image->vk_format);
|
||||
} else {
|
||||
/* Due to a hw bug, TILE_STENCIL_DISABLE must be set to 0 for
|
||||
* the TC-compat ZRANGE issue even if no stencil is used.
|
||||
*/
|
||||
return !vk_format_is_stencil(image->vk_format) &&
|
||||
return !vk_format_has_stencil(image->vk_format) &&
|
||||
!radv_image_is_tc_compat_htile(image);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,31 +77,6 @@ vk_format_get_first_non_void_channel(VkFormat format)
|
|||
return util_format_get_first_non_void_channel(vk_format_to_pipe_format(format));
|
||||
}
|
||||
|
||||
static inline VkImageAspectFlags
|
||||
vk_format_aspects(VkFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case VK_FORMAT_UNDEFINED:
|
||||
return 0;
|
||||
|
||||
case VK_FORMAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM:
|
||||
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
||||
case VK_FORMAT_D32_SFLOAT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
||||
default:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
static inline enum pipe_swizzle
|
||||
radv_swizzle_conv(VkComponentSwizzle component, const unsigned char chan[4], VkComponentSwizzle vk_swiz)
|
||||
{
|
||||
|
@ -144,52 +119,6 @@ vk_format_is_subsampled(VkFormat format)
|
|||
return util_format_is_subsampled_422(vk_format_to_pipe_format(format));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_depth_or_stencil(VkFormat format)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(vk_format_to_pipe_format(format));
|
||||
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return util_format_has_depth(desc) ||
|
||||
util_format_has_stencil(desc);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_depth(VkFormat format)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(vk_format_to_pipe_format(format));
|
||||
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return util_format_has_depth(desc);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_stencil(VkFormat format)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(vk_format_to_pipe_format(format));
|
||||
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return util_format_has_stencil(desc);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_color(VkFormat format)
|
||||
{
|
||||
return !vk_format_is_depth_or_stencil(format);
|
||||
}
|
||||
|
||||
static inline VkFormat
|
||||
vk_format_depth_only(VkFormat format)
|
||||
{
|
||||
|
|
|
@ -30,64 +30,6 @@
|
|||
#include "util/format/u_format.h"
|
||||
#include "vulkan/util/vk_format.h"
|
||||
|
||||
static inline VkImageAspectFlags
|
||||
vk_format_aspects(VkFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case VK_FORMAT_UNDEFINED:
|
||||
return 0;
|
||||
|
||||
case VK_FORMAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM:
|
||||
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
||||
case VK_FORMAT_D32_SFLOAT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM:
|
||||
return (VK_IMAGE_ASPECT_PLANE_0_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_1_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_2_BIT);
|
||||
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM:
|
||||
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM:
|
||||
return (VK_IMAGE_ASPECT_PLANE_0_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_1_BIT);
|
||||
|
||||
default:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_color(VkFormat format)
|
||||
{
|
||||
return vk_format_aspects(format) == VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
|
||||
/* FIXME: from freedreno vk_format.h, common place?*/
|
||||
static inline bool
|
||||
vk_format_is_int(VkFormat format)
|
||||
|
@ -113,27 +55,6 @@ vk_format_is_srgb(VkFormat format)
|
|||
return util_format_is_srgb(vk_format_to_pipe_format(format));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_depth_or_stencil(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_has_depth(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_has_stencil(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
vk_format_get_blocksize(VkFormat format)
|
||||
{
|
||||
|
|
|
@ -68,14 +68,6 @@ vk_format_is_compressed(VkFormat format)
|
|||
return vk_format_get_blockwidth(format) > 1;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_depth_or_stencil(VkFormat format)
|
||||
{
|
||||
const struct util_format_description *desc = vk_format_description(format);
|
||||
|
||||
return util_format_has_depth(desc) || util_format_has_stencil(desc);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_has_alpha(VkFormat format)
|
||||
{
|
||||
|
|
|
@ -285,8 +285,7 @@ VULKAN_FILES := \
|
|||
vulkan/anv_private.h \
|
||||
vulkan/anv_queue.c \
|
||||
vulkan/anv_util.c \
|
||||
vulkan/anv_wsi.c \
|
||||
vulkan/vk_format_info.h
|
||||
vulkan/anv_wsi.c
|
||||
|
||||
VULKAN_NON_ANDROID_FILES := \
|
||||
vulkan/anv_android_stubs.c
|
||||
|
|
|
@ -104,6 +104,69 @@ anv_hal_close(struct hw_device_t *dev)
|
|||
}
|
||||
|
||||
#if ANDROID_API_LEVEL >= 26
|
||||
#include <vndk/hardware_buffer.h>
|
||||
/* See i915_private_android_types.h in minigbm. */
|
||||
#define HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL 0x100
|
||||
|
||||
enum {
|
||||
/* Usage bit equal to GRALLOC_USAGE_HW_CAMERA_MASK */
|
||||
AHARDWAREBUFFER_USAGE_CAMERA_MASK = 0x00060000U,
|
||||
};
|
||||
|
||||
static inline VkFormat
|
||||
vk_format_from_android(unsigned android_format, unsigned android_usage)
|
||||
{
|
||||
switch (android_format) {
|
||||
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
|
||||
case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
|
||||
return VK_FORMAT_R8G8B8_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
|
||||
return VK_FORMAT_R5G6B5_UNORM_PACK16;
|
||||
case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
|
||||
return VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||
case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
|
||||
return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
|
||||
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
|
||||
case HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL:
|
||||
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED:
|
||||
if (android_usage & AHARDWAREBUFFER_USAGE_CAMERA_MASK)
|
||||
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
else
|
||||
return VK_FORMAT_R8G8B8_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_BLOB:
|
||||
default:
|
||||
return VK_FORMAT_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
android_format_from_vk(unsigned vk_format)
|
||||
{
|
||||
switch (vk_format) {
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
return AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
|
||||
case VK_FORMAT_R8G8B8_UNORM:
|
||||
return AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM;
|
||||
case VK_FORMAT_R5G6B5_UNORM_PACK16:
|
||||
return AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM;
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
return AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT;
|
||||
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
|
||||
return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
#ifdef HAVE_CROS_GRALLOC
|
||||
return AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420;
|
||||
#else
|
||||
return HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL;
|
||||
#endif
|
||||
default:
|
||||
return AHARDWAREBUFFER_FORMAT_BLOB;
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult
|
||||
get_ahw_buffer_format_properties(
|
||||
VkDevice device_h,
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "anv_private.h"
|
||||
#include "anv_measure.h"
|
||||
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
/** \file anv_cmd_buffer.c
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "drm-uapi/drm_fourcc.h"
|
||||
#include "vk_enum_to_str.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "vk_util.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_format.h"
|
||||
|
||||
static const enum isl_surf_dim
|
||||
vk_to_isl_surf_dim[] = {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "anv_private.h"
|
||||
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
static void
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "anv_private.h"
|
||||
#include "anv_measure.h"
|
||||
#include "wsi_common.h"
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
static PFN_vkVoidFunction
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "anv_private.h"
|
||||
#include "wsi_common.h"
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_util.h"
|
||||
#include "wsi_common_display.h"
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "anv_private.h"
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_format.h"
|
||||
|
||||
#include "genxml/gen_macros.h"
|
||||
#include "genxml/genX_pack.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "anv_private.h"
|
||||
#include "anv_measure.h"
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_format.h"
|
||||
#include "vk_util.h"
|
||||
#include "util/fast_idiv_by_const.h"
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "common/gen_sample_positions.h"
|
||||
#include "nir/nir_xfb_info.h"
|
||||
#include "vk_util.h"
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_format.h"
|
||||
|
||||
static uint32_t
|
||||
vertex_element_comp_control(enum isl_format format, unsigned comp)
|
||||
|
|
|
@ -107,7 +107,6 @@ libanv_files = files(
|
|||
'anv_queue.c',
|
||||
'anv_util.c',
|
||||
'anv_wsi.c',
|
||||
'vk_format_info.h',
|
||||
)
|
||||
|
||||
anv_deps = [
|
||||
|
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2016 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef VK_FORMAT_INFO_H
|
||||
#define VK_FORMAT_INFO_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
|
||||
#include <vndk/hardware_buffer.h>
|
||||
/* See i915_private_android_types.h in minigbm. */
|
||||
#define HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL 0x100
|
||||
|
||||
enum {
|
||||
/* Usage bit equal to GRALLOC_USAGE_HW_CAMERA_MASK */
|
||||
AHARDWAREBUFFER_USAGE_CAMERA_MASK = 0x00060000U,
|
||||
};
|
||||
|
||||
static inline VkFormat
|
||||
vk_format_from_android(unsigned android_format, unsigned android_usage)
|
||||
{
|
||||
switch (android_format) {
|
||||
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
|
||||
case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
|
||||
return VK_FORMAT_R8G8B8_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
|
||||
return VK_FORMAT_R5G6B5_UNORM_PACK16;
|
||||
case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
|
||||
return VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||
case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
|
||||
return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
|
||||
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
|
||||
case HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL:
|
||||
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED:
|
||||
if (android_usage & AHARDWAREBUFFER_USAGE_CAMERA_MASK)
|
||||
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
else
|
||||
return VK_FORMAT_R8G8B8_UNORM;
|
||||
case AHARDWAREBUFFER_FORMAT_BLOB:
|
||||
default:
|
||||
return VK_FORMAT_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
android_format_from_vk(unsigned vk_format)
|
||||
{
|
||||
switch (vk_format) {
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
return AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
|
||||
case VK_FORMAT_R8G8B8_UNORM:
|
||||
return AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM;
|
||||
case VK_FORMAT_R5G6B5_UNORM_PACK16:
|
||||
return AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM;
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
return AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT;
|
||||
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
|
||||
return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
#ifdef HAVE_CROS_GRALLOC
|
||||
return AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420;
|
||||
#else
|
||||
return HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL;
|
||||
#endif
|
||||
default:
|
||||
return AHARDWAREBUFFER_FORMAT_BLOB;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline VkImageAspectFlags
|
||||
vk_format_aspects(VkFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case VK_FORMAT_UNDEFINED:
|
||||
return 0;
|
||||
|
||||
case VK_FORMAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM:
|
||||
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
||||
case VK_FORMAT_D32_SFLOAT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM:
|
||||
return (VK_IMAGE_ASPECT_PLANE_0_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_1_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_2_BIT);
|
||||
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM:
|
||||
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM:
|
||||
return (VK_IMAGE_ASPECT_PLANE_0_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_1_BIT);
|
||||
|
||||
default:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_color(VkFormat format)
|
||||
{
|
||||
return vk_format_aspects(format) == VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_depth_or_stencil(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_has_depth(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_has_stencil(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
}
|
||||
|
||||
#endif /* VK_FORMAT_INFO_H */
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2016 Intel Corporation
|
||||
* Copyright © 2019 Google LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -286,3 +287,55 @@ vk_format_to_pipe_format(enum VkFormat vkformat)
|
|||
|
||||
return vk_format_map[vkformat];
|
||||
}
|
||||
|
||||
VkImageAspectFlags
|
||||
vk_format_aspects(VkFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case VK_FORMAT_UNDEFINED:
|
||||
return 0;
|
||||
|
||||
case VK_FORMAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
case VK_FORMAT_D16_UNORM:
|
||||
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
||||
case VK_FORMAT_D32_SFLOAT:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM:
|
||||
return (VK_IMAGE_ASPECT_PLANE_0_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_1_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_2_BIT);
|
||||
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM:
|
||||
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16:
|
||||
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM:
|
||||
return (VK_IMAGE_ASPECT_PLANE_0_BIT |
|
||||
VK_IMAGE_ASPECT_PLANE_1_BIT);
|
||||
|
||||
default:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2016 Intel Corporation
|
||||
* Copyright © 2019 Google LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -30,4 +31,34 @@
|
|||
enum pipe_format
|
||||
vk_format_to_pipe_format(enum VkFormat vkformat);
|
||||
|
||||
VkImageAspectFlags
|
||||
vk_format_aspects(VkFormat format);
|
||||
|
||||
static inline bool
|
||||
vk_format_is_color(VkFormat format)
|
||||
{
|
||||
return vk_format_aspects(format) == VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_is_depth_or_stencil(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_has_depth(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vk_format_has_stencil(VkFormat format)
|
||||
{
|
||||
const VkImageAspectFlags aspects = vk_format_aspects(format);
|
||||
return aspects & VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue