Skip to content

[wgsl] support readonly and writeonly on storage buffers #935

Closed

Description

@dneto0

This feature appears in some CTS tests.
It corresponds to the GLSL 'writeonly' and 'readonly' attributes on storage buffer variables.

Example shader:

#version 450
layout (set=0, binding = 0) buffer writeonly BufferName {
 int value;
} buf;

void main() {
  buf.value = 1;
}

In SPIR-V this maps to a NonReadable decoration on the member. (But let's gloss over where it's applied).

The readonly attribute is a hint to an implementation that it is safe to aggressively prefetch and cache accesses.

The writeonly attribute is a hint to an implementation that it's wasteful to cache accesses, and you don't need a snooping mechanism on the store buffer.

If we add this to WGSL, then when translating to another language, a fallback is to drop the attributes.

Activity

  1. added
    wgsl
    on Jul 20, 2020
  2. added this to the MVP milestone on Jul 20, 2020
  3. dneto0 commented on Sep 19, 2020

    @dneto0
    ContributorAuthor

    See discussion on #1059 (comment) for how this should work for both read-only buffers and storage textures (read-only and write-only).

    Since I filed this, I've learned this is more important than I realized. The buffer has to be set up differently on the API side as well.

  4. kvark commented on Sep 19, 2020

    @kvark
    Contributor

    First of all, we probably don't need write-only buffers, since the API doesn't have them (only read-write).
    Secondly, it would be nice if the "readonly/read-write" semantic was a part of the type in WGSL (and not the binding), to be consistent with texture declarations, where it's already a part of the type.

  5. dneto0 commented on Sep 22, 2020

    @dneto0
    ContributorAuthor

    Discussed during 2020-09-22 meeting relation to #1056.

    Suggested direction: Use distinct types for readonly and read-write buffers. Motivation is that HLSL has them as distinct types.

  6. dneto0 commented on May 11, 2021

    @dneto0
    ContributorAuthor

    This is obsolete. See #1064 for the latest iteration.

  7. dneto0 commented on May 11, 2021

    @dneto0
    ContributorAuthor

    Discussed in 2021-05-11

  8. kdashg commented on May 17, 2021

    @kdashg
    Contributor
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

    wgsl

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions