Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Address space struct design #23

Closed
Closed

Description

@khyperia

Issue to discuss how to handle pointer address spaces.

spir-v has the concept of Storage Classes which are declared both on pointer types, as well as load/store instructions. We need to somehow carry through the correct pointer type and emit the correct metadata:

Some thoughts off the top of my head:

Conservative option: declare some intrinsic structs:

struct WorkgroupMemory<T> {
    #[spirv(workgroup_memory)]
    ptr: *mut T,
}
impl<T> WorkgroupMemory<T> {
    pub fn load(&self) -> T {
        spirv_intrinsic_load_workgroup_memory(self.ptr)
    }
}

Way-too-aggressive option: add syntax to Rust:

fn f(x: &workgroup u32);

Activity

  1. added
    t: designDesign of our rust-gpu language and std
    on Aug 24, 2020
  2. khyperia commented on Sep 18, 2020

    @khyperia
    ContributorAuthor

    It looks like we're going with a format similar to:

    #[spirv(storage_class = "private")]
    pub struct Private<T> {
        x: *mut T,
    }

    (where poking at x is an incredibly unsafe operation that requires knowledge of how the backend works, this will be in the spirv-std library, not user code)

    So the question is, what do we call all these structs? do we copy the names directly from the spirv spec, or do we try to make something that's a little easier to type and understand?

    the list of storage classes is here, I'd like to give rusty names to all of them.

    ("uniform_constant", UniformConstant),
    ("input", Input),
    ("uniform", Uniform),
    ("output", Output),
    ("workgroup", Workgroup),
    ("cross_workgroup", CrossWorkgroup),
    ("private", Private),
    ("function", Function),
    ("generic", Generic),
    ("push_constant", PushConstant),
    ("atomic_counter", AtomicCounter),
    ("image", Image),
    ("storage_buffer", StorageBuffer),
    ("callable_data_nv", CallableDataNV),
    ("incoming_callable_data_nv", IncomingCallableDataNV),
    ("ray_payload_nv", RayPayloadNV),
    ("hit_attribute_nv", HitAttributeNV),
    ("incoming_ray_payload_nv", IncomingRayPayloadNV),
    ("shader_record_buffer_nv", ShaderRecordBufferNV),
    ("physical_storage_buffer", PhysicalStorageBuffer),

    Also, how do we load/store from them? If methods, what do we call the load/store methods?

  3. changed the title [-]Handling pointer address spaces[/-] [+]Address space struct design[/+] on Oct 1, 2020
  4. khyperia commented on Nov 12, 2020

    @khyperia
    ContributorAuthor

    This design issue has been open for a while, and no comments have been made, so closing this by assuming that the current design is what we want to go with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    t: designDesign of our rust-gpu language and std

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions