You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Fix shader constant sorting
This commit is contained in:
@@ -368,14 +368,14 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
|
|||||||
|
|
||||||
// constants
|
// constants
|
||||||
|
|
||||||
for (Map<StringName, SL::ShaderNode::Constant>::Element *E = snode->constants.front(); E; E = E->next()) {
|
for (int i = 0; i < snode->vconstants.size(); i++) {
|
||||||
String gcode;
|
String gcode;
|
||||||
gcode += "const ";
|
gcode += "const ";
|
||||||
gcode += _prestr(E->get().precision);
|
gcode += _prestr(snode->vconstants[i].precision);
|
||||||
gcode += _typestr(E->get().type);
|
gcode += _typestr(snode->vconstants[i].type);
|
||||||
gcode += " " + _mkid(E->key());
|
gcode += " " + _mkid(String(snode->vconstants[i].name));
|
||||||
gcode += "=";
|
gcode += "=";
|
||||||
gcode += _dump_node_code(E->get().initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
|
gcode += _dump_node_code(snode->vconstants[i].initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
|
||||||
gcode += ";\n";
|
gcode += ";\n";
|
||||||
vertex_global += gcode;
|
vertex_global += gcode;
|
||||||
fragment_global += gcode;
|
fragment_global += gcode;
|
||||||
|
|||||||
@@ -440,14 +440,14 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
|
|||||||
r_gen_code.fragment_global += interp_mode + "in " + vcode;
|
r_gen_code.fragment_global += interp_mode + "in " + vcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map<StringName, SL::ShaderNode::Constant>::Element *E = pnode->constants.front(); E; E = E->next()) {
|
for (int i = 0; i < pnode->vconstants.size(); i++) {
|
||||||
String gcode;
|
String gcode;
|
||||||
gcode += "const ";
|
gcode += "const ";
|
||||||
gcode += _prestr(E->get().precision);
|
gcode += _prestr(pnode->vconstants[i].precision);
|
||||||
gcode += _typestr(E->get().type);
|
gcode += _typestr(pnode->vconstants[i].type);
|
||||||
gcode += " " + _mkid(E->key());
|
gcode += " " + _mkid(String(pnode->vconstants[i].name));
|
||||||
gcode += "=";
|
gcode += "=";
|
||||||
gcode += _dump_node_code(E->get().initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
|
gcode += _dump_node_code(pnode->vconstants[i].initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
|
||||||
gcode += ";\n";
|
gcode += ";\n";
|
||||||
r_gen_code.vertex_global += gcode;
|
r_gen_code.vertex_global += gcode;
|
||||||
r_gen_code.fragment_global += gcode;
|
r_gen_code.fragment_global += gcode;
|
||||||
|
|||||||
@@ -5156,6 +5156,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
ShaderNode::Constant constant;
|
ShaderNode::Constant constant;
|
||||||
|
constant.name = name;
|
||||||
constant.type = type;
|
constant.type = type;
|
||||||
constant.precision = precision;
|
constant.precision = precision;
|
||||||
constant.initializer = NULL;
|
constant.initializer = NULL;
|
||||||
@@ -5190,6 +5191,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
|||||||
}
|
}
|
||||||
|
|
||||||
shader->constants[name] = constant;
|
shader->constants[name] = constant;
|
||||||
|
shader->vconstants.push_back(constant);
|
||||||
|
|
||||||
if (tk.type == TK_COMMA) {
|
if (tk.type == TK_COMMA) {
|
||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
if (tk.type != TK_IDENTIFIER) {
|
if (tk.type != TK_IDENTIFIER) {
|
||||||
|
|||||||
@@ -512,6 +512,7 @@ public:
|
|||||||
struct ShaderNode : public Node {
|
struct ShaderNode : public Node {
|
||||||
|
|
||||||
struct Constant {
|
struct Constant {
|
||||||
|
StringName name;
|
||||||
DataType type;
|
DataType type;
|
||||||
DataPrecision precision;
|
DataPrecision precision;
|
||||||
ConstantNode *initializer;
|
ConstantNode *initializer;
|
||||||
@@ -577,6 +578,7 @@ public:
|
|||||||
Vector<StringName> render_modes;
|
Vector<StringName> render_modes;
|
||||||
|
|
||||||
Vector<Function> functions;
|
Vector<Function> functions;
|
||||||
|
Vector<Constant> vconstants;
|
||||||
|
|
||||||
ShaderNode() :
|
ShaderNode() :
|
||||||
Node(TYPE_SHADER) {}
|
Node(TYPE_SHADER) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user