Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to allow using the glslang_shader_parse from C API without preprocess #3803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions glslang/CInterface/glslang_c_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,30 @@ GLSLANG_EXPORT int glslang_shader_preprocess(glslang_shader_t* shader, const gls

GLSLANG_EXPORT int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input)
{
const char* preprocessedCStr = shader->preprocessedGLSL.c_str();
shader->shader->setStrings(&preprocessedCStr, 1);

return shader->shader->parse(
reinterpret_cast<const TBuiltInResource*>(input->resource),
input->default_version,
input->forward_compatible != 0,
(EShMessages)c_shader_messages(input->messages)
);
if (shader->preprocessedGLSL.length() > 0) {
const char* preprocessedCStr = shader->preprocessedGLSL.c_str();
shader->shader->setStrings(&preprocessedCStr, 1);

return shader->shader->parse(
reinterpret_cast<const TBuiltInResource*>(input->resource),
input->default_version,
input->forward_compatible != 0,
(EShMessages)c_shader_messages(input->messages)
);
} else {
DirStackFileIncluder dirStackFileIncluder;
CallbackIncluder callbackIncluder(input->callbacks, input->callbacks_ctx);
glslang::TShader::Includer& Includer = (input->callbacks.include_local||input->callbacks.include_system)
? static_cast<glslang::TShader::Includer&>(callbackIncluder)
: static_cast<glslang::TShader::Includer&>(dirStackFileIncluder);
return shader->shader->parse(
reinterpret_cast<const TBuiltInResource*>(input->resource),
input->default_version,
input->forward_compatible != 0,
(EShMessages)c_shader_messages(input->messages),
Includer
);
}
}

GLSLANG_EXPORT const char* glslang_shader_get_info_log(glslang_shader_t* shader) { return shader->shader->getInfoLog(); }
Expand Down