Repository: shader-slang/slang
File: source/slang/slang-ir-glsl-legalize.cpp (C++)

Code before:
        context->requireGLSLExtension(
            UnownedStringSlice::fromLiteral("GL_EXT_fragment_shader_barycentric"));
        name = "gl_BaryCoordEXT";

        // TODO: There is also the `gl_BaryCoordNoPerspNV` builtin, which
        // we ought to use if the `noperspective` modifier has been
        // applied to this varying input.
    }
    else if (semanticName == "sv_cullprimitive")
    {
        name = "gl_CullPrimitiveEXT";
    }
    else if (semanticName == "sv_shadingrate")
    {
        if (kind == LayoutResourceKind::VaryingInput)
        {
            name = "gl_ShadingRateEXT";
        }
        else
        {
            name = "gl_PrimitiveShadingRateEXT";
        }
    }
    else if (semanticName == "sv_fragsize")
    {
        name = "gl_FragSizeEXT";
    }
    else if (semanticName == "sv_fraginvocationcount")
    {
        name = "gl_FragInvocationCountEXT";
    }
    else if (semanticName == "sv_startvertexlocation")
    {
        context->requireGLSLVersion(ProfileVersion::GLSL_460);

        // uint in hlsl, int in glsl (https://www.khronos.org/opengl/wiki/Built-in_Variable_(GLSL))
        requiredType = builder->getBasicType(BaseType::Int);
        name = "gl_BaseVertex";
    }
    else if (semanticName == "sv_startinstancelocation")
    {
        context->requireGLSLVersion(ProfileVersion::GLSL_460);

        // uint in hlsl, int in glsl (https://www.khronos.org/opengl/wiki/Built-in_Variable_(GLSL))
        requiredType = builder->getBasicType(BaseType::Int);
        name = "gl_BaseInstance";
    }

    inStorage->targetVarName = targetVarName;
    if (name)
    {

Review comment (suggestion):
from: https://registry.khronos.org/vulkan/specs/latest/man/html/FragSizeEXT.html

type must be a two-component vector of 32-bit integer values

Code after:
        context->requireGLSLExtension(
            UnownedStringSlice::fromLiteral("GL_EXT_fragment_shader_barycentric"));
        name = "gl_BaryCoordEXT";

        // TODO: There is also the `gl_BaryCoordNoPerspNV` builtin, which
        // we ought to use if the `noperspective` modifier has been
        // applied to this varying input.
    }
    else if (semanticName == "sv_cullprimitive")
    {
        name = "gl_CullPrimitiveEXT";
    }
    else if (semanticName == "sv_shadingrate")
    {
        if (kind == LayoutResourceKind::VaryingInput)
        {
            name = "gl_ShadingRateEXT";
        }
        else
        {
            name = "gl_PrimitiveShadingRateEXT";
        }
    }
    else if (semanticName == "sv_fragsize")
    {
        name = "gl_FragSizeEXT";
        context->requireGLSLVersion(ProfileVersion::GLSL_450);
        context->requireGLSLExtension(
            UnownedStringSlice::fromLiteral("GL_EXT_fragment_invocation_density"));
        requiredType = builder->getVectorType(
            builder->getBasicType(BaseType::Int),
            builder->getIntValue(builder->getIntType(), 2));
    }
    else if (semanticName == "sv_fraginvocationcount")
    {
        name = "gl_FragInvocationCountEXT";
        context->requireGLSLVersion(ProfileVersion::GLSL_450);
        context->requireGLSLExtension(
            UnownedStringSlice::fromLiteral("GL_EXT_fragment_invocation_density"));
        requiredType = builder->getIntType();
    }
    else if (semanticName == "sv_startvertexlocation")
    {
        context->requireGLSLVersion(ProfileVersion::GLSL_460);

        // uint in hlsl, int in glsl (https://www.khronos.org/opengl/wiki/Built-in_Variable_(GLSL))
        requiredType = builder->getBasicType(BaseType::Int);
        name = "gl_BaseVertex";
    }
    else if (semanticName == "sv_startinstancelocation")
    {