Vulkan : Android :: SPIR-V Shader Compilation Magic

I’m now a new Vulkan user.

The api is the best step towards the future.

Moving forward, I hit something.

I am using Android NDK, and I’m at the stage of compiling shaders.
I’ve successfully built the shaderc-lib compiler for GLSL->SPIR-V, but there appears to be a bug in something…

#include <shaderc/shaderc.hpp>

int main(void){
    shaderc::Compiler compiler;
    shaderc::CompileOptions options;
    const char* text = "#version 450\nlayout (local_size_x=1024) in;\nvoid main(){\n}";
    const char* file = "TestShader";
    shaderc::SpvCompilationResult module = compiler.CompileGlslToSpv(text, 58, shaderc_compute_shader, file, options);
    if (module.GetCompilationStatus() != shaderc_compilation_status_success)
        LOGI("ERROR");
    else
        LOGI("SUCCESS");

    std::vector<uint32_t> result(module.cbegin(),module.cbegin());

    std::ostringstream stringBuilder;
    stringBuilder << "WORD LIMIT :: " << result.size();
    const char * msg = stringBuilder.str().c_str();
    ((void)__android_log_print(ANDROID_LOG_DEBUG, "MESSAGE :: ", "%s", msg));
} 

The problem is that result returns a size limit @0. But the compilation status checks @SUCCESS.
No errors are generated. But no SPIR-V code is generated either.

The shaderc build appears to be an accurate implementation of the standard as it is able to detect explicit bugs I place in the GLSL code.

Any ideas?

You probably wanted .cend() for the second one.

That is very odd…

Almost magical…

:sweat_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.