CInterface: Add OpSource support.

Add interface for `TIntermediate::addSourceText` and `TIntermediate::setSourceFile`.
This commit is contained in:
James0124
2022-06-07 01:13:21 +09:00
parent adbf0d3106
commit ea024d2bfc
3 changed files with 39 additions and 3 deletions

View File

@@ -36,6 +36,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SPIRV/Logger.h"
#include "SPIRV/SpvTools.h"
static_assert(sizeof(glslang_spv_options_t) == sizeof(glslang::SpvOptions), "");
typedef struct glslang_program_s {
glslang::TProgram* program;
std::vector<unsigned int> spirv;
@@ -81,13 +83,23 @@ static EShLanguage c_shader_stage(glslang_stage_t stage)
GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage)
{
glslang_spv_options_t spv_options;
spv_options.generate_debug_info = false;
spv_options.strip_debug_info = false;
spv_options.disable_optimizer = true;
spv_options.optimize_size = false;
spv_options.disassemble = false;
spv_options.validate = true;
glslang_program_SPIRV_generate_with_options(program, stage, &spv_options);
}
GLSLANG_EXPORT void glslang_program_SPIRV_generate_with_options(glslang_program_t* program, glslang_stage_t stage, glslang_spv_options_t* spv_options) {
spv::SpvBuildLogger logger;
glslang::SpvOptions spvOptions;
spvOptions.validate = true;
const glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage));
glslang::GlslangToSpv(*intermediate, program->spirv, &logger, &spvOptions);
glslang::GlslangToSpv(*intermediate, program->spirv, &logger, reinterpret_cast<glslang::SpvOptions*>(spv_options));
program->loggerMessages = logger.getAllMessages();
}