Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sampler using unnormalised coordinates and 3d images #1202

Closed
rjodinchr opened this issue Aug 25, 2023 · 1 comment
Closed

sampler using unnormalised coordinates and 3d images #1202

rjodinchr opened this issue Aug 25, 2023 · 1 comment
Assignees

Comments

@rjodinchr
Copy link
Collaborator

A sampler using unnormalised coordinates cannot be used to read/write 3d images:

[CLVK] Validation Error: [ VUID-vkCmdDispatch-None-02702 ] Object 0: handle = 0x625f640000000058, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0x7cd292000000004f, type = VK_OBJECT_TYPE_IMAGE_VIEW; Object 2: handle = 0x2a7f70000000053, type = VK_OBJECT_TYPE_SAMPLER; | MessageID = 0x4fc13051 | vkCmdDispatch: Descriptor set VkDescriptorSet 0x625f640000000058[] Image View VkImageView 0x7cd292000000004f[], type: VK_IMAGE_VIEW_TYPE_3D in Descriptor in binding #0 index 0is used by VkSampler 0x2a7f70000000053[]. The Vulkan spec states: If the VkPipeline
object bound to the pipeline bind point used by this command accesses a VkSampler object that uses unnormalized coordinates, that sampler must not be used to sample from any VkImage with a VkImageView of the type VK_IMAGE_VIEW_TYPE_3D, VK_IMAGE_VIEW_TYPE_CUBE, VK_IMAGE_VIEW_TYPE_1D_ARRAY, VK_IMAGE_VIEW_TYPE_2D_ARRAY or VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage (https://www.khronos.org/registry/vulkan/specs/1.3-khr-extensions/html/vkspec.html#VUID-vkCmdDispatch-None-02702)

Here is my current plan to fix it:

  • literal sampler inside a kernel, example:
    • const sampler_t my_sampler = CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST | CLK_NORMALIZED_COORDS_FALSE;
    • In that case we should be able to detect if the sampler is used to read/write 3d images. Then we can rework everything in the compiler to use a normalise sampler and translate the coordinates accordingly.
  • as an kernel argument, example:
    • kernel void foo(read_only image3d image, sampler_t sampler)
    • This case is a bit more complex:
      • The host API doesn't know for which image the sampler will be used.
        • The compiler needs to expose whether the sampler is used to access 3d images or not.
      • The compiler doesn't know whether the sampler expects normalised of unnormalised coordinates.
        • The compiler needs to generate the 2 ways to access:
          1. as it is now if the sampler uses normalised coordinates.
          2. using the same rework as for the literal sampler
        • The compiler needs to choose the proper access at runtime using a pushconstant that will need to be set before launching the kernel by the host API.
rjodinchr added a commit to rjodinchr/clspv that referenced this issue Aug 31, 2023
We cannot use unormalized sampled with 3D images.

This commit intend to fix that for literal sampler (static sampler
defined in the kernel).

When detecting a case of reading a image3d with a literal sampler
using unnormalized coordinate:
- create a equivalent sampler using normalized coordinate
- normalized the coordinate

Ref google#1202
@rjodinchr rjodinchr self-assigned this Sep 1, 2023
rjodinchr added a commit to rjodinchr/clspv that referenced this issue Sep 6, 2023
We cannot use unormalized sampled with 3D images.

This commit intend to fix that for literal sampler (static sampler
defined in the kernel).

When detecting a case of reading a image3d with a literal sampler
using unnormalized coordinate:
- create a equivalent sampler using normalized coordinate
- normalized the coordinate

Ref google#1202
rjodinchr added a commit to rjodinchr/clspv that referenced this issue Sep 6, 2023
We cannot use unormalized sampled with 3D images.

This commit intend to fix that for literal sampler (static sampler
defined in the kernel).

When detecting a case of reading a image3d with a literal sampler
using unnormalized coordinate:
- create a equivalent sampler using normalized coordinate
- normalized the coordinate

Ref google#1202
rjodinchr added a commit to rjodinchr/clspv that referenced this issue Sep 7, 2023
We cannot use unormalized sampled with 3D images.

This commit intend to fix that for literal sampler (static sampler
defined in the kernel).

When detecting a case of reading a image3d with a literal sampler
using unnormalized coordinate:
- create a equivalent sampler using normalized coordinate
- normalized the coordinate

Ref google#1202
alan-baker pushed a commit that referenced this issue Sep 7, 2023
…1215)

We cannot use unormalized sampled with 3D images.

This commit intend to fix that for literal sampler (static sampler
defined in the kernel).

When detecting a case of reading a image3d with a literal sampler
using unnormalized coordinate:
- create a equivalent sampler using normalized coordinate
- normalized the coordinate

Ref #1202
rjodinchr added a commit to rjodinchr/SPIRV-Headers that referenced this issue Sep 11, 2023
This is needed to implement 3D Image read using unnormalised sampler.
Ref google/clspv#1202
alan-baker pushed a commit to KhronosGroup/SPIRV-Headers that referenced this issue Oct 11, 2023
)

This is needed to implement 3D Image read using unnormalised sampler.
Ref google/clspv#1202
@rjodinchr
Copy link
Collaborator Author

I think for clspv, everything has been done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant