KhronosGroup / KhronosGroup/Vulkan-Docs

Shader generic pointers

Open
#1,963 12 comments 10 reactions 0 assignees View on GitHub
Feature Request
Dominant language
JavaScript
Stars
3.3k
Forks
549
Avg merge
5d 5h
Merged PRs (30d)
2

Description

I'm working on a C to vulkan spir-v compiler (see *_shader.c files in https://gitlab.com/nanokatze/cg2c/-/tree/function_calls/test/hello) and having decided to not have any address space annotations, had to implement generic addressing, so that pointer values can point to either private/scratch or global (or shared, when I get around to implementing that.) I did this by keeping track of address space in bits 62:63 and assuming that no driver will ever use the high bits for anything. Each load/store/atomic expands into a little if/else cascade, testing the address space bits and doing appropriate load/store/atomic. The compiler optimizes some of these checks away, to best of its abilities

Some hardware has load/store/atomics instructions that operate on union of private/scratch, global and shared address spaces, but the code my compiler produces can not be transformed by the driver's compiler to make use of those instructions. Thus I'd like to request an extension for expressing load/store/atomics that are generic over those address spaces in vulkan spir-v so that the driver's compiler can produce better code.

Hopefully common shading languages (glsl and hlsl) acquire generic pointers at some point in the future as well. An extension for generic addressing would thus help furnish this future.

Contributor guide

Open the contributing guide

Research direction

Start with the linked cg2c function_calls/test/hello *_shader.c files and the issue’s description of address-space encoding and load/store/atomic expansion. Then review how Vulkan-Docs represents SPIR-V operations; done would be a concrete extension proposal for generic operations across private, global, and shared address spaces.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.