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
18041804 return VK_FORMAT_UNDEFINED;
18051805 }
18061806
1807−static void bgr_workaround(AVVulkanFramesContext *vkfc,
1807+static void bgr_workaround(FFVulkanContext *s,
1808+ AVVulkanFramesContext *vkfc,
18081809 VkImageViewCreateInfo *ci)
18091810 {
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)
18111814 return;
18121815 switch (ci->format) {
18131816 #define REMAP(src, dst) \
@@ -1858,7 +1861,7 @@ int ff_vk_create_imageview(FFVulkanContext *s, · 44 unmodified lines
18581861 .layerCount = 1,
18591862 },
18601863 };
1861− bgr_workaround(vkfc, &view_create_info);
1864+ bgr_workaround(s, vkfc, &view_create_info);
18621865 if (view_create_info.format == VK_FORMAT_UNDEFINED) {
18631866 av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "
18641867 "of format %i and mode %i\n",
@@ -1920,7 +1923,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 55 unmodified lines
19201923 .layerCount = 1,
19211924 },
19221925 };
1923− bgr_workaround(vkfc, &view_create_info);
1926+ bgr_workaround(s, vkfc, &view_create_info);
19241927 if (view_create_info.format == VK_FORMAT_UNDEFINED) {
19251928 av_log(s, AV_LOG_ERROR, "Unable to find a compatible representation "
19261929 "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
20602063 GLSLC(0, #extension GL_EXT_scalar_block_layout : require );
20612064 GLSLC(0, #extension GL_EXT_shader_explicit_arithmetic_types : require );
20622065 GLSLC(0, #extension GL_EXT_control_flow_attributes : require );
2066+ GLSLC(0, #extension GL_EXT_shader_image_load_formatted : require );
20632067 if (s->extensions & FF_VK_EXT_EXPECT_ASSUME) {
20642068 GLSLC(0, #extension GL_EXT_expect_assume : require );
20652069 } else {
@@ -2457,8 +2461,10 @@ print: · 391 unmodified lines
24572461 const struct descriptor_props *prop = &descriptor_props[desc[i].type];
24582462 GLSLA("layout (set = %i, binding = %i", FFMAX(shd->nb_descriptor_sets - 1, 0), i);
24592463
2460− if (desc[i].mem_layout)
2464+ if (desc[i].mem_layout &&
2465+ (desc[i].type != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE))
24612466 GLSLA(", %s", desc[i].mem_layout);
2467+
24622468 GLSLA(")");
24632469
24642470 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