diff options
Diffstat (limited to 'servers/rendering/rendering_device_binds.cpp')
-rw-r--r-- | servers/rendering/rendering_device_binds.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp index fa3f2f3895..d03c4e0427 100644 --- a/servers/rendering/rendering_device_binds.cpp +++ b/servers/rendering/rendering_device_binds.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -45,7 +45,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String }; String stage_code[RD::SHADER_STAGE_MAX]; int stages_found = 0; - Map<StringName, String> version_texts; + HashMap<StringName, String> version_texts; versions.clear(); base_error = ""; @@ -80,7 +80,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String } } - if (base_error != String()) { + if (!base_error.is_empty()) { break; } } @@ -89,7 +89,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String } } - if (stage == RD::SHADER_STAGE_MAX && line.strip_edges() != "") { + if (stage == RD::SHADER_STAGE_MAX && !line.strip_edges().is_empty()) { line = line.strip_edges(); if (line.begins_with("//") || line.begins_with("/*")) { continue; //assuming comment (single line) @@ -98,12 +98,12 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String if (reading_versions) { String l = line.strip_edges(); - if (l != "") { - if (l.find("=") == -1) { + if (!l.is_empty()) { + if (!l.contains("=")) { base_error = "Missing `=` in '" + l + "'. Version syntax is `version = \"<defines with C escaping>\";`."; break; } - if (l.find(";") == -1) { + if (!l.contains(";")) { // We don't require a semicolon per se, but it's needed for clang-format to handle things properly. base_error = "Missing `;` in '" + l + "'. Version syntax is `version = \"<defines with C escaping>\";`."; break; @@ -124,7 +124,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String version_texts[version] = define + "\n" + p_defines; } } else { - if (stage == RD::SHADER_STAGE_MAX && line.strip_edges() != "") { + if (stage == RD::SHADER_STAGE_MAX && !line.strip_edges().is_empty()) { base_error = "Text was found that does not belong to a valid section: " + line; break; } @@ -140,7 +140,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String } include = include.substr(1, include.length() - 2).strip_edges(); String include_text = p_include_func(include, p_include_func_userdata); - if (include_text != String()) { + if (!include_text.is_empty()) { stage_code[stage] += "\n" + include_text + "\n"; } else { base_error = "#include failed for file '" + include + "'"; @@ -158,7 +158,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String Ref<RDShaderFile> shader_file; shader_file.instantiate(); - if (base_error == "") { + if (base_error.is_empty()) { if (stage_found[RD::SHADER_STAGE_COMPUTE] && stages_found > 1) { ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "When writing compute shaders, [compute] mustbe the only stage present."); } @@ -171,20 +171,20 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String /* STEP 2, Compile the versions, add to shader file */ - for (Map<StringName, String>::Element *E = version_texts.front(); E; E = E->next()) { + for (const KeyValue<StringName, String> &E : version_texts) { Ref<RDShaderSPIRV> bytecode; bytecode.instantiate(); for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { String code = stage_code[i]; - if (code == String()) { + if (code.is_empty()) { continue; } - code = code.replace("VERSION_DEFINES", E->get()); + code = code.replace("VERSION_DEFINES", E.value); String error; Vector<uint8_t> spirv = RenderingDevice::get_singleton()->shader_compile_spirv_from_source(RD::ShaderStage(i), code, RD::SHADER_LANGUAGE_GLSL, &error, false); bytecode->set_stage_bytecode(RD::ShaderStage(i), spirv); - if (error != "") { + if (!error.is_empty()) { error += String() + "\n\nStage '" + stage_str[i] + "' source code: \n\n"; Vector<String> sclines = code.split("\n"); for (int j = 0; j < sclines.size(); j++) { @@ -195,7 +195,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String bytecode->set_stage_compile_error(RD::ShaderStage(i), error); } - set_bytecode(bytecode, E->key()); + set_bytecode(bytecode, E.key); } return errors_found ? ERR_PARSE_ERROR : OK; |