Enable cubic sampling when available

This commit is contained in:
Patrick Nicolas
2024-08-12 11:02:56 +02:00
parent 86ee7c26c1
commit 0cc54b8e71
3 changed files with 25 additions and 12 deletions
+15 -12
View File
@@ -388,7 +388,7 @@ void application::initialize_vulkan()
#endif
std::vector<const char *> instance_extensions{};
std::vector<const char *> device_extensions{};
std::unordered_set<std::string_view> optional_device_extensions{};
#ifndef NDEBUG
bool debug_report_found = false;
@@ -418,17 +418,18 @@ void application::initialize_vulkan()
}
#endif
device_extensions.push_back(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
optional_device_extensions.emplace(VK_IMG_FILTER_CUBIC_EXTENSION_NAME);
#ifdef __ANDROID__
device_extensions.push_back(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
device_extensions.push_back(VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_MAINTENANCE1_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
vk_device_extensions.push_back(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
vk_device_extensions.push_back(VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_MAINTENANCE1_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
instance_extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
instance_extensions.push_back(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME);
#endif
@@ -488,6 +489,8 @@ void application::initialize_vulkan()
for (vk::ExtensionProperties & i: vk_physical_device.enumerateDeviceExtensionProperties())
{
spdlog::info(" {}", i.extensionName);
if (auto it = optional_device_extensions.find(i.extensionName); it != optional_device_extensions.end())
vk_device_extensions.push_back(it->data());
}
vk::PhysicalDeviceProperties prop = vk_physical_device.getProperties();
@@ -524,8 +527,8 @@ void application::initialize_vulkan()
vk::DeviceCreateInfo{
.queueCreateInfoCount = 1,
.pQueueCreateInfos = &queueCreateInfo,
.enabledExtensionCount = (uint32_t)device_extensions.size(),
.ppEnabledExtensionNames = device_extensions.data(),
.enabledExtensionCount = (uint32_t)vk_device_extensions.size(),
.ppEnabledExtensionNames = vk_device_extensions.data(),
.pEnabledFeatures = &device_features,
},
#ifdef __ANDROID__
+6
View File
@@ -134,6 +134,7 @@ class application : public singleton<application>
bool session_visible = false;
bool debug_extensions_found = false;
std::vector<std::string> xr_extensions;
std::vector<const char *> vk_device_extensions;
std::atomic<bool> exit_requested = false;
std::filesystem::path config_path;
std::filesystem::path cache_path;
@@ -431,6 +432,11 @@ public:
return instance().xr_extensions;
}
static const std::vector<const char *> & get_vk_device_extensions()
{
return instance().vk_device_extensions;
}
static configuration & get_config()
{
assert(instance().config);
+4
View File
@@ -19,6 +19,7 @@
#include "stream_reprojection.h"
#include "application.h"
#include "utils/contains.h"
#include "vk/allocation.h"
#include "vk/pipeline.h"
#include "vk/shader.h"
@@ -75,6 +76,9 @@ stream_reprojection::stream_reprojection(
.unnormalizedCoordinates = VK_FALSE,
};
if (utils::contains(application::get_vk_device_extensions(), VK_IMG_FILTER_CUBIC_EXTENSION_NAME))
sampler_info.magFilter = vk::Filter::eCubicIMG;
sampler = vk::raii::Sampler(device, sampler_info);
size_t uniform_size = sizeof(uniform) + properties.limits.minUniformBufferOffsetAlignment - 1;