History

vulkan: always enable ReadWithoutFormat/WriteWithoutFormat

This implements support for reading and writing storage images with no format. The issue is that we define our images as arrays, and arrays can only have a single type, which means that f.ex. NV12 needs two different images, R8 and RG8. The only driver known not to advertise support for the extension as a whole is Intel, because they have parial support for odd formats we never use. Therefore, just always enable it by default.

Lynne committed 1 year ago

Commit ca6392e1 parent ff9f3fb1 file · +11 −5Browse files

Unified · Split

libavutil/vulkan.c+11−5
@@ -1804,10 +1804,13 @@ static VkFormat map_fmt_to_rep(VkFormat fmt, enum FFVkShaderRepFormat rep_fmt) · 1803 unmodified lines
1804 return VK_FORMAT_UNDEFINED;1804 return VK_FORMAT_UNDEFINED;
1805}1805}
1806 1806
1807static void bgr_workaround(AVVulkanFramesContext *vkfc,1807static void bgr_workaround(FFVulkanContext *s,
1808 AVVulkanFramesContext *vkfc,
1808 VkImageViewCreateInfo *ci)1809 VkImageViewCreateInfo *ci)
1809{1810{
1810 if (!(vkfc->usage & VK_IMAGE_USAGE_STORAGE_BIT))1811 if (!(vkfc->usage & VK_IMAGE_USAGE_STORAGE_BIT) ||
1812 s->feats.features.shaderStorageImageReadWithoutFormat ||
1813 s->feats.features.shaderStorageImageWriteWithoutFormat)
1811 return;1814 return;
1812 switch (ci->format) {1815 switch (ci->format) {
1813#define REMAP(src, dst) \1816#define REMAP(src, dst) \
@@ -1858,7 +1861,7 @@ int ff_vk_create_imageview(FFVulkanContext *s, · 44 unmodified lines
1858 .layerCount = 1,1861 .layerCount = 1,
1859 },1862 },
1860 };1863 };
1861 bgr_workaround(vkfc, &view_create_info);1864 bgr_workaround(s, vkfc, &view_create_info);
1862 if (view_create_info.format == VK_FORMAT_UNDEFINED) {1865 if (view_create_info.format == VK_FORMAT_UNDEFINED) {
1863 av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "1866 av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "
1864 "of format %i and mode %i\n",1867 "of format %i and mode %i\n",
@@ -1920,7 +1923,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 55 unmodified lines
1920 .layerCount = 1,1923 .layerCount = 1,
1921 },1924 },
1922 };1925 };
1923 bgr_workaround(vkfc, &view_create_info);1926 bgr_workaround(s, vkfc, &view_create_info);
1924 if (view_create_info.format == VK_FORMAT_UNDEFINED) {1927 if (view_create_info.format == VK_FORMAT_UNDEFINED) {
1925 av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "1928 av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "
1926 "of format %i and mode %i\n",1929 "of format %i and mode %i\n",
@@ -2060,6 +2063,7 @@ int ff_vk_shader_init(FFVulkanContext *s, FFVulkanShader *shd, const char *name, · 133 unmodified lines
2060 GLSLC(0, #extension GL_EXT_scalar_block_layout : require );2063 GLSLC(0, #extension GL_EXT_scalar_block_layout : require );
2061 GLSLC(0, #extension GL_EXT_shader_explicit_arithmetic_types : require );2064 GLSLC(0, #extension GL_EXT_shader_explicit_arithmetic_types : require );
2062 GLSLC(0, #extension GL_EXT_control_flow_attributes : require );2065 GLSLC(0, #extension GL_EXT_control_flow_attributes : require );
2066 GLSLC(0, #extension GL_EXT_shader_image_load_formatted : require );
2063 if (s->extensions & FF_VK_EXT_EXPECT_ASSUME) {2067 if (s->extensions & FF_VK_EXT_EXPECT_ASSUME) {
2064 GLSLC(0, #extension GL_EXT_expect_assume : require );2068 GLSLC(0, #extension GL_EXT_expect_assume : require );
2065 } else {2069 } else {
@@ -2457,8 +2461,10 @@ print: · 391 unmodified lines
2457 const struct descriptor_props *prop = &descriptor_props[desc[i].type];2461 const struct descriptor_props *prop = &descriptor_props[desc[i].type];
2458 GLSLA("layout (set = %i, binding = %i", FFMAX(shd->nb_descriptor_sets - 1, 0), i);2462 GLSLA("layout (set = %i, binding = %i", FFMAX(shd->nb_descriptor_sets - 1, 0), i);
2459 2463
2460 if (desc[i].mem_layout)2464 if (desc[i].mem_layout &&
2465 (desc[i].type != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE))
2461 GLSLA(", %s", desc[i].mem_layout);2466 GLSLA(", %s", desc[i].mem_layout);
2467
2462 GLSLA(")");2468 GLSLA(")");
2463 2469
2464 if (prop->is_uniform)2470 if (prop->is_uniform)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t