Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GLSL_EXT_nontemporal_keyword #275

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ that do not live in the Khronos registries for OpenGL or OpenGL ES.
- link:{repo}/nv/GLSL_NV_cooperative_vector.txt[GL_NV_cooperative_vector]
- link:{repo}/nv/GLSL_NV_cluster_acceleration_structure.txt[GL_NV_cluster_acceleration_structure]
- link:{repo}/nv/GLSL_NV_linear_swept_spheres.txt[GL_NV_linear_swept_spheres]
- link:{repo}/ext/GLSL_EXT_nontemporal_keyword.txt[GL_EXT_nontemporal_keyword]
162 changes: 162 additions & 0 deletions extensions/ext/GLSL_EXT_nontemporal_keyword.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
Name

EXT_nontemporal_keyword

Name Strings

GL_EXT_nontemporal_keyword

Contact

Karen Webb, Umbral Software Ltd (karen.webb 'at' umbralsoftware.co.uk)
Justin Ead, Collins Aerospace (justin.ead2 'at' collins.com)

Contributors

Karen Webb, Umbral Software Ltd (karen.webb 'at' umbralsoftware.co.uk)
Justin Ead, Collins Aerospace (justin.ead2 'at' collins.com)

Status

In-Progress.

Version

Last Modified: Jan 29 2025
Revision: 1

Dependencies

This extension can be applied to OpenGL GLSL versions 4.60
(#version 460) and higher.

This extension can be applied to OpenGL ES ESSL versions 3.20
(#version 320) and higher.

This extension is written against the OpenGL Shading Language
Specification, version 4.60.8, dated August 14, 2023 and the
SPIR-V Specification, version 1.6, revision 4.

Overview

This extension adds the nontemporal keyword for memory and image operands.

Mapping to SPIR-V
-----------------

For informational purposes (non-normative), the following is an
expected way for an implementation to map GLSL constructs to SPIR-V
constructs.

nontemporal buffer access -> Nontemporal Memory Operand
nontemporal image access -> Nontemporal Image Operand

The Nontemporal Image Operand requires SPIR-V 1.6 or higher.

Modifications to the OpenGL Shading Language Specification, Version 4.60

Including the following lines in a shader can be used to control the
language features described in this extension:

#extension GL_EXT_nontemporal_keyword : <behavior>

where <behavior> is as specified in section 3.3.

New preprocessor #defines are added to the OpenGL Shading Language:

#define GL_EXT_nontemporal_keyword 1

Modify Section 3.6. Keywords

Replace the line "coherent volatile restrict readonly writeonly"
with "coherent volatile restrict readonly writeonly nontemporal"

Modify Section 4.10. Memory Qualifiers

Add a new row to the table with the following information:

Qualifier Meaning
--------- -------
nontemporal memory variable whose value is not expected to be read
again in the near future, and should not be cached

After the paragraph beginning "Memory accesses to image variables
declared using the restrict qualifier may be compiled..." add the
following paragraph:

Memory accesses to image variables declared using the `nontemporal`
qualifier may be compiled to assume their value will not be needed
again in the near future. This allows the compiler to avoid bringing
that data unnecessarily into cache.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add here "It is a compile-time error to use the nontemporal qualifier when not generating SPIR-V"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I’d do this. Better to just leave it as a hint. There’s nothing wrong with other backend compilers deciding to use this.


Replace the sentence "The memory qualifiers coherent, volatile, restrict,
readonly, and writeonly may be used in the declaration of buffer variables
(i.e., members of shader storage blocks)." with:

The memory qualifiers coherent, volatile, restrict, readonly, writeonly,
and nontemporal may be used in the declaration of buffer variables
(i.e., members of shader storage blocks).

Replace the sentence beginning "When calling user-defined functions,
opaque-type variables qualified with coherent, volatile, readonly,
writeonly may not be passed to functions whose formal parameters lack such
qualifiers." with the following:

When calling user-defined functions, opaque-type variables qualified with
coherent, volatile, readonly, writeonly, and nontemporal may not be passed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
coherent, volatile, readonly, writeonly, and nontemporal may not be passed
coherent, volatile, readonly, writeonly, or nontemporal may not be passed

or you could use the phrasing "any combination of ... " which is used elsewhere.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original language used “and,” so it doesn’t make sense to change that here. If you want to change the base spec, then that’s outside the scope of this extension.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quotation above ("Replace the sentence...") doesn't include any conjunction here and the referenced version of the spec seems to say "or".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked at 4.10 Memory Qualifiers in the spec and it uses “and”
IMG_5131

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This quotation is a different paragraph. It's only this one use of "and" that I think is incorrect, the others are fine.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see now. Yes that should be corrected.

Copy link

@JebScape JebScape Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original language quote being replaced in this extension is also incorrect and missing the full language.

to functions whose formal parameters lack such qualifiers.

Modify Section 8.11. Memory Qualifiers

Replace the sentance "All the built-in functions in this section accept
arguments with combinations of restrict, coherent, and volatile memory
qualification, despite not having them listed in the prototypes." with
the following:

All the built-in functions in this section accept arguments with
combinations of restrict, coherent, volatile, and nontemporal memory
qualification, despite not having them listed in the prototypes.

Modify Section 8.12. Image Functions

Replace the sentance "All the built-in functions in this section accept
arguments with combinations of restrict, coherent, and volatile memory
qualification, despite not having them listed in the prototypes." with
the following:

All the built-in functions in this section accept arguments with
combinations of restrict, coherent, volatile, and nontemporal memory
qualification, despite not having them listed in the prototypes.

Modify Section 9. Shading Language Grammar

Replace the line "CENTROID IN OUT INOUT UNIFORM PATCH SAMPLE BUFFER SHARED
COHERENT VOLATILE RESTRICT READONLY WRITEONLY NOPERSPECTIVE FLAT SMOOTH
LAYOUT" with the following:

CENTROID IN OUT INOUT UNIFORM PATCH SAMPLE BUFFER SHARED COHERENT
VOLATILE RESTRICT READONLY WRITEONLY NONTEMPORAL NOPERSPECTIVE FLAT
SMOOTH LAYOUT

In the definition of `storage_qualifier` add the following line:

NONTEMPORAL

after the line "WRITEONLY"

Issues

(1) Should implicit removal of the keyword during function call
be allowed (as-per the `restrict` keyword) or forbidden (as-per
the `volatile` and `coherent` keywords)?

Feedback recieved was that behaving like `volatile` would be more
appropriate.

Revision History

Revision 1
- Initial revision.
Revision 2
- Behaviour of `nontemporal` being passed to a function declared without it
is now an error.