summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/renderer_rd/environment/fog.cpp50
-rw-r--r--servers/rendering/renderer_rd/environment/fog.h13
-rw-r--r--servers/rendering/renderer_rd/environment/gi.cpp14
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp2
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp2
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl204
-rw-r--r--servers/rendering/renderer_rd/storage_rd/light_storage.h10
-rw-r--r--servers/rendering/renderer_viewport.cpp7
-rw-r--r--servers/rendering/renderer_viewport.h1
-rw-r--r--servers/rendering/rendering_server_default.h1
-rw-r--r--servers/rendering/shader_compiler.cpp36
-rw-r--r--servers/rendering/shader_language.cpp114
-rw-r--r--servers/rendering/shader_language.h48
13 files changed, 251 insertions, 251 deletions
diff --git a/servers/rendering/renderer_rd/environment/fog.cpp b/servers/rendering/renderer_rd/environment/fog.cpp
index 57da55db4d..78b785153f 100644
--- a/servers/rendering/renderer_rd/environment/fog.cpp
+++ b/servers/rendering/renderer_rd/environment/fog.cpp
@@ -388,6 +388,37 @@ Fog::FogShaderData::~FogShaderData() {
////////////////////////////////////////////////////////////////////////////////
// Volumetric Fog
+bool Fog::VolumetricFog::sync_gi_dependent_sets_validity(bool p_ensure_freed) {
+ bool null = gi_dependent_sets.copy_uniform_set.is_null();
+ bool valid = !null && RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.copy_uniform_set);
+
+#ifdef DEV_ENABLED
+ // It's all-or-nothing, or something else has changed that requires dev attention.
+ DEV_ASSERT(null == gi_dependent_sets.process_uniform_set_density.is_null());
+ DEV_ASSERT(null == gi_dependent_sets.process_uniform_set.is_null());
+ DEV_ASSERT(null == gi_dependent_sets.process_uniform_set2.is_null());
+ DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set_density));
+ DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set));
+ DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set2));
+#endif
+
+ if (valid) {
+ if (p_ensure_freed) {
+ RD::get_singleton()->free(gi_dependent_sets.copy_uniform_set);
+ RD::get_singleton()->free(gi_dependent_sets.process_uniform_set_density);
+ RD::get_singleton()->free(gi_dependent_sets.process_uniform_set);
+ RD::get_singleton()->free(gi_dependent_sets.process_uniform_set2);
+ valid = false;
+ }
+ }
+
+ if (!valid && !null) {
+ gi_dependent_sets = {};
+ }
+
+ return valid;
+}
+
void Fog::VolumetricFog::init(const Vector3i &fog_size, RID p_sky_shader) {
width = fog_size.x;
height = fog_size.y;
@@ -464,17 +495,7 @@ Fog::VolumetricFog::~VolumetricFog() {
RD::get_singleton()->free(fog_uniform_set);
}
- // At this point, due to cascade deletions, the sets may no longer be valid, but still they must work as a group.
- gi_dependent_sets.valid = RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set_density);
-#ifdef DEV_ENABLED
- gi_dependent_sets.assert_actual_validity();
-#endif
- if (gi_dependent_sets.valid) {
- RD::get_singleton()->free(gi_dependent_sets.copy_uniform_set);
- RD::get_singleton()->free(gi_dependent_sets.process_uniform_set_density);
- RD::get_singleton()->free(gi_dependent_sets.process_uniform_set);
- RD::get_singleton()->free(gi_dependent_sets.process_uniform_set2);
- }
+ sync_gi_dependent_sets_validity(true);
if (sdfgi_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sdfgi_uniform_set)) {
RD::get_singleton()->free(sdfgi_uniform_set);
@@ -717,10 +738,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
RD::get_singleton()->compute_list_end();
}
-#ifdef DEV_ENABLED
- fog->gi_dependent_sets.assert_actual_validity();
-#endif
- if (!fog->gi_dependent_sets.valid) {
+ if (!fog->sync_gi_dependent_sets_validity()) {
//re create uniform set if needed
Vector<RD::Uniform> uniforms;
Vector<RD::Uniform> copy_uniforms;
@@ -932,8 +950,6 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
uniforms.remove_at(8);
uniforms.write[7].set_id(0, aux7);
fog->gi_dependent_sets.process_uniform_set_density = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_DENSITY), 0);
-
- fog->gi_dependent_sets.valid = true;
}
bool using_sdfgi = RendererSceneRenderRD::get_singleton()->environment_get_volumetric_fog_gi_inject(p_settings.env) > 0.0001 && RendererSceneRenderRD::get_singleton()->environment_get_sdfgi_enabled(p_settings.env) && (p_settings.sdfgi.is_valid());
diff --git a/servers/rendering/renderer_rd/environment/fog.h b/servers/rendering/renderer_rd/environment/fog.h
index 926da4026c..277389c596 100644
--- a/servers/rendering/renderer_rd/environment/fog.h
+++ b/servers/rendering/renderer_rd/environment/fog.h
@@ -303,21 +303,10 @@ public:
RID fog_uniform_set;
struct {
- bool valid = false;
RID copy_uniform_set;
RID process_uniform_set_density;
RID process_uniform_set;
RID process_uniform_set2;
-
-#ifdef DEV_ENABLED
- void assert_actual_validity() {
- // It's all-or-nothing, or something else has changed that requires dev attention.
- DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(copy_uniform_set));
- DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(process_uniform_set_density));
- DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(process_uniform_set));
- DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(process_uniform_set2));
- }
-#endif
} gi_dependent_sets;
RID sdfgi_uniform_set;
@@ -328,6 +317,8 @@ public:
virtual void configure(RenderSceneBuffersRD *p_render_buffers) override{};
virtual void free_data() override{};
+ bool sync_gi_dependent_sets_validity(bool p_ensure_freed = false);
+
void init(const Vector3i &fog_size, RID p_sky_shader);
~VolumetricFog();
};
diff --git a/servers/rendering/renderer_rd/environment/gi.cpp b/servers/rendering/renderer_rd/environment/gi.cpp
index 52f09e1ccb..c2a018c7c6 100644
--- a/servers/rendering/renderer_rd/environment/gi.cpp
+++ b/servers/rendering/renderer_rd/environment/gi.cpp
@@ -3695,20 +3695,6 @@ void GI::setup_voxel_gi_instances(RenderDataRD *p_render_data, Ref<RenderSceneBu
}
rbgi->uniform_set[v] = RID();
}
- if (p_render_buffers->has_custom_data(RB_SCOPE_FOG)) {
- Ref<Fog::VolumetricFog> fog = p_render_buffers->get_custom_data(RB_SCOPE_FOG);
-
-#ifdef DEV_ENABLED
- fog->gi_dependent_sets.assert_actual_validity();
-#endif
- if (fog->gi_dependent_sets.valid) {
- RD::get_singleton()->free(fog->gi_dependent_sets.copy_uniform_set);
- RD::get_singleton()->free(fog->gi_dependent_sets.process_uniform_set_density);
- RD::get_singleton()->free(fog->gi_dependent_sets.process_uniform_set);
- RD::get_singleton()->free(fog->gi_dependent_sets.process_uniform_set2);
- fog->gi_dependent_sets.valid = false;
- }
- }
}
if (p_voxel_gi_instances.size() > 0) {
diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
index ff180b5465..ff6195abfa 100644
--- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
@@ -632,7 +632,7 @@ void SceneShaderForwardClustered::init(const String p_defines) {
actions.renames["CAMERA_POSITION_WORLD"] = "scene_data.inv_view_matrix[3].xyz";
actions.renames["CAMERA_DIRECTION_WORLD"] = "scene_data.view_matrix[3].xyz";
actions.renames["CAMERA_VISIBLE_LAYERS"] = "scene_data.camera_visible_layers";
- actions.renames["NODE_POSITION_VIEW"] = "(read_model_matrix * scene_data.view_matrix)[3].xyz";
+ actions.renames["NODE_POSITION_VIEW"] = "(scene_data.view_matrix * read_model_matrix)[3].xyz";
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "0";
diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
index 453cad5271..9a38406c0a 100644
--- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
@@ -522,7 +522,7 @@ void SceneShaderForwardMobile::init(const String p_defines) {
actions.renames["CAMERA_POSITION_WORLD"] = "scene_data.inv_view_matrix[3].xyz";
actions.renames["CAMERA_DIRECTION_WORLD"] = "scene_data.view_matrix[3].xyz";
actions.renames["CAMERA_VISIBLE_LAYERS"] = "scene_data.camera_visible_layers";
- actions.renames["NODE_POSITION_VIEW"] = "(read_model_matrix * scene_data.view_matrix)[3].xyz";
+ actions.renames["NODE_POSITION_VIEW"] = "(scene_data.view_matrix * read_model_matrix)[3].xyz";
actions.renames["VIEW_INDEX"] = "ViewIndex";
actions.renames["VIEW_MONO_LEFT"] = "0";
diff --git a/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl b/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl
index 0828ffd921..b8c64d09f4 100644
--- a/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl
+++ b/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl
@@ -55,109 +55,107 @@ void main() {
// Converted from compute shader which uses absolute coordinates.
// Could possibly simplify this
float face_size = float(params.face_size);
+ float inv_face_size = 1.0 / face_size;
+ vec2 id = floor(uv_interp);
- if (uv_interp.x < face_size && uv_interp.y < face_size) {
- float inv_face_size = 1.0 / face_size;
-
- float u0 = (uv_interp.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0;
- float u1 = (uv_interp.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0;
-
- float v0 = (uv_interp.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0;
- float v1 = (uv_interp.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0;
-
- float weights[4];
- weights[0] = calcWeight(u0, v0);
- weights[1] = calcWeight(u1, v0);
- weights[2] = calcWeight(u0, v1);
- weights[3] = calcWeight(u1, v1);
-
- const float wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]);
- for (int i = 0; i < 4; i++) {
- weights[i] = weights[i] * wsum + .125;
- }
-
- vec3 dir;
- vec4 color;
- switch (params.face_id) {
- case 0:
- get_dir_0(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_0(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_0(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_0(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 1:
- get_dir_1(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_1(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_1(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_1(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 2:
- get_dir_2(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_2(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_2(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_2(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 3:
- get_dir_3(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_3(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_3(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_3(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- case 4:
- get_dir_4(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_4(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_4(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_4(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- default:
- get_dir_5(dir, u0, v0);
- color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
-
- get_dir_5(dir, u1, v0);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
-
- get_dir_5(dir, u0, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
-
- get_dir_5(dir, u1, v1);
- color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
- break;
- }
- frag_color = color;
+ float u1 = (id.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0;
+ float u0 = (id.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0;
+
+ float v0 = (id.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0;
+ float v1 = (id.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0;
+
+ float weights[4];
+ weights[0] = calcWeight(u0, v0);
+ weights[1] = calcWeight(u1, v0);
+ weights[2] = calcWeight(u0, v1);
+ weights[3] = calcWeight(u1, v1);
+
+ const float wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]);
+ for (int i = 0; i < 4; i++) {
+ weights[i] = weights[i] * wsum + .125;
+ }
+
+ vec3 dir;
+ vec4 color;
+ switch (params.face_id) {
+ case 0:
+ get_dir_0(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_0(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_0(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_0(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 1:
+ get_dir_1(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_1(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_1(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_1(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 2:
+ get_dir_2(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_2(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_2(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_2(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 3:
+ get_dir_3(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_3(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_3(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_3(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ case 4:
+ get_dir_4(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_4(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_4(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_4(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
+ default:
+ get_dir_5(dir, u0, v0);
+ color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0];
+
+ get_dir_5(dir, u1, v0);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1];
+
+ get_dir_5(dir, u0, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2];
+
+ get_dir_5(dir, u1, v1);
+ color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3];
+ break;
}
+ frag_color = color;
}
diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.h b/servers/rendering/renderer_rd/storage_rd/light_storage.h
index c36d1ef503..3360358169 100644
--- a/servers/rendering/renderer_rd/storage_rd/light_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/light_storage.h
@@ -93,11 +93,11 @@ private:
struct ShadowTransform {
Projection camera;
Transform3D transform;
- float farplane;
- float split;
- float bias_scale;
- float shadow_texel_size;
- float range_begin;
+ float farplane = 0.0;
+ float split = 0.0;
+ float bias_scale = 0.0;
+ float shadow_texel_size = 0.0;
+ float range_begin = 0.0;
Rect2 atlas_rect;
Vector2 uv_scale;
};
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp
index f609fa6023..8813c2e651 100644
--- a/servers/rendering/renderer_viewport.cpp
+++ b/servers/rendering/renderer_viewport.cpp
@@ -962,6 +962,13 @@ void RendererViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpda
viewport->update_mode = p_mode;
}
+RID RendererViewport::viewport_get_render_target(RID p_viewport) const {
+ const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
+ ERR_FAIL_COND_V(!viewport, RID());
+
+ return viewport->render_target;
+}
+
RID RendererViewport::viewport_get_texture(RID p_viewport) const {
const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h
index c24275de6e..2f9537a47c 100644
--- a/servers/rendering/renderer_viewport.h
+++ b/servers/rendering/renderer_viewport.h
@@ -231,6 +231,7 @@ public:
void viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode);
+ RID viewport_get_render_target(RID p_viewport) const;
RID viewport_get_texture(RID p_viewport) const;
RID viewport_get_occluder_debug_texture(RID p_viewport) const;
diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h
index a3bdf7d146..3e30ae0313 100644
--- a/servers/rendering/rendering_server_default.h
+++ b/servers/rendering/rendering_server_default.h
@@ -606,6 +606,7 @@ public:
FUNC2(viewport_set_update_mode, RID, ViewportUpdateMode)
+ FUNC1RC(RID, viewport_get_render_target, RID)
FUNC1RC(RID, viewport_get_texture, RID)
FUNC2(viewport_set_disable_2d, RID, bool)
diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp
index 8737d3b217..1f889572df 100644
--- a/servers/rendering/shader_compiler.cpp
+++ b/servers/rendering/shader_compiler.cpp
@@ -441,7 +441,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
String code;
switch (p_node->type) {
- case SL::Node::TYPE_SHADER: {
+ case SL::Node::NODE_TYPE_SHADER: {
SL::ShaderNode *pnode = (SL::ShaderNode *)p_node;
for (int i = 0; i < pnode->render_modes.size(); i++) {
@@ -786,11 +786,11 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
//code+=dump_node_code(pnode->body,p_level);
} break;
- case SL::Node::TYPE_STRUCT: {
+ case SL::Node::NODE_TYPE_STRUCT: {
} break;
- case SL::Node::TYPE_FUNCTION: {
+ case SL::Node::NODE_TYPE_FUNCTION: {
} break;
- case SL::Node::TYPE_BLOCK: {
+ case SL::Node::NODE_TYPE_BLOCK: {
SL::BlockNode *bnode = (SL::BlockNode *)p_node;
//variables
@@ -801,7 +801,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
for (int i = 0; i < bnode->statements.size(); i++) {
String scode = _dump_node_code(bnode->statements[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
- if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW || bnode->single_statement) {
+ if (bnode->statements[i]->type == SL::Node::NODE_TYPE_CONTROL_FLOW || bnode->single_statement) {
code += scode; //use directly
if (bnode->use_comma_between_statements && i + 1 < bnode->statements.size()) {
code += ",";
@@ -815,7 +815,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
} break;
- case SL::Node::TYPE_VARIABLE_DECLARATION: {
+ case SL::Node::NODE_TYPE_VARIABLE_DECLARATION: {
SL::VariableDeclarationNode *vdnode = (SL::VariableDeclarationNode *)p_node;
String declaration;
@@ -873,7 +873,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
code += declaration;
} break;
- case SL::Node::TYPE_VARIABLE: {
+ case SL::Node::NODE_TYPE_VARIABLE: {
SL::VariableNode *vnode = (SL::VariableNode *)p_node;
bool use_fragment_varying = false;
@@ -966,7 +966,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
} break;
- case SL::Node::TYPE_ARRAY_CONSTRUCT: {
+ case SL::Node::NODE_TYPE_ARRAY_CONSTRUCT: {
SL::ArrayConstructNode *acnode = (SL::ArrayConstructNode *)p_node;
int sz = acnode->initializer.size();
if (acnode->datatype == SL::TYPE_STRUCT) {
@@ -986,7 +986,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
code += ")";
} break;
- case SL::Node::TYPE_ARRAY: {
+ case SL::Node::NODE_TYPE_ARRAY: {
SL::ArrayNode *anode = (SL::ArrayNode *)p_node;
bool use_fragment_varying = false;
@@ -1077,7 +1077,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
} break;
- case SL::Node::TYPE_CONSTANT: {
+ case SL::Node::NODE_TYPE_CONSTANT: {
SL::ConstantNode *cnode = (SL::ConstantNode *)p_node;
if (cnode->array_size == 0) {
@@ -1104,7 +1104,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
} break;
- case SL::Node::TYPE_OPERATOR: {
+ case SL::Node::NODE_TYPE_OPERATOR: {
SL::OperatorNode *onode = (SL::OperatorNode *)p_node;
switch (onode->op) {
@@ -1135,7 +1135,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
case SL::OP_CALL:
case SL::OP_STRUCT:
case SL::OP_CONSTRUCT: {
- ERR_FAIL_COND_V(onode->arguments[0]->type != SL::Node::TYPE_VARIABLE, String());
+ ERR_FAIL_COND_V(onode->arguments[0]->type != SL::Node::NODE_TYPE_VARIABLE, String());
const SL::VariableNode *vnode = static_cast<const SL::VariableNode *>(onode->arguments[0]);
const SL::FunctionNode *func = nullptr;
const bool is_internal_func = internal_functions.has(vnode->name);
@@ -1205,12 +1205,12 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
bool done = false;
do {
switch (node->type) {
- case SL::Node::TYPE_VARIABLE: {
+ case SL::Node::NODE_TYPE_VARIABLE: {
name = static_cast<const SL::VariableNode *>(node)->name;
done = true;
found = true;
} break;
- case SL::Node::TYPE_MEMBER: {
+ case SL::Node::NODE_TYPE_MEMBER: {
node = static_cast<const SL::MemberNode *>(node)->owner;
} break;
default: {
@@ -1232,12 +1232,12 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
bool correct_texture_uniform = false;
switch (onode->arguments[i]->type) {
- case SL::Node::TYPE_VARIABLE: {
+ case SL::Node::NODE_TYPE_VARIABLE: {
const SL::VariableNode *varnode = static_cast<const SL::VariableNode *>(onode->arguments[i]);
texture_uniform = varnode->name;
correct_texture_uniform = true;
} break;
- case SL::Node::TYPE_ARRAY: {
+ case SL::Node::NODE_TYPE_ARRAY: {
const SL::ArrayNode *anode = static_cast<const SL::ArrayNode *>(onode->arguments[i]);
texture_uniform = anode->name;
correct_texture_uniform = true;
@@ -1366,7 +1366,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
} break;
- case SL::Node::TYPE_CONTROL_FLOW: {
+ case SL::Node::NODE_TYPE_CONTROL_FLOW: {
SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node;
if (cfnode->flow_op == SL::FLOW_OP_IF) {
code += _mktab(p_level) + "if (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")\n";
@@ -1418,7 +1418,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
} break;
- case SL::Node::TYPE_MEMBER: {
+ 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;
if (mnode->index_expression != nullptr) {
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 084fb64a53..0e880e5cf1 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -3063,7 +3063,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
Vector<StringName> args2;
Vector<int> args3;
- ERR_FAIL_COND_V(p_func->arguments[0]->type != Node::TYPE_VARIABLE, false);
+ ERR_FAIL_COND_V(p_func->arguments[0]->type != Node::NODE_TYPE_VARIABLE, false);
StringName name = static_cast<VariableNode *>(p_func->arguments[0])->name.operator String();
@@ -3117,14 +3117,14 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
failed_builtin = true;
bool fail = false;
for (int i = 0; i < argcount; i++) {
- if (p_func->arguments[i + 1]->type == Node::TYPE_ARRAY) {
+ if (p_func->arguments[i + 1]->type == Node::NODE_TYPE_ARRAY) {
const ArrayNode *anode = static_cast<const ArrayNode *>(p_func->arguments[i + 1]);
if (anode->call_expression == nullptr && !anode->is_indexed()) {
fail = true;
break;
}
}
- if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) {
+ if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::NODE_TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) {
//all good, but needs implicit conversion later
} else if (args[i] != builtin_func_defs[idx].args[i]) {
fail = true;
@@ -3160,7 +3160,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
int max = builtin_func_const_args[constarg_idx].max;
bool error = false;
- if (p_func->arguments[arg]->type == Node::TYPE_VARIABLE) {
+ if (p_func->arguments[arg]->type == Node::NODE_TYPE_VARIABLE) {
const VariableNode *vn = static_cast<VariableNode *>(p_func->arguments[arg]);
bool is_const = false;
@@ -3172,7 +3172,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
error = true;
}
} else {
- if (p_func->arguments[arg]->type == Node::TYPE_CONSTANT) {
+ if (p_func->arguments[arg]->type == Node::NODE_TYPE_CONSTANT) {
const ConstantNode *cn = static_cast<ConstantNode *>(p_func->arguments[arg]);
if (cn->get_datatype() == TYPE_INT && cn->values.size() == 1) {
@@ -3207,17 +3207,17 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
break;
}
if (arg_idx < argcount) {
- if (p_func->arguments[arg_idx + 1]->type != Node::TYPE_VARIABLE && p_func->arguments[arg_idx + 1]->type != Node::TYPE_MEMBER && p_func->arguments[arg_idx + 1]->type != Node::TYPE_ARRAY) {
+ if (p_func->arguments[arg_idx + 1]->type != Node::NODE_TYPE_VARIABLE && p_func->arguments[arg_idx + 1]->type != Node::NODE_TYPE_MEMBER && p_func->arguments[arg_idx + 1]->type != Node::NODE_TYPE_ARRAY) {
_set_error(vformat(RTR("Argument %d of function '%s' is not a variable, array, or member."), arg_idx + 1, String(name)));
return false;
}
- if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_ARRAY) {
+ if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_ARRAY) {
ArrayNode *mn = static_cast<ArrayNode *>(p_func->arguments[arg_idx + 1]);
if (mn->is_const) {
fail = true;
}
- } else if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_MEMBER) {
+ } else if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_MEMBER) {
MemberNode *mn = static_cast<MemberNode *>(p_func->arguments[arg_idx + 1]);
if (mn->basetype_const) {
fail = true;
@@ -3250,18 +3250,18 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
}
StringName var_name;
- if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_ARRAY) {
+ if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_ARRAY) {
var_name = static_cast<const ArrayNode *>(p_func->arguments[arg_idx + 1])->name;
- } else if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_MEMBER) {
+ } else if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_MEMBER) {
Node *n = static_cast<const MemberNode *>(p_func->arguments[arg_idx + 1])->owner;
- while (n->type == Node::TYPE_MEMBER) {
+ while (n->type == Node::NODE_TYPE_MEMBER) {
n = static_cast<const MemberNode *>(n)->owner;
}
- if (n->type != Node::TYPE_VARIABLE && n->type != Node::TYPE_ARRAY) {
+ if (n->type != Node::NODE_TYPE_VARIABLE && n->type != Node::NODE_TYPE_ARRAY) {
_set_error(vformat(RTR("Argument %d of function '%s' is not a variable, array, or member."), arg_idx + 1, String(name)));
return false;
}
- if (n->type == Node::TYPE_VARIABLE) {
+ if (n->type == Node::NODE_TYPE_VARIABLE) {
var_name = static_cast<const VariableNode *>(n)->name;
} else { // TYPE_ARRAY
var_name = static_cast<const ArrayNode *>(n)->name;
@@ -3298,7 +3298,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
}
//implicitly convert values if possible
for (int i = 0; i < argcount; i++) {
- if (get_scalar_type(args[i]) != args[i] || args[i] == builtin_func_defs[idx].args[i] || p_func->arguments[i + 1]->type != Node::TYPE_CONSTANT) {
+ if (get_scalar_type(args[i]) != args[i] || args[i] == builtin_func_defs[idx].args[i] || p_func->arguments[i + 1]->type != Node::NODE_TYPE_CONSTANT) {
//can't do implicit conversion here
continue;
}
@@ -3422,7 +3422,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
bool fail = false;
for (int j = 0; j < args.size(); j++) {
- if (get_scalar_type(args[j]) == args[j] && p_func->arguments[j + 1]->type == Node::TYPE_CONSTANT && args3[j] == 0 && convert_constant(static_cast<ConstantNode *>(p_func->arguments[j + 1]), pfunc->arguments[j].type)) {
+ if (get_scalar_type(args[j]) == args[j] && p_func->arguments[j + 1]->type == Node::NODE_TYPE_CONSTANT && args3[j] == 0 && convert_constant(static_cast<ConstantNode *>(p_func->arguments[j + 1]), pfunc->arguments[j].type)) {
//all good, but it needs implicit conversion later
} else if (args[j] != pfunc->arguments[j].type || (args[j] == TYPE_STRUCT && args2[j] != pfunc->arguments[j].type_str) || args3[j] != pfunc->arguments[j].array_size) {
String func_arg_name;
@@ -3457,7 +3457,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
if (!fail) {
//implicitly convert values if possible
for (int k = 0; k < args.size(); k++) {
- if (get_scalar_type(args[k]) != args[k] || args[k] == pfunc->arguments[k].type || p_func->arguments[k + 1]->type != Node::TYPE_CONSTANT) {
+ if (get_scalar_type(args[k]) != args[k] || args[k] == pfunc->arguments[k].type || p_func->arguments[k + 1]->type != Node::NODE_TYPE_CONSTANT) {
//can't do implicit conversion here
continue;
}
@@ -3565,7 +3565,7 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Functio
return false;
}
- if (is_const_decl && arg->type == Node::TYPE_VARIABLE) {
+ if (is_const_decl && arg->type == Node::NODE_TYPE_VARIABLE) {
const VariableNode *var = static_cast<const VariableNode *>(arg);
if (!var->is_const) {
_set_error(RTR("Expected constant expression."));
@@ -4531,7 +4531,7 @@ bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, St
bool ShaderLanguage::_check_node_constness(const Node *p_node) const {
switch (p_node->type) {
- case Node::TYPE_OPERATOR: {
+ case Node::NODE_TYPE_OPERATOR: {
const OperatorNode *op_node = static_cast<const OperatorNode *>(p_node);
for (int i = int(op_node->op == OP_CALL); i < op_node->arguments.size(); i++) {
if (!_check_node_constness(op_node->arguments[i])) {
@@ -4539,15 +4539,15 @@ bool ShaderLanguage::_check_node_constness(const Node *p_node) const {
}
}
} break;
- case Node::TYPE_CONSTANT:
+ case Node::NODE_TYPE_CONSTANT:
break;
- case Node::TYPE_VARIABLE: {
+ case Node::NODE_TYPE_VARIABLE: {
const VariableNode *var_node = static_cast<const VariableNode *>(p_node);
if (!var_node->is_const) {
return false;
}
} break;
- case Node::TYPE_ARRAY: {
+ case Node::NODE_TYPE_ARRAY: {
const ArrayNode *arr_node = static_cast<const ArrayNode *>(p_node);
if (!arr_node->is_const) {
return false;
@@ -4560,7 +4560,7 @@ bool ShaderLanguage::_check_node_constness(const Node *p_node) const {
}
bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_function_info, String *r_message) {
- if (p_node->type == Node::TYPE_OPERATOR) {
+ if (p_node->type == Node::NODE_TYPE_OPERATOR) {
OperatorNode *op = static_cast<OperatorNode *>(p_node);
if (op->op == OP_INDEX) {
@@ -4577,7 +4577,7 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi
return false;
}
- } else if (p_node->type == Node::TYPE_MEMBER) {
+ } else if (p_node->type == Node::NODE_TYPE_MEMBER) {
MemberNode *member = static_cast<MemberNode *>(p_node);
if (member->has_swizzling_duplicates) {
@@ -4589,7 +4589,7 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi
return _validate_assign(member->owner, p_function_info, r_message);
- } else if (p_node->type == Node::TYPE_VARIABLE) {
+ } else if (p_node->type == Node::NODE_TYPE_VARIABLE) {
VariableNode *var = static_cast<VariableNode *>(p_node);
if (shader->uniforms.has(var->name)) {
@@ -4609,7 +4609,7 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi
if (!(p_function_info.built_ins.has(var->name) && p_function_info.built_ins[var->name].constant)) {
return true;
}
- } else if (p_node->type == Node::TYPE_ARRAY) {
+ } else if (p_node->type == Node::NODE_TYPE_ARRAY) {
ArrayNode *arr = static_cast<ArrayNode *>(p_node);
if (shader->constants.has(arr->name) || arr->is_const) {
@@ -4727,7 +4727,7 @@ Error ShaderLanguage::_parse_array_size(BlockNode *p_block, const FunctionInfo &
_set_tkpos(pos);
Node *n = _parse_and_reduce_expression(p_block, p_function_info);
if (n) {
- if (n->type == Node::TYPE_VARIABLE) {
+ if (n->type == Node::NODE_TYPE_VARIABLE) {
VariableNode *vn = static_cast<VariableNode *>(n);
if (vn) {
ConstantNode::Value v;
@@ -4750,7 +4750,7 @@ Error ShaderLanguage::_parse_array_size(BlockNode *p_block, const FunctionInfo &
}
}
}
- } else if (n->type == Node::TYPE_OPERATOR) {
+ } else if (n->type == Node::NODE_TYPE_OPERATOR) {
_set_error(vformat(RTR("Array size expressions are not supported.")));
return ERR_PARSE_ERROR;
}
@@ -5296,10 +5296,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
ArgumentQualifier arg_qual = call_function->arguments[i].qualifier;
bool is_out_arg = arg_qual != ArgumentQualifier::ARGUMENT_QUALIFIER_IN;
- if (n->type == Node::TYPE_VARIABLE || n->type == Node::TYPE_ARRAY) {
+ if (n->type == Node::NODE_TYPE_VARIABLE || n->type == Node::NODE_TYPE_ARRAY) {
StringName varname;
- if (n->type == Node::TYPE_VARIABLE) {
+ if (n->type == Node::NODE_TYPE_VARIABLE) {
VariableNode *vn = static_cast<VariableNode *>(n);
varname = vn->name;
} else { // TYPE_ARRAY
@@ -5347,23 +5347,23 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
if (is_const_arg || is_out_arg) {
StringName varname;
- if (n->type == Node::TYPE_CONSTANT || n->type == Node::TYPE_OPERATOR || n->type == Node::TYPE_ARRAY_CONSTRUCT) {
+ if (n->type == Node::NODE_TYPE_CONSTANT || n->type == Node::NODE_TYPE_OPERATOR || n->type == Node::NODE_TYPE_ARRAY_CONSTRUCT) {
if (!is_const_arg) {
error = true;
}
- } else if (n->type == Node::TYPE_ARRAY) {
+ } else if (n->type == Node::NODE_TYPE_ARRAY) {
ArrayNode *an = static_cast<ArrayNode *>(n);
if (!is_const_arg && (an->call_expression != nullptr || an->is_const)) {
error = true;
}
varname = an->name;
- } else if (n->type == Node::TYPE_VARIABLE) {
+ } else if (n->type == Node::NODE_TYPE_VARIABLE) {
VariableNode *vn = static_cast<VariableNode *>(n);
if (vn->is_const && !is_const_arg) {
error = true;
}
varname = vn->name;
- } else if (n->type == Node::TYPE_MEMBER) {
+ } else if (n->type == Node::NODE_TYPE_MEMBER) {
MemberNode *mn = static_cast<MemberNode *>(n);
if (mn->basetype_const && is_out_arg) {
error = true;
@@ -5389,7 +5389,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
if (is_sampler_type(call_function->arguments[i].type)) {
//let's see where our argument comes from
- ERR_CONTINUE(n->type != Node::TYPE_VARIABLE); //bug? this should always be a variable
+ ERR_CONTINUE(n->type != Node::NODE_TYPE_VARIABLE); //bug? this should always be a variable
VariableNode *vn = static_cast<VariableNode *>(n);
StringName varname = vn->name;
if (shader->uniforms.has(varname)) {
@@ -5599,7 +5599,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
return nullptr;
}
- if (index_expression->type == Node::TYPE_CONSTANT) {
+ if (index_expression->type == Node::NODE_TYPE_CONSTANT) {
ConstantNode *cnode = static_cast<ConstantNode *>(index_expression);
if (cnode) {
if (!cnode->values.is_empty()) {
@@ -6064,7 +6064,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
return nullptr;
}
- if (index_expression->type == Node::TYPE_CONSTANT) {
+ if (index_expression->type == Node::NODE_TYPE_CONSTANT) {
ConstantNode *cnode = static_cast<ConstantNode *>(index_expression);
if (cnode) {
if (!cnode->values.is_empty()) {
@@ -6118,7 +6118,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
String member_struct_name;
if (expr->get_array_size() > 0) {
- if (index->type == Node::TYPE_CONSTANT) {
+ if (index->type == Node::NODE_TYPE_CONSTANT) {
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
if (index_constant >= (uint32_t)expr->get_array_size()) {
_set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, expr->get_array_size() - 1));
@@ -6136,7 +6136,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
case TYPE_IVEC2:
case TYPE_UVEC2:
case TYPE_MAT2:
- if (index->type == Node::TYPE_CONSTANT) {
+ if (index->type == Node::NODE_TYPE_CONSTANT) {
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
if (index_constant >= 2) {
_set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, 1));
@@ -6170,7 +6170,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
case TYPE_IVEC3:
case TYPE_UVEC3:
case TYPE_MAT3:
- if (index->type == Node::TYPE_CONSTANT) {
+ if (index->type == Node::NODE_TYPE_CONSTANT) {
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
if (index_constant >= 3) {
_set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, 2));
@@ -6203,7 +6203,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
case TYPE_IVEC4:
case TYPE_UVEC4:
case TYPE_MAT4:
- if (index->type == Node::TYPE_CONSTANT) {
+ if (index->type == Node::NODE_TYPE_CONSTANT) {
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
if (index_constant >= 4) {
_set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, 3));
@@ -6702,7 +6702,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node) {
- if (p_node->type != Node::TYPE_OPERATOR) {
+ if (p_node->type != Node::NODE_TYPE_OPERATOR) {
return p_node;
}
@@ -6710,7 +6710,7 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
OperatorNode *op = static_cast<OperatorNode *>(p_node);
if (op->op == OP_CONSTRUCT) {
- ERR_FAIL_COND_V(op->arguments[0]->type != Node::TYPE_VARIABLE, p_node);
+ ERR_FAIL_COND_V(op->arguments[0]->type != Node::NODE_TYPE_VARIABLE, p_node);
DataType type = op->get_datatype();
DataType base = get_scalar_type(type);
@@ -6720,7 +6720,7 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
for (int i = 1; i < op->arguments.size(); i++) {
op->arguments.write[i] = _reduce_expression(p_block, op->arguments[i]);
- if (op->arguments[i]->type == Node::TYPE_CONSTANT) {
+ if (op->arguments[i]->type == Node::NODE_TYPE_CONSTANT) {
ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[i]);
if (get_scalar_type(cn->datatype) == base) {
@@ -6772,7 +6772,7 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
return cn;
} else if (op->op == OP_NEGATE) {
op->arguments.write[0] = _reduce_expression(p_block, op->arguments[0]);
- if (op->arguments[0]->type == Node::TYPE_CONSTANT) {
+ if (op->arguments[0]->type == Node::NODE_TYPE_CONSTANT) {
ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[0]);
DataType base = get_scalar_type(cn->datatype);
@@ -7179,7 +7179,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
return ERR_PARSE_ERROR;
}
- if (is_const && n->type == Node::TYPE_OPERATOR && static_cast<OperatorNode *>(n)->op == OP_CALL) {
+ if (is_const && n->type == Node::NODE_TYPE_OPERATOR && static_cast<OperatorNode *>(n)->op == OP_CALL) {
_set_error(RTR("Expected a constant expression."));
return ERR_PARSE_ERROR;
}
@@ -7235,7 +7235,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
if (!n) {
return ERR_PARSE_ERROR;
}
- if (is_const && n->type == Node::TYPE_OPERATOR && static_cast<OperatorNode *>(n)->op == OP_CALL) {
+ if (is_const && n->type == Node::NODE_TYPE_OPERATOR && static_cast<OperatorNode *>(n)->op == OP_CALL) {
OperatorNode *op = static_cast<OperatorNode *>(n);
for (int i = 1; i < op->arguments.size(); i++) {
if (!_check_node_constness(op->arguments[i])) {
@@ -7245,7 +7245,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
}
}
- if (n->type == Node::TYPE_CONSTANT) {
+ if (n->type == Node::NODE_TYPE_CONSTANT) {
ConstantNode *const_node = static_cast<ConstantNode *>(n);
if (const_node && const_node->values.size() == 1) {
var.value = const_node->values[0];
@@ -7412,7 +7412,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
ControlFlowNode *flow = static_cast<ControlFlowNode *>(switch_block->statements[i]);
if (flow) {
if (flow->flow_op == FLOW_OP_CASE) {
- if (flow->expressions[0]->type == Node::TYPE_CONSTANT) {
+ if (flow->expressions[0]->type == Node::NODE_TYPE_CONSTANT) {
ConstantNode *cn = static_cast<ConstantNode *>(flow->expressions[0]);
if (!cn || cn->values.is_empty()) {
return ERR_PARSE_ERROR;
@@ -7422,7 +7422,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
return ERR_PARSE_ERROR;
}
constants.insert(cn->values[0].sint);
- } else if (flow->expressions[0]->type == Node::TYPE_VARIABLE) {
+ } else if (flow->expressions[0]->type == Node::NODE_TYPE_VARIABLE) {
VariableNode *vn = static_cast<VariableNode *>(flow->expressions[0]);
if (!vn) {
return ERR_PARSE_ERROR;
@@ -7852,9 +7852,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
if (!expr) {
return ERR_PARSE_ERROR;
}
- is_condition = expr->type == Node::TYPE_OPERATOR && expr->get_datatype() == TYPE_BOOL;
+ is_condition = expr->type == Node::NODE_TYPE_OPERATOR && expr->get_datatype() == TYPE_BOOL;
- if (expr->type == Node::TYPE_OPERATOR) {
+ if (expr->type == Node::NODE_TYPE_OPERATOR) {
OperatorNode *op = static_cast<OperatorNode *>(expr);
if (op->op == OP_EMPTY) {
is_var_init = true;
@@ -8916,7 +8916,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
if (!expr) {
return ERR_PARSE_ERROR;
}
- if (expr->type != Node::TYPE_CONSTANT) {
+ if (expr->type != Node::NODE_TYPE_CONSTANT) {
_set_error(RTR("Expected constant expression after '='."));
return ERR_PARSE_ERROR;
}
@@ -9276,7 +9276,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
return ERR_PARSE_ERROR;
}
- if (n->type == Node::TYPE_OPERATOR && static_cast<OperatorNode *>(n)->op == OP_CALL) {
+ if (n->type == Node::NODE_TYPE_OPERATOR && static_cast<OperatorNode *>(n)->op == OP_CALL) {
_set_error(RTR("Expected constant expression."));
return ERR_PARSE_ERROR;
}
@@ -9343,7 +9343,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
keyword_completion_context = CF_GLOBAL_SPACE;
}
#endif // DEBUG_ENABLED
- if (expr->type == Node::TYPE_OPERATOR && static_cast<OperatorNode *>(expr)->op == OP_CALL) {
+ if (expr->type == Node::NODE_TYPE_OPERATOR && static_cast<OperatorNode *>(expr)->op == OP_CALL) {
OperatorNode *op = static_cast<OperatorNode *>(expr);
for (int i = 1; i < op->arguments.size(); i++) {
if (!_check_node_constness(op->arguments[i])) {
@@ -9756,7 +9756,7 @@ Error ShaderLanguage::_find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOper
bool found = false;
for (int i = p_flow->blocks.size() - 1; i >= 0; i--) {
- if (p_flow->blocks[i]->type == Node::TYPE_BLOCK) {
+ if (p_flow->blocks[i]->type == Node::NODE_TYPE_BLOCK) {
BlockNode *last_block = static_cast<BlockNode *>(p_flow->blocks[i]);
if (_find_last_flow_op_in_block(last_block, p_op) == OK) {
found = true;
@@ -9774,7 +9774,7 @@ Error ShaderLanguage::_find_last_flow_op_in_block(BlockNode *p_block, FlowOperat
bool found = false;
for (int i = p_block->statements.size() - 1; i >= 0; i--) {
- if (p_block->statements[i]->type == Node::TYPE_CONTROL_FLOW) {
+ if (p_block->statements[i]->type == Node::NODE_TYPE_CONTROL_FLOW) {
ControlFlowNode *flow = static_cast<ControlFlowNode *>(p_block->statements[i]);
if (flow->flow_op == p_op) {
found = true;
@@ -9785,7 +9785,7 @@ Error ShaderLanguage::_find_last_flow_op_in_block(BlockNode *p_block, FlowOperat
break;
}
}
- } else if (p_block->statements[i]->type == Node::TYPE_BLOCK) {
+ } else if (p_block->statements[i]->type == Node::NODE_TYPE_BLOCK) {
BlockNode *block = static_cast<BlockNode *>(p_block->statements[i]);
if (_find_last_flow_op_in_block(block, p_op) == OK) {
found = true;
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index 220160e5fd..0ddd27f028 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -357,18 +357,18 @@ public:
Node *next = nullptr;
enum Type {
- TYPE_SHADER,
- TYPE_FUNCTION,
- TYPE_BLOCK,
- TYPE_VARIABLE,
- TYPE_VARIABLE_DECLARATION,
- TYPE_CONSTANT,
- TYPE_OPERATOR,
- TYPE_CONTROL_FLOW,
- TYPE_MEMBER,
- TYPE_ARRAY,
- TYPE_ARRAY_CONSTRUCT,
- TYPE_STRUCT,
+ NODE_TYPE_SHADER,
+ NODE_TYPE_FUNCTION,
+ NODE_TYPE_BLOCK,
+ NODE_TYPE_VARIABLE,
+ NODE_TYPE_VARIABLE_DECLARATION,
+ NODE_TYPE_CONSTANT,
+ NODE_TYPE_OPERATOR,
+ NODE_TYPE_CONTROL_FLOW,
+ NODE_TYPE_MEMBER,
+ NODE_TYPE_ARRAY,
+ NODE_TYPE_ARRAY_CONSTRUCT,
+ NODE_TYPE_STRUCT,
};
Type type;
@@ -407,7 +407,7 @@ public:
virtual bool is_indexed() const override { return op == OP_INDEX; }
OperatorNode() :
- Node(TYPE_OPERATOR) {}
+ Node(NODE_TYPE_OPERATOR) {}
};
struct VariableNode : public Node {
@@ -421,7 +421,7 @@ public:
virtual String get_datatype_name() const override { return String(struct_name); }
VariableNode() :
- Node(TYPE_VARIABLE) {}
+ Node(NODE_TYPE_VARIABLE) {}
};
struct VariableDeclarationNode : public Node {
@@ -442,7 +442,7 @@ public:
virtual DataType get_datatype() const override { return datatype; }
VariableDeclarationNode() :
- Node(TYPE_VARIABLE_DECLARATION) {}
+ Node(NODE_TYPE_VARIABLE_DECLARATION) {}
};
struct ArrayNode : public Node {
@@ -462,7 +462,7 @@ public:
virtual bool is_indexed() const override { return index_expression != nullptr; }
ArrayNode() :
- Node(TYPE_ARRAY) {}
+ Node(NODE_TYPE_ARRAY) {}
};
struct ArrayConstructNode : public Node {
@@ -475,7 +475,7 @@ public:
virtual int get_array_size() const override { return initializer.size(); }
ArrayConstructNode() :
- Node(TYPE_ARRAY_CONSTRUCT) {}
+ Node(NODE_TYPE_ARRAY_CONSTRUCT) {}
};
struct ConstantNode : public Node {
@@ -498,7 +498,7 @@ public:
virtual int get_array_size() const override { return array_size; }
ConstantNode() :
- Node(TYPE_CONSTANT) {}
+ Node(NODE_TYPE_CONSTANT) {}
};
struct FunctionNode;
@@ -536,7 +536,7 @@ public:
bool use_comma_between_statements = false;
BlockNode() :
- Node(TYPE_BLOCK) {}
+ Node(NODE_TYPE_BLOCK) {}
};
struct ControlFlowNode : public Node {
@@ -545,7 +545,7 @@ public:
Vector<BlockNode *> blocks;
ControlFlowNode() :
- Node(TYPE_CONTROL_FLOW) {}
+ Node(NODE_TYPE_CONTROL_FLOW) {}
};
struct MemberNode : public Node {
@@ -569,13 +569,13 @@ public:
virtual bool is_indexed() const override { return index_expression != nullptr || call_expression != nullptr; }
MemberNode() :
- Node(TYPE_MEMBER) {}
+ Node(NODE_TYPE_MEMBER) {}
};
struct StructNode : public Node {
List<MemberNode *> members;
StructNode() :
- Node(TYPE_STRUCT) {}
+ Node(NODE_TYPE_STRUCT) {}
};
struct FunctionNode : public Node {
@@ -611,7 +611,7 @@ public:
virtual int get_array_size() const override { return return_array_size; }
FunctionNode() :
- Node(TYPE_FUNCTION) {}
+ Node(NODE_TYPE_FUNCTION) {}
};
struct ShaderNode : public Node {
@@ -718,7 +718,7 @@ public:
Vector<Struct> vstructs;
ShaderNode() :
- Node(TYPE_SHADER) {}
+ Node(NODE_TYPE_SHADER) {}
};
struct UniformOrderComparator {