[SPIR-V] Version, float controls
This commit is contained in:
@@ -26,7 +26,7 @@ namespace xe {
|
||||
namespace ui {
|
||||
namespace vulkan {
|
||||
|
||||
bool SpirvToolsContext::Initialize() {
|
||||
bool SpirvToolsContext::Initialize(unsigned int spirv_version) {
|
||||
const char* vulkan_sdk_env = std::getenv("VULKAN_SDK");
|
||||
if (!vulkan_sdk_env) {
|
||||
XELOGE("SPIRV-Tools: Failed to get the VULKAN_SDK environment variable");
|
||||
@@ -63,7 +63,17 @@ bool SpirvToolsContext::Initialize() {
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
context_ = fn_spvContextCreate_(SPV_ENV_VULKAN_1_0);
|
||||
spv_target_env target_env;
|
||||
if (spirv_version >= 0x10500) {
|
||||
target_env = SPV_ENV_VULKAN_1_2;
|
||||
} else if (spirv_version >= 0x10400) {
|
||||
target_env = SPV_ENV_VULKAN_1_1_SPIRV_1_4;
|
||||
} else if (spirv_version >= 0x10300) {
|
||||
target_env = SPV_ENV_VULKAN_1_1;
|
||||
} else {
|
||||
target_env = SPV_ENV_VULKAN_1_0;
|
||||
}
|
||||
context_ = fn_spvContextCreate_(target_env);
|
||||
if (!context_) {
|
||||
XELOGE("SPIRV-Tools: Failed to create a Vulkan 1.0 context");
|
||||
Shutdown();
|
||||
|
||||
@@ -32,7 +32,7 @@ class SpirvToolsContext {
|
||||
SpirvToolsContext(const SpirvToolsContext& context) = delete;
|
||||
SpirvToolsContext& operator=(const SpirvToolsContext& context) = delete;
|
||||
~SpirvToolsContext() { Shutdown(); }
|
||||
bool Initialize();
|
||||
bool Initialize(unsigned int spirv_version);
|
||||
void Shutdown();
|
||||
|
||||
spv_result_t Validate(const uint32_t* words, size_t num_words,
|
||||
|
||||
@@ -392,6 +392,10 @@ bool VulkanProvider::Initialize() {
|
||||
std::memset(&device_extensions_, 0, sizeof(device_extensions_));
|
||||
if (device_properties_.apiVersion >= VK_MAKE_VERSION(1, 1, 0)) {
|
||||
device_extensions_.khr_dedicated_allocation = true;
|
||||
if (device_properties_.apiVersion >= VK_MAKE_VERSION(1, 2, 0)) {
|
||||
device_extensions_.khr_shader_float_controls = true;
|
||||
device_extensions_.khr_spirv_1_4 = true;
|
||||
}
|
||||
}
|
||||
bool device_supports_swapchain = false;
|
||||
for (const VkExtensionProperties& device_extension :
|
||||
@@ -405,6 +409,13 @@ bool VulkanProvider::Initialize() {
|
||||
!std::strcmp(device_extension_name,
|
||||
"VK_KHR_dedicated_allocation")) {
|
||||
device_extensions_.khr_dedicated_allocation = true;
|
||||
} else if (!device_extensions_.khr_shader_float_controls &&
|
||||
!std::strcmp(device_extension_name,
|
||||
"VK_KHR_shader_float_controls")) {
|
||||
device_extensions_.khr_shader_float_controls = true;
|
||||
} else if (!device_extensions_.khr_spirv_1_4 &&
|
||||
!std::strcmp(device_extension_name, "VK_KHR_spirv_1_4")) {
|
||||
device_extensions_.khr_spirv_1_4 = true;
|
||||
} else if (!device_supports_swapchain &&
|
||||
!std::strcmp(device_extension_name, "VK_KHR_swapchain")) {
|
||||
device_supports_swapchain = true;
|
||||
@@ -466,6 +477,10 @@ bool VulkanProvider::Initialize() {
|
||||
device_extensions_.ext_fragment_shader_interlock ? "yes" : "no");
|
||||
XELOGVK("* VK_KHR_dedicated_allocation: {}",
|
||||
device_extensions_.khr_dedicated_allocation ? "yes" : "no");
|
||||
XELOGVK("* VK_KHR_shader_float_controls: {}",
|
||||
device_extensions_.khr_shader_float_controls ? "yes" : "no");
|
||||
XELOGVK("* VK_KHR_spirv_1_4: {}",
|
||||
device_extensions_.khr_spirv_1_4 ? "yes" : "no");
|
||||
// TODO(Triang3l): Report properties, features.
|
||||
|
||||
// Create the device.
|
||||
@@ -493,9 +508,17 @@ bool VulkanProvider::Initialize() {
|
||||
if (device_extensions_.ext_fragment_shader_interlock) {
|
||||
device_extensions_enabled.push_back("VK_EXT_fragment_shader_interlock");
|
||||
}
|
||||
if (device_properties_.apiVersion < VK_MAKE_VERSION(1, 1, 0)) {
|
||||
if (device_extensions_.khr_dedicated_allocation) {
|
||||
device_extensions_enabled.push_back("VK_KHR_dedicated_allocation");
|
||||
if (device_properties_.apiVersion < VK_MAKE_VERSION(1, 2, 0)) {
|
||||
if (device_properties_.apiVersion < VK_MAKE_VERSION(1, 1, 0)) {
|
||||
if (device_extensions_.khr_dedicated_allocation) {
|
||||
device_extensions_enabled.push_back("VK_KHR_dedicated_allocation");
|
||||
}
|
||||
}
|
||||
if (device_extensions_.khr_shader_float_controls) {
|
||||
device_extensions_enabled.push_back("VK_KHR_shader_float_controls");
|
||||
}
|
||||
if (device_extensions_.khr_spirv_1_4) {
|
||||
device_extensions_enabled.push_back("VK_KHR_spirv_1_4");
|
||||
}
|
||||
}
|
||||
VkDeviceCreateInfo device_create_info;
|
||||
|
||||
@@ -104,6 +104,10 @@ class VulkanProvider : public GraphicsProvider {
|
||||
bool ext_fragment_shader_interlock;
|
||||
// Core since 1.1.0.
|
||||
bool khr_dedicated_allocation;
|
||||
// Core since 1.2.0.
|
||||
bool khr_shader_float_controls;
|
||||
// Core since 1.2.0.
|
||||
bool khr_spirv_1_4;
|
||||
};
|
||||
const DeviceExtensions& device_extensions() const {
|
||||
return device_extensions_;
|
||||
|
||||
Reference in New Issue
Block a user