glslang is unable to parse built-ins

885 Views Asked by At

Here is my code:

bool ParseShader(glslang::TShader* p_shader) {
    EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules);
    TBuiltInResource resources;
    InitializeResources(resources);

    if (!p_shader->parse(&resources, 100, false, messages)) {
        std::cout << p_shader->getInfoLog() << std::endl;
        std::cout << p_shader->getInfoDebugLog() << std::endl;
        return false;
    }
    return true;
}

You can get full source codes and project on my Github repos.
I build this code with linking glslang related libraries which is from Vulkan 1.0.54.0. And I don't know why I got following error messages:

Unable to parse built-ins
ERROR: 0:100: 'int64_t' : overloaded functions must have the same return type
INTERNAL ERROR: Unable to parse built-ins

The source of build-ins post on gist.

I tried both two test cases. All can be parsed and compiled into SPIRV by official tools(glslangValidator) successfully. But in case 2, my tool failed in parsing phase.

Case 1

#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout(location=0) in vec3 inPos;
layout(location=1) in vec3 inNormal;
layout(location=2) in vec2 inUV;

layout(std140, push_constant) uniform MVP {
    mat4 m;
} mvp;

layout (location = 0) out vec2 outUV;

out gl_PerVertex 
{
    vec4 gl_Position;   
};

void main() 
{
    outUV = inUV;
    gl_Position = mvp.m * vec4(inPos.xyz, 1.0);
}

Case 2

#version 450

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout(set=0, binding=1) uniform sampler2D samplerColor;

layout(location=0) in vec2 inUV;
layout(location=0) out vec4 outFragColor;

void main() 
{
    vec4 texs = texture(samplerColor, inUV, 0.0f);
    outFragColor = texs;
}

Dose anyone know what I did wrong?

I have had this problem once, then solved it by reseting project(delete, clone, build again) but did't know why. Now, I got this problem again. however, this time reseting project doesn't help.

1

There are 1 best solutions below

0
On

I found the answer is in the Vulkan official project.
I should define following symbol

AMD_EXTENSIONS
NV_EXTENSIONS

to make those built-ins able to work.