Name Strings

SPV_NV_compute_shader_derivatives

Contact

To report problems with this extension, please open a new issue at:

Contributors

  • Daniel Koch, NVIDIA

  • John Kessenich, Google

Status

  • Complete

Version

Last Modified Date

2018-09-12

Revision

1

Dependencies

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

This extension requires SPIR-V 1.0.

Overview

This extension provides a capability to enable derivatives in the GLCompute Execution Model. There are two new execution modes added which specify which four compute shader invocations are grouped together.

The new ComputeDerivativeGroupQuadsNV and ComputeDerivativeGroupLinearNV capabilities enable the use of OpImageQueryLod, the ImplicitLod instructions, and the Derivative instructions in the GLCompute Execution Model.

This SPIR-V extension provides support for the GLSL GL_NV_compute_shader_derivatives extension.

Extension Name

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

OpExtension "SPV_NV_compute_shader_derivatives"

Modifications to the SPIR-V Specification, Version 1.3

(Modify Section 2.2.4, Control Flow)

(Modify the definition of Derivative Group, to include GLCompute)

Derivative Group: Defined only for the Fragment and GLCompute Execution Models. In the Fragment execution model this is the set of invocations collectively processing a single point, line, or triangle, including any helper invocations. In the GLCompute execution model this is a single local workgroup.

(Modify Section 2.19, Derivatives)

(Replace the first sentence:)

Derivatives appear only in the Fragment Execution Model.

(with the following:)

Derivatives appear in the Fragment and GLCompute Execution Models.

(Modify Section 3.6, Execution Mode)

(add new rows to the Execution Mode table)

Execution Mode Enabling Capabilities Extra Operands

5289

DerivativeGroupQuadsNV
Specifies that compute shader derivatives are evaluated over 2x2 groups of invocations. See the Vulkan or OpenGL API specifications for more detail. Only valid with the GLCompute Execution Model.

ComputeDerivativeGroupQuadsNV

5290

DerivativeGroupLinearNV
Specifies that compute shader derivatives are evaluated over groups of four invocations with consecutive LocalInvocationIndex values. See the Vulkan or OpenGL API specifications for more detail. Only valid with the Compute Execution Model.

ComputeDerivativeGroupLinearNV

(Modify Section 3.31, Capability, adding a new row to the Capability table)
Capability Depends On Enabled by Extension

5288

ComputeDerivativeGroupQuadsNV
Uses the DerivativeGroupQuadsNV execution mode.

Shader

SPV_NV_compute_shader_derivatives

5350

ComputeDerivativeGroupLinearNV
Uses the DerivativeGroupLinearNV execution mode.

Shader

SPV_NV_compute_shader_derivatives

(Modify Section 3.32.10, Image Instructions)

(Modify the description of the following instructions to allow them in the GLCompute Execution Model in addition to the Fragment Execution Model)

  • OpImageSampleImplicitLod

  • OpImageSampleDrefImplicitLod

  • OpImageSampleProjImplicitLod

  • OpImageSampleProjDrefImplicitLod

  • OpImageQueryLod

  • OpImageSparseSampleImplicitLod

  • OpImageSparseSampleDrefImplicitLod

    • This instruction is only valid in the Fragment and GLCompute Execution Models. In addition, it consumes an implicit derivative that can be affected by code motion.

(Modify Section 3.32.16, Derivative Instructions)

(Modify the description of the following instructions to allow them in the GLCompute Execution Model in addition to the Fragment Execution Model)

  • OpDPdx

  • OpDPdy

  • OpFwidth

  • OpDPdxFine

  • OpDPdyFine

  • OpFwidthFine

  • OpDPdxCoarse

  • OpDPdyCoarse

  • OpFwidthCoarse

    • This instruction is only valid in the Fragment and GLCompute Execution Models.

(Modify the existing descriptions of OpDPd{x,y}{Fine,Course}, prefacing the existing language that talks about partial derivatives relative to the window x or y coordinate with "In the Fragment Execution Model:")

(Add the following to the descriptions of OpDPd{x,y}{Fine,Course}, describing how partial derivatives work in compute shaders)

In the GLCompute Execution Model:
Result is the partial derivative of P evaluated over groups of four invocations. Selection of the four invocations is determined by the DerivativeGroup*NV execution mode that was specified for the entry point. If neither derivative group mode was specified, the derivatives return zero.

Validation Rules

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

OpExtension "SPV_NV_compute_shader_derivatives"
  • An entry point cannot have both the DerivativeGroupQuadsNV and DerivativeGroupLinearNV execution modes specified.

  • The DerivativeGroupQuadsNV and DerivativeGroupLinearNV execution modes can only be used on entry points with an execution model of GLCompute

Issues

None yet!

Revision History

Rev Date Author Changes

1

2018-09-12

Daniel Koch

Internal revisions