diff options
author | Dave Airlie <[email protected]> | 2018-11-05 02:41:37 +0000 |
---|---|---|
committer | Erik Faye-Lund <[email protected]> | 2019-10-28 08:51:45 +0000 |
commit | 4480aefc38ab9bbac965d36942ee8c0111a4f988 (patch) | |
tree | 23e6bf50e8913ed4f5d552c78aa92818f61516f9 /src/gallium | |
parent | e234116a96604d787bcc05a3b9ebcf8701682e6f (diff) |
zink: attempt to get multisample resource creation right
Use the exposed vulkan limits to fill out supported formats.
Acked-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/zink/zink_screen.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index db9f9d3a9a2..260d4bf90db 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -554,6 +554,22 @@ zink_get_format(enum pipe_format format) return formats[format]; } +static VkSampleCountFlagBits +vk_sample_count_flags(uint32_t sample_count) +{ + switch (sample_count) { + case 1: return VK_SAMPLE_COUNT_1_BIT; + case 2: return VK_SAMPLE_COUNT_2_BIT; + case 4: return VK_SAMPLE_COUNT_4_BIT; + case 8: return VK_SAMPLE_COUNT_8_BIT; + case 16: return VK_SAMPLE_COUNT_16_BIT; + case 32: return VK_SAMPLE_COUNT_32_BIT; + case 64: return VK_SAMPLE_COUNT_64_BIT; + default: + return 0; + } +} + static bool zink_is_format_supported(struct pipe_screen *pscreen, enum pipe_format format, @@ -564,13 +580,51 @@ zink_is_format_supported(struct pipe_screen *pscreen, { struct zink_screen *screen = zink_screen(pscreen); - if (sample_count > 1) - return FALSE; + if (format == PIPE_FORMAT_NONE) + return screen->props.limits.framebufferNoAttachmentsSampleCounts & + vk_sample_count_flags(sample_count); VkFormat vkformat = formats[format]; if (vkformat == VK_FORMAT_UNDEFINED) return FALSE; + const struct util_format_description *desc = util_format_description(format); + if (sample_count >= 1) { + VkSampleCountFlagBits sample_mask = vk_sample_count_flags(sample_count); + if (util_format_is_depth_or_stencil(format)) { + if (util_format_has_depth(desc)) { + if (bind & PIPE_BIND_DEPTH_STENCIL && + (screen->props.limits.framebufferDepthSampleCounts & sample_mask) != sample_mask) + return FALSE; + if (bind & PIPE_BIND_SAMPLER_VIEW && + (screen->props.limits.sampledImageDepthSampleCounts & sample_mask) != sample_mask) + return FALSE; + } + if (util_format_has_stencil(desc)) { + if (bind & PIPE_BIND_DEPTH_STENCIL && + (screen->props.limits.framebufferStencilSampleCounts & sample_mask) != sample_mask) + return FALSE; + if (bind & PIPE_BIND_SAMPLER_VIEW && + (screen->props.limits.sampledImageStencilSampleCounts & sample_mask) != sample_mask) + return FALSE; + } + } else if (util_format_is_pure_integer(format)) { + if (bind & PIPE_BIND_RENDER_TARGET && + !(screen->props.limits.framebufferColorSampleCounts & sample_mask)) + return FALSE; + if (bind & PIPE_BIND_SAMPLER_VIEW && + !(screen->props.limits.sampledImageIntegerSampleCounts & sample_mask)) + return FALSE; + } else { + if (bind & PIPE_BIND_RENDER_TARGET && + !(screen->props.limits.framebufferColorSampleCounts & sample_mask)) + return FALSE; + if (bind & PIPE_BIND_SAMPLER_VIEW && + !(screen->props.limits.sampledImageColorSampleCounts & sample_mask)) + return FALSE; + } + } + VkFormatProperties props; vkGetPhysicalDeviceFormatProperties(screen->pdev, vkformat, &props); @@ -597,7 +651,6 @@ zink_is_format_supported(struct pipe_screen *pscreen, return FALSE; } - const struct util_format_description *desc = util_format_description(format); if (desc->layout == UTIL_FORMAT_LAYOUT_BPTC && !screen->feats.textureCompressionBC) return FALSE; |