Skip to content

PackHalf2x16 rounding behavior is ambiguously defined #1825

@DadSchoorse

Description

@DadSchoorse

The "Precision and Operation of SPIR-V Instructions" section doesn't explicitly list a required precision of PackHalf2x16 so it is affected by

GLSL.std.450 extended instructions specifically defined in terms of the above instructions inherit the above errors.
GLSL.std.450 extended instructions not listed above and not defined in terms of the above have undefined precision.

The extended GLSL.std.450 spir-v spec defines PackHalf2x16 as

Result is the unsigned integer obtained by converting the components of a two-component floating-point vector to the 16-bit OpTypeFloat, and then packing these two 16-bit integers into a 32-bit unsigned integer. The first vector component specifies the 16 least-significant bits of the result; the second component specifies the 16 most-significant bits.

This can be interpreted as PackHalf2x16 inheriting the precision requirements from OpFConvert, which is "Correctly rounded" as a conversions between types. That would mean PackHalf2x16 is affected by the per entry point rounding mode decorations.

That conflicts with the answer to the following question in the VK_KHR_shader_float_controls issue list, which says rounding mode doesn't affect any Pack instructions.

  1. Do any of the “Pack” GLSL.std.450 instructions count as conversion instructions and have the rounding mode applied?
    RESOLVED: No, only instructions listed in “section 3.32.11. Conversion Instructions” of the SPIR-V specification count as conversion instructions.

If it's intended that PackHalf2x16 has a undefined rounding mode, it should be clarified in the "Precision and Operation of SPIR-V Instructions" section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions