Skip to content

spirv-opt: The convert-relaxed-to-half optimization pass generates invalid SPIR-V. #3099

@bejado

Description

@bejado

Steps to repro:

With the following GLSL frag shader:

#version 410 core

precision mediump float;

layout(location = 1) in vec3 foo;
layout(location = 2) in mat2 bar;

vec3 func(vec3 tap, mat2 M) {
    return vec3(M * tap.xy, 1.0);

    // Doing this instead solves the issue:
    // vec2 temp = M * tap.xy;
    // return vec3(temp, 1.0);
}

void main() {
    vec3 result = func(foo, bar);
}

Compile to SPIR-V, optimize, and validate:

$ glslangValidator -V -o test.spv test.frag
$ spirv-opt --convert-relaxed-to-half -o half.spv test.spv
$ spirv-val half.spv

The validator errors with the following:

error: line 71: Expected Constituents to be scalars or vectors of the same type as Result Type components
  %24 = OpCompositeConstruct %v3float %22 %23 %float_1

The problematic SPIR-V:

%22 = OpCompositeExtract %half %20 0
%23 = OpCompositeExtract %half %20 1
%24 = OpCompositeConstruct %v3float %22 %23 %float_1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions