Name Strings

SPV_KHR_shader_clock

Contact

See Issues list in the Khronos SPIRV-Registry repository: https://github.com/KhronosGroup/SPIRV-Registry

Contributors

  • Aaron Hagan, AMD

  • Neil Henning, AMD

  • Daniel Rakos, AMD

  • David Neto, Google

  • Daniel Koch, NVIDIA

Status

  • Complete

  • Approved by the SPIR Working Group: 2019-03-06

  • Ratified by Khronos on 2019-05-03

Version

Last Modified Date

2019-10-30

Revision

3

Dependencies

This extension is written against the SPIR-V Specification, Version 1.3 Revision 1.

This extension requires SPIR-V 1.0.

Overview

This extension adds new capabilities to support the GL_ARB_shader_clock and GL_EXT_shader_realtime_clock GLSL extensions in SPIR-V.

Extension Name

To use this extension within a SPIR-V module, the following OpExtension must be present in the module:

OpExtension "SPV_KHR_shader_clock"

New Capabilities

This extension introduces a new capability:

ShaderClockKHR

New Instructions

Instructions added under the ShaderClockKHR capability:

OpReadClockKHR

Token Number Assignments

ShaderClockKHR

5055

OpReadClockKHR

5056

Modifications to the SPIR-V Specification, Version 1.3

Capabilities

Modify Section 3.31, Capability, adding rows to the Capability table:

Capability Implicitly Declares

5055

ShaderClockKHR

Instructions

(Add Section 3.32.25, Time Instructions)

OpReadClockKHR

Result is the sample value of a clock as seen by the shader processor. An idealized clock is an unbounded unsigned scalar integer tick count increasing monotonically over time. A clock’s rate of progress may vary within the lifetime of an invocation, may vary across different executions of the program, and may be affected by conditions beyond the control of the programmer. The sampled value read by this instruction consists of the least significant bits of the idealized clock’s tick count at the time the instruction was executed. In particular, an observer may see sampled values wrap around zero.

Result Type must be a 64-bit unsigned integer type or a vector of two-components of 32-bit unsigned integer type with the first component containing the 32 least significant bits and the second component containing the 32 most significant bits.

All invocations within the Scope read from the same source clock. Scope must be a valid Scope <id> (Section 3.27).

Capability:
ShaderClockKHR

4

5055

<id> Result Type

<id> Result

Scope <id> Scope

(Add to Used by: list in Section 3.27, Scope <id>)
OpReadClockKHR

Validation Rules

An OpExtension must be added to SPIR-V for validation layers to check legal use of this extension:

OpExtension "SPV_KHR_shader_clock"

The Scope operand of the OpReadClockKHR instruction must be a valid Scope <id>.

Issues

  1. How does this extension interact with ARB_shader_clock ?

    RESOLVED: This extension purposefully does not fully implement ARB_shader_clock, as there is no guarantee of code motion barriers.

  2. If two invocations execute the same dynamic instance of the ReadClockKHR instruction, do both invocations get exactly the same value ?

    RESOLVED: There is no guarantee that two invocations will produce exactly the same value.

Revision History

Rev Date Author Changes

1

2019-02-22

Aaron Hagan

Initial draft

2

2019-10-29

Daniel Koch

Add Op prefix to new instruction, add links to GLSL specs

3

2019-10-30

Daniel Koch

SPIR-V/issues/511 (gitlab) - stop calling the scope "Execution Scope"