You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
Improve ubershader compatibility
- Prevent debug enforced use of ubershader on shaders not supporting it - Use unsigned integer for ubershader flags - Add project setting for disabling async shader compilation on mobile - Stop sampling some textures through different kinds of samplers at the same time
This commit is contained in:
@@ -123,7 +123,7 @@ bool ShaderGLES3::_bind(bool p_binding_fallback) {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (ready) {
|
||||
if (VS::get_singleton()->is_force_shader_fallbacks_enabled() && !must_be_ready_now) {
|
||||
if (VS::get_singleton()->is_force_shader_fallbacks_enabled() && !must_be_ready_now && get_ubershader_flags_uniform() != -1) {
|
||||
ready = false;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ bool ShaderGLES3::_bind_ubershader() {
|
||||
ERR_FAIL_COND_V(conditionals_uniform == -1, false);
|
||||
#endif
|
||||
new_conditional_version.version &= ~VersionKey::UBERSHADER_FLAG;
|
||||
glUniform1i(conditionals_uniform, new_conditional_version.version);
|
||||
glUniform1ui(conditionals_uniform, new_conditional_version.version);
|
||||
return bound;
|
||||
}
|
||||
|
||||
@@ -454,11 +454,11 @@ static CharString _prepare_ubershader_chunk(const CharString &p_chunk) {
|
||||
} else if (l.begins_with("#ifdef")) {
|
||||
Vector<String> pieces = l.split_spaces();
|
||||
CRASH_COND(pieces.size() != 2);
|
||||
s += "if ((ubershader_flags & FLAG_" + pieces[1] + ") != 0) {\n";
|
||||
s += "if ((ubershader_flags & FLAG_" + pieces[1] + ") != 0u) {\n";
|
||||
} else if (l.begins_with("#ifndef")) {
|
||||
Vector<String> pieces = l.split_spaces();
|
||||
CRASH_COND(pieces.size() != 2);
|
||||
s += "if ((ubershader_flags & FLAG_" + pieces[1] + ") == 0) {\n";
|
||||
s += "if ((ubershader_flags & FLAG_" + pieces[1] + ") == 0u) {\n";
|
||||
} else {
|
||||
CRASH_NOW_MSG("The shader template is using too complex syntax in a line marked with ubershader-runtime.");
|
||||
}
|
||||
@@ -532,7 +532,7 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version(bool &r_async_forbidden)
|
||||
if (build_ubershader) {
|
||||
strings_common.push_back("#define IS_UBERSHADER\n");
|
||||
for (int i = 0; i < conditional_count; i++) {
|
||||
String s = vformat("#define FLAG_%s (1 << %d)\n", String(conditional_defines[i]).strip_edges().trim_prefix("#define "), i);
|
||||
String s = vformat("#define FLAG_%s (1u << %du)\n", String(conditional_defines[i]).strip_edges().trim_prefix("#define "), i);
|
||||
CharString cs = s.ascii();
|
||||
flag_macros.push_back(cs);
|
||||
strings_common.push_back(cs.ptr());
|
||||
|
||||
Reference in New Issue
Block a user