mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
vulkan: always use optimal image tiling.
Linear is useful for intermediate texture copy steps between the CPU and GPU, but we use buffers instead of textures for that.
This commit is contained in:
@@ -59,12 +59,12 @@ enum TextureType
|
||||
|
||||
enum PixelFormatUsage
|
||||
{
|
||||
PIXELFORMATUSAGE_SAMPLE,
|
||||
PIXELFORMATUSAGE_LINEAR,
|
||||
PIXELFORMATUSAGE_RENDERTARGET,
|
||||
PIXELFORMATUSAGE_BLEND,
|
||||
PIXELFORMATUSAGE_MSAA,
|
||||
PIXELFORMATUSAGE_COMPUTEWRITE,
|
||||
PIXELFORMATUSAGE_SAMPLE, // Any sampling in shaders.
|
||||
PIXELFORMATUSAGE_LINEAR, // Linear filtering.
|
||||
PIXELFORMATUSAGE_RENDERTARGET, // Usable as a render target.
|
||||
PIXELFORMATUSAGE_BLEND, // Blend support when used as a render target.
|
||||
PIXELFORMATUSAGE_MSAA, // MSAA support when used as a render target.
|
||||
PIXELFORMATUSAGE_COMPUTEWRITE, // Writable in compute shaders via imageStore.
|
||||
PIXELFORMATUSAGE_MAX_ENUM
|
||||
};
|
||||
|
||||
|
||||
@@ -965,21 +965,9 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRG
|
||||
VkFormatProperties formatProperties;
|
||||
vkGetPhysicalDeviceFormatProperties(physicalDevice, vulkanFormat.internalFormat, &formatProperties);
|
||||
|
||||
VkFormatFeatureFlags featureFlags;
|
||||
VkImageTiling tiling;
|
||||
VkFormatFeatureFlags featureFlags = formatProperties.optimalTilingFeatures;
|
||||
VkImageUsageFlags usageFlags = 0;
|
||||
|
||||
if (usage & PIXELFORMATUSAGEFLAGS_LINEAR)
|
||||
{
|
||||
tiling = VK_IMAGE_TILING_LINEAR;
|
||||
featureFlags = formatProperties.linearTilingFeatures;
|
||||
}
|
||||
else
|
||||
{
|
||||
tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
featureFlags = formatProperties.optimalTilingFeatures;
|
||||
}
|
||||
|
||||
if (!featureFlags)
|
||||
return false;
|
||||
|
||||
@@ -990,6 +978,12 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRG
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usage & PIXELFORMATUSAGE_LINEAR)
|
||||
{
|
||||
if (!(featureFlags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usage & PIXELFORMATUSAGEFLAGS_RENDERTARGET)
|
||||
{
|
||||
if (isPixelFormatDepth(format) || isPixelFormatDepthStencil(format))
|
||||
@@ -1007,8 +1001,10 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRG
|
||||
}
|
||||
|
||||
if (usage & PIXELFORMATUSAGEFLAGS_BLEND)
|
||||
{
|
||||
if (!(featureFlags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usage & PIXELFORMATUSAGEFLAGS_COMPUTEWRITE)
|
||||
{
|
||||
@@ -1021,7 +1017,8 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRG
|
||||
{
|
||||
VkImageFormatProperties properties;
|
||||
|
||||
vkGetPhysicalDeviceImageFormatProperties(physicalDevice, vulkanFormat.internalFormat, VK_IMAGE_TYPE_2D, tiling, usageFlags, 0, &properties);
|
||||
if (vkGetPhysicalDeviceImageFormatProperties(physicalDevice, vulkanFormat.internalFormat, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, usageFlags, 0, &properties) != VK_SUCCESS)
|
||||
return false;
|
||||
|
||||
if (static_cast<uint32_t>(properties.sampleCounts) == 1)
|
||||
return false;
|
||||
|
||||
@@ -99,10 +99,7 @@ bool Texture::loadVolatile()
|
||||
imageInfo.arrayLayers = static_cast<uint32_t>(layerCount);
|
||||
imageInfo.mipLevels = static_cast<uint32_t>(mipmapCount);
|
||||
imageInfo.format = vulkanFormat.internalFormat;
|
||||
if (isPixelFormatCompressed(format))
|
||||
imageInfo.tiling = VK_IMAGE_TILING_LINEAR;
|
||||
else
|
||||
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
imageInfo.usage = usageFlags;
|
||||
imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
|
||||
Reference in New Issue
Block a user