mirror of
https://github.com/RPCS3/glslang.git
synced 2024-11-27 13:10:37 +00:00
Merge pull request #2962 from James2022-rgb/feature/c_interface_opsource_support
Add OpSource support to the C interface.
This commit is contained in:
commit
bffcf209cb
@ -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();
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "glslang/Include/ResourceLimits.h"
|
||||
#include "glslang/MachineIndependent/Versions.h"
|
||||
#include "glslang/MachineIndependent/localintermediate.h"
|
||||
|
||||
static_assert(int(GLSLANG_STAGE_COUNT) == EShLangCount, "");
|
||||
static_assert(int(GLSLANG_STAGE_MASK_COUNT) == EShLanguageMaskCount, "");
|
||||
@ -455,6 +456,16 @@ GLSLANG_EXPORT int glslang_program_link(glslang_program_t* program, int messages
|
||||
return (int)program->program->link((EShMessages)messages);
|
||||
}
|
||||
|
||||
GLSLANG_EXPORT void glslang_program_add_source_text(glslang_program_t* program, glslang_stage_t stage, const char* text, size_t len) {
|
||||
glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage));
|
||||
intermediate->addSourceText(text, len);
|
||||
}
|
||||
|
||||
GLSLANG_EXPORT void glslang_program_set_source_file(glslang_program_t* program, glslang_stage_t stage, const char* file) {
|
||||
glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage));
|
||||
intermediate->setSourceFile(file);
|
||||
}
|
||||
|
||||
GLSLANG_EXPORT int glslang_program_map_io(glslang_program_t* program)
|
||||
{
|
||||
return (int)program->program->mapIO();
|
||||
|
@ -199,6 +199,16 @@ typedef struct glsl_include_callbacks_s {
|
||||
glsl_free_include_result_func free_include_result;
|
||||
} glsl_include_callbacks_t;
|
||||
|
||||
/* SpvOptions counterpart */
|
||||
typedef struct glslang_spv_options_s {
|
||||
bool generate_debug_info;
|
||||
bool strip_debug_info;
|
||||
bool disable_optimizer;
|
||||
bool optimize_size;
|
||||
bool disassemble;
|
||||
bool validate;
|
||||
} glslang_spv_options_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -238,8 +248,11 @@ GLSLANG_EXPORT glslang_program_t* glslang_program_create();
|
||||
GLSLANG_EXPORT void glslang_program_delete(glslang_program_t* program);
|
||||
GLSLANG_EXPORT void glslang_program_add_shader(glslang_program_t* program, glslang_shader_t* shader);
|
||||
GLSLANG_EXPORT int glslang_program_link(glslang_program_t* program, int messages); // glslang_messages_t
|
||||
GLSLANG_EXPORT void glslang_program_add_source_text(glslang_program_t* program, glslang_stage_t stage, const char* text, size_t len);
|
||||
GLSLANG_EXPORT void glslang_program_set_source_file(glslang_program_t* program, glslang_stage_t stage, const char* file);
|
||||
GLSLANG_EXPORT int glslang_program_map_io(glslang_program_t* program);
|
||||
GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage);
|
||||
GLSLANG_EXPORT void glslang_program_SPIRV_generate_with_options(glslang_program_t* program, glslang_stage_t stage, glslang_spv_options_t* spv_options);
|
||||
GLSLANG_EXPORT size_t glslang_program_SPIRV_get_size(glslang_program_t* program);
|
||||
GLSLANG_EXPORT void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int*);
|
||||
GLSLANG_EXPORT unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program);
|
||||
|
Loading…
Reference in New Issue
Block a user