Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion lib/API/VK/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ class VKDevice : public offloadtest::Device {
VkPhysicalDeviceProperties2 Props2;
VkPhysicalDeviceFloatControlsProperties FloatControlProp;
VkPhysicalDeviceDriverProperties DriverProps;
VkPhysicalDeviceSubgroupProperties SubgroupProps;
VkPhysicalDeviceVulkan13Properties Vulkan13Props;
Capabilities Caps;
using LayerVector = std::vector<VkLayerProperties>;
LayerVector Layers;
Expand Down Expand Up @@ -392,11 +394,25 @@ class VKDevice : public offloadtest::Device {
FloatControlProp.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES;
FloatControlProp.pNext = nullptr;
SubgroupProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
SubgroupProps.pNext = &FloatControlProp;
DriverProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES;
DriverProps.pNext = &FloatControlProp;
DriverProps.pNext = &SubgroupProps;
Props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
Props2.pNext = &DriverProps;
vkGetPhysicalDeviceProperties2(Device, &Props2);

// Query Vulkan 1.3 properties for subgroup size control range.
memset(&Vulkan13Props, 0, sizeof(Vulkan13Props));
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 3, 0)) {
Vulkan13Props.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES;
Vulkan13Props.pNext = nullptr;
VkPhysicalDeviceProperties2 Props2ForVk13{};
Props2ForVk13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
Props2ForVk13.pNext = &Vulkan13Props;
vkGetPhysicalDeviceProperties2(Device, &Props2ForVk13);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why create a second Properties2 just to query the Vulkan13 props? Couldn't we just put this Props object on the chain of Props objects above (under an if for the api version) and get this in the previous vkGetPhysicalDeviceProperties2 call?

That said, I'm not actually convinced the lifetime of Vulkan13Props and SubgroupProps makes sense here given that they're only ever used in queryCapabilities. It would probably be better to put these objects on the stack there and query them similarly to how we query the features.

note: there's a bit of irony here, because the Features are used in more than one place and apparently we just query them twice. These two objects really are only ever needed to populate Caps.

}
const uint64_t DriverNameSz =
strnlen(DriverProps.driverName, VK_MAX_DRIVER_NAME_SIZE);
DriverName = std::string(DriverProps.driverName, DriverNameSz);
Expand Down Expand Up @@ -526,6 +542,24 @@ class VKDevice : public offloadtest::Device {
std::make_pair(#Name, make_capability<bool>(#Name, Features14.Name)));
#endif
#include "VKFeatures.def"

// Subgroup capabilities
Caps.insert(std::make_pair(
"subgroupSize",
make_capability<uint32_t>("subgroupSize", SubgroupProps.subgroupSize)));
uint32_t MinSize = SubgroupProps.subgroupSize;
uint32_t MaxSize = SubgroupProps.subgroupSize;
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 3, 0) &&
Features13.subgroupSizeControl) {
MinSize = Vulkan13Props.minSubgroupSize;
MaxSize = Vulkan13Props.maxSubgroupSize;
}
Caps.insert(
std::make_pair("minSubgroupSize",
make_capability<uint32_t>("minSubgroupSize", MinSize)));
Caps.insert(
std::make_pair("maxSubgroupSize",
make_capability<uint32_t>("maxSubgroupSize", MaxSize)));
}

void queryLayers() {
Expand Down
15 changes: 12 additions & 3 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def getHighestShaderModel(features):
return int(major), int(minor)


def setWaveSizeFeaturesDirectX(config, device):
MinSize = device["Features"]["WaveLaneCountMin"]
MaxSize = device["Features"]["WaveLaneCountMax"]
def setWaveSizeFeatures(config, device, minFeature, maxFeature):
MinSize = device["Features"][minFeature]
MaxSize = device["Features"][maxFeature]
if not MinSize or not MaxSize:
return

Expand All @@ -77,6 +77,14 @@ def setWaveSizeFeaturesDirectX(config, device):
MinSizeInt *= 2


def setWaveSizeFeaturesDirectX(config, device):
setWaveSizeFeatures(config, device, "WaveLaneCountMin", "WaveLaneCountMax")


def setWaveSizeFeaturesVulkan(config, device):
setWaveSizeFeatures(config, device, "minSubgroupSize", "maxSubgroupSize")


def setDeviceFeatures(config, device, compiler):
API = device["API"]
config.available_features.add(API)
Expand Down Expand Up @@ -139,6 +147,7 @@ def setDeviceFeatures(config, device, compiler):
config.available_features.add("Double")
if device["Features"].get("shaderInt64", False):
config.available_features.add("Int64")
setWaveSizeFeaturesVulkan(config, device)

# Add supported extensions.
for Extension in device["Extensions"]:
Expand Down
Loading