mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 22:21:18 +00:00
Allow passing non-variable constant to const function param in shaders
This commit is contained in:
parent
0deccc550c
commit
f4c0e90fd9
3 changed files with 26 additions and 17 deletions
|
|
@ -227,6 +227,13 @@ static String _prestr(SL::DataPrecision p_pres, bool p_force_highp = false) {
|
|||
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:
|
||||
|
|
@ -417,9 +424,7 @@ void ShaderCompilerRD::_dump_function_deps(const SL::ShaderNode *p_node, const S
|
|||
if (i > 0) {
|
||||
header += ", ";
|
||||
}
|
||||
if (fnode->arguments[i].is_const) {
|
||||
header += "const ";
|
||||
}
|
||||
header += _constr(fnode->arguments[i].is_const);
|
||||
if (fnode->arguments[i].type == SL::TYPE_STRUCT) {
|
||||
header += _qualstr(fnode->arguments[i].qualifier) + _mkid(fnode->arguments[i].type_str) + " " + _mkid(fnode->arguments[i].name);
|
||||
} else {
|
||||
|
|
@ -791,7 +796,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
|
|||
for (int i = 0; i < pnode->vconstants.size(); i++) {
|
||||
const SL::ShaderNode::Constant &cnode = pnode->vconstants[i];
|
||||
String gcode;
|
||||
gcode += "const ";
|
||||
gcode += _constr(true);
|
||||
gcode += _prestr(cnode.precision, ShaderLanguage::is_float_type(cnode.type));
|
||||
if (cnode.type == SL::TYPE_STRUCT) {
|
||||
gcode += _mkid(cnode.type_str);
|
||||
|
|
@ -875,9 +880,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
|
|||
SL::VariableDeclarationNode *vdnode = (SL::VariableDeclarationNode *)p_node;
|
||||
|
||||
String declaration;
|
||||
if (vdnode->is_const) {
|
||||
declaration += "const ";
|
||||
}
|
||||
declaration += _constr(vdnode->is_const);
|
||||
if (vdnode->datatype == SL::TYPE_STRUCT) {
|
||||
declaration += _mkid(vdnode->struct_name);
|
||||
} else {
|
||||
|
|
@ -997,9 +1000,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
|
|||
case SL::Node::TYPE_ARRAY_DECLARATION: {
|
||||
SL::ArrayDeclarationNode *adnode = (SL::ArrayDeclarationNode *)p_node;
|
||||
String declaration;
|
||||
if (adnode->is_const) {
|
||||
declaration += "const ";
|
||||
}
|
||||
declaration += _constr(adnode->is_const);
|
||||
if (adnode->datatype == SL::TYPE_STRUCT) {
|
||||
declaration += _mkid(adnode->struct_name);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue