Skip to content

Using pointers with OpPhi requires capability VariablePointers or VariablePointersStorageBuffer #294

Closed as not planned
@nazar-pc

Description

@nazar-pc

Code:

use spirv_std::glam::UVec4;
use spirv_std::spirv;

#[derive(Copy, Clone)]
#[repr(C, align(16))]
pub struct ChaCha8Block(pub [UVec4; 4]);

#[spirv(compute(threads(64, 1, 1)))]
pub fn chacha8_keystream_block(
    #[spirv(uniform, descriptor_set = 1, binding = 0)] initial_state: &ChaCha8Block,
) {
    ChaCha8State::from_repr(*initial_state);
}

#[derive(Copy, Clone)]
pub(crate) struct ChaCha8State {
    data: [u32; 16],
}

impl ChaCha8State {
    pub(crate) fn from_repr(data: ChaCha8Block) -> Self {
        Self {
            data: [
                data.0[0][0], data.0[0][1], data.0[0][2], data.0[0][3],
                data.0[1][0], data.0[1][1], data.0[1][2], data.0[1][3],
                data.0[2][0], data.0[2][1], data.0[2][2], data.0[2][3],
                data.0[3][0], data.0[3][1], data.0[3][2], data.0[3][3],
            ],
        }
    }
}

Results in this:

  error: Using pointers with OpPhi requires capability VariablePointers or VariablePointersStorageBuffer
    |
    = note: module `.../spirv-unknown-vulkan1.1/release/deps/ab_proof_of_space_gpu.spv`

  warning: an unknown error occurred
    |
    = note: spirv-opt failed, leaving as unoptimized
    = note: module `.../spirv-unknown-vulkan1.1/release/deps/ab_proof_of_space_gpu.spv`

  error: error:0:0 - Using pointers with OpPhi requires capability VariablePointers or VariablePointersStorageBuffer
           %58 = OpPhi %_ptr_Function_uint %54 %50 %55 %51 %56 %52 %57 %53
    |
    = note: spirv-val failed
    = note: module `.../spirv-unknown-vulkan1.1/release/deps/ab_proof_of_space_gpu.spv`

It looks like almost anything involving references, de-referencing, etc. results in this error. I'm a bit puzzled how to write anything useful at all if this doesn't work.

Using current main: e6d017d

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions