summaryrefslogtreecommitdiffstats
path: root/tools/gfx/vulkan/vk-device.cpp
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-04-18 16:18:02 -0700
committerGitHub <noreply@github.com>2025-04-18 16:18:02 -0700
commit591affaf733ec82d7b38a7bf9c4d2f49a69a2c66 (patch)
tree89d5819114b0d40a4c927ed1185fcda0d94b5679 /tools/gfx/vulkan/vk-device.cpp
parenta597a0358f2c2b8ec1b71b7959861658a2c06ecc (diff)
Check the available VK extensions before using CoopVec APIs in GFX (#6849)
* Check the available VK extensions before using CoopVec APIs in GFX * Remove a redundant request for cooperative vector extension for vk
Diffstat (limited to 'tools/gfx/vulkan/vk-device.cpp')
-rw-r--r--tools/gfx/vulkan/vk-device.cpp57
1 files changed, 47 insertions, 10 deletions
diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp
index 981b5abac..b9ca76493 100644
--- a/tools/gfx/vulkan/vk-device.cpp
+++ b/tools/gfx/vulkan/vk-device.cpp
@@ -730,6 +730,12 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
"ray-tracing-validation");
}
+ SIMPLE_EXTENSION_FEATURE(
+ extendedFeatures.cooperativeVectorFeatures,
+ cooperativeVector,
+ VK_NV_COOPERATIVE_VECTOR_EXTENSION_NAME,
+ "cooperative-vector");
+
#undef SIMPLE_EXTENSION_FEATURE
if (extendedFeatures.vulkan12Features.shaderBufferInt64Atomics)
@@ -752,16 +758,6 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
deviceCreateInfo.pNext = &extendedFeatures.vulkan12Features;
}
- if (extendedFeatures.cooperativeVectorFeatures.cooperativeVector)
- {
- deviceExtensions.add(VK_NV_COOPERATIVE_VECTOR_EXTENSION_NAME);
-
- extendedFeatures.cooperativeVectorFeatures.pNext = (void*)deviceCreateInfo.pNext;
- deviceCreateInfo.pNext = &extendedFeatures.cooperativeVectorFeatures;
-
- m_features.add("cooperative-vector");
- }
-
VkPhysicalDeviceProperties2 extendedProps = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2};
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rtProps = {
@@ -1548,6 +1544,47 @@ Result DeviceImpl::getTextureRowAlignment(Size* outAlignment)
return SLANG_OK;
}
+Result DeviceImpl::getCooperativeVectorProperties(
+ CooperativeVectorProperties* properties,
+ uint32_t* propertyCount)
+{
+ if (!m_api.m_extendedFeatures.cooperativeVectorFeatures.cooperativeVector ||
+ !m_api.vkGetPhysicalDeviceCooperativeVectorPropertiesNV)
+ return SLANG_E_NOT_AVAILABLE;
+
+ if (m_cooperativeVectorProperties.empty())
+ {
+ uint32_t vkPropertyCount = 0;
+ m_api.vkGetPhysicalDeviceCooperativeVectorPropertiesNV(
+ m_api.m_physicalDevice,
+ &vkPropertyCount,
+ nullptr);
+ std::vector<VkCooperativeVectorPropertiesNV> vkProperties(vkPropertyCount);
+ SLANG_VK_RETURN_ON_FAIL(m_api.vkGetPhysicalDeviceCooperativeVectorPropertiesNV(
+ m_api.m_physicalDevice,
+ &vkPropertyCount,
+ vkProperties.data()));
+ for (const auto& vkProps : vkProperties)
+ {
+ CooperativeVectorProperties props;
+ props.inputType =
+ VulkanUtil::translateCooperativeVectorComponentType(vkProps.inputType);
+ props.inputInterpretation =
+ VulkanUtil::translateCooperativeVectorComponentType(vkProps.inputInterpretation);
+ props.matrixInterpretation =
+ VulkanUtil::translateCooperativeVectorComponentType(vkProps.matrixInterpretation);
+ props.biasInterpretation =
+ VulkanUtil::translateCooperativeVectorComponentType(vkProps.biasInterpretation);
+ props.resultType =
+ VulkanUtil::translateCooperativeVectorComponentType(vkProps.resultType);
+ props.transpose = vkProps.transpose;
+ m_cooperativeVectorProperties.push_back(props);
+ }
+ }
+
+ return RendererBase::getCooperativeVectorProperties(properties, propertyCount);
+}
+
Result DeviceImpl::createTextureResource(
const ITextureResource::Desc& descIn,
const ITextureResource::SubresourceData* initData,