GPUOpen-Archive / Anvil

Anvil is a cross-platform framework for Vulkan
MIT License
594 stars 62 forks source link

GLSLShaderToSPIRVGenerator::get_spirv_blob throws std::out_of_range exception if shader compilation or linking failed #70

Closed Silverlan closed 6 years ago

Silverlan commented 6 years ago

According to the description of _get_shader_infolog and _get_program_infolog, you should be able to call _get_spirvblob and check if its return value is nullptr to find out whether there was a problem during compilation or linking. However looking at the definition of _get_spirvblob, it looks like it can never return nullptr and will throw an exception instead (or an assertion failure in debug mode):

const char* get_spirv_blob() const
{
    if (m_spirv_blob.size() == 0)
    {
        bool result = bake_spirv_blob();

        ANVIL_REDUNDANT_VARIABLE(result);

        anvil_assert(result);
        anvil_assert(m_spirv_blob.size() != 0);
    }

    return &m_spirv_blob.at(0);
}

As far as I can tell, there's no way to actually check if an error has occurred at the moment, even _get_spirv_blobsize would cause an assertion failure.

DominikWitczakAMD commented 6 years ago

This is a fair observation. I will be addressing this later next week. Also hoping I'll finally get around to posting an update next week, too!

DominikWitczakAMD commented 6 years ago

Addressed internally.