KhronosGroup / KhronosGroup/SPIRV-LLVM-Translator

Consider removing images with sampled == 0 to unify Shader and Kernel SPIR-V?

Open
#1,831 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
LLVM
Stars
625
Forks
279
Avg merge
3d 5h
Merged PRs (30d)
34

Description

One of the long-term goals of the SPIR-V working group is to reduced deltas between the "compute" and "graphics" SPIR-V variants to simplify the specification and tooling. One of the current deltas relates to images, and specifically to the _Sampled_ operand to [OpTypeImage](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpTypeImage). Even though there is nothing in the SPIR-V specification specifically tying values of the _Sampled_ operand to Shader or Kernel capabilities, the [Vulkan SPIR-V Environment](https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-StandaloneSpirv-OpTypeImage-04657) restricts _Sampled_ to the values of 1 (sampled image) or 2 (storage image), whereas the [OpenCL SPIR-V Environment](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Env.html#validation-rules) restricts _Sampled_ to the value 0, indicating that the image usage will only be known at run-time.

This issue is to track required changes to the SPIR-V LLVM Translator, were the SPIR-V working group to deprecate (and eventually remove?) support for _Sampled_ == 0 images.

In short, I think we would need the following changes:

* Read-only images will be assigned "Sampled == 1" since they may be used with a sampler.
* Write-only or read-write images will be assigned "Sampled == 2" since they will never be used with a sampler.
* When a "Sampled == 2" image is declared, the Image1D or ImageBuffer capabilities will need to be declared instead of (or in addition to) the Sampled1D or SampledBuffer capabilities.
* Depending whether "Sampled == 1" images work with OpImageRead, OpImageFetch may need to be generated instead.
* For a "Sampled == 1" image, generate OpImageQuerySizeLod with a fixed LOD equal to zero instead of OpImageQuerySize. OpImageQuerySize should continue to be generated for a "Sampled == 2" image.

It'd be great to develop a POC with these changes to ensure there are no unexpected complications.

Contributor guide

Open the contributing guide

Research direction

No repository files, tests, or entry points are named. Start by reviewing the SPIR-V Translator behavior against the Vulkan and OpenCL validation rules linked in the issue. A useful proof of concept should cover sampled values 1 and 2, capability declarations, image read operations, and image-size queries without relying on Sampled == 0.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.