mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
pvr: Merge imagination/vulkan/vk_format.h into imagination/vulkan/pvr_formats.h
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Matt Coster <matt.coster@imgtec.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28266>
This commit is contained in:
parent
a4a42eb652
commit
86c88369c6
3 changed files with 65 additions and 105 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "util/format/u_formats.h"
|
||||
#include "vk_format.h"
|
||||
|
||||
/* This is based on VkClearColorValue which is an array of RGBA, and on the
|
||||
* output register usage for the biggest 32 bit 4 component formats which use up
|
||||
|
|
@ -252,4 +253,67 @@ void pvr_get_hw_clear_color(VkFormat vk_format,
|
|||
|
||||
uint32_t pvr_pbe_pixel_num_loads(enum pvr_transfer_pbe_pixel_src pbe_format);
|
||||
|
||||
static inline bool vk_format_has_32bit_component(VkFormat vk_format)
|
||||
{
|
||||
const struct util_format_description *desc =
|
||||
vk_format_description(vk_format);
|
||||
|
||||
for (uint32_t i = 0; i < desc->nr_channels; i++) {
|
||||
if (desc->channel[i].size == 32U)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool vk_format_is_normalized(VkFormat vk_format)
|
||||
{
|
||||
const struct util_format_description *desc =
|
||||
vk_format_description(vk_format);
|
||||
|
||||
for (uint32_t i = 0; i < desc->nr_channels; i++) {
|
||||
if (!desc->channel[i].normalized)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
vk_format_get_common_color_channel_count(VkFormat src_format,
|
||||
VkFormat dst_format)
|
||||
{
|
||||
const struct util_format_description *dst_desc =
|
||||
vk_format_description(dst_format);
|
||||
const struct util_format_description *src_desc =
|
||||
vk_format_description(src_format);
|
||||
uint32_t count = 0;
|
||||
|
||||
/* Check if destination format is alpha only and source format has alpha
|
||||
* channel.
|
||||
*/
|
||||
if (util_format_is_alpha(vk_format_to_pipe_format(dst_format))) {
|
||||
count = 1;
|
||||
} else if (dst_desc->nr_channels <= src_desc->nr_channels) {
|
||||
for (uint32_t i = 0; i < dst_desc->nr_channels; i++) {
|
||||
enum pipe_swizzle swizzle = dst_desc->swizzle[i];
|
||||
|
||||
if (swizzle > PIPE_SWIZZLE_W)
|
||||
continue;
|
||||
|
||||
for (uint32_t j = 0; j < src_desc->nr_channels; j++) {
|
||||
if (src_desc->swizzle[j] == swizzle) {
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
count = dst_desc->nr_channels;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
#endif /* PVR_FORMATS_H */
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "hwdef/rogue_hw_utils.h"
|
||||
#include "pvr_csb_enum_helpers.h"
|
||||
#include "pvr_device_info.h"
|
||||
#include "pvr_formats.h"
|
||||
#include "pvr_job_common.h"
|
||||
#include "pvr_private.h"
|
||||
#include "util/macros.h"
|
||||
|
|
|
|||
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2022 Imagination Technologies Ltd.
|
||||
*
|
||||
* based in part on radv driver which is:
|
||||
* Copyright © 2016 Red Hat.
|
||||
* Copyright © 2016 Bas Nieuwenhuizen
|
||||
*
|
||||
* Based on u_format.h which is:
|
||||
* Copyright 2009-2010 VMware, Inc.
|
||||
*
|
||||
* 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_H
|
||||
#define VK_FORMAT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <util/format/u_format.h>
|
||||
#include <vulkan/util/vk_format.h>
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "util/u_endian.h"
|
||||
|
||||
|
||||
static inline bool vk_format_has_32bit_component(VkFormat vk_format)
|
||||
{
|
||||
const struct util_format_description *desc =
|
||||
vk_format_description(vk_format);
|
||||
|
||||
for (uint32_t i = 0; i < desc->nr_channels; i++) {
|
||||
if (desc->channel[i].size == 32U)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool vk_format_is_normalized(VkFormat vk_format)
|
||||
{
|
||||
const struct util_format_description *desc =
|
||||
vk_format_description(vk_format);
|
||||
|
||||
for (uint32_t i = 0; i < desc->nr_channels; i++) {
|
||||
if (!desc->channel[i].normalized)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
vk_format_get_common_color_channel_count(VkFormat src_format,
|
||||
VkFormat dst_format)
|
||||
{
|
||||
const struct util_format_description *dst_desc =
|
||||
vk_format_description(dst_format);
|
||||
const struct util_format_description *src_desc =
|
||||
vk_format_description(src_format);
|
||||
uint32_t count = 0;
|
||||
|
||||
/* Check if destination format is alpha only and source format has alpha
|
||||
* channel.
|
||||
*/
|
||||
if (util_format_is_alpha(vk_format_to_pipe_format(dst_format))) {
|
||||
count = 1;
|
||||
} else if (dst_desc->nr_channels <= src_desc->nr_channels) {
|
||||
for (uint32_t i = 0; i < dst_desc->nr_channels; i++) {
|
||||
enum pipe_swizzle swizzle = dst_desc->swizzle[i];
|
||||
|
||||
if (swizzle > PIPE_SWIZZLE_W)
|
||||
continue;
|
||||
|
||||
for (uint32_t j = 0; j < src_desc->nr_channels; j++) {
|
||||
if (src_desc->swizzle[j] == swizzle) {
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
count = dst_desc->nr_channels;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif /* VK_FORMAT_H */
|
||||
Loading…
Add table
Reference in a new issue