[vulkan] Add image format qualifier to glsl files (#69330)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69330

 ---

## Context

Previously, our shader files did not declare any [image format qualifiers](https://www.khronos.org/opengl/wiki/Layout_Qualifier_(GLSL)#Image_formats) for image layouts. This causes the SPIR-V modules produced to declare the [StorageImageWriteWithoutFormat](https://www.khronos.org/registry/SPIR-V/specs/unified1/SPIRV.html#_a_id_capability_a_capability) capability, which requires `shaderStorageImageWriteWithoutFormat` to be enabled in [VkPhysicalDeviceFeatures](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPhysicalDeviceFeatures.html). `shaderStorageImageWriteWithoutFormat` is not available on some devices, causing errors to be reported by the Vulkan validation layer.

## Changes

Vulkan shaders now declare the image format explicitly so that the SPIR-V modules produced are compatible with devices that do not have `shaderStorageImageWriteWithoutFormat` enabled.

Test Plan: Imported from OSS

Reviewed By: beback4u

Differential Revision: D32840909

Pulled By: SS-JIA

fbshipit-source-id: 76e0a0da68b423ebc74ae7e839b9cfaf57d2cd39
This commit is contained in:
Sicheng Stephen Jia
2021-12-07 16:21:18 -08:00
committed by Facebook GitHub Bot
parent e5a1ee0e5a
commit bede33e3f5
53 changed files with 218 additions and 164 deletions

View File

@ -9,6 +9,9 @@ set(VULKAN_GEN_ARG_ENV "")
if(USE_VULKAN_RELAXED_PRECISION)
string(APPEND VULKAN_GEN_ARG_ENV "precision=mediump")
endif()
if(USE_VULKAN_FP16_INFERENCE)
string(APPEND VULKAN_GEN_ARG_ENV "format=rgba16f")
endif()
if(USE_VULKAN_SHADERC_RUNTIME)
set(PYTHONPATH "$ENV{PYTHONPATH}")