#include <assert.h>
#include <vulkan/vulkan.h>
+#include <util/macros.h>
enum vk_format_layout {
/**
* Formats with vk_format_block::width == vk_format_block::height == 1
/**
* Return total bits needed for the pixel format per block.
*/
-static inline uint
+static inline unsigned
vk_format_get_blocksizebits(VkFormat format)
{
const struct vk_format_description *desc = vk_format_description(format);
/**
* Return bytes per block (not pixel) for the given format.
*/
-static inline uint
+static inline unsigned
vk_format_get_blocksize(VkFormat format)
{
- uint bits = vk_format_get_blocksizebits(format);
- uint bytes = bits / 8;
+ unsigned bits = vk_format_get_blocksizebits(format);
+ unsigned bytes = bits / 8;
assert(bits % 8 == 0);
assert(bytes > 0);
return bytes;
}
-static inline uint
+static inline unsigned
vk_format_get_blockwidth(VkFormat format)
{
const struct vk_format_description *desc = vk_format_description(format);
return desc->block.width;
}
-static inline uint
+static inline unsigned
vk_format_get_blockheight(VkFormat format)
{
const struct vk_format_description *desc = vk_format_description(format);
}
static inline enum vk_swizzle
-radv_swizzle_conv(int idx, const unsigned char chan[4], VkComponentSwizzle vk_swiz)
+radv_swizzle_conv(VkComponentSwizzle component, const unsigned char chan[4], VkComponentSwizzle vk_swiz)
{
int x;
+
+ if (vk_swiz == VK_COMPONENT_SWIZZLE_IDENTITY)
+ vk_swiz = component;
switch (vk_swiz) {
- case VK_COMPONENT_SWIZZLE_IDENTITY:
- return chan[idx];
case VK_COMPONENT_SWIZZLE_ZERO:
return VK_SWIZZLE_0;
case VK_COMPONENT_SWIZZLE_ONE:
return x;
return VK_SWIZZLE_1;
default:
- return chan[idx];
+ unreachable("Illegal swizzle");
}
}
const unsigned char swz[4],
enum vk_swizzle dst[4])
{
- dst[0] = radv_swizzle_conv(0, swz, mapping->r);
- dst[1] = radv_swizzle_conv(1, swz, mapping->g);
- dst[2] = radv_swizzle_conv(2, swz, mapping->b);
- dst[3] = radv_swizzle_conv(3, swz, mapping->a);
+ dst[0] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_R, swz, mapping->r);
+ dst[1] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_G, swz, mapping->g);
+ dst[2] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_B, swz, mapping->b);
+ dst[3] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_A, swz, mapping->a);
}
static inline bool
return VK_FORMAT_S8_UINT;
}
-static inline uint
+static inline unsigned
vk_format_get_component_bits(VkFormat format,
enum vk_format_colorspace colorspace,
- uint component)
+ unsigned component)
{
const struct vk_format_description *desc = vk_format_description(format);
enum vk_format_colorspace desc_colorspace;