feat: add missing c++ API functions to C API

add glslang_shader_add_source_text()
add glslang_shader_set_source_file()
add GLSLANG_SHADER_HLSL_IO_MAPPING
add GLSLANG_SHADER_HLSL_FLATTEN_UNIFORM_ARRAYS
This commit is contained in:
Kai Angulo 2024-10-27 23:57:59 -07:00
parent 8838252618
commit 5aa896ae05
3 changed files with 25 additions and 0 deletions

View file

@ -396,6 +396,17 @@ GLSLANG_EXPORT void glslang_shader_set_options(glslang_shader_t* shader, int opt
if (options & GLSLANG_SHADER_INVERT_Y) {
shader->shader->setInvertY(true);
}
#ifdef ENABLE_HLSL
if (options & GLSLANG_SHADER_HLSL_IO_MAPPING) {
shader->shader->setHlslIoMapping(true);
}
if (options & GLSLANG_SHADER_HLSL_FLATTEN_UNIFORM_ARRAYS) {
shader->shader->setFlattenUniformArrays(true);
}
#endif
}
GLSLANG_EXPORT void glslang_shader_set_glsl_version(glslang_shader_t* shader, int version)
@ -422,6 +433,14 @@ GLSLANG_EXPORT void glslang_shader_set_resource_set_binding(glslang_shader_t* sh
shader->shader->setResourceSetBinding(shader->baseResourceSetBinding);
}
GLSLANG_EXPORT void glslang_shader_add_source_text(glslang_shader_t* shader, const char* text, size_t len) {
shader->shader->addSourceText(text, len);
}
GLSLANG_EXPORT void glslang_shader_set_source_file(glslang_shader_t* shader, const char* file) {
shader->shader->setSourceFile(file);
}
GLSLANG_EXPORT const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader)
{
return shader->preprocessedGLSL.c_str();

View file

@ -263,6 +263,8 @@ GLSLANG_EXPORT void glslang_shader_set_glsl_version(glslang_shader_t* shader, in
GLSLANG_EXPORT void glslang_shader_set_default_uniform_block_set_and_binding(glslang_shader_t* shader, unsigned int set, unsigned int binding);
GLSLANG_EXPORT void glslang_shader_set_default_uniform_block_name(glslang_shader_t* shader, const char *name);
GLSLANG_EXPORT void glslang_shader_set_resource_set_binding(glslang_shader_t* shader, const char *const *bindings, unsigned int num_bindings);
GLSLANG_EXPORT void glslang_shader_add_source_text(glslang_shader_t* shader, const char* text, size_t len);
GLSLANG_EXPORT void glslang_shader_set_source_file(glslang_shader_t* shader, const char* file);
GLSLANG_EXPORT int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* input);
GLSLANG_EXPORT int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input);
GLSLANG_EXPORT const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader);

View file

@ -212,6 +212,10 @@ typedef enum {
GLSLANG_SHADER_AUTO_MAP_LOCATIONS = (1 << 1),
GLSLANG_SHADER_VULKAN_RULES_RELAXED = (1 << 2),
GLSLANG_SHADER_INVERT_Y = (1 << 3),
#ifdef ENABLE_HLSL
GLSLANG_SHADER_HLSL_IO_MAPPING = (1 << 4),
GLSLANG_SHADER_HLSL_FLATTEN_UNIFORM_ARRAYS = (1 << 5),
#endif
LAST_ELEMENT_MARKER(GLSLANG_SHADER_COUNT),
} glslang_shader_options_t;