diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2021-11-19 11:25:23 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2021-11-19 12:14:13 +0300 |
commit | f4c0e90fd94708b26abbe945e131e0b96836b34a (patch) | |
tree | 0db77967337f785ec7a4872949ce49c3c5b787fa /drivers/gles3 | |
parent | 0deccc550c6898f6719b05bd01d0676b15a7e3b2 (diff) |
Allow passing non-variable constant to const function param in shaders
Diffstat (limited to 'drivers/gles3')
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index fa607472d3..f9443e11db 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -65,6 +65,13 @@ static String _prestr(SL::DataPrecision p_pres) { return ""; } +static String _constr(bool p_is_const) { + if (p_is_const) { + return "const "; + } + return ""; +} + static String _qualstr(SL::ArgumentQualifier p_qual) { switch (p_qual) { case SL::ARGUMENT_QUALIFIER_IN: @@ -246,9 +253,10 @@ void ShaderCompilerGLES3::_dump_function_deps(SL::ShaderNode *p_node, const Stri header += "("; for (int i = 0; i < fnode->arguments.size(); i++) { - if (i > 0) + if (i > 0) { header += ", "; - + } + header += _constr(fnode->arguments[i].is_const); header += _qualstr(fnode->arguments[i].qualifier); header += _prestr(fnode->arguments[i].precision); header += _typestr(fnode->arguments[i].type); @@ -365,7 +373,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener for (int i = 0; i < snode->vconstants.size(); i++) { String gcode; - gcode += "const "; + gcode += _constr(true); gcode += _prestr(snode->vconstants[i].precision); gcode += _typestr(snode->vconstants[i].type); gcode += " " + _mkid(String(snode->vconstants[i].name)); @@ -446,9 +454,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener SL::VariableDeclarationNode *var_dec_node = (SL::VariableDeclarationNode *)p_node; StringBuffer<> declaration; - if (var_dec_node->is_const) { - declaration += "const "; - } + declaration += _constr(var_dec_node->is_const); declaration += _prestr(var_dec_node->precision); declaration += _typestr(var_dec_node->datatype); |