feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "shader_compiler.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/os.h"
|
||||
#include "servers/rendering/rendering_server_globals.h"
|
||||
#include "servers/rendering/shader_types.h"
|
||||
|
||||
|
|
@ -113,6 +111,8 @@ static int _get_datatype_alignment(SL::DataType p_type) {
|
|||
return 16;
|
||||
case SL::TYPE_SAMPLERCUBEARRAY:
|
||||
return 16;
|
||||
case SL::TYPE_SAMPLEREXT:
|
||||
return 16;
|
||||
case SL::TYPE_STRUCT:
|
||||
return 0;
|
||||
case SL::TYPE_MAX: {
|
||||
|
|
@ -179,13 +179,13 @@ static String _mkid(const String &p_id) {
|
|||
|
||||
static String f2sp0(float p_float) {
|
||||
String num = rtos(p_float);
|
||||
if (!num.contains(".") && !num.contains("e")) {
|
||||
if (!num.contains_char('.') && !num.contains_char('e')) {
|
||||
num += ".0";
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) {
|
||||
static String get_constant_text(SL::DataType p_type, const Vector<SL::Scalar> &p_values) {
|
||||
switch (p_type) {
|
||||
case SL::TYPE_BOOL:
|
||||
return p_values[0].boolean ? "true" : "false";
|
||||
|
|
@ -353,7 +353,7 @@ void ShaderCompiler::_dump_function_deps(const SL::ShaderNode *p_node, const Str
|
|||
}
|
||||
|
||||
header += " ";
|
||||
header += _mkid(fnode->name);
|
||||
header += _mkid(fnode->rname);
|
||||
header += "(";
|
||||
|
||||
for (int i = 0; i < fnode->arguments.size(); i++) {
|
||||
|
|
@ -487,7 +487,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
struct_code += _typestr(m->datatype);
|
||||
}
|
||||
struct_code += " ";
|
||||
struct_code += m->name;
|
||||
struct_code += _mkid(m->name);
|
||||
if (m->array_size > 0) {
|
||||
struct_code += "[";
|
||||
struct_code += itos(m->array_size);
|
||||
|
|
@ -672,7 +672,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
const StringName &varying_name = varying_names[k];
|
||||
const SL::ShaderNode::Varying &varying = pnode->varyings[varying_name];
|
||||
|
||||
if (varying.stage == SL::ShaderNode::Varying::STAGE_FRAGMENT_TO_LIGHT || varying.stage == SL::ShaderNode::Varying::STAGE_FRAGMENT) {
|
||||
if (varying.stage == SL::ShaderNode::Varying::STAGE_FRAGMENT) {
|
||||
var_frag_to_light.push_back(Pair<StringName, SL::ShaderNode::Varying>(varying_name, varying));
|
||||
fragment_varyings.insert(varying_name);
|
||||
continue;
|
||||
|
|
@ -686,30 +686,14 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
vcode += _prestr(varying.precision, ShaderLanguage::is_float_type(varying.type));
|
||||
vcode += _typestr(varying.type);
|
||||
vcode += " " + _mkid(varying_name);
|
||||
uint32_t inc = 1U;
|
||||
uint32_t inc = varying.get_size();
|
||||
|
||||
if (varying.array_size > 0) {
|
||||
inc = (uint32_t)varying.array_size;
|
||||
|
||||
vcode += "[";
|
||||
vcode += itos(varying.array_size);
|
||||
vcode += "]";
|
||||
}
|
||||
|
||||
switch (varying.type) {
|
||||
case SL::TYPE_MAT2:
|
||||
inc *= 2U;
|
||||
break;
|
||||
case SL::TYPE_MAT3:
|
||||
inc *= 3U;
|
||||
break;
|
||||
case SL::TYPE_MAT4:
|
||||
inc *= 4U;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
vcode += ";\n";
|
||||
// GLSL ES 3.0 does not allow layout qualifiers for varyings
|
||||
if (!RS::get_singleton()->is_low_end()) {
|
||||
|
|
@ -922,7 +906,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
if (shader->uniforms.has(vnode->name)) {
|
||||
//its a uniform!
|
||||
const ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[vnode->name];
|
||||
if (u.texture_order >= 0) {
|
||||
if (u.is_texture()) {
|
||||
StringName name;
|
||||
if (u.hint == ShaderLanguage::ShaderNode::Uniform::HINT_SCREEN_TEXTURE) {
|
||||
name = "color_buffer";
|
||||
|
|
@ -949,7 +933,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
code = _get_global_shader_uniform_from_type_and_index(p_default_actions.global_buffer_array_variable, code, u.type);
|
||||
} else if (u.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
|
||||
//instance variable, index it as such
|
||||
code = "(" + p_default_actions.instance_uniform_index_variable + "+" + itos(u.instance_index) + ")";
|
||||
code = "(" + p_default_actions.instance_uniform_index_variable + "+" + itos(u.instance_index) + "u)";
|
||||
code = _get_global_shader_uniform_from_type_and_index(p_default_actions.global_buffer_array_variable, code, u.type);
|
||||
} else {
|
||||
//regular uniform, index from UBO
|
||||
|
|
@ -1039,7 +1023,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
if (shader->uniforms.has(anode->name)) {
|
||||
//its a uniform!
|
||||
const ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[anode->name];
|
||||
if (u.texture_order >= 0) {
|
||||
if (u.is_texture()) {
|
||||
code = _mkid(anode->name); //texture, use as is
|
||||
} else {
|
||||
//a scalar or vector
|
||||
|
|
@ -1049,7 +1033,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
code = _get_global_shader_uniform_from_type_and_index(p_default_actions.global_buffer_array_variable, code, u.type);
|
||||
} else if (u.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
|
||||
//instance variable, index it as such
|
||||
code = "(" + p_default_actions.instance_uniform_index_variable + "+" + itos(u.instance_index) + ")";
|
||||
code = "(" + p_default_actions.instance_uniform_index_variable + "+" + itos(u.instance_index) + "u)";
|
||||
code = _get_global_shader_uniform_from_type_and_index(p_default_actions.global_buffer_array_variable, code, u.type);
|
||||
} else {
|
||||
//regular uniform, index from UBO
|
||||
|
|
@ -1134,9 +1118,16 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
case SL::OP_NEGATE:
|
||||
case SL::OP_NOT:
|
||||
case SL::OP_DECREMENT:
|
||||
case SL::OP_INCREMENT:
|
||||
code = _opstr(onode->op) + _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
|
||||
break;
|
||||
case SL::OP_INCREMENT: {
|
||||
const String node_code = _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
|
||||
|
||||
if (onode->op == SL::OP_NEGATE && node_code.begins_with("-")) { // To prevent writing unary minus twice.
|
||||
code = node_code;
|
||||
} else {
|
||||
code = _opstr(onode->op) + node_code;
|
||||
}
|
||||
|
||||
} break;
|
||||
case SL::OP_POST_DECREMENT:
|
||||
case SL::OP_POST_INCREMENT:
|
||||
code = _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + _opstr(onode->op);
|
||||
|
|
@ -1181,7 +1172,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
} else if (p_default_actions.renames.has(vnode->name)) {
|
||||
code += p_default_actions.renames[vnode->name];
|
||||
} else {
|
||||
code += _mkid(vnode->name);
|
||||
code += _mkid(vnode->rname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1345,7 +1336,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
}
|
||||
code += ")";
|
||||
if (is_screen_texture && !texture_func_returns_data && actions.apply_luminance_multiplier) {
|
||||
code = "(" + code + " * vec4(vec3(sc_luminance_multiplier), 1.0))";
|
||||
code = "(" + code + " * vec4(vec3(sc_luminance_multiplier()), 1.0))";
|
||||
}
|
||||
if (is_normal_roughness_texture && !texture_func_returns_data) {
|
||||
code = "normal_roughness_compatibility(" + code + ")";
|
||||
|
|
@ -1439,7 +1430,13 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
} break;
|
||||
case SL::Node::NODE_TYPE_MEMBER: {
|
||||
SL::MemberNode *mnode = (SL::MemberNode *)p_node;
|
||||
code = _dump_node_code(mnode->owner, p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + "." + mnode->name;
|
||||
String name;
|
||||
if (mnode->basetype == SL::TYPE_STRUCT) {
|
||||
name = _mkid(mnode->name);
|
||||
} else {
|
||||
name = mnode->name;
|
||||
}
|
||||
code = _dump_node_code(mnode->owner, p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + "." + name;
|
||||
if (mnode->index_expression != nullptr) {
|
||||
code += "[";
|
||||
code += _dump_node_code(mnode->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
|
||||
|
|
@ -1468,6 +1465,7 @@ Error ShaderCompiler::compile(RS::ShaderMode p_mode, const String &p_code, Ident
|
|||
info.render_modes = ShaderTypes::get_singleton()->get_modes(p_mode);
|
||||
info.shader_types = ShaderTypes::get_singleton()->get_types();
|
||||
info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
|
||||
info.base_varying_index = actions.base_varying_index;
|
||||
|
||||
Error err = parser.compile(p_code, info);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue