--- /dev/null
+#include "nvk_format.h"
+
+#include "nvtypes.h"
+#include "classes/cl902d.h"
+
+/*
+ * nvidia names
+ * _: UNORM
+ * F: SFLOAT (and maybe UFLOAT?)
+ * L: SINT and UINT
+ * N: SNORM
+ * and for whatever reason, 8 bit format names are in BE order
+ *
+ * TODO: swizzles
+ * TODO: X formats
+ * TODO: Y formats
+ * TODO: Z formats
+ * TODO: O formats
+ */
+
+struct nvk_format nvk_formats[NVK_FORMATS] = {
+ {
+ .vk_format = VK_FORMAT_R8_UNORM,
+ .hw_format = 0x0,
+ .supports_2d_blit = false,
+ },
+
+ {
+ .vk_format = VK_FORMAT_A1R5G5B5_UNORM_PACK16,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A1R5G5B5,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_A2B10G10R10_UNORM_PACK32,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A2B10G10R10,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_A2R10G10B10_UNORM_PACK32,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A2R10G10B10,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_A8B8G8R8_SINT_PACK32,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8BL8GL8RL8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_A8B8G8R8_SNORM_PACK32,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_AN8BN8GN8RN8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_A8B8G8R8_UINT_PACK32,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8BL8GL8RL8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_A8B8G8R8_UNORM_PACK32,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8B8G8R8,
+ .supports_2d_blit = true,
+ },
+
+ {
+ .vk_format = VK_FORMAT_B8G8R8A8_SINT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8RL8GL8BL8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_B8G8R8A8_UINT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8RL8GL8BL8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_B8G8R8A8_UNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8R8G8B8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_B10G11R11_UFLOAT_PACK32,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_BF10GF11RF11,
+ .supports_2d_blit = true,
+ },
+
+ {
+ .vk_format = VK_FORMAT_R5G6B5_UNORM_PACK16,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_R5G6B5,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R8G8_SNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_GN8RN8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R8G8_UNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_G8R8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R8G8B8A8_SINT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8BL8GL8RL8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R8G8B8A8_SNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_AN8BN8GN8RN8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R8G8B8A8_UINT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8BL8GL8RL8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R8G8B8A8_UNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_A8B8G8R8,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R16G16_SFLOAT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_RF16_GF16,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R16G16_SNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_RN16_GN16,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R16G16_UNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_R16_G16,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_RF16_GF16_BF16_AF16,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R16G16B16A16_SNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_RN16_GN16_BN16_AN16,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R16G16B16A16_UNORM,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_R16_G16_B16_A16,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R32G32_SFLOAT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_RF32_GF32,
+ .supports_2d_blit = true,
+ },
+ {
+ .vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
+ .hw_format = NV902D_SET_SRC_FORMAT_V_RF32_GF32_BF32_AF32,
+ .supports_2d_blit = true,
+ },
+};
#include "nvk_bo_sync.h"
#include "nvk_entrypoints.h"
+#include "nvk_format.h"
#include "nvk_instance.h"
#include "nvk_wsi.h"
.deviceType = pdevice->dev->is_integrated ? VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
: VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU,
.limits = (VkPhysicalDeviceLimits) {
+ .maxImageArrayLayers = 2048,
+ .maxImageDimension1D = pdevice->dev->chipset >= 0x130 ? 0x8000 : 0x4000,
+ .maxImageDimension2D = pdevice->dev->chipset >= 0x130 ? 0x8000 : 0x4000,
.nonCoherentAtomSize = 64,
},
VkFormat vk_format,
VkFormatProperties2 *pFormatProperties)
{
+ pFormatProperties->formatProperties.linearTilingFeatures =
+ VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
+ pFormatProperties->formatProperties.optimalTilingFeatures =
+ VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
+
vk_foreach_struct(ext, pFormatProperties->pNext)
{
/* Use unsigned since some cases are not in the VkStructureType enum. */
const VkPhysicalDeviceImageFormatInfo2 *base_info,
VkImageFormatProperties2 *base_props)
{
+ if (base_info->usage & ~(VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT))
+ return VK_ERROR_FORMAT_NOT_SUPPORTED;
+
+ for (unsigned i = 0; i < ARRAY_SIZE(nvk_formats); i++) {
+ struct nvk_format *format = &nvk_formats[i];
+
+ if (format->vk_format != base_info->format)
+ continue;
+
+ if (!format->supports_2d_blit)
+ return VK_ERROR_FORMAT_NOT_SUPPORTED;
+
+ if (base_info->type == VK_IMAGE_TYPE_1D)
+ base_props->imageFormatProperties.maxExtent = (VkExtent3D){32768, 1, 1};
+ else if (base_info->type == VK_IMAGE_TYPE_2D)
+ base_props->imageFormatProperties.maxExtent = (VkExtent3D){32768, 32768, 1};
+ else
+ return VK_ERROR_FORMAT_NOT_SUPPORTED;
+
+ base_props->imageFormatProperties.maxMipLevels = 0;
+ base_props->imageFormatProperties.maxArrayLayers = 2048;
+ base_props->imageFormatProperties.sampleCounts = 0;
+ base_props->imageFormatProperties.maxResourceSize = 0xffffffff; // TODO proper value
+
+ vk_foreach_struct(s, base_props->pNext) {
+ switch (s->sType) {
+ default:
+ nvk_debug_ignored_stype(s->sType);
+ break;
+ }
+ }
+
+ vk_foreach_struct(ext, base_info->pNext)
+ {
+ /* Use unsigned since some cases are not in the VkStructureType enum. */
+ switch ((unsigned)ext->sType) {
+ default:
+ nvk_debug_ignored_stype(ext->sType);
+ break;
+ }
+ }
+
+ return VK_SUCCESS;
+ }
+
return VK_ERROR_FORMAT_NOT_SUPPORTED;
}