diff --git a/src/kosmickrisp/bridge/mtl_device.h b/src/kosmickrisp/bridge/mtl_device.h index 1732f924750..9a42b614e28 100644 --- a/src/kosmickrisp/bridge/mtl_device.h +++ b/src/kosmickrisp/bridge/mtl_device.h @@ -9,6 +9,7 @@ #include "mtl_types.h" +#include #include /* TODO_KOSMICKRISP Remove */ @@ -27,6 +28,7 @@ void mtl_device_get_architecture_name(mtl_device *dev, char buffer[256]); uint64_t mtl_device_get_peer_group_id(mtl_device *dev); uint32_t mtl_device_get_peer_index(mtl_device *dev); uint64_t mtl_device_get_registry_id(mtl_device *dev); +bool mtl_device_supports_sample_count(mtl_device *dev, uint32_t sample_count); struct mtl_size mtl_device_max_threads_per_threadgroup(mtl_device *dev); uint32_t mtl_device_max_threadgroup_memory_length(mtl_device *dev); uint64_t mtl_device_max_buffer_length(mtl_device *dev); diff --git a/src/kosmickrisp/bridge/mtl_device.m b/src/kosmickrisp/bridge/mtl_device.m index 6159d95fb31..f607d2f18cc 100644 --- a/src/kosmickrisp/bridge/mtl_device.m +++ b/src/kosmickrisp/bridge/mtl_device.m @@ -118,6 +118,15 @@ mtl_device_get_registry_id(mtl_device *dev) } } +bool +mtl_device_supports_sample_count(mtl_device *dev, uint32_t sample_count) +{ + @autoreleasepool { + id device = (id)dev; + return [device supportsTextureSampleCount:sample_count]; + } +} + struct mtl_size mtl_device_max_threads_per_threadgroup(mtl_device *dev) { diff --git a/src/kosmickrisp/bridge/stubs/mtl_device.c b/src/kosmickrisp/bridge/stubs/mtl_device.c index 26d19cc1d50..da9accf7285 100644 --- a/src/kosmickrisp/bridge/stubs/mtl_device.c +++ b/src/kosmickrisp/bridge/stubs/mtl_device.c @@ -53,6 +53,12 @@ mtl_device_get_registry_id(mtl_device *dev) return 0u; } +bool +mtl_device_supports_sample_count(mtl_device *dev, uint32_t sample_count) +{ + return false; +} + struct mtl_size mtl_device_max_threads_per_threadgroup(mtl_device *dev) { diff --git a/src/kosmickrisp/vulkan/kk_physical_device.c b/src/kosmickrisp/vulkan/kk_physical_device.c index f3a3de15c2d..a836bec2c6c 100644 --- a/src/kosmickrisp/vulkan/kk_physical_device.c +++ b/src/kosmickrisp/vulkan/kk_physical_device.c @@ -365,12 +365,13 @@ kk_get_device_properties(const struct kk_physical_device *pdev, const struct kk_instance *instance, struct vk_properties *properties) { - const VkSampleCountFlagBits sample_counts = - VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_2_BIT | - // TODO_KOSMICKRISP Modify sample count based on what pdev supports - VK_SAMPLE_COUNT_4_BIT /* | - VK_SAMPLE_COUNT_8_BIT */ - ; + VkSampleCountFlagBits sample_counts = VK_SAMPLE_COUNT_1_BIT; + for (uint32_t sample_count = VK_SAMPLE_COUNT_2_BIT; + sample_count <= VK_SAMPLE_COUNT_8_BIT; sample_count <<= 1) { + if (mtl_device_supports_sample_count(pdev->mtl_dev_handle, + sample_count)) + sample_counts |= sample_count; + } assert(sample_counts <= (KK_MAX_SAMPLES << 1) - 1);