KhronosGroup / KhronosGroup/SPIRV-Cross

OpPtrAccessChain

Open
#1,913 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
GLSL
Stars
2.5k
Forks
713
Avg merge
2d 18h
Merged PRs (30d)
16

Description

SPIRV-Cross currently can't translate OpPtrAccessChain (provided by PhysicalStorageBuffer cap, among others) to GLSL.

It is not possible to translate all uses of OpPtrAccessChain into OpAccessChain on an unbounded array: OpPtrAccessChain can be used to compute pointer to one past the end using the element operand, while OpAccessChain can not. Considering this, I think translating the B+E part of OpPtrAccessChain (when used on a PhysicalStorageBuffer pointer) to integer arithmetic, and the remaining part to ordinary OpAccessChain is the way go. This loses pointer provenance information but is correct and as a nice bonus should be simple: the case when OpPtrAccessChain is just used to perform pointer arithmetic, without creating a pointer into an element, doesn't need any special handling.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the existing handling of OpAccessChain and the GLSL translation path for PhysicalStorageBuffer pointers. Determine how OpPtrAccessChain's B+E pointer arithmetic and one-past-the-end behavior should be represented, then verify that all stated uses translate correctly.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.