Add C interface types and functions for IO mapping

This commit is contained in:
Steve Urquhart 2024-07-10 15:30:22 -07:00 committed by arcady-lunarg
parent 10a923f740
commit 3c7b12c643
2 changed files with 42 additions and 0 deletions

View File

@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "glslang/Include/ShHandle.h" #include "glslang/Include/ShHandle.h"
#include "glslang/Include/ResourceLimits.h" #include "glslang/Include/ResourceLimits.h"
#include "glslang/MachineIndependent/iomapper.h"
#include "glslang/MachineIndependent/Versions.h" #include "glslang/MachineIndependent/Versions.h"
#include "glslang/MachineIndependent/localintermediate.h" #include "glslang/MachineIndependent/localintermediate.h"
@ -482,6 +483,11 @@ GLSLANG_EXPORT int glslang_program_map_io(glslang_program_t* program)
return (int)program->program->mapIO(); return (int)program->program->mapIO();
} }
GLSLANG_EXPORT int glslang_program_map_io_with_resolver_and_mapper(glslang_program_t* program, glslang_resolver_t* resolver, glslang_mapper_t* mapper)
{
return (int)program->program->mapIO(reinterpret_cast<glslang::TDefaultGlslIoResolver*>(resolver), reinterpret_cast<glslang::TGlslIoMapper*>(mapper));
}
GLSLANG_EXPORT const char* glslang_program_get_info_log(glslang_program_t* program) GLSLANG_EXPORT const char* glslang_program_get_info_log(glslang_program_t* program)
{ {
return program->program->getInfoLog(); return program->program->getInfoLog();
@ -491,3 +497,30 @@ GLSLANG_EXPORT const char* glslang_program_get_info_debug_log(glslang_program_t*
{ {
return program->program->getInfoDebugLog(); return program->program->getInfoDebugLog();
} }
GLSLANG_EXPORT glslang_mapper_t* glslang_glsl_mapper_create()
{
return reinterpret_cast<glslang_mapper_t*>(new glslang::TGlslIoMapper());
}
GLSLANG_EXPORT void glslang_glsl_mapper_delete(glslang_mapper_t* mapper)
{
if (!mapper)
return;
delete reinterpret_cast<glslang::TGlslIoMapper* >(mapper);
}
GLSLANG_EXPORT glslang_resolver_t* glslang_glsl_resolver_create(glslang_program_t* program, glslang_stage_t stage)
{
glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage));
return reinterpret_cast<glslang_resolver_t*>(new glslang::TDefaultGlslIoResolver(reinterpret_cast<const glslang::TIntermediate&>(*intermediate)));
}
GLSLANG_EXPORT void glslang_glsl_resolver_delete(glslang_resolver_t* resolver)
{
if (!resolver)
return;
delete reinterpret_cast<glslang::TDefaultGlslIoResolver* >(resolver);
}

View File

@ -40,6 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
typedef struct glslang_shader_s glslang_shader_t; typedef struct glslang_shader_s glslang_shader_t;
typedef struct glslang_program_s glslang_program_t; typedef struct glslang_program_s glslang_program_t;
typedef struct glslang_mapper_s glslang_mapper_t;
typedef struct glslang_resolver_s glslang_resolver_t;
/* Version counterpart */ /* Version counterpart */
typedef struct glslang_version_s { typedef struct glslang_version_s {
@ -285,6 +287,7 @@ GLSLANG_EXPORT int glslang_program_link(glslang_program_t* program, int messages
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_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 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 int glslang_program_map_io(glslang_program_t* program);
GLSLANG_EXPORT int glslang_program_map_io_with_resolver_and_mapper(glslang_program_t* program, glslang_resolver_t* resolver, glslang_mapper_t* mapper);
GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage); 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 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 size_t glslang_program_SPIRV_get_size(glslang_program_t* program);
@ -294,6 +297,12 @@ GLSLANG_EXPORT const char* glslang_program_SPIRV_get_messages(glslang_program_t*
GLSLANG_EXPORT const char* glslang_program_get_info_log(glslang_program_t* program); GLSLANG_EXPORT const char* glslang_program_get_info_log(glslang_program_t* program);
GLSLANG_EXPORT const char* glslang_program_get_info_debug_log(glslang_program_t* program); GLSLANG_EXPORT const char* glslang_program_get_info_debug_log(glslang_program_t* program);
GLSLANG_EXPORT glslang_mapper_t* glslang_glsl_mapper_create();
GLSLANG_EXPORT void glslang_glsl_mapper_delete(glslang_mapper_t* mapper);
GLSLANG_EXPORT glslang_resolver_t* glslang_glsl_resolver_create(glslang_program_t* program, glslang_stage_t stage);
GLSLANG_EXPORT void glslang_glsl_resolver_delete(glslang_resolver_t* resolver);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif