Merge pull request #116454 from akien-mga/renderingserver-split-enums

Decouple RenderingServer from as much of the codebase as possible, moving enums to a new `RSE` namespace
This commit is contained in:
Rémi Verschelde 2026-02-26 12:04:54 +01:00 committed by GitHub
commit ebc126193a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
406 changed files with 8214 additions and 7428 deletions

View file

@ -78,3 +78,6 @@ c5df0cb82bc539eff7dcfb2add99d60771fc50c5
# Style: Convert `*.gen.inc` to `*.gen.h`
7dae5da1982f4a55ba91557814905faef9ce461b
# Move RenderingServer enums to a dedicated RenderingServerEnums (`RSE`) namespace
f5a290ac462765afca34e64dd39f883511510147

View file

@ -44,7 +44,6 @@
#include "core/variant/typed_array.h"
#include "core/variant/variant_parser.h"
#include "core/version.h"
#include "servers/rendering/rendering_server.h"
#ifdef TOOLS_ENABLED
#include "modules/modules_enabled.gen.h" // For mono.
@ -636,7 +635,8 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) {
} else if (p_from_version <= 6) {
// Check if we still have legacy boot splash (removed in 4.6), map it to new project setting, then remove legacy setting.
if (has_setting("application/boot_splash/fullsize")) {
set_setting("application/boot_splash/stretch_mode", RenderingServer::map_scaling_option_to_stretch_mode(get_setting("application/boot_splash/fullsize")));
// See RenderingServerEnums::SplashStretchMode.
set_setting("application/boot_splash/stretch_mode", get_setting("application/boot_splash/fullsize") ? 1 : 0);
set_setting("application/boot_splash/fullsize", Variant());
}
}

View file

@ -558,10 +558,10 @@ public:
::ClassDB::bind_integer_constant(get_class_static(), __constant_get_enum_name(m_constant), __constant_get_enum_value_name(#m_constant), m_constant);
#define BIND_BITFIELD_FLAG(m_constant) \
::ClassDB::bind_integer_constant(get_class_static(), __constant_get_bitfield_name(m_constant), #m_constant, m_constant, true);
::ClassDB::bind_integer_constant(get_class_static(), __constant_get_bitfield_name(m_constant), __constant_get_enum_value_name(#m_constant), m_constant, true);
#define BIND_CONSTANT(m_constant) \
::ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant);
::ClassDB::bind_integer_constant(get_class_static(), StringName(), __constant_get_enum_value_name(#m_constant), m_constant);
#ifdef DEBUG_ENABLED

View file

@ -93,10 +93,11 @@ struct VariantCaster<const T &> {
};
#define VARIANT_ENUM_CAST(m_enum) MAKE_ENUM_TYPE_INFO(m_enum, m_enum)
#define VARIANT_BITFIELD_CAST(m_enum) MAKE_BITFIELD_TYPE_INFO(m_enum)
#define VARIANT_BITFIELD_CAST(m_enum) MAKE_BITFIELD_TYPE_INFO(m_enum, m_enum)
// Use only for backwards compatibility when the location of an enum changes.
#define VARIANT_ENUM_CAST_EXT(m_enum, m_bound_name) MAKE_ENUM_TYPE_INFO(m_enum, m_bound_name)
#define VARIANT_BITFIELD_CAST_EXT(m_enum, m_bound_name) MAKE_BITFIELD_TYPE_INFO(m_enum, m_bound_name)
// Object enum casts must go here
VARIANT_ENUM_CAST(Object::ConnectFlags);

View file

@ -254,14 +254,14 @@ inline StringName __constant_get_enum_value_name(const char *p_name) {
return String(p_name).get_slice("::", 1);
}
#define MAKE_BITFIELD_TYPE_INFO(m_enum) \
#define MAKE_BITFIELD_TYPE_INFO(m_enum, m_bound_name) \
template <> \
struct GetTypeInfo<m_enum> { \
static const Variant::Type VARIANT_TYPE = Variant::INT; \
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \
static inline PropertyInfo get_class_info() { \
return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \
GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \
GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_bound_name))); \
} \
}; \
template <> \
@ -270,7 +270,7 @@ inline StringName __constant_get_enum_value_name(const char *p_name) {
static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \
static inline PropertyInfo get_class_info() { \
return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \
GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \
GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_bound_name))); \
} \
};

View file

@ -33,7 +33,10 @@
#include "core/crypto/crypto_core.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#ifdef WINDOWS_ENABLED
#include "drivers/gles3/rasterizer_gles3.h"
#endif
#ifdef EGL_ENABLED

View file

@ -68,8 +68,8 @@ CopyEffects::CopyEffects() {
glGenVertexArrays(1, &screen_triangle_array);
glBindVertexArray(screen_triangle_array);
glBindBuffer(GL_ARRAY_BUFFER, screen_triangle);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}
@ -100,8 +100,8 @@ CopyEffects::CopyEffects() {
glGenVertexArrays(1, &quad_array);
glBindVertexArray(quad_array);
glBindBuffer(GL_ARRAY_BUFFER, quad);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}

View file

@ -72,8 +72,8 @@ CubemapFilter::CubemapFilter() {
glGenVertexArrays(1, &screen_triangle_array);
glBindVertexArray(screen_triangle_array);
glBindBuffer(GL_ARRAY_BUFFER, screen_triangle);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}

View file

@ -32,6 +32,9 @@
#ifdef GLES3_ENABLED
#include "core/os/os.h"
#include "servers/rendering/rendering_server_enums.h"
using namespace GLES3;
FeedEffects *FeedEffects::singleton = nullptr;
@ -66,8 +69,8 @@ FeedEffects::FeedEffects() {
glGenVertexArrays(1, &screen_triangle_array);
glBindVertexArray(screen_triangle_array);
glBindBuffer(GL_ARRAY_BUFFER, screen_triangle);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}

View file

@ -67,8 +67,8 @@ Glow::Glow() {
glGenVertexArrays(1, &screen_triangle_array);
glBindVertexArray(screen_triangle_array);
glBindBuffer(GL_ARRAY_BUFFER, screen_triangle);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}

View file

@ -68,8 +68,8 @@ PostEffects::PostEffects() {
glGenVertexArrays(1, &screen_triangle_array);
glBindVertexArray(screen_triangle_array);
glBindBuffer(GL_ARRAY_BUFFER, screen_triangle);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}
@ -109,13 +109,13 @@ void PostEffects::post_copy(
flags |= PostShaderGLES3::USE_GLOW;
}
if (p_ssao_enabled) {
if (p_ssao_quality_level == RS::ENV_SSAO_QUALITY_VERY_LOW) {
if (p_ssao_quality_level == RSE::ENV_SSAO_QUALITY_VERY_LOW) {
flags |= PostShaderGLES3::USE_SSAO_ABYSS;
} else if (p_ssao_quality_level == RS::ENV_SSAO_QUALITY_LOW) {
} else if (p_ssao_quality_level == RSE::ENV_SSAO_QUALITY_LOW) {
flags |= PostShaderGLES3::USE_SSAO_LOW;
} else if (p_ssao_quality_level == RS::ENV_SSAO_QUALITY_HIGH) {
} else if (p_ssao_quality_level == RSE::ENV_SSAO_QUALITY_HIGH) {
flags |= PostShaderGLES3::USE_SSAO_HIGH;
} else if (p_ssao_quality_level == RS::ENV_SSAO_QUALITY_ULTRA) {
} else if (p_ssao_quality_level == RSE::ENV_SSAO_QUALITY_ULTRA) {
flags |= PostShaderGLES3::USE_SSAO_MEGA;
} else {
flags |= PostShaderGLES3::USE_SSAO_MED;

View file

@ -32,6 +32,9 @@
#ifdef GLES3_ENABLED
#include "core/math/aabb.h"
#include "core/templates/rid.h"
using namespace GLES3;
/* FOG */
@ -46,7 +49,7 @@ void Fog::fog_volume_initialize(RID p_rid) {
void Fog::fog_volume_free(RID p_rid) {
}
void Fog::fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) {
void Fog::fog_volume_set_shape(RID p_fog_volume, RSE::FogVolumeShape p_shape) {
}
void Fog::fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) {
@ -59,8 +62,8 @@ AABB Fog::fog_volume_get_aabb(RID p_fog_volume) const {
return AABB();
}
RS::FogVolumeShape Fog::fog_volume_get_shape(RID p_fog_volume) const {
return RS::FOG_VOLUME_SHAPE_BOX;
RSE::FogVolumeShape Fog::fog_volume_get_shape(RID p_fog_volume) const {
return RSE::FOG_VOLUME_SHAPE_BOX;
}
#endif // GLES3_ENABLED

View file

@ -44,11 +44,11 @@ public:
virtual void fog_volume_initialize(RID p_rid) override;
virtual void fog_volume_free(RID p_rid) override;
virtual void fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) override;
virtual void fog_volume_set_shape(RID p_fog_volume, RSE::FogVolumeShape p_shape) override;
virtual void fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) override;
virtual void fog_volume_set_material(RID p_fog_volume, RID p_material) override;
virtual AABB fog_volume_get_aabb(RID p_fog_volume) const override;
virtual RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const override;
virtual RSE::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const override;
};
} // namespace GLES3

View file

@ -32,6 +32,12 @@
#ifdef GLES3_ENABLED
#include "core/math/aabb.h"
#include "core/math/transform_3d.h"
#include "core/math/vector3i.h"
#include "core/templates/rid.h"
#include "core/templates/vector.h"
using namespace GLES3;
/* VOXEL GI API */

View file

@ -43,6 +43,7 @@
#include "drivers/gles3/storage/utilities.h"
#include "servers/rendering/rendering_server_default.h"
#include "servers/rendering/rendering_server_globals.h"
#include "servers/rendering/rendering_server_types.h"
void RasterizerCanvasGLES3::_update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4) {
p_mat4[0] = p_transform.columns[0][0];
@ -103,7 +104,7 @@ void RasterizerCanvasGLES3::_update_transform_to_mat4(const Transform3D &p_trans
p_mat4[15] = 1;
}
void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_light_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used, RenderingMethod::RenderInfo *r_render_info) {
void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_light_list, const Transform2D &p_canvas_transform, RSE::CanvasItemTextureFilter p_default_filter, RSE::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used, RenderingServerTypes::RenderInfo *r_render_info) {
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
GLES3::MaterialStorage *material_storage = GLES3::MaterialStorage::get_singleton();
GLES3::MeshStorage *mesh_storage = GLES3::MeshStorage::get_singleton();
@ -422,7 +423,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
// Check material for something that may change flow of rendering, but do not bind for now.
RID material = ci->material_owner == nullptr ? ci->material : ci->material_owner->material;
if (material.is_valid()) {
GLES3::CanvasMaterialData *md = static_cast<GLES3::CanvasMaterialData *>(material_storage->material_get_data(material, RS::SHADER_CANVAS_ITEM));
GLES3::CanvasMaterialData *md = static_cast<GLES3::CanvasMaterialData *>(material_storage->material_get_data(material, RSE::SHADER_CANVAS_ITEM));
if (md && md->shader_data->valid) {
if (md->shader_data->uses_screen_texture && canvas_group_owner == nullptr) {
if (!material_screen_texture_cached) {
@ -469,10 +470,10 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
_render_items(p_to_render_target, item_count, canvas_transform_inverse, p_light_list, r_sdf_used, false, r_render_info, material_screen_texture_mipmaps_cached);
item_count = 0;
if (ci->canvas_group_owner->canvas_group->mode != RS::CANVAS_GROUP_MODE_TRANSPARENT) {
if (ci->canvas_group_owner->canvas_group->mode != RSE::CANVAS_GROUP_MODE_TRANSPARENT) {
Rect2i group_rect = ci->canvas_group_owner->global_rect_cache;
texture_storage->render_target_copy_to_back_buffer(p_to_render_target, group_rect, false);
if (ci->canvas_group_owner->canvas_group->mode == RS::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
if (ci->canvas_group_owner->canvas_group->mode == RSE::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
ci->canvas_group_owner->use_canvas_group = false;
items[item_count++] = ci->canvas_group_owner;
}
@ -488,7 +489,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
ci->canvas_group_owner = nullptr; //must be cleared
}
if (canvas_group_owner == nullptr && ci->canvas_group != nullptr && ci->canvas_group->mode != RS::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
if (canvas_group_owner == nullptr && ci->canvas_group != nullptr && ci->canvas_group->mode != RSE::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
skip_item = true;
}
@ -571,7 +572,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
state.current_instance_buffer_index = 0;
}
void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, bool &r_sdf_used, bool p_to_backbuffer, RenderingMethod::RenderInfo *r_render_info, bool p_backbuffer_has_mipmaps) {
void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, bool &r_sdf_used, bool p_to_backbuffer, RenderingServerTypes::RenderInfo *r_render_info, bool p_backbuffer_has_mipmaps) {
GLES3::MaterialStorage *material_storage = GLES3::MaterialStorage::get_singleton();
canvas_begin(p_to_render_target, p_to_backbuffer, p_backbuffer_has_mipmaps);
@ -605,11 +606,11 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
RID material = ci->material_owner == nullptr ? ci->material : ci->material_owner->material;
if (ci->use_canvas_group) {
if (ci->canvas_group->mode == RS::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
if (ci->canvas_group->mode == RSE::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
material = default_clip_children_material;
} else {
if (material.is_null()) {
if (ci->canvas_group->mode == RS::CANVAS_GROUP_MODE_CLIP_ONLY) {
if (ci->canvas_group->mode == RSE::CANVAS_GROUP_MODE_CLIP_ONLY) {
material = default_clip_children_material;
} else {
material = default_canvas_group_material;
@ -623,7 +624,7 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
GLES3::CanvasMaterialData *material_data = nullptr;
if (material.is_valid()) {
material_data = static_cast<GLES3::CanvasMaterialData *>(material_storage->material_get_data(material, RS::SHADER_CANVAS_ITEM));
material_data = static_cast<GLES3::CanvasMaterialData *>(material_storage->material_get_data(material, RSE::SHADER_CANVAS_ITEM));
}
shader_data_cache = nullptr;
if (material_data) {
@ -810,7 +811,7 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
}
void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_render_target, const Transform2D &p_canvas_transform_inverse, Item *&current_clip, GLES3::CanvasShaderData::BlendMode p_blend_mode, Light *p_lights, uint32_t &r_index, bool &r_batch_broken, bool &r_sdf_used, const Point2 &p_repeat_offset) {
RenderingServer::CanvasItemTextureFilter texture_filter = p_item->texture_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT ? state.default_filter : p_item->texture_filter;
RSE::CanvasItemTextureFilter texture_filter = p_item->texture_filter == RSE::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT ? state.default_filter : p_item->texture_filter;
const uint64_t specialization_command_mask = ~(CanvasShaderGLES3::USE_NINEPATCH | CanvasShaderGLES3::USE_PRIMITIVE | CanvasShaderGLES3::USE_ATTRIBUTES | CanvasShaderGLES3::USE_INSTANCING);
if (texture_filter != state.canvas_instance_batches[state.current_batch_index].filter) {
@ -819,7 +820,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
state.canvas_instance_batches[state.current_batch_index].filter = texture_filter;
}
RenderingServer::CanvasItemTextureRepeat texture_repeat = p_item->texture_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT ? state.default_repeat : p_item->texture_repeat;
RSE::CanvasItemTextureRepeat texture_repeat = p_item->texture_repeat == RSE::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT ? state.default_repeat : p_item->texture_repeat;
if (texture_repeat != state.canvas_instance_batches[state.current_batch_index].repeat) {
_new_batch(r_batch_broken);
@ -932,9 +933,9 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
case Item::Command::TYPE_RECT: {
const Item::CommandRect *rect = static_cast<const Item::CommandRect *>(c);
if (rect->flags & CANVAS_RECT_TILE && state.canvas_instance_batches[state.current_batch_index].repeat != RenderingServer::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED) {
if (rect->flags & CANVAS_RECT_TILE && state.canvas_instance_batches[state.current_batch_index].repeat != RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED) {
_new_batch(r_batch_broken);
state.canvas_instance_batches[state.current_batch_index].repeat = RenderingServer::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED;
state.canvas_instance_batches[state.current_batch_index].repeat = RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED;
}
if (rect->texture != state.canvas_instance_batches[state.current_batch_index].tex || state.canvas_instance_batches[state.current_batch_index].command_type != Item::Command::TYPE_RECT) {
@ -1292,13 +1293,13 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
}
}
_FORCE_INLINE_ static uint32_t _indices_to_primitives(RS::PrimitiveType p_primitive, uint32_t p_indices) {
static const uint32_t divisor[RS::PRIMITIVE_MAX] = { 1, 2, 1, 3, 1 };
static const uint32_t subtractor[RS::PRIMITIVE_MAX] = { 0, 0, 1, 0, 2 };
_FORCE_INLINE_ static uint32_t _indices_to_primitives(RSE::PrimitiveType p_primitive, uint32_t p_indices) {
static const uint32_t divisor[RSE::PRIMITIVE_MAX] = { 1, 2, 1, 3, 1 };
static const uint32_t subtractor[RSE::PRIMITIVE_MAX] = { 0, 0, 1, 0, 2 };
return (p_indices - subtractor[p_primitive]) / divisor[p_primitive];
}
void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, RenderingMethod::RenderInfo *r_render_info) {
void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, RenderingServerTypes::RenderInfo *r_render_info) {
ERR_FAIL_NULL(state.canvas_instance_batches[state.current_batch_index].command);
// Used by Polygon and Mesh.
@ -1318,9 +1319,9 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
glBindVertexArray(0);
if (r_render_info) {
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] += state.canvas_instance_batches[p_index].instance_count;
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += 2 * state.canvas_instance_batches[p_index].instance_count;
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] += state.canvas_instance_batches[p_index].instance_count;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += 2 * state.canvas_instance_batches[p_index].instance_count;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
}
} break;
@ -1338,7 +1339,7 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
_enable_attributes(range_start, false);
if (pb->color_disabled && pb->color != Color(1.0, 1.0, 1.0, 1.0)) {
glVertexAttrib4f(RS::ARRAY_COLOR, pb->color.r, pb->color.g, pb->color.b, pb->color.a);
glVertexAttrib4f(RSE::ARRAY_COLOR, pb->color.r, pb->color.g, pb->color.b, pb->color.a);
}
if (pb->index_buffer != 0) {
@ -1350,13 +1351,13 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
if (pb->color_disabled && pb->color != Color(1.0, 1.0, 1.0, 1.0)) {
// Reset so this doesn't pollute other draw calls.
glVertexAttrib4f(RS::ARRAY_COLOR, 1.0, 1.0, 1.0, 1.0);
glVertexAttrib4f(RSE::ARRAY_COLOR, 1.0, 1.0, 1.0, 1.0);
}
if (r_render_info) {
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME]++;
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += _indices_to_primitives(polygon->primitive, pb->count);
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME]++;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += _indices_to_primitives(polygon->primitive, pb->count);
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
}
} break;
@ -1373,10 +1374,10 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
glDrawArraysInstanced(primitive[state.canvas_instance_batches[p_index].primitive_points], 0, state.canvas_instance_batches[p_index].primitive_points, instance_count);
}
if (r_render_info) {
const RenderingServer::PrimitiveType rs_primitive[5] = { RS::PRIMITIVE_POINTS, RS::PRIMITIVE_POINTS, RS::PRIMITIVE_LINES, RS::PRIMITIVE_TRIANGLES, RS::PRIMITIVE_TRIANGLES };
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] += instance_count;
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += _indices_to_primitives(rs_primitive[state.canvas_instance_batches[p_index].primitive_points], state.canvas_instance_batches[p_index].primitive_points) * instance_count;
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
const RSE::PrimitiveType rs_primitive[5] = { RSE::PRIMITIVE_POINTS, RSE::PRIMITIVE_POINTS, RSE::PRIMITIVE_LINES, RSE::PRIMITIVE_TRIANGLES, RSE::PRIMITIVE_TRIANGLES };
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] += instance_count;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += _indices_to_primitives(rs_primitive[state.canvas_instance_batches[p_index].primitive_points], state.canvas_instance_batches[p_index].primitive_points) * instance_count;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
}
} break;
@ -1406,7 +1407,7 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
RID multimesh = mm->multimesh;
mesh = mesh_storage->multimesh_get_mesh(multimesh);
if (mesh_storage->multimesh_get_transform_format(multimesh) != RS::MULTIMESH_TRANSFORM_2D) {
if (mesh_storage->multimesh_get_transform_format(multimesh) != RSE::MULTIMESH_TRANSFORM_2D) {
break;
}
@ -1428,7 +1429,7 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
RID particles = pt->particles;
mesh = particles_storage->particles_get_draw_pass_mesh(particles, 0);
ERR_BREAK(particles_storage->particles_get_mode(particles) != RS::PARTICLES_MODE_2D);
ERR_BREAK(particles_storage->particles_get_mode(particles) != RSE::PARTICLES_MODE_2D);
particles_storage->particles_request_process(particles);
if (particles_storage->particles_is_inactive(particles)) {
@ -1458,8 +1459,8 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
for (uint32_t j = 0; j < surf_count; j++) {
void *surface = mesh_storage->mesh_get_surface(mesh, j);
RS::PrimitiveType primitive = mesh_storage->mesh_surface_get_primitive(surface);
ERR_CONTINUE(primitive < 0 || primitive >= RS::PRIMITIVE_MAX);
RSE::PrimitiveType primitive = mesh_storage->mesh_surface_get_primitive(surface);
ERR_CONTINUE(primitive < 0 || primitive >= RSE::PRIMITIVE_MAX);
GLuint vertex_array_gl = 0;
GLuint index_array_gl = 0;
@ -1531,9 +1532,9 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
}
if (r_render_info) {
// Meshes, Particles, and MultiMesh are always just one object with one draw call.
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME]++;
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += _indices_to_primitives(primitive, vertex_count) * instance_count;
r_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME]++;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] += _indices_to_primitives(primitive, vertex_count) * instance_count;
r_render_info->info[RSE::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RSE::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME]++;
}
}
@ -1667,7 +1668,7 @@ void RasterizerCanvasGLES3::light_update_shadow(RID p_rid, int p_shadow_index, c
glCullFace(GL_BACK);
glDisable(GL_CULL_FACE);
RS::CanvasOccluderPolygonCullMode cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
RSE::CanvasOccluderPolygonCullMode cull_mode = RSE::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
CanvasOcclusionShaderGLES3::ShaderVariant variant = config->float_texture_supported ? CanvasOcclusionShaderGLES3::MODE_SHADOW : CanvasOcclusionShaderGLES3::MODE_SHADOW_RGBA;
bool success = shadow_render.shader.version_bind_shader(shadow_render.shader_version, variant);
@ -1728,14 +1729,14 @@ void RasterizerCanvasGLES3::light_update_shadow(RID p_rid, int p_shadow_index, c
shadow_render.shader.version_set_uniform(CanvasOcclusionShaderGLES3::MODELVIEW2, modelview.columns[0][1], modelview.columns[1][1], 0, modelview.columns[2][1], shadow_render.shader_version, variant);
if (co->cull_mode != cull_mode) {
if (co->cull_mode == RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
if (co->cull_mode == RSE::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
glDisable(GL_CULL_FACE);
} else {
if (cull_mode == RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
if (cull_mode == RSE::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
// Last time was disabled, so enable and set proper face.
glEnable(GL_CULL_FACE);
}
glCullFace(co->cull_mode == RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? GL_FRONT : GL_BACK);
glCullFace(co->cull_mode == RSE::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? GL_FRONT : GL_BACK);
}
cull_mode = co->cull_mode;
}
@ -1800,7 +1801,7 @@ void RasterizerCanvasGLES3::light_update_directional_shadow(RID p_rid, int p_sha
glCullFace(GL_BACK);
glDisable(GL_CULL_FACE);
RS::CanvasOccluderPolygonCullMode cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
RSE::CanvasOccluderPolygonCullMode cull_mode = RSE::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
CanvasOcclusionShaderGLES3::ShaderVariant variant = config->float_texture_supported ? CanvasOcclusionShaderGLES3::MODE_SHADOW : CanvasOcclusionShaderGLES3::MODE_SHADOW_RGBA;
bool success = shadow_render.shader.version_bind_shader(shadow_render.shader_version, variant);
@ -1831,14 +1832,14 @@ void RasterizerCanvasGLES3::light_update_directional_shadow(RID p_rid, int p_sha
shadow_render.shader.version_set_uniform(CanvasOcclusionShaderGLES3::MODELVIEW2, modelview.columns[0][1], modelview.columns[1][1], 0, modelview.columns[2][1], shadow_render.shader_version, variant);
if (co->cull_mode != cull_mode) {
if (co->cull_mode == RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
if (co->cull_mode == RSE::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
glDisable(GL_CULL_FACE);
} else {
if (cull_mode == RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
if (cull_mode == RSE::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED) {
// Last time was disabled, so enable and set proper face.
glEnable(GL_CULL_FACE);
}
glCullFace(co->cull_mode == RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? GL_FRONT : GL_BACK);
glCullFace(co->cull_mode == RSE::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? GL_FRONT : GL_BACK);
}
cull_mode = co->cull_mode;
}
@ -2070,8 +2071,8 @@ void RasterizerCanvasGLES3::occluder_polygon_set_shape(RID p_occluder, const Vec
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, oc->vertex_buffer, lc * 6 * sizeof(float), geometry.ptr(), GL_STATIC_DRAW, "Occluder polygon vertex buffer");
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
glGenBuffers(1, &oc->index_buffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, oc->index_buffer);
@ -2133,8 +2134,8 @@ void RasterizerCanvasGLES3::occluder_polygon_set_shape(RID p_occluder, const Vec
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, oc->sdf_vertex_buffer, oc->sdf_point_count * 2 * sizeof(float), p_points.ptr(), GL_STATIC_DRAW, "Occluder polygon SDF vertex buffer");
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr);
glGenBuffers(1, &oc->sdf_index_buffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, oc->sdf_index_buffer);
@ -2152,7 +2153,7 @@ void RasterizerCanvasGLES3::occluder_polygon_set_shape(RID p_occluder, const Vec
}
}
void RasterizerCanvasGLES3::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
void RasterizerCanvasGLES3::occluder_polygon_set_cull_mode(RID p_occluder, RSE::CanvasOccluderPolygonCullMode p_mode) {
OccluderPolygon *oc = occluder_polygon_owner.get_or_null(p_occluder);
ERR_FAIL_NULL(oc);
oc->cull_mode = p_mode;
@ -2242,7 +2243,7 @@ void RasterizerCanvasGLES3::canvas_begin(RID p_to_render_target, bool p_to_backb
glBindTexture(GL_TEXTURE_2D, tex->tex_id);
}
void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat) {
void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RSE::CanvasItemTextureFilter p_base_filter, RSE::CanvasItemTextureRepeat p_base_repeat) {
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
GLES3::Config *config = GLES3::Config::get_singleton();
@ -2278,11 +2279,11 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe
return;
}
RS::CanvasItemTextureFilter filter = ct->texture_filter != RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT ? ct->texture_filter : p_base_filter;
ERR_FAIL_COND(filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT);
RSE::CanvasItemTextureFilter filter = ct->texture_filter != RSE::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT ? ct->texture_filter : p_base_filter;
ERR_FAIL_COND(filter == RSE::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT);
RS::CanvasItemTextureRepeat repeat = ct->texture_repeat != RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT ? ct->texture_repeat : p_base_repeat;
ERR_FAIL_COND(repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
RSE::CanvasItemTextureRepeat repeat = ct->texture_repeat != RSE::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT ? ct->texture_repeat : p_base_repeat;
ERR_FAIL_COND(repeat == RSE::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
GLES3::Texture *texture = texture_storage->get_texture(ct->diffuse);
@ -2333,7 +2334,7 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe
}
}
void RasterizerCanvasGLES3::_prepare_canvas_texture(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat, uint32_t &r_index, Size2 &r_texpixel_size) {
void RasterizerCanvasGLES3::_prepare_canvas_texture(RID p_texture, RSE::CanvasItemTextureFilter p_base_filter, RSE::CanvasItemTextureRepeat p_base_repeat, uint32_t &r_index, Size2 &r_texpixel_size) {
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
if (p_texture == RID()) {
@ -2456,8 +2457,8 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
uint32_t base_offset = 0;
{
// Always uses vertex positions
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), nullptr);
const Vector2 *points_ptr = p_points.ptr();
for (uint32_t i = 0; i < vertex_count; i++) {
@ -2470,8 +2471,8 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
// Next add colors
if ((uint32_t)p_colors.size() == vertex_count) {
glEnableVertexAttribArray(RS::ARRAY_COLOR);
glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
glEnableVertexAttribArray(RSE::ARRAY_COLOR);
glVertexAttribPointer(RSE::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
const Color *color_ptr = p_colors.ptr();
@ -2483,14 +2484,14 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
}
base_offset += 4;
} else {
glDisableVertexAttribArray(RS::ARRAY_COLOR);
glDisableVertexAttribArray(RSE::ARRAY_COLOR);
pb.color_disabled = true;
pb.color = p_colors.size() == 1 ? p_colors[0] : Color(1.0, 1.0, 1.0, 1.0);
}
if ((uint32_t)p_uvs.size() == vertex_count) {
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
glEnableVertexAttribArray(RSE::ARRAY_TEX_UV);
glVertexAttribPointer(RSE::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
const Vector2 *uv_ptr = p_uvs.ptr();
@ -2501,12 +2502,12 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
base_offset += 2;
} else {
glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
glDisableVertexAttribArray(RSE::ARRAY_TEX_UV);
}
if ((uint32_t)p_indices.size() == vertex_count * 4 && (uint32_t)p_weights.size() == vertex_count * 4) {
glEnableVertexAttribArray(RS::ARRAY_BONES);
glVertexAttribPointer(RS::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
glEnableVertexAttribArray(RSE::ARRAY_BONES);
glVertexAttribPointer(RSE::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
const int *bone_ptr = p_bones.ptr();
@ -2521,12 +2522,12 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
base_offset += 2;
} else {
glDisableVertexAttribArray(RS::ARRAY_BONES);
glDisableVertexAttribArray(RSE::ARRAY_BONES);
}
if ((uint32_t)p_weights.size() == vertex_count * 4) {
glEnableVertexAttribArray(RS::ARRAY_WEIGHTS);
glVertexAttribPointer(RS::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
glEnableVertexAttribArray(RSE::ARRAY_WEIGHTS);
glVertexAttribPointer(RSE::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(base_offset * sizeof(float)));
const float *weight_ptr = p_weights.ptr();
@ -2541,7 +2542,7 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
base_offset += 2;
} else {
glDisableVertexAttribArray(RS::ARRAY_WEIGHTS);
glDisableVertexAttribArray(RSE::ARRAY_WEIGHTS);
}
ERR_FAIL_COND_V(base_offset != stride, 0);
@ -2652,7 +2653,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
GLES3::MaterialStorage *material_storage = GLES3::MaterialStorage::get_singleton();
GLES3::Config *config = GLES3::Config::get_singleton();
glVertexAttrib4f(RS::ARRAY_COLOR, 1.0, 1.0, 1.0, 1.0);
glVertexAttrib4f(RSE::ARRAY_COLOR, 1.0, 1.0, 1.0, 1.0);
polygon_buffers.last_id = 1;
// quad buffer
@ -2706,10 +2707,10 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
glGenVertexArrays(1, &data.particle_quad_array);
glBindVertexArray(data.particle_quad_array);
glBindBuffer(GL_ARRAY_BUFFER, data.particle_quad_vertices);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr);
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8));
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_TEX_UV);
glVertexAttribPointer(RSE::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8));
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}

View file

@ -36,6 +36,7 @@
#include "drivers/gles3/shaders/canvas_occlusion.glsl.gen.h"
#include "drivers/gles3/storage/material_storage.h"
#include "servers/rendering/renderer_canvas_render.h"
#include "servers/rendering/rendering_server_enums.h"
class RasterizerCanvasGLES3 : public RendererCanvasRender {
static RasterizerCanvasGLES3 *singleton;
@ -107,7 +108,7 @@ class RasterizerCanvasGLES3 : public RendererCanvasRender {
RID_Owner<CanvasLight> canvas_light_owner;
struct OccluderPolygon {
RS::CanvasOccluderPolygonCullMode cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
RSE::CanvasOccluderPolygonCullMode cull_mode = RSE::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
int line_point_count = 0;
GLuint vertex_buffer = 0;
GLuint vertex_array = 0;
@ -254,8 +255,8 @@ public:
uint32_t instance_buffer_index = 0;
RID tex;
RS::CanvasItemTextureFilter filter = RS::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RS::CanvasItemTextureRepeat repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX;
RSE::CanvasItemTextureFilter filter = RSE::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RSE::CanvasItemTextureRepeat repeat = RSE::CANVAS_ITEM_TEXTURE_REPEAT_MAX;
GLES3::CanvasShaderData::BlendMode blend_mode = GLES3::CanvasShaderData::BLEND_MODE_MIX;
Color blend_color = Color(1.0, 1.0, 1.0, 1.0);
@ -264,7 +265,7 @@ public:
RID material;
GLES3::CanvasMaterialData *material_data = nullptr;
uint64_t vertex_input_mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_COLOR | RS::ARRAY_FORMAT_TEX_UV;
uint64_t vertex_input_mask = RSE::ARRAY_FORMAT_VERTEX | RSE::ARRAY_FORMAT_COLOR | RSE::ARRAY_FORMAT_TEX_UV;
uint64_t specialization = 0;
const Item::Command *command = nullptr;
@ -308,15 +309,15 @@ public:
bool using_directional_lights = false;
RID current_tex;
RS::CanvasItemTextureFilter current_filter_mode = RS::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RS::CanvasItemTextureRepeat current_repeat_mode = RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX;
RSE::CanvasItemTextureFilter current_filter_mode = RSE::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RSE::CanvasItemTextureRepeat current_repeat_mode = RSE::CANVAS_ITEM_TEXTURE_REPEAT_MAX;
bool transparent_render_target = false;
double time = 0.0;
RS::CanvasItemTextureFilter default_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
RS::CanvasItemTextureRepeat default_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
RSE::CanvasItemTextureFilter default_filter = RSE::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
RSE::CanvasItemTextureRepeat default_repeat = RSE::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
} state;
Item *items[MAX_RENDER_ITEMS];
@ -345,19 +346,19 @@ public:
void render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) override;
RID occluder_polygon_create() override;
void occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) override;
void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) override;
void occluder_polygon_set_cull_mode(RID p_occluder, RSE::CanvasOccluderPolygonCullMode p_mode) override;
void set_shadow_texture_size(int p_size) override;
bool free(RID p_rid) override;
void update() override;
void _bind_canvas_texture(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat);
void _prepare_canvas_texture(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat, uint32_t &r_index, Size2 &r_texpixel_size);
void _bind_canvas_texture(RID p_texture, RSE::CanvasItemTextureFilter p_base_filter, RSE::CanvasItemTextureRepeat p_base_repeat);
void _prepare_canvas_texture(RID p_texture, RSE::CanvasItemTextureFilter p_base_filter, RSE::CanvasItemTextureRepeat p_base_repeat, uint32_t &r_index, Size2 &r_texpixel_size);
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used, RenderingMethod::RenderInfo *r_render_info = nullptr) override;
void _render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, bool &r_sdf_used, bool p_to_backbuffer = false, RenderingMethod::RenderInfo *r_render_info = nullptr, bool p_backbuffer_has_mipmaps = false);
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RSE::CanvasItemTextureFilter p_default_filter, RSE::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used, RenderingServerTypes::RenderInfo *r_render_info = nullptr) override;
void _render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, bool &r_sdf_used, bool p_to_backbuffer = false, RenderingServerTypes::RenderInfo *r_render_info = nullptr, bool p_backbuffer_has_mipmaps = false);
void _record_item_commands(const Item *p_item, RID p_render_target, const Transform2D &p_canvas_transform_inverse, Item *&current_clip, GLES3::CanvasShaderData::BlendMode p_blend_mode, Light *p_lights, uint32_t &r_index, bool &r_break_batch, bool &r_sdf_used, const Point2 &p_repeat_offset);
void _render_batch(Light *p_lights, uint32_t p_index, RenderingMethod::RenderInfo *r_render_info = nullptr);
void _render_batch(Light *p_lights, uint32_t p_index, RenderingServerTypes::RenderInfo *r_render_info = nullptr);
bool _bind_material(GLES3::CanvasMaterialData *p_material_data, CanvasShaderGLES3::ShaderVariant p_variant, uint64_t p_specialization);
void _new_batch(bool &r_batch_broken);
void _add_to_batch(uint32_t &r_index, bool &r_batch_broken);
@ -373,7 +374,7 @@ public:
}
}
virtual uint32_t get_pipeline_compilations(RS::PipelineSource p_source) override { return 0; }
virtual uint32_t get_pipeline_compilations(RSE::PipelineSource p_source) override { return 0; }
static RasterizerCanvasGLES3 *get_singleton();
RasterizerCanvasGLES3();

View file

@ -36,6 +36,8 @@
#include "core/io/dir_access.h"
#include "core/io/image.h"
#include "core/os/os.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_types.h"
#define _EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
#define _EXT_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
@ -365,7 +367,7 @@ RasterizerGLES3::RasterizerGLES3() {
RasterizerGLES3::~RasterizerGLES3() {
}
void RasterizerGLES3::_blit_render_target_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen &p_blit, bool p_first) {
void RasterizerGLES3::_blit_render_target_to_screen(DisplayServer::WindowID p_screen, const RenderingServerTypes::BlitToScreen &p_blit, bool p_first) {
GLES3::RenderTarget *rt = GLES3::TextureStorage::get_singleton()->get_render_target(p_blit.render_target);
ERR_FAIL_NULL(rt);
@ -440,13 +442,13 @@ void RasterizerGLES3::_blit_render_target_to_screen(DisplayServer::WindowID p_sc
}
// is this p_screen useless in a multi window environment?
void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const RenderingServerTypes::BlitToScreen *p_render_targets, int p_amount) {
for (int i = 0; i < p_amount; i++) {
_blit_render_target_to_screen(p_screen, p_render_targets[i], i == 0);
}
}
void RasterizerGLES3::set_boot_image_with_stretch(const Ref<Image> &p_image, const Color &p_color, RenderingServer::SplashStretchMode p_stretch_mode, bool p_use_filter) {
void RasterizerGLES3::set_boot_image_with_stretch(const Ref<Image> &p_image, const Color &p_color, RSE::SplashStretchMode p_stretch_mode, bool p_use_filter) {
if (p_image.is_null() || p_image->is_empty()) {
return;
}
@ -464,7 +466,7 @@ void RasterizerGLES3::set_boot_image_with_stretch(const Ref<Image> &p_image, con
RID texture = texture_storage->texture_allocate();
texture_storage->texture_2d_initialize(texture, p_image);
Rect2 screenrect = RenderingServer::get_splash_stretched_screen_rect(p_image->get_size(), win_size, p_stretch_mode);
Rect2 screenrect = RenderingServerTypes::get_splash_stretched_screen_rect(p_image->get_size(), win_size, p_stretch_mode);
#ifdef WINDOWS_ENABLED
if (!screen_flipped_y)
@ -480,7 +482,7 @@ void RasterizerGLES3::set_boot_image_with_stretch(const Ref<Image> &p_image, con
screenrect.size /= win_size;
GLES3::Texture *t = texture_storage->get_texture(texture);
t->gl_set_filter(p_use_filter ? RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR : RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
t->gl_set_filter(p_use_filter ? RSE::CANVAS_ITEM_TEXTURE_FILTER_LINEAR : RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, t->tex_id);
copy_effects->copy_to_rect(screenrect);

View file

@ -81,7 +81,7 @@ protected:
RasterizerSceneGLES3 *scene = nullptr;
static RasterizerGLES3 *singleton;
void _blit_render_target_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen &p_blit, bool p_first = true);
void _blit_render_target_to_screen(DisplayServer::WindowID p_screen, const RenderingServerTypes::BlitToScreen &p_blit, bool p_first = true);
public:
RendererUtilities *get_utilities() { return utilities; }
@ -95,12 +95,12 @@ public:
RendererCanvasRender *get_canvas() { return canvas; }
RendererSceneRender *get_scene() { return scene; }
void set_boot_image_with_stretch(const Ref<Image> &p_image, const Color &p_color, RenderingServer::SplashStretchMode p_stretch_mode, bool p_use_filter = true);
void set_boot_image_with_stretch(const Ref<Image> &p_image, const Color &p_color, RSE::SplashStretchMode p_stretch_mode, bool p_use_filter = true);
void initialize();
void begin_frame(double frame_step);
void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);
void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const RenderingServerTypes::BlitToScreen *p_render_targets, int p_amount);
bool is_opengl() { return true; }
void gl_end_frame(bool p_swap_buffers);

File diff suppressed because it is too large Load diff

View file

@ -39,7 +39,8 @@
#include "drivers/gles3/storage/light_storage.h"
#include "drivers/gles3/storage/material_storage.h"
#include "servers/rendering/renderer_scene_render.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_enums.h"
#include "servers/rendering/rendering_server_types.h"
class RenderSceneBuffersGLES3;
@ -137,7 +138,7 @@ struct RenderDataGLES3 {
float luminance_multiplier = 1.0;
RenderingMethod::RenderInfo *render_info = nullptr;
RenderingServerTypes::RenderInfo *render_info = nullptr;
/* Shadow data */
const RendererSceneRender::RenderShadowData *render_shadows = nullptr;
@ -149,7 +150,7 @@ class RasterizerCanvasGLES3;
class RasterizerSceneGLES3 : public RendererSceneRender {
private:
static RasterizerSceneGLES3 *singleton;
RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED;
RSE::ViewportDebugDraw debug_draw = RSE::VIEWPORT_DEBUG_DRAW_DISABLED;
uint64_t scene_pass = 0;
template <typename T>
@ -272,7 +273,7 @@ private:
};
} sort;
RS::PrimitiveType primitive = RS::PRIMITIVE_MAX;
RSE::PrimitiveType primitive = RSE::PRIMITIVE_MAX;
uint32_t flags = 0;
uint32_t surface_index = 0;
uint32_t lod_index = 0;
@ -348,7 +349,7 @@ private:
virtual void set_lightmap_capture(const Color *p_sh9) override;
virtual void clear_light_instances() override;
virtual void pair_light_instance(const RID p_light_instance, RS::LightType light_type, uint32_t placement_idx) override;
virtual void pair_light_instance(const RID p_light_instance, RSE::LightType light_type, uint32_t placement_idx) override;
virtual void pair_reflection_probe_instances(const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) override;
virtual void pair_decal_instances(const RID *p_decal_instances, uint32_t p_decal_instance_count) override {}
virtual void pair_voxel_gi_instances(const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override {}
@ -477,7 +478,7 @@ private:
bool used_depth_prepass = false;
GLES3::SceneShaderData::BlendMode current_blend_mode = GLES3::SceneShaderData::BLEND_MODE_MIX;
RS::CullMode cull_mode = RS::CULL_MODE_BACK;
RSE::CullMode cull_mode = RSE::CULL_MODE_BACK;
GLenum current_depth_function = GL_GEQUAL;
bool current_blend_enabled = false;
@ -494,7 +495,7 @@ private:
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
cull_mode = RS::CULL_MODE_BACK;
cull_mode = RSE::CULL_MODE_BACK;
glDepthMask(GL_FALSE);
current_depth_draw_enabled = false;
@ -514,16 +515,16 @@ private:
current_stencil_compare_mask = 255;
}
void set_gl_cull_mode(RS::CullMode p_mode) {
void set_gl_cull_mode(RSE::CullMode p_mode) {
if (cull_mode != p_mode) {
if (p_mode == RS::CULL_MODE_DISABLED) {
if (p_mode == RSE::CULL_MODE_DISABLED) {
glDisable(GL_CULL_FACE);
} else {
if (cull_mode == RS::CULL_MODE_DISABLED) {
if (cull_mode == RSE::CULL_MODE_DISABLED) {
// Last time was disabled, so enable and set proper face.
glEnable(GL_CULL_FACE);
}
glCullFace(p_mode == RS::CULL_MODE_FRONT ? GL_FRONT : GL_BACK);
glCullFace(p_mode == RSE::CULL_MODE_FRONT ? GL_FRONT : GL_BACK);
}
cull_mode = p_mode;
}
@ -638,13 +639,13 @@ private:
GLuint positional_shadow_buffer = 0;
uint32_t omni_light_count = 0;
uint32_t spot_light_count = 0;
RS::ShadowQuality positional_shadow_quality = RS::ShadowQuality::SHADOW_QUALITY_SOFT_LOW;
RSE::ShadowQuality positional_shadow_quality = RSE::ShadowQuality::SHADOW_QUALITY_SOFT_LOW;
DirectionalLightData *directional_lights = nullptr;
GLuint directional_light_buffer = 0;
DirectionalShadowData *directional_shadows = nullptr;
GLuint directional_shadow_buffer = 0;
RS::ShadowQuality directional_shadow_quality = RS::ShadowQuality::SHADOW_QUALITY_SOFT_LOW;
RSE::ShadowQuality directional_shadow_quality = RSE::ShadowQuality::SHADOW_QUALITY_SOFT_LOW;
} scene_state;
struct RenderListParameters {
@ -727,7 +728,7 @@ private:
void _setup_environment(const RenderDataGLES3 *p_render_data, bool p_no_fog, const Size2i &p_screen_size, bool p_flip_y, const Color &p_default_bg_color, bool p_pancake_shadows, float p_shadow_bias = 0.0);
void _fill_render_list(RenderListType p_render_list, const RenderDataGLES3 *p_render_data, PassMode p_pass_mode, bool p_append = false);
void _render_shadows(const RenderDataGLES3 *p_render_data, const Size2i &p_viewport_size = Size2i(1, 1));
void _render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<RenderGeometryInstance *> &p_instances, float p_lod_distance_multiplier = 0, float p_screen_mesh_lod_threshold = 0.0, RenderingMethod::RenderInfo *p_render_info = nullptr, const Size2i &p_viewport_size = Size2i(1, 1), const Transform3D &p_main_cam_transform = Transform3D());
void _render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<RenderGeometryInstance *> &p_instances, float p_lod_distance_multiplier = 0, float p_screen_mesh_lod_threshold = 0.0, RenderingServerTypes::RenderInfo *p_render_info = nullptr, const Size2i &p_viewport_size = Size2i(1, 1), const Transform3D &p_main_cam_transform = Transform3D());
void _render_post_processing(const RenderDataGLES3 *p_render_data);
template <PassMode p_pass_mode>
@ -755,7 +756,7 @@ protected:
/* Environment */
RS::EnvironmentSSAOQuality ssao_quality = RS::ENV_SSAO_QUALITY_MEDIUM;
RSE::EnvironmentSSAOQuality ssao_quality = RSE::ENV_SSAO_QUALITY_MEDIUM;
bool ssao_half_size = false;
float ssao_adaptive_target = 0.5;
int ssao_blur_passes = 2;
@ -812,7 +813,7 @@ protected:
int radiance_size = 256;
int mipmap_count = 1;
RS::SkyMode mode = RS::SKY_MODE_AUTOMATIC;
RSE::SkyMode mode = RSE::SKY_MODE_AUTOMATIC;
//ReflectionData reflection;
bool reflection_dirty = false;
@ -854,7 +855,7 @@ public:
/* PIPELINES */
virtual void mesh_generate_pipelines(RID p_mesh, bool p_background_compilation) override {}
virtual uint32_t get_pipeline_compilations(RS::PipelineSource p_source) override { return 0; }
virtual uint32_t get_pipeline_compilations(RSE::PipelineSource p_source) override { return 0; }
/* SDFGI UPDATE */
@ -874,7 +875,7 @@ public:
RID sky_allocate() override;
void sky_initialize(RID p_rid) override;
void sky_set_radiance_size(RID p_sky, int p_radiance_size) override;
void sky_set_mode(RID p_sky, RS::SkyMode p_mode) override;
void sky_set_mode(RID p_sky, RSE::SkyMode p_mode) override;
void sky_set_material(RID p_sky, RID p_material) override;
Ref<Image> sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) override;
float sky_get_baked_exposure(RID p_sky) const;
@ -884,15 +885,15 @@ public:
void environment_glow_set_use_bicubic_upscale(bool p_enable) override;
void environment_set_ssr_half_size(bool p_half_size) override;
void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) override;
void environment_set_ssr_roughness_quality(RSE::EnvironmentSSRRoughnessQuality p_quality) override;
void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) override;
void environment_set_ssao_quality(RSE::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) override;
void environment_set_ssil_quality(RS::EnvironmentSSILQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) override;
void environment_set_ssil_quality(RSE::EnvironmentSSILQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) override;
void environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) override;
void environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) override;
void environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) override;
void environment_set_sdfgi_ray_count(RSE::EnvironmentSDFGIRayCount p_ray_count) override;
void environment_set_sdfgi_frames_to_converge(RSE::EnvironmentSDFGIFramesToConverge p_frames) override;
void environment_set_sdfgi_frames_to_update_light(RSE::EnvironmentSDFGIFramesToUpdateLight p_update) override;
void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) override;
void environment_set_volumetric_fog_filter_active(bool p_enable) override;
@ -903,8 +904,8 @@ public:
return use_physical_light_units;
}
void positional_soft_shadow_filter_set_quality(RS::ShadowQuality p_quality) override;
void directional_soft_shadow_filter_set_quality(RS::ShadowQuality p_quality) override;
void positional_soft_shadow_filter_set_quality(RSE::ShadowQuality p_quality) override;
void directional_soft_shadow_filter_set_quality(RSE::ShadowQuality p_quality) override;
RID fog_volume_instance_create(RID p_fog_volume) override;
void fog_volume_instance_set_transform(RID p_fog_volume_instance, const Transform3D &p_transform) override;
@ -917,9 +918,9 @@ public:
bool voxel_gi_needs_update(RID p_probe) const override;
void voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RenderGeometryInstance *> &p_dynamic_objects) override;
void voxel_gi_set_quality(RS::VoxelGIQuality) override;
void voxel_gi_set_quality(RSE::VoxelGIQuality) override;
void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_compositor, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, float p_window_output_max_value, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RenderingMethod::RenderInfo *r_render_info = nullptr) override;
void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_compositor, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, float p_window_output_max_value, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RenderingServerTypes::RenderInfo *r_render_info = nullptr) override;
void render_material(const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, const PagedArray<RenderGeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override;
void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<RenderGeometryInstance *> &p_instances) override;
@ -932,8 +933,8 @@ public:
}
void set_time(double p_time, double p_step) override;
void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) override;
_FORCE_INLINE_ RS::ViewportDebugDraw get_debug_draw_mode() const {
void set_debug_draw_mode(RSE::ViewportDebugDraw p_debug_draw) override;
_FORCE_INLINE_ RSE::ViewportDebugDraw get_debug_draw_mode() const {
return debug_draw;
}
@ -943,7 +944,7 @@ public:
void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) override;
bool screen_space_roughness_limiter_is_active() const override;
void sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) override;
void sub_surface_scattering_set_quality(RSE::SubSurfaceScatteringQuality p_quality) override;
void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) override;
TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) override;
@ -953,8 +954,8 @@ public:
void update() override;
void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) override;
void decals_set_filter(RS::DecalFilter p_filter) override;
void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override;
void decals_set_filter(RSE::DecalFilter p_filter) override;
void light_projectors_set_filter(RSE::LightProjectorFilter p_filter) override;
virtual void lightmaps_set_bicubic_filter(bool p_enable) override;
virtual void material_set_use_debanding(bool p_enable) override;

View file

@ -466,9 +466,9 @@ void ShaderGLES3::_compile_specialization(Version::Specialization &spec, uint32_
spec.ok = true;
}
RS::ShaderNativeSourceCode ShaderGLES3::version_get_native_source_code(RID p_version) {
RenderingServerTypes::ShaderNativeSourceCode ShaderGLES3::version_get_native_source_code(RID p_version) {
Version *version = version_owner.get_or_null(p_version);
RS::ShaderNativeSourceCode source_code;
RenderingServerTypes::ShaderNativeSourceCode source_code;
ERR_FAIL_NULL_V(version, source_code);
source_code.versions.resize(variant_count);
@ -480,7 +480,7 @@ RS::ShaderNativeSourceCode ShaderGLES3::version_get_native_source_code(RID p_ver
StringBuilder builder;
_build_variant_code(builder, i, version, STAGE_TYPE_VERTEX, specialization_default_mask);
RS::ShaderNativeSourceCode::Version::Stage stage;
RenderingServerTypes::ShaderNativeSourceCode::Version::Stage stage;
stage.name = "vertex";
stage.code = builder.as_string();
@ -492,7 +492,7 @@ RS::ShaderNativeSourceCode ShaderGLES3::version_get_native_source_code(RID p_ver
StringBuilder builder;
_build_variant_code(builder, i, version, STAGE_TYPE_FRAGMENT, specialization_default_mask);
RS::ShaderNativeSourceCode::Version::Stage stage;
RenderingServerTypes::ShaderNativeSourceCode::Version::Stage stage;
stage.name = "fragment";
stage.code = builder.as_string();

View file

@ -36,7 +36,7 @@
#include "core/templates/hash_map.h"
#include "core/templates/local_vector.h"
#include "core/templates/rid_owner.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_types.h"
#include "platform_gl.h"
@ -248,7 +248,7 @@ public:
static void set_shader_cache_save_compressed_zstd(bool p_enable);
static void set_shader_cache_save_debug(bool p_enable);
RS::ShaderNativeSourceCode version_get_native_source_code(RID p_version);
RenderingServerTypes::ShaderNativeSourceCode version_get_native_source_code(RID p_version);
void initialize(const String &p_general_defines = "", int p_base_texture_index = 0);
virtual ~ShaderGLES3();

View file

@ -34,6 +34,7 @@
#include "core/config/project_settings.h"
#include "core/math/geometry_3d.h"
#include "core/os/os.h"
#include "drivers/gles3/effects/cubemap_filter.h"
#include "drivers/gles3/rasterizer_scene_gles3.h"
#include "drivers/gles3/rasterizer_util_gles3.h"
@ -63,31 +64,31 @@ LightStorage::~LightStorage() {
/* Light API */
void LightStorage::_light_initialize(RID p_light, RS::LightType p_type) {
void LightStorage::_light_initialize(RID p_light, RSE::LightType p_type) {
Light light;
light.type = p_type;
light.param[RS::LIGHT_PARAM_ENERGY] = 1.0;
light.param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
light.param[RS::LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY] = 1.0;
light.param[RS::LIGHT_PARAM_SPECULAR] = 0.5;
light.param[RS::LIGHT_PARAM_RANGE] = 1.0;
light.param[RS::LIGHT_PARAM_SIZE] = 0.0;
light.param[RS::LIGHT_PARAM_ATTENUATION] = 1.0;
light.param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45;
light.param[RS::LIGHT_PARAM_SPOT_ATTENUATION] = 1.0;
light.param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
light.param[RS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8;
light.param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 1.0;
light.param[RS::LIGHT_PARAM_SHADOW_OPACITY] = 1.0;
light.param[RS::LIGHT_PARAM_SHADOW_BIAS] = 0.02;
light.param[RS::LIGHT_PARAM_SHADOW_BLUR] = 0;
light.param[RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE] = 20.0;
light.param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS] = 0.05;
light.param[RS::LIGHT_PARAM_INTENSITY] = p_type == RS::LIGHT_DIRECTIONAL ? 100000.0 : 1000.0;
light.param[RSE::LIGHT_PARAM_ENERGY] = 1.0;
light.param[RSE::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
light.param[RSE::LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY] = 1.0;
light.param[RSE::LIGHT_PARAM_SPECULAR] = 0.5;
light.param[RSE::LIGHT_PARAM_RANGE] = 1.0;
light.param[RSE::LIGHT_PARAM_SIZE] = 0.0;
light.param[RSE::LIGHT_PARAM_ATTENUATION] = 1.0;
light.param[RSE::LIGHT_PARAM_SPOT_ANGLE] = 45;
light.param[RSE::LIGHT_PARAM_SPOT_ATTENUATION] = 1.0;
light.param[RSE::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
light.param[RSE::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
light.param[RSE::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
light.param[RSE::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
light.param[RSE::LIGHT_PARAM_SHADOW_FADE_START] = 0.8;
light.param[RSE::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 1.0;
light.param[RSE::LIGHT_PARAM_SHADOW_OPACITY] = 1.0;
light.param[RSE::LIGHT_PARAM_SHADOW_BIAS] = 0.02;
light.param[RSE::LIGHT_PARAM_SHADOW_BLUR] = 0;
light.param[RSE::LIGHT_PARAM_SHADOW_PANCAKE_SIZE] = 20.0;
light.param[RSE::LIGHT_PARAM_TRANSMITTANCE_BIAS] = 0.05;
light.param[RSE::LIGHT_PARAM_INTENSITY] = p_type == RSE::LIGHT_DIRECTIONAL ? 100000.0 : 1000.0;
light_owner.initialize_rid(p_light, light);
}
@ -97,7 +98,7 @@ RID LightStorage::directional_light_allocate() {
}
void LightStorage::directional_light_initialize(RID p_rid) {
_light_initialize(p_rid, RS::LIGHT_DIRECTIONAL);
_light_initialize(p_rid, RSE::LIGHT_DIRECTIONAL);
}
RID LightStorage::omni_light_allocate() {
@ -105,7 +106,7 @@ RID LightStorage::omni_light_allocate() {
}
void LightStorage::omni_light_initialize(RID p_rid) {
_light_initialize(p_rid, RS::LIGHT_OMNI);
_light_initialize(p_rid, RSE::LIGHT_OMNI);
}
RID LightStorage::spot_light_allocate() {
@ -113,7 +114,7 @@ RID LightStorage::spot_light_allocate() {
}
void LightStorage::spot_light_initialize(RID p_rid) {
_light_initialize(p_rid, RS::LIGHT_SPOT);
_light_initialize(p_rid, RSE::LIGHT_SPOT);
}
void LightStorage::light_free(RID p_rid) {
@ -132,29 +133,29 @@ void LightStorage::light_set_color(RID p_light, const Color &p_color) {
light->color = p_color;
}
void LightStorage::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
void LightStorage::light_set_param(RID p_light, RSE::LightParam p_param, float p_value) {
Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL(light);
ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
ERR_FAIL_INDEX(p_param, RSE::LIGHT_PARAM_MAX);
if (light->param[p_param] == p_value) {
return;
}
switch (p_param) {
case RS::LIGHT_PARAM_RANGE:
case RS::LIGHT_PARAM_SPOT_ANGLE:
case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
case RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE:
case RS::LIGHT_PARAM_SHADOW_BIAS: {
case RSE::LIGHT_PARAM_RANGE:
case RSE::LIGHT_PARAM_SPOT_ANGLE:
case RSE::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
case RSE::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
case RSE::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
case RSE::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
case RSE::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
case RSE::LIGHT_PARAM_SHADOW_PANCAKE_SIZE:
case RSE::LIGHT_PARAM_SHADOW_BIAS: {
light->version++;
light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
} break;
case RS::LIGHT_PARAM_SIZE: {
case RSE::LIGHT_PARAM_SIZE: {
if ((light->param[p_param] > CMP_EPSILON) != (p_value > CMP_EPSILON)) {
//changing from no size to size and the opposite
light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR);
@ -185,15 +186,15 @@ void LightStorage::light_set_projector(RID p_light, RID p_texture) {
return;
}
if (light->type != RS::LIGHT_DIRECTIONAL && light->projector.is_valid()) {
texture_storage->texture_remove_from_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI);
if (light->type != RSE::LIGHT_DIRECTIONAL && light->projector.is_valid()) {
texture_storage->texture_remove_from_decal_atlas(light->projector, light->type == RSE::LIGHT_OMNI);
}
light->projector = p_texture;
if (light->type != RS::LIGHT_DIRECTIONAL) {
if (light->type != RSE::LIGHT_DIRECTIONAL) {
if (light->projector.is_valid()) {
texture_storage->texture_add_to_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI);
texture_storage->texture_add_to_decal_atlas(light->projector, light->type == RSE::LIGHT_OMNI);
}
light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR);
}
@ -253,7 +254,7 @@ void LightStorage::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled)
light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
}
void LightStorage::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {
void LightStorage::light_set_bake_mode(RID p_light, RSE::LightBakeMode p_bake_mode) {
Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL(light);
@ -263,7 +264,7 @@ void LightStorage::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mod
light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
}
void LightStorage::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
void LightStorage::light_omni_set_shadow_mode(RID p_light, RSE::LightOmniShadowMode p_mode) {
Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL(light);
@ -273,14 +274,14 @@ void LightStorage::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMo
light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
}
RS::LightOmniShadowMode LightStorage::light_omni_get_shadow_mode(RID p_light) {
RSE::LightOmniShadowMode LightStorage::light_omni_get_shadow_mode(RID p_light) {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_OMNI_SHADOW_CUBE);
ERR_FAIL_NULL_V(light, RSE::LIGHT_OMNI_SHADOW_CUBE);
return light->omni_shadow_mode;
}
void LightStorage::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
void LightStorage::light_directional_set_shadow_mode(RID p_light, RSE::LightDirectionalShadowMode p_mode) {
Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL(light);
@ -305,30 +306,30 @@ bool LightStorage::light_directional_get_blend_splits(RID p_light) const {
return light->directional_blend_splits;
}
void LightStorage::light_directional_set_sky_mode(RID p_light, RS::LightDirectionalSkyMode p_mode) {
void LightStorage::light_directional_set_sky_mode(RID p_light, RSE::LightDirectionalSkyMode p_mode) {
Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL(light);
light->directional_sky_mode = p_mode;
}
RS::LightDirectionalSkyMode LightStorage::light_directional_get_sky_mode(RID p_light) const {
RSE::LightDirectionalSkyMode LightStorage::light_directional_get_sky_mode(RID p_light) const {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
ERR_FAIL_NULL_V(light, RSE::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
return light->directional_sky_mode;
}
RS::LightDirectionalShadowMode LightStorage::light_directional_get_shadow_mode(RID p_light) {
RSE::LightDirectionalShadowMode LightStorage::light_directional_get_shadow_mode(RID p_light) {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
ERR_FAIL_NULL_V(light, RSE::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
return light->directional_shadow_mode;
}
RS::LightBakeMode LightStorage::light_get_bake_mode(RID p_light) {
RSE::LightBakeMode LightStorage::light_get_bake_mode(RID p_light) {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_BAKE_DISABLED);
ERR_FAIL_NULL_V(light, RSE::LIGHT_BAKE_DISABLED);
return light->bake_mode;
}
@ -352,9 +353,9 @@ AABB LightStorage::light_get_aabb(RID p_light) const {
ERR_FAIL_NULL_V(light, AABB());
switch (light->type) {
case RS::LIGHT_SPOT: {
float len = light->param[RS::LIGHT_PARAM_RANGE];
float angle = Math::deg_to_rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE]);
case RSE::LIGHT_SPOT: {
float len = light->param[RSE::LIGHT_PARAM_RANGE];
float angle = Math::deg_to_rad(light->param[RSE::LIGHT_PARAM_SPOT_ANGLE]);
if (angle > Math::PI * 0.5) {
// Light casts backwards as well.
@ -364,11 +365,11 @@ AABB LightStorage::light_get_aabb(RID p_light) const {
float size = Math::sin(angle) * len;
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
};
case RS::LIGHT_OMNI: {
float r = light->param[RS::LIGHT_PARAM_RANGE];
case RSE::LIGHT_OMNI: {
float r = light->param[RSE::LIGHT_PARAM_RANGE];
return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
};
case RS::LIGHT_DIRECTIONAL: {
case RSE::LIGHT_DIRECTIONAL: {
return AABB();
};
}
@ -466,7 +467,7 @@ void LightStorage::reflection_probe_free(RID p_rid) {
reflection_probe_owner.free(p_rid);
}
void LightStorage::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
void LightStorage::reflection_probe_set_update_mode(RID p_probe, RSE::ReflectionProbeUpdateMode p_mode) {
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_NULL(reflection_probe);
@ -488,7 +489,7 @@ void LightStorage::reflection_probe_set_blend_distance(RID p_probe, float p_blen
reflection_probe->blend_distance = p_blend_distance;
}
void LightStorage::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) {
void LightStorage::reflection_probe_set_ambient_mode(RID p_probe, RSE::ReflectionProbeAmbientMode p_mode) {
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_NULL(reflection_probe);
@ -587,9 +588,9 @@ AABB LightStorage::reflection_probe_get_aabb(RID p_probe) const {
return aabb;
}
RS::ReflectionProbeUpdateMode LightStorage::reflection_probe_get_update_mode(RID p_probe) const {
RSE::ReflectionProbeUpdateMode LightStorage::reflection_probe_get_update_mode(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_NULL_V(reflection_probe, RenderingServer::REFLECTION_PROBE_UPDATE_ONCE);
ERR_FAIL_NULL_V(reflection_probe, RSE::REFLECTION_PROBE_UPDATE_ONCE);
return reflection_probe->update_mode;
}
@ -795,7 +796,7 @@ bool LightStorage::reflection_probe_instance_needs_redraw(RID p_instance) {
return true;
}
if (reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS) {
if (reflection_probe_get_update_mode(rpi->probe) == RSE::REFLECTION_PROBE_UPDATE_ALWAYS) {
return true;
}
@ -1016,7 +1017,7 @@ bool LightStorage::reflection_probe_instance_postprocess_step(RID p_instance) {
return false;
}
if (LightStorage::get_singleton()->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS) {
if (LightStorage::get_singleton()->reflection_probe_get_update_mode(rpi->probe) == RSE::REFLECTION_PROBE_UPDATE_ALWAYS) {
// Using real time reflections, all roughness is done in one step
for (int m = 0; m < atlas->mipmap_count; m++) {
const GLES3::ReflectionAtlas::Reflection &reflection = atlas->reflections[rpi->atlas_index];
@ -1242,14 +1243,14 @@ void LightStorage::lightmap_set_shadowmask_textures(RID p_lightmap, RID p_shadow
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
}
RS::ShadowmaskMode LightStorage::lightmap_get_shadowmask_mode(RID p_lightmap) {
RSE::ShadowmaskMode LightStorage::lightmap_get_shadowmask_mode(RID p_lightmap) {
Lightmap *lightmap = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_NULL_V(lightmap, RS::SHADOWMASK_MODE_NONE);
ERR_FAIL_NULL_V(lightmap, RSE::SHADOWMASK_MODE_NONE);
return lightmap->shadowmask_mode;
}
void LightStorage::lightmap_set_shadowmask_mode(RID p_lightmap, RS::ShadowmaskMode p_mode) {
void LightStorage::lightmap_set_shadowmask_mode(RID p_lightmap, RSE::ShadowmaskMode p_mode) {
Lightmap *lightmap = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_NULL(lightmap);
lightmap->shadowmask_mode = p_mode;
@ -1468,7 +1469,7 @@ bool LightStorage::shadow_atlas_update_light(RID p_atlas, RID p_light_instance,
old_subdivision = shadow_atlas->quadrants[old_quadrant].subdivision;
}
bool is_omni = li->light_type == RS::LIGHT_OMNI;
bool is_omni = li->light_type == RSE::LIGHT_OMNI;
bool found_shadow = false;
int new_quadrant = -1;
int new_shadow = -1;
@ -1735,12 +1736,12 @@ int LightStorage::get_directional_light_shadow_size(RID p_light_instance) {
ERR_FAIL_NULL_V(light_instance, 0);
switch (light_directional_get_shadow_mode(light_instance->light)) {
case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL:
case RSE::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL:
break; //none
case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS:
case RSE::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS:
r.size.height /= 2;
break;
case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS:
case RSE::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS:
r.size /= 2;
break;
}

View file

@ -47,14 +47,14 @@ namespace GLES3 {
/* LIGHT */
struct Light {
RS::LightType type;
float param[RS::LIGHT_PARAM_MAX];
RSE::LightType type;
float param[RSE::LIGHT_PARAM_MAX];
Color color = Color(1, 1, 1, 1);
RID projector;
bool shadow = false;
bool negative = false;
bool reverse_cull = false;
RS::LightBakeMode bake_mode = RS::LIGHT_BAKE_DYNAMIC;
RSE::LightBakeMode bake_mode = RSE::LIGHT_BAKE_DYNAMIC;
uint32_t max_sdfgi_cascade = 2;
uint32_t cull_mask = 0xFFFFFFFF;
uint32_t shadow_caster_mask = 0xFFFFFFFF;
@ -62,10 +62,10 @@ struct Light {
real_t distance_fade_begin = 40.0;
real_t distance_fade_shadow = 50.0;
real_t distance_fade_length = 10.0;
RS::LightOmniShadowMode omni_shadow_mode = RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
RS::LightDirectionalShadowMode directional_shadow_mode = RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL;
RSE::LightOmniShadowMode omni_shadow_mode = RSE::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
RSE::LightDirectionalShadowMode directional_shadow_mode = RSE::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL;
bool directional_blend_splits = false;
RS::LightDirectionalSkyMode directional_sky_mode = RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY;
RSE::LightDirectionalSkyMode directional_sky_mode = RSE::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY;
uint64_t version = 0;
Dependency dependency;
@ -86,7 +86,7 @@ struct LightInstance {
};
ShadowTransform shadow_transform[6];
RS::LightType light_type = RS::LIGHT_DIRECTIONAL;
RSE::LightType light_type = RSE::LIGHT_DIRECTIONAL;
AABB aabb;
RID self;
@ -113,10 +113,10 @@ struct LightInstance {
/* REFLECTION PROBE */
struct ReflectionProbe {
RS::ReflectionProbeUpdateMode update_mode = RS::REFLECTION_PROBE_UPDATE_ONCE;
RSE::ReflectionProbeUpdateMode update_mode = RSE::REFLECTION_PROBE_UPDATE_ONCE;
float intensity = 1.0;
float blend_distance = 1.0;
RS::ReflectionProbeAmbientMode ambient_mode = RS::REFLECTION_PROBE_AMBIENT_ENVIRONMENT;
RSE::ReflectionProbeAmbientMode ambient_mode = RSE::REFLECTION_PROBE_AMBIENT_ENVIRONMENT;
Color ambient_color;
float ambient_color_energy = 1.0;
float max_distance = 0;
@ -182,7 +182,7 @@ struct Lightmap {
float baked_exposure = 1.0;
Vector2i light_texture_size;
int32_t array_index = -1; //unassigned
RS::ShadowmaskMode shadowmask_mode = RS::SHADOWMASK_MODE_NONE;
RSE::ShadowmaskMode shadowmask_mode = RSE::SHADOWMASK_MODE_NONE;
PackedVector3Array points;
PackedColorArray point_sh;
PackedInt32Array tetrahedra;
@ -307,7 +307,7 @@ public:
Light *get_light(RID p_rid) { return light_owner.get_or_null(p_rid); }
bool owns_light(RID p_rid) { return light_owner.owns(p_rid); }
void _light_initialize(RID p_rid, RS::LightType p_type);
void _light_initialize(RID p_rid, RSE::LightType p_type);
virtual RID directional_light_allocate() override;
virtual void directional_light_initialize(RID p_rid) override;
@ -319,7 +319,7 @@ public:
virtual void light_free(RID p_rid) override;
virtual void light_set_color(RID p_light, const Color &p_color) override;
virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value) override;
virtual void light_set_param(RID p_light, RSE::LightParam p_param, float p_value) override;
virtual void light_set_shadow(RID p_light, bool p_enabled) override;
virtual void light_set_projector(RID p_light, RID p_texture) override;
virtual void light_set_negative(RID p_light, bool p_enable) override;
@ -328,28 +328,28 @@ public:
virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) override;
virtual void light_set_shadow_caster_mask(RID p_light, uint32_t p_caster_mask) override;
virtual uint32_t light_get_shadow_caster_mask(RID p_light) const override;
virtual void light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) override;
virtual void light_set_bake_mode(RID p_light, RSE::LightBakeMode p_bake_mode) override;
virtual void light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) override {}
virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) override;
virtual void light_omni_set_shadow_mode(RID p_light, RSE::LightOmniShadowMode p_mode) override;
virtual void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) override;
virtual void light_directional_set_shadow_mode(RID p_light, RSE::LightDirectionalShadowMode p_mode) override;
virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) override;
virtual bool light_directional_get_blend_splits(RID p_light) const override;
virtual void light_directional_set_sky_mode(RID p_light, RS::LightDirectionalSkyMode p_mode) override;
virtual RS::LightDirectionalSkyMode light_directional_get_sky_mode(RID p_light) const override;
virtual void light_directional_set_sky_mode(RID p_light, RSE::LightDirectionalSkyMode p_mode) override;
virtual RSE::LightDirectionalSkyMode light_directional_get_sky_mode(RID p_light) const override;
virtual RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) override;
virtual RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) override;
virtual RS::LightType light_get_type(RID p_light) const override {
virtual RSE::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) override;
virtual RSE::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) override;
virtual RSE::LightType light_get_type(RID p_light) const override {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
ERR_FAIL_NULL_V(light, RSE::LIGHT_DIRECTIONAL);
return light->type;
}
virtual AABB light_get_aabb(RID p_light) const override;
virtual float light_get_param(RID p_light, RS::LightParam p_param) override {
virtual float light_get_param(RID p_light, RSE::LightParam p_param) override {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, 0);
@ -392,21 +392,21 @@ public:
virtual bool light_has_shadow(RID p_light) const override {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
ERR_FAIL_NULL_V(light, RSE::LIGHT_DIRECTIONAL);
return light->shadow;
}
virtual bool light_has_projector(RID p_light) const override {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
ERR_FAIL_NULL_V(light, RSE::LIGHT_DIRECTIONAL);
return TextureStorage::get_singleton()->owns_texture(light->projector);
}
_FORCE_INLINE_ bool light_is_negative(RID p_light) const {
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL);
ERR_FAIL_NULL_V(light, RSE::LIGHT_DIRECTIONAL);
return light->negative;
}
@ -415,7 +415,7 @@ public:
const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_NULL_V(light, 0.0);
return light->param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS];
return light->param[RSE::LIGHT_PARAM_TRANSMITTANCE_BIAS];
}
virtual bool light_get_reverse_cull_face_mode(RID p_light) const override {
@ -425,7 +425,7 @@ public:
return light->reverse_cull;
}
virtual RS::LightBakeMode light_get_bake_mode(RID p_light) override;
virtual RSE::LightBakeMode light_get_bake_mode(RID p_light) override;
virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) override { return 0; }
virtual uint64_t light_get_version(RID p_light) const override;
virtual uint32_t light_get_cull_mask(RID p_light) const override;
@ -614,7 +614,7 @@ public:
return li->directional_rect;
}
_FORCE_INLINE_ RS::LightType light_instance_get_type(RID p_light_instance) {
_FORCE_INLINE_ RSE::LightType light_instance_get_type(RID p_light_instance) {
LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->light_type;
}
@ -638,10 +638,10 @@ public:
virtual void reflection_probe_initialize(RID p_rid) override;
virtual void reflection_probe_free(RID p_rid) override;
virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) override;
virtual void reflection_probe_set_update_mode(RID p_probe, RSE::ReflectionProbeUpdateMode p_mode) override;
virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) override;
virtual void reflection_probe_set_blend_distance(RID p_probe, float p_blend_distance) override;
virtual void reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) override;
virtual void reflection_probe_set_ambient_mode(RID p_probe, RSE::ReflectionProbeAmbientMode p_mode) override;
virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) override;
virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) override;
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) override;
@ -657,7 +657,7 @@ public:
virtual float reflection_probe_get_mesh_lod_threshold(RID p_probe) const override;
virtual AABB reflection_probe_get_aabb(RID p_probe) const override;
virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const override;
virtual RSE::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const override;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const override;
virtual uint32_t reflection_probe_get_reflection_mask(RID p_probe) const override;
virtual Vector3 reflection_probe_get_size(RID p_probe) const override;
@ -738,8 +738,8 @@ public:
virtual float lightmap_get_probe_capture_update_speed() const override;
virtual void lightmap_set_shadowmask_textures(RID p_lightmap, RID p_shadow) override;
virtual RS::ShadowmaskMode lightmap_get_shadowmask_mode(RID p_lightmap) override;
virtual void lightmap_set_shadowmask_mode(RID p_lightmap, RS::ShadowmaskMode p_mode) override;
virtual RSE::ShadowmaskMode lightmap_get_shadowmask_mode(RID p_lightmap) override;
virtual void lightmap_set_shadowmask_mode(RID p_lightmap, RSE::ShadowmaskMode p_mode) override;
/* LIGHTMAP INSTANCE */

View file

@ -33,10 +33,12 @@
#ifdef GLES3_ENABLED
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
#include "drivers/gles3/rasterizer_canvas_gles3.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "drivers/gles3/storage/config.h"
#include "drivers/gles3/storage/texture_storage.h"
#include "servers/rendering/rendering_server_types.h"
#include "servers/rendering/storage/variant_converters.h"
using namespace GLES3;
@ -680,36 +682,36 @@ static const GLenum target_from_type[ShaderLanguage::TYPE_MAX] = {
GL_TEXTURE_2D, // TYPE_STRUCT
};
static const RS::CanvasItemTextureRepeat repeat_from_uniform[ShaderLanguage::REPEAT_DEFAULT + 1] = {
RS::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, // ShaderLanguage::TextureRepeat::REPEAT_DISABLE,
RS::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, // ShaderLanguage::TextureRepeat::REPEAT_ENABLE,
RS::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, // ShaderLanguage::TextureRepeat::REPEAT_DEFAULT,
static const RSE::CanvasItemTextureRepeat repeat_from_uniform[ShaderLanguage::REPEAT_DEFAULT + 1] = {
RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, // ShaderLanguage::TextureRepeat::REPEAT_DISABLE,
RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, // ShaderLanguage::TextureRepeat::REPEAT_ENABLE,
RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, // ShaderLanguage::TextureRepeat::REPEAT_DEFAULT,
};
static const RS::CanvasItemTextureRepeat repeat_from_uniform_canvas[ShaderLanguage::REPEAT_DEFAULT + 1] = {
RS::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, // ShaderLanguage::TextureRepeat::REPEAT_DISABLE,
RS::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, // ShaderLanguage::TextureRepeat::REPEAT_ENABLE,
RS::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, // ShaderLanguage::TextureRepeat::REPEAT_DEFAULT,
static const RSE::CanvasItemTextureRepeat repeat_from_uniform_canvas[ShaderLanguage::REPEAT_DEFAULT + 1] = {
RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, // ShaderLanguage::TextureRepeat::REPEAT_DISABLE,
RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, // ShaderLanguage::TextureRepeat::REPEAT_ENABLE,
RSE::CanvasItemTextureRepeat::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, // ShaderLanguage::TextureRepeat::REPEAT_DEFAULT,
};
static const RS::CanvasItemTextureFilter filter_from_uniform[ShaderLanguage::FILTER_DEFAULT + 1] = {
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, // ShaderLanguage::TextureFilter::FILTER_NEAREST,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, // ShaderLanguage::TextureFilter::FILTER_LINEAR,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP_ANISOTROPIC,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP_ANISOTROPIC,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_DEFAULT,
static const RSE::CanvasItemTextureFilter filter_from_uniform[ShaderLanguage::FILTER_DEFAULT + 1] = {
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, // ShaderLanguage::TextureFilter::FILTER_NEAREST,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, // ShaderLanguage::TextureFilter::FILTER_LINEAR,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP_ANISOTROPIC,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP_ANISOTROPIC,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_DEFAULT,
};
static const RS::CanvasItemTextureFilter filter_from_uniform_canvas[ShaderLanguage::FILTER_DEFAULT + 1] = {
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, // ShaderLanguage::TextureFilter::FILTER_NEAREST,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, // ShaderLanguage::TextureFilter::FILTER_LINEAR,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP_ANISOTROPIC,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP_ANISOTROPIC,
RS::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, // ShaderLanguage::TextureFilter::FILTER_DEFAULT,
static const RSE::CanvasItemTextureFilter filter_from_uniform_canvas[ShaderLanguage::FILTER_DEFAULT + 1] = {
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, // ShaderLanguage::TextureFilter::FILTER_NEAREST,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, // ShaderLanguage::TextureFilter::FILTER_LINEAR,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_NEAREST_MIPMAP_ANISOTROPIC,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, // ShaderLanguage::TextureFilter::FILTER_LINEAR_MIPMAP_ANISOTROPIC,
RSE::CanvasItemTextureFilter::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, // ShaderLanguage::TextureFilter::FILTER_DEFAULT,
};
void MaterialData::update_uniform_buffer(const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const HashMap<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size) {
@ -834,7 +836,7 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
#ifdef TOOLS_ENABLED
Texture *roughness_detect_texture = nullptr;
RS::TextureDetectRoughnessChannel roughness_channel = RS::TEXTURE_DETECT_ROUGHNESS_R;
RSE::TextureDetectRoughnessChannel roughness_channel = RSE::TEXTURE_DETECT_ROUGHNESS_R;
Texture *normal_detect_texture = nullptr;
#endif
@ -1039,7 +1041,7 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
if (tex->detect_roughness_callback && (p_texture_uniforms[i].hint >= ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R || p_texture_uniforms[i].hint <= ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_GRAY)) {
//find the normal texture
roughness_detect_texture = tex;
roughness_channel = RS::TextureDetectRoughnessChannel(p_texture_uniforms[i].hint - ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R);
roughness_channel = RSE::TextureDetectRoughnessChannel(p_texture_uniforms[i].hint - ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R);
}
#endif
}
@ -1131,19 +1133,19 @@ MaterialStorage *MaterialStorage::get_singleton() {
MaterialStorage::MaterialStorage() {
singleton = this;
shader_data_request_func[RS::SHADER_SPATIAL] = _create_scene_shader_func;
shader_data_request_func[RS::SHADER_CANVAS_ITEM] = _create_canvas_shader_func;
shader_data_request_func[RS::SHADER_PARTICLES] = _create_particles_shader_func;
shader_data_request_func[RS::SHADER_SKY] = _create_sky_shader_func;
shader_data_request_func[RS::SHADER_TEXTURE_BLIT] = _create_tex_blit_shader_func;
shader_data_request_func[RS::SHADER_FOG] = nullptr;
shader_data_request_func[RSE::SHADER_SPATIAL] = _create_scene_shader_func;
shader_data_request_func[RSE::SHADER_CANVAS_ITEM] = _create_canvas_shader_func;
shader_data_request_func[RSE::SHADER_PARTICLES] = _create_particles_shader_func;
shader_data_request_func[RSE::SHADER_SKY] = _create_sky_shader_func;
shader_data_request_func[RSE::SHADER_TEXTURE_BLIT] = _create_tex_blit_shader_func;
shader_data_request_func[RSE::SHADER_FOG] = nullptr;
material_data_request_func[RS::SHADER_SPATIAL] = _create_scene_material_func;
material_data_request_func[RS::SHADER_CANVAS_ITEM] = _create_canvas_material_func;
material_data_request_func[RS::SHADER_PARTICLES] = _create_particles_material_func;
material_data_request_func[RS::SHADER_SKY] = _create_sky_material_func;
material_data_request_func[RS::SHADER_TEXTURE_BLIT] = _create_tex_blit_material_func;
material_data_request_func[RS::SHADER_FOG] = nullptr;
material_data_request_func[RSE::SHADER_SPATIAL] = _create_scene_material_func;
material_data_request_func[RSE::SHADER_CANVAS_ITEM] = _create_canvas_material_func;
material_data_request_func[RSE::SHADER_PARTICLES] = _create_particles_material_func;
material_data_request_func[RSE::SHADER_SKY] = _create_sky_material_func;
material_data_request_func[RSE::SHADER_TEXTURE_BLIT] = _create_tex_blit_material_func;
material_data_request_func[RSE::SHADER_FOG] = nullptr;
static_assert(sizeof(GlobalShaderUniforms::Value) == 16);
@ -1612,9 +1614,9 @@ int32_t MaterialStorage::_global_shader_uniform_allocate(uint32_t p_elements) {
return -1;
}
void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value) {
void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RSE::GlobalShaderParameterType p_type, const Variant &p_value) {
switch (p_type) {
case RS::GLOBAL_VAR_TYPE_BOOL: {
case RSE::GLOBAL_VAR_TYPE_BOOL: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
bool b = p_value;
bv.x = b ? 1.0 : 0.0;
@ -1623,7 +1625,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.w = 0.0;
} break;
case RS::GLOBAL_VAR_TYPE_BVEC2: {
case RSE::GLOBAL_VAR_TYPE_BVEC2: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
uint32_t bvec = p_value;
bv.x = (bvec & 1) ? 1.0 : 0.0;
@ -1631,7 +1633,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = 0.0;
bv.w = 0.0;
} break;
case RS::GLOBAL_VAR_TYPE_BVEC3: {
case RSE::GLOBAL_VAR_TYPE_BVEC3: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
uint32_t bvec = p_value;
bv.x = (bvec & 1) ? 1.0 : 0.0;
@ -1639,7 +1641,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = (bvec & 4) ? 1.0 : 0.0;
bv.w = 0.0;
} break;
case RS::GLOBAL_VAR_TYPE_BVEC4: {
case RSE::GLOBAL_VAR_TYPE_BVEC4: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
uint32_t bvec = p_value;
bv.x = (bvec & 1) ? 1.0 : 0.0;
@ -1647,7 +1649,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = (bvec & 4) ? 1.0 : 0.0;
bv.w = (bvec & 8) ? 1.0 : 0.0;
} break;
case RS::GLOBAL_VAR_TYPE_INT: {
case RSE::GLOBAL_VAR_TYPE_INT: {
GlobalShaderUniforms::ValueInt &bv = *(GlobalShaderUniforms::ValueInt *)&global_shader_uniforms.buffer_values[p_index];
int32_t v = p_value;
bv.x = v;
@ -1655,7 +1657,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = 0;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_IVEC2: {
case RSE::GLOBAL_VAR_TYPE_IVEC2: {
GlobalShaderUniforms::ValueInt &bv = *(GlobalShaderUniforms::ValueInt *)&global_shader_uniforms.buffer_values[p_index];
Vector2i v = convert_to_vector<Vector2i>(p_value);
bv.x = v.x;
@ -1663,7 +1665,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = 0;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_IVEC3: {
case RSE::GLOBAL_VAR_TYPE_IVEC3: {
GlobalShaderUniforms::ValueInt &bv = *(GlobalShaderUniforms::ValueInt *)&global_shader_uniforms.buffer_values[p_index];
Vector3i v = convert_to_vector<Vector3i>(p_value);
bv.x = v.x;
@ -1671,7 +1673,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.z;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_IVEC4: {
case RSE::GLOBAL_VAR_TYPE_IVEC4: {
GlobalShaderUniforms::ValueInt &bv = *(GlobalShaderUniforms::ValueInt *)&global_shader_uniforms.buffer_values[p_index];
Vector4i v = convert_to_vector<Vector4i>(p_value);
bv.x = v.x;
@ -1679,7 +1681,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.z;
bv.w = v.w;
} break;
case RS::GLOBAL_VAR_TYPE_RECT2I: {
case RSE::GLOBAL_VAR_TYPE_RECT2I: {
GlobalShaderUniforms::ValueInt &bv = *(GlobalShaderUniforms::ValueInt *)&global_shader_uniforms.buffer_values[p_index];
Rect2i v = p_value;
bv.x = v.position.x;
@ -1687,7 +1689,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.size.x;
bv.w = v.size.y;
} break;
case RS::GLOBAL_VAR_TYPE_UINT: {
case RSE::GLOBAL_VAR_TYPE_UINT: {
GlobalShaderUniforms::ValueUInt &bv = *(GlobalShaderUniforms::ValueUInt *)&global_shader_uniforms.buffer_values[p_index];
uint32_t v = p_value;
bv.x = v;
@ -1695,7 +1697,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = 0;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_UVEC2: {
case RSE::GLOBAL_VAR_TYPE_UVEC2: {
GlobalShaderUniforms::ValueUInt &bv = *(GlobalShaderUniforms::ValueUInt *)&global_shader_uniforms.buffer_values[p_index];
Vector2i v = convert_to_vector<Vector2i>(p_value);
bv.x = v.x;
@ -1703,7 +1705,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = 0;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_UVEC3: {
case RSE::GLOBAL_VAR_TYPE_UVEC3: {
GlobalShaderUniforms::ValueUInt &bv = *(GlobalShaderUniforms::ValueUInt *)&global_shader_uniforms.buffer_values[p_index];
Vector3i v = convert_to_vector<Vector3i>(p_value);
bv.x = v.x;
@ -1711,7 +1713,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.z;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_UVEC4: {
case RSE::GLOBAL_VAR_TYPE_UVEC4: {
GlobalShaderUniforms::ValueUInt &bv = *(GlobalShaderUniforms::ValueUInt *)&global_shader_uniforms.buffer_values[p_index];
Vector4i v = convert_to_vector<Vector4i>(p_value);
bv.x = v.x;
@ -1719,7 +1721,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.z;
bv.w = v.w;
} break;
case RS::GLOBAL_VAR_TYPE_FLOAT: {
case RSE::GLOBAL_VAR_TYPE_FLOAT: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
float v = p_value;
bv.x = v;
@ -1727,7 +1729,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = 0;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_VEC2: {
case RSE::GLOBAL_VAR_TYPE_VEC2: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
Vector2 v = convert_to_vector<Vector2>(p_value);
bv.x = v.x;
@ -1735,7 +1737,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = 0;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_VEC3: {
case RSE::GLOBAL_VAR_TYPE_VEC3: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
Vector3 v = convert_to_vector<Vector3>(p_value);
bv.x = v.x;
@ -1743,7 +1745,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.z;
bv.w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_VEC4: {
case RSE::GLOBAL_VAR_TYPE_VEC4: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
Vector4 v = convert_to_vector<Vector4>(p_value);
bv.x = v.x;
@ -1751,7 +1753,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.z;
bv.w = v.w;
} break;
case RS::GLOBAL_VAR_TYPE_COLOR: {
case RSE::GLOBAL_VAR_TYPE_COLOR: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
Color v = p_value;
bv.x = v.r;
@ -1767,7 +1769,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv_linear.w = v.a;
} break;
case RS::GLOBAL_VAR_TYPE_RECT2: {
case RSE::GLOBAL_VAR_TYPE_RECT2: {
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
Rect2 v = p_value;
bv.x = v.position.x;
@ -1775,7 +1777,7 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv.z = v.size.x;
bv.w = v.size.y;
} break;
case RS::GLOBAL_VAR_TYPE_MAT2: {
case RSE::GLOBAL_VAR_TYPE_MAT2: {
GlobalShaderUniforms::Value *bv = &global_shader_uniforms.buffer_values[p_index];
Vector<float> m2 = p_value;
if (m2.size() < 4) {
@ -1792,25 +1794,25 @@ void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS
bv[1].w = 0;
} break;
case RS::GLOBAL_VAR_TYPE_MAT3: {
case RSE::GLOBAL_VAR_TYPE_MAT3: {
GlobalShaderUniforms::Value *bv = &global_shader_uniforms.buffer_values[p_index];
Basis v = p_value;
convert_item_std140<Basis>(v, &bv->x);
} break;
case RS::GLOBAL_VAR_TYPE_MAT4: {
case RSE::GLOBAL_VAR_TYPE_MAT4: {
GlobalShaderUniforms::Value *bv = &global_shader_uniforms.buffer_values[p_index];
Projection m = p_value;
convert_item_std140<Projection>(m, &bv->x);
} break;
case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
case RSE::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
GlobalShaderUniforms::Value *bv = &global_shader_uniforms.buffer_values[p_index];
Transform2D v = p_value;
convert_item_std140<Transform2D>(v, &bv->x);
} break;
case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
case RSE::GLOBAL_VAR_TYPE_TRANSFORM: {
GlobalShaderUniforms::Value *bv = &global_shader_uniforms.buffer_values[p_index];
Transform3D v = p_value;
convert_item_std140<Transform3D>(v, &bv->x);
@ -1838,27 +1840,27 @@ void MaterialStorage::_global_shader_uniform_mark_buffer_dirty(int32_t p_index,
}
}
void MaterialStorage::global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) {
void MaterialStorage::global_shader_parameter_add(const StringName &p_name, RSE::GlobalShaderParameterType p_type, const Variant &p_value) {
ERR_FAIL_COND(global_shader_uniforms.variables.has(p_name));
GlobalShaderUniforms::Variable gv;
gv.type = p_type;
gv.value = p_value;
gv.buffer_index = -1;
if (p_type >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) {
if (p_type >= RSE::GLOBAL_VAR_TYPE_SAMPLER2D) {
//is texture
global_shader_uniforms.must_update_texture_materials = true; //normally there are none
} else {
gv.buffer_elements = 1;
if (p_type == RS::GLOBAL_VAR_TYPE_COLOR || p_type == RS::GLOBAL_VAR_TYPE_MAT2) {
if (p_type == RSE::GLOBAL_VAR_TYPE_COLOR || p_type == RSE::GLOBAL_VAR_TYPE_MAT2) {
//color needs to elements to store srgb and linear
gv.buffer_elements = 2;
}
if (p_type == RS::GLOBAL_VAR_TYPE_MAT3 || p_type == RS::GLOBAL_VAR_TYPE_TRANSFORM_2D) {
if (p_type == RSE::GLOBAL_VAR_TYPE_MAT3 || p_type == RSE::GLOBAL_VAR_TYPE_TRANSFORM_2D) {
//color needs to elements to store srgb and linear
gv.buffer_elements = 3;
}
if (p_type == RS::GLOBAL_VAR_TYPE_MAT4 || p_type == RS::GLOBAL_VAR_TYPE_TRANSFORM) {
if (p_type == RSE::GLOBAL_VAR_TYPE_MAT4 || p_type == RSE::GLOBAL_VAR_TYPE_TRANSFORM) {
//color needs to elements to store srgb and linear
gv.buffer_elements = 4;
}
@ -1969,17 +1971,17 @@ Variant MaterialStorage::global_shader_parameter_get(const StringName &p_name) c
return global_shader_uniforms.variables[p_name].value;
}
RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type_internal(const StringName &p_name) const {
RSE::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type_internal(const StringName &p_name) const {
if (!global_shader_uniforms.variables.has(p_name)) {
return RS::GLOBAL_VAR_TYPE_MAX;
return RSE::GLOBAL_VAR_TYPE_MAX;
}
return global_shader_uniforms.variables[p_name].type;
}
RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type(const StringName &p_name) const {
RSE::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type(const StringName &p_name) const {
if (!Engine::get_singleton()->is_editor_hint()) {
ERR_FAIL_V_MSG(RS::GLOBAL_VAR_TYPE_MAX, "This function should never be used outside the editor, it can severely damage performance.");
ERR_FAIL_V_MSG(RSE::GLOBAL_VAR_TYPE_MAX, "This function should never be used outside the editor, it can severely damage performance.");
}
return global_shader_parameter_get_type_internal(p_name);
@ -1999,7 +2001,7 @@ void MaterialStorage::global_shader_parameters_load_settings(bool p_load_texture
String type = d["type"];
static const char *global_var_type_names[RS::GLOBAL_VAR_TYPE_MAX] = {
static const char *global_var_type_names[RSE::GLOBAL_VAR_TYPE_MAX] = {
"bool",
"bvec2",
"bvec3",
@ -2031,20 +2033,20 @@ void MaterialStorage::global_shader_parameters_load_settings(bool p_load_texture
"samplerExternalOES"
};
RS::GlobalShaderParameterType gvtype = RS::GLOBAL_VAR_TYPE_MAX;
RSE::GlobalShaderParameterType gvtype = RSE::GLOBAL_VAR_TYPE_MAX;
for (int i = 0; i < RS::GLOBAL_VAR_TYPE_MAX; i++) {
for (int i = 0; i < RSE::GLOBAL_VAR_TYPE_MAX; i++) {
if (global_var_type_names[i] == type) {
gvtype = RS::GlobalShaderParameterType(i);
gvtype = RSE::GlobalShaderParameterType(i);
break;
}
}
ERR_CONTINUE(gvtype == RS::GLOBAL_VAR_TYPE_MAX); //type invalid
ERR_CONTINUE(gvtype == RSE::GLOBAL_VAR_TYPE_MAX); //type invalid
Variant value = d["value"];
if (gvtype >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) {
if (gvtype >= RSE::GLOBAL_VAR_TYPE_SAMPLER2D) {
String path = value;
// Don't load the textures, but still add the parameter so shaders compile correctly while loading.
if (!p_load_textures || path.is_empty()) {
@ -2215,7 +2217,7 @@ RID MaterialStorage::shader_allocate() {
void MaterialStorage::shader_initialize(RID p_rid, bool p_embedded) {
Shader shader;
shader.data = nullptr;
shader.mode = RS::SHADER_MAX;
shader.mode = RSE::SHADER_MAX;
shader_owner.initialize_rid(p_rid, shader);
}
@ -2244,21 +2246,21 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
String mode_string = ShaderLanguage::get_shader_type(p_code);
RS::ShaderMode new_mode;
RSE::ShaderMode new_mode;
if (mode_string == "canvas_item") {
new_mode = RS::SHADER_CANVAS_ITEM;
new_mode = RSE::SHADER_CANVAS_ITEM;
} else if (mode_string == "particles") {
new_mode = RS::SHADER_PARTICLES;
new_mode = RSE::SHADER_PARTICLES;
} else if (mode_string == "spatial") {
new_mode = RS::SHADER_SPATIAL;
new_mode = RSE::SHADER_SPATIAL;
} else if (mode_string == "sky") {
new_mode = RS::SHADER_SKY;
new_mode = RSE::SHADER_SKY;
//} else if (mode_string == "fog") {
// new_mode = RS::SHADER_FOG;
// new_mode = RSE::SHADER_FOG;
} else if (mode_string == "texture_blit") {
new_mode = RS::SHADER_TEXTURE_BLIT;
new_mode = RSE::SHADER_TEXTURE_BLIT;
} else {
new_mode = RS::SHADER_MAX;
new_mode = RSE::SHADER_MAX;
ERR_PRINT("shader type " + mode_string + " not supported in OpenGL renderer");
}
@ -2279,10 +2281,10 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
shader->mode = new_mode;
if (new_mode < RS::SHADER_MAX && shader_data_request_func[new_mode]) {
if (new_mode < RSE::SHADER_MAX && shader_data_request_func[new_mode]) {
shader->data = shader_data_request_func[new_mode]();
} else {
shader->mode = RS::SHADER_MAX; //invalid
shader->mode = RSE::SHADER_MAX; //invalid
}
for (Material *E : shader->owners) {
@ -2387,13 +2389,13 @@ Variant MaterialStorage::shader_get_parameter_default(RID p_shader, const String
return Variant();
}
RS::ShaderNativeSourceCode MaterialStorage::shader_get_native_source_code(RID p_shader) const {
RenderingServerTypes::ShaderNativeSourceCode MaterialStorage::shader_get_native_source_code(RID p_shader) const {
Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_NULL_V(shader, RS::ShaderNativeSourceCode());
ERR_FAIL_NULL_V(shader, RenderingServerTypes::ShaderNativeSourceCode());
if (shader->data) {
return shader->data->get_native_source_code();
}
return RS::ShaderNativeSourceCode();
return RenderingServerTypes::ShaderNativeSourceCode();
}
/* MATERIAL API */
@ -2464,7 +2466,7 @@ void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
if (material->shader) {
material->shader->owners.erase(material);
material->shader = nullptr;
material->shader_mode = RS::SHADER_MAX;
material->shader_mode = RSE::SHADER_MAX;
}
if (p_shader.is_null()) {
@ -2480,7 +2482,7 @@ void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
material->shader_id = p_shader.get_local_index();
shader->owners.insert(material);
if (shader->mode == RS::SHADER_MAX) {
if (shader->mode == RSE::SHADER_MAX) {
return;
}
@ -2541,8 +2543,8 @@ void MaterialStorage::material_set_next_pass(RID p_material, RID p_next_material
}
void MaterialStorage::material_set_render_priority(RID p_material, int priority) {
ERR_FAIL_COND(priority < RS::MATERIAL_RENDER_PRIORITY_MIN);
ERR_FAIL_COND(priority > RS::MATERIAL_RENDER_PRIORITY_MAX);
ERR_FAIL_COND(priority < RSE::MATERIAL_RENDER_PRIORITY_MIN);
ERR_FAIL_COND(priority > RSE::MATERIAL_RENDER_PRIORITY_MAX);
GLES3::Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_NULL(material);
@ -2579,17 +2581,17 @@ bool MaterialStorage::material_casts_shadows(RID p_material) {
return true; //by default everything casts shadows
}
RS::CullMode MaterialStorage::material_get_cull_mode(RID p_material) const {
RSE::CullMode MaterialStorage::material_get_cull_mode(RID p_material) const {
const GLES3::Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_NULL_V(material, RS::CULL_MODE_DISABLED);
ERR_FAIL_NULL_V(material->shader, RS::CULL_MODE_DISABLED);
ERR_FAIL_NULL_V(material, RSE::CULL_MODE_DISABLED);
ERR_FAIL_NULL_V(material->shader, RSE::CULL_MODE_DISABLED);
if (material->shader->data) {
SceneShaderData *data = dynamic_cast<SceneShaderData *>(material->shader->data);
if (data) {
return (RS::CullMode)data->cull_mode;
return (RSE::CullMode)data->cull_mode;
}
}
return RS::CULL_MODE_DISABLED;
return RSE::CULL_MODE_DISABLED;
}
void MaterialStorage::material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) {
@ -2669,7 +2671,7 @@ void CanvasShaderData::set_code(const String &p_code) {
actions.usage_flag_pointers["CUSTOM1"] = &uses_custom1;
actions.uniforms = &uniforms;
Error err = MaterialStorage::get_singleton()->shaders.compiler_canvas.compile(RS::SHADER_CANVAS_ITEM, code, &actions, path, gen_code);
Error err = MaterialStorage::get_singleton()->shaders.compiler_canvas.compile(RSE::SHADER_CANVAS_ITEM, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
if (version.is_null()) {
@ -2703,9 +2705,9 @@ void CanvasShaderData::set_code(const String &p_code) {
MaterialStorage::get_singleton()->shaders.canvas_shader.version_set_code(version, gen_code.code, gen_code.uniforms, gen_code.stage_globals[ShaderCompiler::STAGE_VERTEX], gen_code.stage_globals[ShaderCompiler::STAGE_FRAGMENT], gen_code.defines, texture_uniform_data);
ERR_FAIL_COND(!MaterialStorage::get_singleton()->shaders.canvas_shader.version_is_valid(version));
vertex_input_mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_COLOR | RS::ARRAY_FORMAT_TEX_UV;
vertex_input_mask |= uses_custom0 << RS::ARRAY_CUSTOM0;
vertex_input_mask |= uses_custom1 << RS::ARRAY_CUSTOM1;
vertex_input_mask = RSE::ARRAY_FORMAT_VERTEX | RSE::ARRAY_FORMAT_COLOR | RSE::ARRAY_FORMAT_TEX_UV;
vertex_input_mask |= uses_custom0 << RSE::ARRAY_CUSTOM0;
vertex_input_mask |= uses_custom1 << RSE::ARRAY_CUSTOM1;
ubo_size = gen_code.uniform_total_size;
ubo_offsets = gen_code.uniform_offsets;
@ -2722,7 +2724,7 @@ bool CanvasShaderData::casts_shadows() const {
return false;
}
RS::ShaderNativeSourceCode CanvasShaderData::get_native_source_code() const {
RenderingServerTypes::ShaderNativeSourceCode CanvasShaderData::get_native_source_code() const {
return MaterialStorage::get_singleton()->shaders.canvas_shader.version_get_native_source_code(version);
}
@ -2747,7 +2749,7 @@ void CanvasMaterialData::update_parameters(const HashMap<StringName, Variant> &p
update_parameters_internal(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, false);
}
static void bind_uniforms_generic(const Vector<RID> &p_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, int texture_offset = 0, const RS::CanvasItemTextureFilter *filter_mapping = filter_from_uniform, const RS::CanvasItemTextureRepeat *repeat_mapping = repeat_from_uniform) {
static void bind_uniforms_generic(const Vector<RID> &p_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, int texture_offset = 0, const RSE::CanvasItemTextureFilter *filter_mapping = filter_from_uniform, const RSE::CanvasItemTextureRepeat *repeat_mapping = repeat_from_uniform) {
const RID *textures = p_textures.ptr();
const ShaderCompiler::GeneratedCode::Texture *texture_uniforms = p_texture_uniforms.ptr();
int texture_uniform_index = 0;
@ -2849,7 +2851,7 @@ void SkyShaderData::set_code(const String &p_code) {
actions.uniforms = &uniforms;
Error err = MaterialStorage::get_singleton()->shaders.compiler_sky.compile(RS::SHADER_SKY, code, &actions, path, gen_code);
Error err = MaterialStorage::get_singleton()->shaders.compiler_sky.compile(RSE::SHADER_SKY, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
if (version.is_null()) {
@ -2894,7 +2896,7 @@ bool SkyShaderData::casts_shadows() const {
return false;
}
RS::ShaderNativeSourceCode SkyShaderData::get_native_source_code() const {
RenderingServerTypes::ShaderNativeSourceCode SkyShaderData::get_native_source_code() const {
return MaterialStorage::get_singleton()->shaders.sky_shader.version_get_native_source_code(version);
}
@ -2996,7 +2998,7 @@ void SceneShaderData::set_code(const String &p_code) {
int depth_test_disabledi = 0;
int depth_test_invertedi = 0;
int alpha_antialiasing_modei = ALPHA_ANTIALIASING_OFF;
int cull_modei = RS::CULL_MODE_BACK;
int cull_modei = RSE::CULL_MODE_BACK;
int depth_drawi = DEPTH_DRAW_OPAQUE;
int stencil_readi = 0;
@ -3026,9 +3028,9 @@ void SceneShaderData::set_code(const String &p_code) {
actions.render_mode_values["depth_test_disabled"] = Pair<int *, int>(&depth_test_disabledi, 1);
actions.render_mode_values["depth_test_inverted"] = Pair<int *, int>(&depth_test_invertedi, 1);
actions.render_mode_values["cull_disabled"] = Pair<int *, int>(&cull_modei, RS::CULL_MODE_DISABLED);
actions.render_mode_values["cull_front"] = Pair<int *, int>(&cull_modei, RS::CULL_MODE_FRONT);
actions.render_mode_values["cull_back"] = Pair<int *, int>(&cull_modei, RS::CULL_MODE_BACK);
actions.render_mode_values["cull_disabled"] = Pair<int *, int>(&cull_modei, RSE::CULL_MODE_DISABLED);
actions.render_mode_values["cull_front"] = Pair<int *, int>(&cull_modei, RSE::CULL_MODE_FRONT);
actions.render_mode_values["cull_back"] = Pair<int *, int>(&cull_modei, RSE::CULL_MODE_BACK);
actions.render_mode_flags["unshaded"] = &unshaded;
actions.render_mode_flags["wireframe"] = &wireframe;
@ -3090,7 +3092,7 @@ void SceneShaderData::set_code(const String &p_code) {
actions.uniforms = &uniforms;
Error err = MaterialStorage::get_singleton()->shaders.compiler_scene.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code);
Error err = MaterialStorage::get_singleton()->shaders.compiler_scene.compile(RSE::SHADER_SPATIAL, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
if (version.is_null()) {
@ -3107,19 +3109,19 @@ void SceneShaderData::set_code(const String &p_code) {
} else {
depth_test = DEPTH_TEST_ENABLED;
}
cull_mode = RS::CullMode(cull_modei);
cull_mode = RSE::CullMode(cull_modei);
vertex_input_mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL; // We can always read vertices and normals.
vertex_input_mask |= uses_tangent << RS::ARRAY_TANGENT;
vertex_input_mask |= uses_color << RS::ARRAY_COLOR;
vertex_input_mask |= uses_uv << RS::ARRAY_TEX_UV;
vertex_input_mask |= uses_uv2 << RS::ARRAY_TEX_UV2;
vertex_input_mask |= uses_custom0 << RS::ARRAY_CUSTOM0;
vertex_input_mask |= uses_custom1 << RS::ARRAY_CUSTOM1;
vertex_input_mask |= uses_custom2 << RS::ARRAY_CUSTOM2;
vertex_input_mask |= uses_custom3 << RS::ARRAY_CUSTOM3;
vertex_input_mask |= uses_bones << RS::ARRAY_BONES;
vertex_input_mask |= uses_weights << RS::ARRAY_WEIGHTS;
vertex_input_mask = RSE::ARRAY_FORMAT_VERTEX | RSE::ARRAY_FORMAT_NORMAL; // We can always read vertices and normals.
vertex_input_mask |= uses_tangent << RSE::ARRAY_TANGENT;
vertex_input_mask |= uses_color << RSE::ARRAY_COLOR;
vertex_input_mask |= uses_uv << RSE::ARRAY_TEX_UV;
vertex_input_mask |= uses_uv2 << RSE::ARRAY_TEX_UV2;
vertex_input_mask |= uses_custom0 << RSE::ARRAY_CUSTOM0;
vertex_input_mask |= uses_custom1 << RSE::ARRAY_CUSTOM1;
vertex_input_mask |= uses_custom2 << RSE::ARRAY_CUSTOM2;
vertex_input_mask |= uses_custom3 << RSE::ARRAY_CUSTOM3;
vertex_input_mask |= uses_bones << RSE::ARRAY_BONES;
vertex_input_mask |= uses_weights << RSE::ARRAY_WEIGHTS;
uses_screen_texture = gen_code.uses_screen_texture;
uses_screen_texture_mipmaps = gen_code.uses_screen_texture_mipmaps;
@ -3202,7 +3204,7 @@ bool SceneShaderData::casts_shadows() const {
return !has_alpha || (uses_depth_prepass_alpha && !(depth_draw == DEPTH_DRAW_DISABLED || depth_test != DEPTH_TEST_ENABLED));
}
RS::ShaderNativeSourceCode SceneShaderData::get_native_source_code() const {
RenderingServerTypes::ShaderNativeSourceCode SceneShaderData::get_native_source_code() const {
return MaterialStorage::get_singleton()->shaders.scene_shader.version_get_native_source_code(version);
}
@ -3223,7 +3225,7 @@ GLES3::ShaderData *GLES3::_create_scene_shader_func() {
}
void SceneMaterialData::set_render_priority(int p_priority) {
priority = p_priority - RS::MATERIAL_RENDER_PRIORITY_MIN; //8 bits
priority = p_priority - RSE::MATERIAL_RENDER_PRIORITY_MIN; //8 bits
}
void SceneMaterialData::set_next_pass(RID p_pass) {
@ -3284,7 +3286,7 @@ void ParticlesShaderData::set_code(const String &p_code) {
actions.uniforms = &uniforms;
Error err = MaterialStorage::get_singleton()->shaders.compiler_particles.compile(RS::SHADER_PARTICLES, code, &actions, path, gen_code);
Error err = MaterialStorage::get_singleton()->shaders.compiler_particles.compile(RSE::SHADER_PARTICLES, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
if (version.is_null()) {
@ -3317,7 +3319,7 @@ bool ParticlesShaderData::casts_shadows() const {
return false;
}
RS::ShaderNativeSourceCode ParticlesShaderData::get_native_source_code() const {
RenderingServerTypes::ShaderNativeSourceCode ParticlesShaderData::get_native_source_code() const {
return MaterialStorage::get_singleton()->shaders.particles_process_shader.version_get_native_source_code(version);
}
@ -3382,7 +3384,7 @@ void TexBlitShaderData::set_code(const String &p_code) {
actions.render_mode_values["blend_disabled"] = Pair<int *, int>(&blend_modei, BLEND_MODE_DISABLED);
actions.uniforms = &uniforms;
Error err = MaterialStorage::get_singleton()->shaders.compiler_tex_blit.compile(RS::SHADER_TEXTURE_BLIT, code, &actions, path, gen_code);
Error err = MaterialStorage::get_singleton()->shaders.compiler_tex_blit.compile(RSE::SHADER_TEXTURE_BLIT, code, &actions, path, gen_code);
ERR_FAIL_COND_MSG(err != OK, "Shader compilation failed.");
if (version.is_null()) {
@ -3429,7 +3431,7 @@ bool TexBlitShaderData::casts_shadows() const {
return false;
}
RS::ShaderNativeSourceCode TexBlitShaderData::get_native_source_code() const {
RenderingServerTypes::ShaderNativeSourceCode TexBlitShaderData::get_native_source_code() const {
return MaterialStorage::get_singleton()->shaders.tex_blit_shader.version_get_native_source_code(version);
}

View file

@ -39,6 +39,7 @@
#include "drivers/gles3/shaders/scene.glsl.gen.h"
#include "drivers/gles3/shaders/sky.glsl.gen.h"
#include "drivers/gles3/shaders/tex_blit.glsl.gen.h"
#include "servers/rendering/rendering_server_types.h"
#include "servers/rendering/shader_compiler.h"
#include "servers/rendering/shader_language.h"
#include "servers/rendering/storage/material_storage.h"
@ -63,7 +64,7 @@ struct ShaderData {
virtual void set_code(const String &p_Code) = 0;
virtual bool is_animated() const = 0;
virtual bool casts_shadows() const = 0;
virtual RS::ShaderNativeSourceCode get_native_source_code() const { return RS::ShaderNativeSourceCode(); }
virtual RenderingServerTypes::ShaderNativeSourceCode get_native_source_code() const { return RenderingServerTypes::ShaderNativeSourceCode(); }
virtual ~ShaderData() {}
};
@ -76,7 +77,7 @@ struct Shader {
ShaderData *data = nullptr;
String code;
String path_hint;
RS::ShaderMode mode;
RSE::ShaderMode mode;
HashMap<StringName, HashMap<int, RID>> default_texture_parameter;
HashSet<Material *> owners;
};
@ -117,7 +118,7 @@ struct Material {
MaterialData *data = nullptr;
Shader *shader = nullptr;
//shortcut to shader data and type
RS::ShaderMode shader_mode = RS::SHADER_MAX;
RSE::ShaderMode shader_mode = RSE::SHADER_MAX;
uint32_t shader_id = 0;
bool uniform_dirty = false;
bool texture_dirty = false;
@ -172,7 +173,7 @@ struct CanvasShaderData : public ShaderData {
virtual void set_code(const String &p_Code);
virtual bool is_animated() const;
virtual bool casts_shadows() const;
virtual RS::ShaderNativeSourceCode get_native_source_code() const;
virtual RenderingServerTypes::ShaderNativeSourceCode get_native_source_code() const;
CanvasShaderData();
virtual ~CanvasShaderData();
@ -217,7 +218,7 @@ struct SkyShaderData : public ShaderData {
virtual void set_code(const String &p_Code);
virtual bool is_animated() const;
virtual bool casts_shadows() const;
virtual RS::ShaderNativeSourceCode get_native_source_code() const;
virtual RenderingServerTypes::ShaderNativeSourceCode get_native_source_code() const;
SkyShaderData();
virtual ~SkyShaderData();
};
@ -301,7 +302,7 @@ struct SceneShaderData : public ShaderData {
AlphaAntiAliasing alpha_antialiasing_mode;
DepthDraw depth_draw;
DepthTest depth_test;
RS::CullMode cull_mode;
RSE::CullMode cull_mode;
StencilCompare stencil_compare;
uint32_t stencil_flags;
@ -350,7 +351,7 @@ struct SceneShaderData : public ShaderData {
virtual void set_code(const String &p_Code);
virtual bool is_animated() const;
virtual bool casts_shadows() const;
virtual RS::ShaderNativeSourceCode get_native_source_code() const;
virtual RenderingServerTypes::ShaderNativeSourceCode get_native_source_code() const;
SceneShaderData();
virtual ~SceneShaderData();
@ -402,7 +403,7 @@ struct ParticlesShaderData : public ShaderData {
virtual void set_code(const String &p_Code);
virtual bool is_animated() const;
virtual bool casts_shadows() const;
virtual RS::ShaderNativeSourceCode get_native_source_code() const;
virtual RenderingServerTypes::ShaderNativeSourceCode get_native_source_code() const;
ParticlesShaderData() {}
virtual ~ParticlesShaderData();
@ -449,7 +450,7 @@ struct TexBlitShaderData : public ShaderData {
virtual void set_code(const String &p_code);
virtual bool is_animated() const;
virtual bool casts_shadows() const;
virtual RS::ShaderNativeSourceCode get_native_source_code() const;
virtual RenderingServerTypes::ShaderNativeSourceCode get_native_source_code() const;
TexBlitShaderData();
virtual ~TexBlitShaderData();
@ -477,7 +478,7 @@ struct GlobalShaderUniforms {
struct Variable {
HashSet<RID> texture_materials; // materials using this
RS::GlobalShaderParameterType type;
RSE::GlobalShaderParameterType type;
Variant value;
Variant override;
int32_t buffer_index; //for vectors
@ -538,16 +539,16 @@ private:
GlobalShaderUniforms global_shader_uniforms;
int32_t _global_shader_uniform_allocate(uint32_t p_elements);
void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value);
void _global_shader_uniform_store_in_buffer(int32_t p_index, RSE::GlobalShaderParameterType p_type, const Variant &p_value);
void _global_shader_uniform_mark_buffer_dirty(int32_t p_index, int32_t p_elements);
/* SHADER API */
ShaderDataRequestFunction shader_data_request_func[RS::SHADER_MAX];
ShaderDataRequestFunction shader_data_request_func[RSE::SHADER_MAX];
mutable RID_Owner<Shader, true> shader_owner;
/* MATERIAL API */
MaterialDataRequestFunction material_data_request_func[RS::SHADER_MAX];
MaterialDataRequestFunction material_data_request_func[RSE::SHADER_MAX];
mutable RID_Owner<Material, true> material_owner;
SelfList<Material>::List material_update_list;
@ -619,15 +620,15 @@ public:
void _update_global_shader_uniforms();
virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) override;
virtual void global_shader_parameter_add(const StringName &p_name, RSE::GlobalShaderParameterType p_type, const Variant &p_value) override;
virtual void global_shader_parameter_remove(const StringName &p_name) override;
virtual Vector<StringName> global_shader_parameter_get_list() const override;
virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) override;
virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) override;
virtual Variant global_shader_parameter_get(const StringName &p_name) const override;
virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override;
RS::GlobalShaderParameterType global_shader_parameter_get_type_internal(const StringName &p_name) const;
virtual RSE::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override;
RSE::GlobalShaderParameterType global_shader_parameter_get_type_internal(const StringName &p_name) const;
virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override;
virtual void global_shader_parameters_clear() override;
@ -658,7 +659,7 @@ public:
virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override;
virtual Variant shader_get_parameter_default(RID p_shader, const StringName &p_name) const override;
virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override;
virtual RenderingServerTypes::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override;
virtual void shader_embedded_set_lock() override {}
virtual const HashSet<RID> &shader_embedded_set_get() const override { return dummy_embedded_set; }
virtual void shader_embedded_set_unlock() override {}
@ -685,7 +686,7 @@ public:
virtual bool material_is_animated(RID p_material) override;
virtual bool material_casts_shadows(RID p_material) override;
virtual RS::CullMode material_get_cull_mode(RID p_material) const override;
virtual RSE::CullMode material_get_cull_mode(RID p_material) const override;
virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) override;
@ -696,7 +697,7 @@ public:
return material->shader_id;
}
_FORCE_INLINE_ MaterialData *material_get_data(RID p_material, RS::ShaderMode p_shader_mode) {
_FORCE_INLINE_ MaterialData *material_get_data(RID p_material, RSE::ShaderMode p_shader_mode) {
Material *material = material_owner.get_or_null(p_material);
if (!material || material->shader_mode != p_shader_mode) {
return nullptr;

View file

@ -35,6 +35,8 @@
#include "drivers/gles3/storage/config.h"
#include "drivers/gles3/storage/texture_storage.h"
#include "drivers/gles3/storage/utilities.h"
#include "servers/rendering/renderer_viewport.h"
#include "servers/rendering/rendering_server.h"
using namespace GLES3;
@ -105,11 +107,11 @@ bool MeshStorage::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
return mesh->blend_shape_count > 0 || (mesh->has_bone_weights && p_has_skeleton);
}
void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {
void MeshStorage::mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_NULL(mesh);
ERR_FAIL_COND(mesh->surface_count == RS::MAX_MESH_SURFACES);
ERR_FAIL_COND(mesh->surface_count == RSE::MAX_MESH_SURFACES);
#ifdef DEBUG_ENABLED
//do a validation, to catch errors first
@ -118,57 +120,57 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
uint32_t attrib_stride = 0;
uint32_t skin_stride = 0;
for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) {
for (int i = 0; i < RSE::ARRAY_WEIGHTS; i++) {
if ((p_surface.format & (1ULL << i))) {
switch (i) {
case RS::ARRAY_VERTEX: {
if ((p_surface.format & RS::ARRAY_FLAG_USE_2D_VERTICES) || (p_surface.format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
case RSE::ARRAY_VERTEX: {
if ((p_surface.format & RSE::ARRAY_FLAG_USE_2D_VERTICES) || (p_surface.format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
stride += sizeof(float) * 2;
} else {
stride += sizeof(float) * 3;
}
} break;
case RS::ARRAY_NORMAL: {
case RSE::ARRAY_NORMAL: {
stride += sizeof(uint16_t) * 2;
} break;
case RS::ARRAY_TANGENT: {
if (!(p_surface.format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
case RSE::ARRAY_TANGENT: {
if (!(p_surface.format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
stride += sizeof(uint16_t) * 2;
}
} break;
case RS::ARRAY_COLOR: {
case RSE::ARRAY_COLOR: {
attrib_stride += sizeof(uint32_t);
} break;
case RS::ARRAY_TEX_UV: {
if (p_surface.format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
case RSE::ARRAY_TEX_UV: {
if (p_surface.format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
attrib_stride += sizeof(uint16_t) * 2;
} else {
attrib_stride += sizeof(float) * 2;
}
} break;
case RS::ARRAY_TEX_UV2: {
if (p_surface.format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
case RSE::ARRAY_TEX_UV2: {
if (p_surface.format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
attrib_stride += sizeof(uint16_t) * 2;
} else {
attrib_stride += sizeof(float) * 2;
}
} break;
case RS::ARRAY_CUSTOM0:
case RS::ARRAY_CUSTOM1:
case RS::ARRAY_CUSTOM2:
case RS::ARRAY_CUSTOM3: {
int idx = i - RS::ARRAY_CUSTOM0;
uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT };
uint32_t fmt = (p_surface.format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK;
uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
case RSE::ARRAY_CUSTOM0:
case RSE::ARRAY_CUSTOM1:
case RSE::ARRAY_CUSTOM2:
case RSE::ARRAY_CUSTOM3: {
int idx = i - RSE::ARRAY_CUSTOM0;
uint32_t fmt_shift[RSE::ARRAY_CUSTOM_COUNT] = { RSE::ARRAY_FORMAT_CUSTOM0_SHIFT, RSE::ARRAY_FORMAT_CUSTOM1_SHIFT, RSE::ARRAY_FORMAT_CUSTOM2_SHIFT, RSE::ARRAY_FORMAT_CUSTOM3_SHIFT };
uint32_t fmt = (p_surface.format >> fmt_shift[idx]) & RSE::ARRAY_FORMAT_CUSTOM_MASK;
uint32_t fmtsize[RSE::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
attrib_stride += fmtsize[fmt];
} break;
case RS::ARRAY_WEIGHTS:
case RS::ARRAY_BONES: {
case RSE::ARRAY_WEIGHTS:
case RSE::ARRAY_BONES: {
//uses a separate array
bool use_8 = p_surface.format & RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
bool use_8 = p_surface.format & RSE::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
skin_stride += sizeof(int16_t) * (use_8 ? 16 : 8);
} break;
}
@ -185,7 +187,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
int expected_attrib_size = attrib_stride * p_surface.vertex_count;
ERR_FAIL_COND_MSG(expected_attrib_size != p_surface.attribute_data.size(), "Size of attribute data provided (" + itos(p_surface.attribute_data.size()) + ") does not match expected (" + itos(expected_attrib_size) + ")");
if ((p_surface.format & RS::ARRAY_FORMAT_WEIGHTS) && (p_surface.format & RS::ARRAY_FORMAT_BONES)) {
if ((p_surface.format & RSE::ARRAY_FORMAT_WEIGHTS) && (p_surface.format & RSE::ARRAY_FORMAT_BONES)) {
expected_size = skin_stride * p_surface.vertex_count;
ERR_FAIL_COND_MSG(expected_size != p_surface.skin_data.size(), "Size of skin data provided (" + itos(p_surface.skin_data.size()) + ") does not match expected (" + itos(expected_size) + ")");
}
@ -193,21 +195,21 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
#endif
uint64_t surface_version = p_surface.format & (uint64_t(RS::ARRAY_FLAG_FORMAT_VERSION_MASK) << RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT);
RS::SurfaceData new_surface = p_surface;
uint64_t surface_version = p_surface.format & (uint64_t(RSE::ARRAY_FLAG_FORMAT_VERSION_MASK) << RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT);
RenderingServerTypes::SurfaceData new_surface = p_surface;
#ifdef DISABLE_DEPRECATED
ERR_FAIL_COND_MSG(surface_version != RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION, "Surface version provided (" + itos(int(surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT)) + ") does not match current version (" + itos(RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) + ")");
ERR_FAIL_COND_MSG(surface_version != RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION, "Surface version provided (" + itos(int(surface_version >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT)) + ") does not match current version (" + itos(RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT) + ")");
#else
if (surface_version != uint64_t(RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION)) {
if (surface_version != uint64_t(RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION)) {
RS::get_singleton()->fix_surface_compatibility(new_surface);
surface_version = new_surface.format & (uint64_t(RS::ARRAY_FLAG_FORMAT_VERSION_MASK) << RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT);
ERR_FAIL_COND_MSG(surface_version != RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION,
surface_version = new_surface.format & (uint64_t(RSE::ARRAY_FLAG_FORMAT_VERSION_MASK) << RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT);
ERR_FAIL_COND_MSG(surface_version != RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION,
vformat("Surface version provided (%d) does not match current version (%d).",
(surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK,
(RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK));
(surface_version >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RSE::ARRAY_FLAG_FORMAT_VERSION_MASK,
(RSE::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RSE::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RSE::ARRAY_FLAG_FORMAT_VERSION_MASK));
}
#endif
@ -225,15 +227,15 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
// This allows us to avoid adding a shader permutation, and avoid passing dummy tangents. Since the stride is kept small
// this should still be a net win for bandwidth.
// If we do this, then the last normal will read past the end of the array. So we need to pad the array with dummy data.
if (!(new_surface.format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && (new_surface.format & RS::ARRAY_FORMAT_NORMAL) && !(new_surface.format & RS::ARRAY_FORMAT_TANGENT)) {
if (!(new_surface.format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && (new_surface.format & RSE::ARRAY_FORMAT_NORMAL) && !(new_surface.format & RSE::ARRAY_FORMAT_TANGENT)) {
// Unfortunately, we need to copy the buffer, which is fine as doing a resize triggers a CoW anyway.
Vector<uint8_t> new_vertex_data;
new_vertex_data.resize_initialized(new_surface.vertex_data.size() + sizeof(uint16_t) * 2);
memcpy(new_vertex_data.ptrw(), new_surface.vertex_data.ptr(), new_surface.vertex_data.size());
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->vertex_buffer, new_vertex_data.size(), new_vertex_data.ptr(), (s->format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh vertex buffer");
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->vertex_buffer, new_vertex_data.size(), new_vertex_data.ptr(), (s->format & RSE::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh vertex buffer");
s->vertex_buffer_size = new_vertex_data.size();
} else {
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->vertex_buffer, new_surface.vertex_data.size(), new_surface.vertex_data.ptr(), (s->format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh vertex buffer");
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->vertex_buffer, new_surface.vertex_data.size(), new_surface.vertex_data.ptr(), (s->format & RSE::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh vertex buffer");
s->vertex_buffer_size = new_surface.vertex_data.size();
}
}
@ -241,14 +243,14 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
if (new_surface.attribute_data.size()) {
glGenBuffers(1, &s->attribute_buffer);
glBindBuffer(GL_ARRAY_BUFFER, s->attribute_buffer);
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->attribute_buffer, new_surface.attribute_data.size(), new_surface.attribute_data.ptr(), (s->format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh attribute buffer");
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->attribute_buffer, new_surface.attribute_data.size(), new_surface.attribute_data.ptr(), (s->format & RSE::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh attribute buffer");
s->attribute_buffer_size = new_surface.attribute_data.size();
}
if (new_surface.skin_data.size()) {
glGenBuffers(1, &s->skin_buffer);
glBindBuffer(GL_ARRAY_BUFFER, s->skin_buffer);
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->skin_buffer, new_surface.skin_data.size(), new_surface.skin_data.ptr(), (s->format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh skin buffer");
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->skin_buffer, new_surface.skin_data.size(), new_surface.skin_data.ptr(), (s->format & RSE::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh skin buffer");
s->skin_buffer_size = new_surface.skin_data.size();
}
@ -256,7 +258,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
s->vertex_count = new_surface.vertex_count;
if (new_surface.format & RS::ARRAY_FORMAT_BONES) {
if (new_surface.format & RSE::ARRAY_FORMAT_BONES) {
mesh->has_bone_weights = true;
}
@ -287,14 +289,14 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
ERR_FAIL_COND_MSG(!new_surface.index_count && !new_surface.vertex_count, "Meshes must contain a vertex array, an index array, or both");
if (GLES3::Config::get_singleton()->generate_wireframes && s->primitive == RS::PRIMITIVE_TRIANGLES) {
if (GLES3::Config::get_singleton()->generate_wireframes && s->primitive == RSE::PRIMITIVE_TRIANGLES) {
// Generate wireframes. This is mostly used by the editor.
s->wireframe = memnew(Mesh::Surface::Wireframe);
Vector<uint32_t> wf_indices;
uint32_t &wf_index_count = s->wireframe->index_count;
uint32_t *wr = nullptr;
if (new_surface.format & RS::ARRAY_FORMAT_INDEX) {
if (new_surface.format & RSE::ARRAY_FORMAT_INDEX) {
wf_index_count = s->index_count * 2;
wf_indices.resize(wf_index_count);
@ -364,12 +366,12 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
int normal_tangent_stride = 0;
int normal_offset = 0;
int tangent_offset = 0;
if ((new_surface.format & (1ULL << RS::ARRAY_VERTEX))) {
if (new_surface.format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
if ((new_surface.format & (1ULL << RSE::ARRAY_VERTEX))) {
if (new_surface.format & RSE::ARRAY_FLAG_USE_2D_VERTICES) {
vertex_size = 2;
position_stride = sizeof(float) * vertex_size;
} else {
if (new_surface.format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
if (new_surface.format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
vertex_size = 4;
position_stride = sizeof(uint16_t) * vertex_size;
} else {
@ -378,11 +380,11 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
}
}
}
if ((new_surface.format & (1ULL << RS::ARRAY_NORMAL))) {
if ((new_surface.format & (1ULL << RSE::ARRAY_NORMAL))) {
normal_offset = position_stride * s->vertex_count;
normal_tangent_stride += sizeof(uint16_t) * 2;
}
if ((new_surface.format & (1ULL << RS::ARRAY_TANGENT))) {
if ((new_surface.format & (1ULL << RSE::ARRAY_TANGENT))) {
tangent_offset = normal_offset + normal_tangent_stride;
normal_tangent_stride += sizeof(uint16_t) * 2;
}
@ -396,20 +398,20 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
glBindVertexArray(s->blend_shapes[i].vertex_array);
glGenBuffers(1, &s->blend_shapes[i].vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, s->blend_shapes[i].vertex_buffer);
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->blend_shapes[i].vertex_buffer, size, new_surface.blend_shape_data.ptr() + i * size, (s->format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh blend shape buffer");
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, s->blend_shapes[i].vertex_buffer, size, new_surface.blend_shape_data.ptr() + i * size, (s->format & RSE::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Mesh blend shape buffer");
if ((new_surface.format & (1ULL << RS::ARRAY_VERTEX))) {
glEnableVertexAttribArray(RS::ARRAY_VERTEX + 3);
glVertexAttribPointer(RS::ARRAY_VERTEX + 3, vertex_size, GL_FLOAT, GL_FALSE, position_stride, CAST_INT_TO_UCHAR_PTR(0));
if ((new_surface.format & (1ULL << RSE::ARRAY_VERTEX))) {
glEnableVertexAttribArray(RSE::ARRAY_VERTEX + 3);
glVertexAttribPointer(RSE::ARRAY_VERTEX + 3, vertex_size, GL_FLOAT, GL_FALSE, position_stride, CAST_INT_TO_UCHAR_PTR(0));
}
if ((new_surface.format & (1ULL << RS::ARRAY_NORMAL))) {
if ((new_surface.format & (1ULL << RSE::ARRAY_NORMAL))) {
// Normal and tangent are packed into the same attribute.
glEnableVertexAttribArray(RS::ARRAY_NORMAL + 3);
glVertexAttribPointer(RS::ARRAY_NORMAL + 3, 2, GL_UNSIGNED_SHORT, GL_TRUE, normal_tangent_stride, CAST_INT_TO_UCHAR_PTR(normal_offset));
glEnableVertexAttribArray(RSE::ARRAY_NORMAL + 3);
glVertexAttribPointer(RSE::ARRAY_NORMAL + 3, 2, GL_UNSIGNED_SHORT, GL_TRUE, normal_tangent_stride, CAST_INT_TO_UCHAR_PTR(normal_offset));
}
if ((p_surface.format & (1ULL << RS::ARRAY_TANGENT))) {
glEnableVertexAttribArray(RS::ARRAY_TANGENT + 3);
glVertexAttribPointer(RS::ARRAY_TANGENT + 3, 2, GL_UNSIGNED_SHORT, GL_TRUE, normal_tangent_stride, CAST_INT_TO_UCHAR_PTR(tangent_offset));
if ((p_surface.format & (1ULL << RSE::ARRAY_TANGENT))) {
glEnableVertexAttribArray(RSE::ARRAY_TANGENT + 3);
glVertexAttribPointer(RSE::ARRAY_TANGENT + 3, 2, GL_UNSIGNED_SHORT, GL_TRUE, normal_tangent_stride, CAST_INT_TO_UCHAR_PTR(tangent_offset));
}
}
glBindVertexArray(0);
@ -520,7 +522,7 @@ int MeshStorage::mesh_get_blend_shape_count(RID p_mesh) const {
return mesh->blend_shape_count;
}
void MeshStorage::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
void MeshStorage::mesh_set_blend_shape_mode(RID p_mesh, RSE::BlendShapeMode p_mode) {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_NULL(mesh);
ERR_FAIL_INDEX((int)p_mode, 2);
@ -528,9 +530,9 @@ void MeshStorage::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mod
mesh->blend_shape_mode = p_mode;
}
RS::BlendShapeMode MeshStorage::mesh_get_blend_shape_mode(RID p_mesh) const {
RSE::BlendShapeMode MeshStorage::mesh_get_blend_shape_mode(RID p_mesh) const {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_NULL_V(mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
ERR_FAIL_NULL_V(mesh, RSE::BLEND_SHAPE_MODE_NORMALIZED);
return mesh->blend_shape_mode;
}
@ -612,20 +614,20 @@ RID MeshStorage::mesh_surface_get_material(RID p_mesh, int p_surface) const {
return mesh->surfaces[p_surface]->material;
}
RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const {
RenderingServerTypes::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_NULL_V(mesh, RS::SurfaceData());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData());
ERR_FAIL_NULL_V(mesh, RenderingServerTypes::SurfaceData());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RenderingServerTypes::SurfaceData());
Mesh::Surface &s = *mesh->surfaces[p_surface];
RS::SurfaceData sd;
RenderingServerTypes::SurfaceData sd;
sd.format = s.format;
if (s.vertex_buffer != 0) {
sd.vertex_data = Utilities::buffer_get_data(GL_ARRAY_BUFFER, s.vertex_buffer, s.vertex_buffer_size);
// When using an uncompressed buffer with normals, but without tangents, we have to trim the padding.
if (!(s.format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && (s.format & RS::ARRAY_FORMAT_NORMAL) && !(s.format & RS::ARRAY_FORMAT_TANGENT)) {
if (!(s.format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && (s.format & RSE::ARRAY_FORMAT_NORMAL) && !(s.format & RSE::ARRAY_FORMAT_TANGENT)) {
sd.vertex_data.resize(sd.vertex_data.size() - sizeof(uint16_t) * 2);
}
}
@ -648,7 +650,7 @@ RS::SurfaceData MeshStorage::mesh_get_surface(RID p_mesh, int p_surface) const {
sd.aabb = s.aabb;
for (uint32_t i = 0; i < s.lod_count; i++) {
RS::SurfaceData::LOD lod;
RenderingServerTypes::SurfaceData::LOD lod;
lod.edge_length = s.lods[i].edge_length;
lod.index_data = Utilities::buffer_get_data(GL_ELEMENT_ARRAY_BUFFER, s.lods[i].index_buffer, s.lods[i].index_buffer_size);
sd.lods.push_back(lod);
@ -710,7 +712,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
for (uint32_t i = 0; i < mesh->surface_count; i++) {
AABB laabb;
const Mesh::Surface &surface = *mesh->surfaces[i];
if ((surface.format & RS::ARRAY_FORMAT_BONES) && surface.bone_aabbs.size()) {
if ((surface.format & RSE::ARRAY_FORMAT_BONES) && surface.bone_aabbs.size()) {
int bs = surface.bone_aabbs.size();
const AABB *skbones = surface.bone_aabbs.ptr();
@ -874,14 +876,14 @@ void MeshStorage::mesh_clear(RID p_mesh) {
}
void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::Version &v, Mesh::Surface *s, uint64_t p_input_mask, bool p_uses_motion_vectors, MeshInstance::Surface *mis, int p_current_vertex_buffer, int p_prev_vertex_buffer) {
Mesh::Surface::Attrib attribs[RS::ARRAY_MAX];
Mesh::Surface::Attrib attribs[RSE::ARRAY_MAX];
int position_stride = 0; // Vertex position only.
int normal_tangent_stride = 0;
int attributes_stride = 0;
int skin_stride = 0;
for (int i = 0; i < RS::ARRAY_INDEX; i++) {
for (int i = 0; i < RSE::ARRAY_INDEX; i++) {
attribs[i].enabled = false;
attribs[i].integer = false;
if (!(s->format & (1ULL << i))) {
@ -895,15 +897,15 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
}
switch (i) {
case RS::ARRAY_VERTEX: {
case RSE::ARRAY_VERTEX: {
attribs[i].offset = 0;
attribs[i].type = GL_FLOAT;
attribs[i].normalized = GL_FALSE;
if (s->format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
if (s->format & RSE::ARRAY_FLAG_USE_2D_VERTICES) {
attribs[i].size = 2;
position_stride = attribs[i].size * sizeof(float);
} else {
if (!mis && (s->format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
if (!mis && (s->format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
attribs[i].size = 4;
position_stride = attribs[i].size * sizeof(uint16_t);
attribs[i].type = GL_UNSIGNED_SHORT;
@ -914,8 +916,8 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
}
}
} break;
case RS::ARRAY_NORMAL: {
if (!mis && (s->format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
case RSE::ARRAY_NORMAL: {
if (!mis && (s->format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
attribs[i].size = 2;
normal_tangent_stride += 2 * attribs[i].size;
} else {
@ -923,7 +925,7 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
// A small trick here: if we are uncompressed and we have normals, but no tangents. We need
// the shader to think there are 4 components to "axis_tangent_attrib". So we give a size of 4,
// but a stride based on only having 2 elements.
if (!(s->format & RS::ARRAY_FORMAT_TANGENT)) {
if (!(s->format & RSE::ARRAY_FORMAT_TANGENT)) {
normal_tangent_stride += (mis ? sizeof(float) : sizeof(uint16_t)) * 2;
} else {
normal_tangent_stride += (mis ? sizeof(float) : sizeof(uint16_t)) * 4;
@ -941,22 +943,22 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
attribs[i].type = (mis ? GL_FLOAT : GL_UNSIGNED_SHORT);
attribs[i].normalized = GL_TRUE;
} break;
case RS::ARRAY_TANGENT: {
case RSE::ARRAY_TANGENT: {
// We never use the tangent attribute. It is always packed in ARRAY_NORMAL, or ARRAY_VERTEX.
attribs[i].enabled = false;
attribs[i].integer = false;
} break;
case RS::ARRAY_COLOR: {
case RSE::ARRAY_COLOR: {
attribs[i].offset = attributes_stride;
attribs[i].size = 4;
attribs[i].type = GL_UNSIGNED_BYTE;
attributes_stride += 4;
attribs[i].normalized = GL_TRUE;
} break;
case RS::ARRAY_TEX_UV: {
case RSE::ARRAY_TEX_UV: {
attribs[i].offset = attributes_stride;
attribs[i].size = 2;
if (s->format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
if (s->format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
attribs[i].type = GL_UNSIGNED_SHORT;
attributes_stride += 2 * sizeof(uint16_t);
attribs[i].normalized = GL_TRUE;
@ -966,10 +968,10 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
attribs[i].normalized = GL_FALSE;
}
} break;
case RS::ARRAY_TEX_UV2: {
case RSE::ARRAY_TEX_UV2: {
attribs[i].offset = attributes_stride;
attribs[i].size = 2;
if (s->format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
if (s->format & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
attribs[i].type = GL_UNSIGNED_SHORT;
attributes_stride += 2 * sizeof(uint16_t);
attribs[i].normalized = GL_TRUE;
@ -979,24 +981,24 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
attribs[i].normalized = GL_FALSE;
}
} break;
case RS::ARRAY_CUSTOM0:
case RS::ARRAY_CUSTOM1:
case RS::ARRAY_CUSTOM2:
case RS::ARRAY_CUSTOM3: {
case RSE::ARRAY_CUSTOM0:
case RSE::ARRAY_CUSTOM1:
case RSE::ARRAY_CUSTOM2:
case RSE::ARRAY_CUSTOM3: {
attribs[i].offset = attributes_stride;
int idx = i - RS::ARRAY_CUSTOM0;
uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT };
uint32_t fmt = (s->format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK;
uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
GLenum gl_type[RS::ARRAY_CUSTOM_MAX] = { GL_UNSIGNED_BYTE, GL_BYTE, GL_HALF_FLOAT, GL_HALF_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT };
GLboolean norm[RS::ARRAY_CUSTOM_MAX] = { GL_TRUE, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
int idx = i - RSE::ARRAY_CUSTOM0;
uint32_t fmt_shift[RSE::ARRAY_CUSTOM_COUNT] = { RSE::ARRAY_FORMAT_CUSTOM0_SHIFT, RSE::ARRAY_FORMAT_CUSTOM1_SHIFT, RSE::ARRAY_FORMAT_CUSTOM2_SHIFT, RSE::ARRAY_FORMAT_CUSTOM3_SHIFT };
uint32_t fmt = (s->format >> fmt_shift[idx]) & RSE::ARRAY_FORMAT_CUSTOM_MASK;
uint32_t fmtsize[RSE::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 };
GLenum gl_type[RSE::ARRAY_CUSTOM_MAX] = { GL_UNSIGNED_BYTE, GL_BYTE, GL_HALF_FLOAT, GL_HALF_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT };
GLboolean norm[RSE::ARRAY_CUSTOM_MAX] = { GL_TRUE, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
attribs[i].type = gl_type[fmt];
attributes_stride += fmtsize[fmt];
attribs[i].size = fmtsize[fmt] / sizeof(float);
attribs[i].normalized = norm[fmt];
} break;
case RS::ARRAY_BONES: {
case RSE::ARRAY_BONES: {
attribs[i].offset = skin_stride;
attribs[i].size = 4;
attribs[i].type = GL_UNSIGNED_SHORT;
@ -1004,7 +1006,7 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
attribs[i].normalized = GL_FALSE;
attribs[i].integer = true;
} break;
case RS::ARRAY_WEIGHTS: {
case RSE::ARRAY_WEIGHTS: {
attribs[i].offset = skin_stride;
attribs[i].size = 4;
attribs[i].type = GL_UNSIGNED_SHORT;
@ -1017,19 +1019,19 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
glGenVertexArrays(1, &v.vertex_array);
glBindVertexArray(v.vertex_array);
for (int i = 0; i < RS::ARRAY_INDEX; i++) {
for (int i = 0; i < RSE::ARRAY_INDEX; i++) {
if (!attribs[i].enabled) {
glDisableVertexAttribArray(i);
continue;
}
if (i <= RS::ARRAY_TANGENT) {
attribs[i].stride = (i == RS::ARRAY_VERTEX) ? position_stride : normal_tangent_stride;
if (i <= RSE::ARRAY_TANGENT) {
attribs[i].stride = (i == RSE::ARRAY_VERTEX) ? position_stride : normal_tangent_stride;
if (mis) {
glBindBuffer(GL_ARRAY_BUFFER, mis->vertex_buffers[p_current_vertex_buffer]);
} else {
glBindBuffer(GL_ARRAY_BUFFER, s->vertex_buffer);
}
} else if (i <= RS::ARRAY_CUSTOM3) {
} else if (i <= RSE::ARRAY_CUSTOM3) {
attribs[i].stride = attributes_stride;
glBindBuffer(GL_ARRAY_BUFFER, s->attribute_buffer);
} else {
@ -1046,7 +1048,7 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
}
if (p_uses_motion_vectors) {
for (int i = 0; i < RS::ARRAY_TANGENT; i++) {
for (int i = 0; i < RSE::ARRAY_TANGENT; i++) {
if (mis) {
glBindBuffer(GL_ARRAY_BUFFER, mis->vertex_buffers[mis->prev_vertex_buffer]);
} else {
@ -1094,7 +1096,7 @@ void MeshStorage::mesh_surface_remove(RID p_mesh, int p_surface) {
if (mesh->has_bone_weights) {
mesh->has_bone_weights = false;
for (uint32_t i = 0; i < mesh->surface_count; i++) {
if (mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) {
if (mesh->surfaces[i]->format & RSE::ARRAY_FORMAT_BONES) {
mesh->has_bone_weights = true;
break;
}
@ -1184,22 +1186,22 @@ void MeshStorage::_mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh, uint3
}
MeshInstance::Surface s;
if ((mesh->blend_shape_count > 0 || (mesh->surfaces[p_surface]->format & RS::ARRAY_FORMAT_BONES)) && mesh->surfaces[p_surface]->vertex_buffer_size > 0) {
if ((mesh->blend_shape_count > 0 || (mesh->surfaces[p_surface]->format & RSE::ARRAY_FORMAT_BONES)) && mesh->surfaces[p_surface]->vertex_buffer_size > 0) {
// Cache surface properties
s.format_cache = mesh->surfaces[p_surface]->format;
if ((s.format_cache & (1ULL << RS::ARRAY_VERTEX))) {
if (s.format_cache & RS::ARRAY_FLAG_USE_2D_VERTICES) {
if ((s.format_cache & (1ULL << RSE::ARRAY_VERTEX))) {
if (s.format_cache & RSE::ARRAY_FLAG_USE_2D_VERTICES) {
s.vertex_size_cache = 2;
} else {
s.vertex_size_cache = 3;
}
s.vertex_stride_cache = sizeof(float) * s.vertex_size_cache;
}
if ((s.format_cache & (1ULL << RS::ARRAY_NORMAL))) {
if ((s.format_cache & (1ULL << RSE::ARRAY_NORMAL))) {
s.vertex_normal_offset_cache = s.vertex_stride_cache;
s.vertex_stride_cache += sizeof(uint32_t) * 2;
}
if ((s.format_cache & (1ULL << RS::ARRAY_TANGENT))) {
if ((s.format_cache & (1ULL << RSE::ARRAY_TANGENT))) {
s.vertex_tangent_offset_cache = s.vertex_stride_cache;
s.vertex_stride_cache += sizeof(uint32_t) * 2;
}
@ -1290,23 +1292,23 @@ void MeshStorage::mesh_instance_set_canvas_item_transform(RID p_mesh_instance, c
void MeshStorage::_blend_shape_bind_mesh_instance_buffer(MeshInstance *p_mi, uint32_t p_surface) {
glBindBuffer(GL_ARRAY_BUFFER, p_mi->surfaces[p_surface].blend_shape_vertex_buffers[0]);
if ((p_mi->surfaces[p_surface].format_cache & (1ULL << RS::ARRAY_VERTEX))) {
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, p_mi->surfaces[p_surface].vertex_size_cache, GL_FLOAT, GL_FALSE, p_mi->surfaces[p_surface].vertex_stride_cache, CAST_INT_TO_UCHAR_PTR(0));
if ((p_mi->surfaces[p_surface].format_cache & (1ULL << RSE::ARRAY_VERTEX))) {
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, p_mi->surfaces[p_surface].vertex_size_cache, GL_FLOAT, GL_FALSE, p_mi->surfaces[p_surface].vertex_stride_cache, CAST_INT_TO_UCHAR_PTR(0));
} else {
glDisableVertexAttribArray(RS::ARRAY_VERTEX);
glDisableVertexAttribArray(RSE::ARRAY_VERTEX);
}
if ((p_mi->surfaces[p_surface].format_cache & (1ULL << RS::ARRAY_NORMAL))) {
glEnableVertexAttribArray(RS::ARRAY_NORMAL);
glVertexAttribIPointer(RS::ARRAY_NORMAL, 2, GL_UNSIGNED_INT, p_mi->surfaces[p_surface].vertex_stride_cache, CAST_INT_TO_UCHAR_PTR(p_mi->surfaces[p_surface].vertex_normal_offset_cache));
if ((p_mi->surfaces[p_surface].format_cache & (1ULL << RSE::ARRAY_NORMAL))) {
glEnableVertexAttribArray(RSE::ARRAY_NORMAL);
glVertexAttribIPointer(RSE::ARRAY_NORMAL, 2, GL_UNSIGNED_INT, p_mi->surfaces[p_surface].vertex_stride_cache, CAST_INT_TO_UCHAR_PTR(p_mi->surfaces[p_surface].vertex_normal_offset_cache));
} else {
glDisableVertexAttribArray(RS::ARRAY_NORMAL);
glDisableVertexAttribArray(RSE::ARRAY_NORMAL);
}
if ((p_mi->surfaces[p_surface].format_cache & (1ULL << RS::ARRAY_TANGENT))) {
glEnableVertexAttribArray(RS::ARRAY_TANGENT);
glVertexAttribIPointer(RS::ARRAY_TANGENT, 2, GL_UNSIGNED_INT, p_mi->surfaces[p_surface].vertex_stride_cache, CAST_INT_TO_UCHAR_PTR(p_mi->surfaces[p_surface].vertex_tangent_offset_cache));
if ((p_mi->surfaces[p_surface].format_cache & (1ULL << RSE::ARRAY_TANGENT))) {
glEnableVertexAttribArray(RSE::ARRAY_TANGENT);
glVertexAttribIPointer(RSE::ARRAY_TANGENT, 2, GL_UNSIGNED_INT, p_mi->surfaces[p_surface].vertex_stride_cache, CAST_INT_TO_UCHAR_PTR(p_mi->surfaces[p_surface].vertex_tangent_offset_cache));
} else {
glDisableVertexAttribArray(RS::ARRAY_TANGENT);
glDisableVertexAttribArray(RSE::ARRAY_TANGENT);
}
}
@ -1314,10 +1316,10 @@ void MeshStorage::_compute_skeleton(MeshInstance *p_mi, Skeleton *p_sk, uint32_t
// Add in the bones and weights.
glBindBuffer(GL_ARRAY_BUFFER, p_mi->mesh->surfaces[p_surface]->skin_buffer);
bool use_8_weights = p_mi->surfaces[p_surface].format_cache & RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
bool use_8_weights = p_mi->surfaces[p_surface].format_cache & RSE::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
int skin_stride = sizeof(int16_t) * (use_8_weights ? 16 : 8);
glEnableVertexAttribArray(RS::ARRAY_BONES);
glVertexAttribIPointer(RS::ARRAY_BONES, 4, GL_UNSIGNED_SHORT, skin_stride, CAST_INT_TO_UCHAR_PTR(0));
glEnableVertexAttribArray(RSE::ARRAY_BONES);
glVertexAttribIPointer(RSE::ARRAY_BONES, 4, GL_UNSIGNED_SHORT, skin_stride, CAST_INT_TO_UCHAR_PTR(0));
if (use_8_weights) {
glEnableVertexAttribArray(11);
glVertexAttribIPointer(11, 4, GL_UNSIGNED_SHORT, skin_stride, CAST_INT_TO_UCHAR_PTR(4 * sizeof(uint16_t)));
@ -1326,8 +1328,8 @@ void MeshStorage::_compute_skeleton(MeshInstance *p_mi, Skeleton *p_sk, uint32_t
glEnableVertexAttribArray(13);
glVertexAttribPointer(13, 4, GL_UNSIGNED_SHORT, GL_TRUE, skin_stride, CAST_INT_TO_UCHAR_PTR(12 * sizeof(uint16_t)));
} else {
glEnableVertexAttribArray(RS::ARRAY_WEIGHTS);
glVertexAttribPointer(RS::ARRAY_WEIGHTS, 4, GL_UNSIGNED_SHORT, GL_TRUE, skin_stride, CAST_INT_TO_UCHAR_PTR(4 * sizeof(uint16_t)));
glEnableVertexAttribArray(RSE::ARRAY_WEIGHTS);
glVertexAttribPointer(RSE::ARRAY_WEIGHTS, 4, GL_UNSIGNED_SHORT, GL_TRUE, skin_stride, CAST_INT_TO_UCHAR_PTR(4 * sizeof(uint16_t)));
}
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, p_mi->surfaces[p_surface].vertex_buffers[p_mi->surfaces[p_surface].current_vertex_buffer]);
@ -1338,10 +1340,10 @@ void MeshStorage::_compute_skeleton(MeshInstance *p_mi, Skeleton *p_sk, uint32_t
glDrawArrays(GL_POINTS, 0, p_mi->mesh->surfaces[p_surface]->vertex_count);
glEndTransformFeedback();
glDisableVertexAttribArray(RS::ARRAY_BONES);
glDisableVertexAttribArray(RS::ARRAY_WEIGHTS);
glDisableVertexAttribArray(RS::ARRAY_BONES + 2);
glDisableVertexAttribArray(RS::ARRAY_WEIGHTS + 2);
glDisableVertexAttribArray(RSE::ARRAY_BONES);
glDisableVertexAttribArray(RSE::ARRAY_WEIGHTS);
glDisableVertexAttribArray(RSE::ARRAY_BONES + 2);
glDisableVertexAttribArray(RSE::ARRAY_WEIGHTS + 2);
glBindVertexArray(0);
glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
}
@ -1374,7 +1376,7 @@ void MeshStorage::update_mesh_instances() {
int buffer_size = mi->surfaces[i].vertex_stride_cache * surface->vertex_count;
glGenBuffers(1, &new_vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, new_vertex_buffer);
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, new_vertex_buffer, buffer_size, nullptr, (surface->format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Secondary mesh vertex buffer");
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ARRAY_BUFFER, new_vertex_buffer, buffer_size, nullptr, (surface->format & RSE::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW, "Secondary mesh vertex buffer");
glBindBuffer(GL_ARRAY_BUFFER, 0);
mi->surfaces[i].vertex_buffers[new_buffer_index] = new_vertex_buffer;
@ -1391,7 +1393,7 @@ void MeshStorage::update_mesh_instances() {
// Precompute base weight if using blend shapes.
float base_weight = 1.0;
if (mi->surfaces.size() && mi->mesh->blend_shape_count && mi->mesh->blend_shape_mode == RS::BLEND_SHAPE_MODE_NORMALIZED) {
if (mi->surfaces.size() && mi->mesh->blend_shape_count && mi->mesh->blend_shape_mode == RSE::BLEND_SHAPE_MODE_NORMALIZED) {
for (uint32_t i = 0; i < mi->mesh->blend_shape_count; i++) {
base_weight -= mi->blend_weights[i];
}
@ -1402,9 +1404,9 @@ void MeshStorage::update_mesh_instances() {
continue;
}
bool array_is_2d = mi->surfaces[i].format_cache & RS::ARRAY_FLAG_USE_2D_VERTICES;
bool can_use_skeleton = sk != nullptr && sk->use_2d == array_is_2d && (mi->surfaces[i].format_cache & RS::ARRAY_FORMAT_BONES);
bool use_8_weights = mi->surfaces[i].format_cache & RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
bool array_is_2d = mi->surfaces[i].format_cache & RSE::ARRAY_FLAG_USE_2D_VERTICES;
bool can_use_skeleton = sk != nullptr && sk->use_2d == array_is_2d && (mi->surfaces[i].format_cache & RSE::ARRAY_FORMAT_BONES);
bool use_8_weights = mi->surfaces[i].format_cache & RSE::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
// Always process blend shapes first.
if (mi->mesh->blend_shape_count) {
@ -1413,10 +1415,10 @@ void MeshStorage::update_mesh_instances() {
specialization |= array_is_2d ? SkeletonShaderGLES3::MODE_2D : 0;
specialization |= SkeletonShaderGLES3::USE_BLEND_SHAPES;
if (!array_is_2d) {
if ((mi->surfaces[i].format_cache & (1ULL << RS::ARRAY_NORMAL))) {
if ((mi->surfaces[i].format_cache & (1ULL << RSE::ARRAY_NORMAL))) {
specialization |= SkeletonShaderGLES3::USE_NORMAL;
}
if ((mi->surfaces[i].format_cache & (1ULL << RS::ARRAY_TANGENT))) {
if ((mi->surfaces[i].format_cache & (1ULL << RSE::ARRAY_TANGENT))) {
specialization |= SkeletonShaderGLES3::USE_TANGENT;
}
}
@ -1431,7 +1433,7 @@ void MeshStorage::update_mesh_instances() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLuint vertex_array_gl = 0;
uint64_t mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL | RS::ARRAY_FORMAT_VERTEX;
uint64_t mask = RSE::ARRAY_FORMAT_VERTEX | RSE::ARRAY_FORMAT_NORMAL | RSE::ARRAY_FORMAT_VERTEX;
uint64_t format = mi->mesh->surfaces[i]->format & mask; // Format should only have vertex, normal, tangent (as necessary).
mesh_surface_get_vertex_arrays_and_format(mi->mesh->surfaces[i], format, false, vertex_array_gl);
glBindVertexArray(vertex_array_gl);
@ -1523,10 +1525,10 @@ void MeshStorage::update_mesh_instances() {
specialization |= SkeletonShaderGLES3::FINAL_PASS;
specialization |= use_8_weights ? SkeletonShaderGLES3::USE_EIGHT_WEIGHTS : 0;
if (!array_is_2d) {
if ((mi->surfaces[i].format_cache & (1ULL << RS::ARRAY_NORMAL))) {
if ((mi->surfaces[i].format_cache & (1ULL << RSE::ARRAY_NORMAL))) {
specialization |= SkeletonShaderGLES3::USE_NORMAL;
}
if ((mi->surfaces[i].format_cache & (1ULL << RS::ARRAY_TANGENT))) {
if ((mi->surfaces[i].format_cache & (1ULL << RSE::ARRAY_TANGENT))) {
specialization |= SkeletonShaderGLES3::USE_TANGENT;
}
}
@ -1547,7 +1549,7 @@ void MeshStorage::update_mesh_instances() {
skeleton_shader.shader.version_set_uniform(SkeletonShaderGLES3::INVERSE_TRANSFORM_OFFSET, inverse_transform[2], skeleton_shader.shader_version, variant, specialization);
GLuint vertex_array_gl = 0;
uint64_t mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL | RS::ARRAY_FORMAT_VERTEX;
uint64_t mask = RSE::ARRAY_FORMAT_VERTEX | RSE::ARRAY_FORMAT_NORMAL | RSE::ARRAY_FORMAT_VERTEX;
uint64_t format = mi->mesh->surfaces[i]->format & mask; // Format should only have vertex, normal, tangent (as necessary).
mesh_surface_get_vertex_arrays_and_format(mi->mesh->surfaces[i], format, false, vertex_array_gl);
glBindVertexArray(vertex_array_gl);
@ -1579,13 +1581,13 @@ void MeshStorage::_multimesh_free(RID p_rid) {
// Remove from interpolator.
_interpolation_data.notify_free_multimesh(p_rid);
_update_dirty_multimeshes();
multimesh_allocate_data(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D);
multimesh_allocate_data(p_rid, 0, RSE::MULTIMESH_TRANSFORM_2D);
MultiMesh *multimesh = multimesh_owner.get_or_null(p_rid);
multimesh->dependency.deleted_notify(p_rid);
multimesh_owner.free(p_rid);
}
void MeshStorage::_multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data, bool p_use_indirect) {
void MeshStorage::_multimesh_allocate_data(RID p_multimesh, int p_instances, RSE::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data, bool p_use_indirect) {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL(multimesh);
@ -1613,7 +1615,7 @@ void MeshStorage::_multimesh_allocate_data(RID p_multimesh, int p_instances, RS:
multimesh->instances = p_instances;
multimesh->xform_format = p_transform_format;
multimesh->uses_colors = p_use_colors;
multimesh->color_offset_cache = p_transform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
multimesh->color_offset_cache = p_transform_format == RSE::MULTIMESH_TRANSFORM_2D ? 8 : 12;
multimesh->uses_custom_data = p_use_custom_data;
multimesh->custom_data_offset_cache = multimesh->color_offset_cache + color_and_custom_strides;
multimesh->stride_cache = multimesh->custom_data_offset_cache + color_and_custom_strides;
@ -1756,7 +1758,7 @@ void MeshStorage::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p
const float *data = p_data + multimesh->stride_cache * i;
Transform3D t;
if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) {
if (multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_3D) {
t.basis.rows[0][0] = data[0];
t.basis.rows[0][1] = data[1];
t.basis.rows[0][2] = data[2];
@ -1794,7 +1796,7 @@ void MeshStorage::_multimesh_instance_set_transform(RID p_multimesh, int p_index
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL(multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D);
ERR_FAIL_COND(multimesh->xform_format != RSE::MULTIMESH_TRANSFORM_3D);
_multimesh_make_local(multimesh);
@ -1824,7 +1826,7 @@ void MeshStorage::_multimesh_instance_set_transform_2d(RID p_multimesh, int p_in
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL(multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D);
ERR_FAIL_COND(multimesh->xform_format != RSE::MULTIMESH_TRANSFORM_2D);
_multimesh_make_local(multimesh);
@ -1921,7 +1923,7 @@ Transform3D MeshStorage::_multimesh_instance_get_transform(RID p_multimesh, int
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, Transform3D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform3D());
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D, Transform3D());
ERR_FAIL_COND_V(multimesh->xform_format != RSE::MULTIMESH_TRANSFORM_3D, Transform3D());
_multimesh_make_local(multimesh);
@ -1952,7 +1954,7 @@ Transform2D MeshStorage::_multimesh_instance_get_transform_2d(RID p_multimesh, i
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, Transform2D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D());
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D, Transform2D());
ERR_FAIL_COND_V(multimesh->xform_format != RSE::MULTIMESH_TRANSFORM_2D, Transform2D());
_multimesh_make_local(multimesh);
@ -2034,7 +2036,7 @@ void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_
_multimesh_make_local(multimesh);
uint32_t old_stride = multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
uint32_t old_stride = multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_2D ? 8 : 12;
old_stride += multimesh->uses_colors ? 4 : 0;
old_stride += multimesh->uses_custom_data ? 4 : 0;
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)old_stride));
@ -2051,7 +2053,7 @@ void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_
memcpy(newptr, vals, 8 * 4);
}
if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) {
if (multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_3D) {
float *dataptr = w + i * old_stride + 8;
float *newptr = w + i * multimesh->stride_cache + 8;
float vals[8] = { dataptr[0], dataptr[1], dataptr[2], dataptr[3] };
@ -2059,13 +2061,13 @@ void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_
}
if (multimesh->uses_colors) {
float *dataptr = w + i * old_stride + (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12);
float *dataptr = w + i * old_stride + (multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_2D ? 8 : 12);
float *newptr = w + i * multimesh->stride_cache + multimesh->color_offset_cache;
uint16_t val[4] = { Math::make_half_float(dataptr[0]), Math::make_half_float(dataptr[1]), Math::make_half_float(dataptr[2]), Math::make_half_float(dataptr[3]) };
memcpy(newptr, val, 2 * 4);
}
if (multimesh->uses_custom_data) {
float *dataptr = w + i * old_stride + (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12) + (multimesh->uses_colors ? 4 : 0);
float *dataptr = w + i * old_stride + (multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_2D ? 8 : 12) + (multimesh->uses_colors ? 4 : 0);
float *newptr = w + i * multimesh->stride_cache + multimesh->custom_data_offset_cache;
uint16_t val[4] = { Math::make_half_float(dataptr[0]), Math::make_half_float(dataptr[1]), Math::make_half_float(dataptr[2]), Math::make_half_float(dataptr[3]) };
memcpy(newptr, val, 2 * 4);
@ -2143,7 +2145,7 @@ Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
}
if (multimesh->uses_colors || multimesh->uses_custom_data) {
// Need to decompress buffer.
uint32_t new_stride = multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
uint32_t new_stride = multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_2D ? 8 : 12;
new_stride += multimesh->uses_colors ? 4 : 0;
new_stride += multimesh->uses_custom_data ? 4 : 0;
@ -2160,7 +2162,7 @@ Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
memcpy(newptr, vals, 8 * 4);
}
if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) {
if (multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_3D) {
float *newptr = w + i * new_stride + 8;
const float *oldptr = r + i * multimesh->stride_cache + 8;
float vals[8] = { oldptr[0], oldptr[1], oldptr[2], oldptr[3] };
@ -2168,7 +2170,7 @@ Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
}
if (multimesh->uses_colors) {
float *newptr = w + i * new_stride + (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12);
float *newptr = w + i * new_stride + (multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_2D ? 8 : 12);
const float *oldptr = r + i * multimesh->stride_cache + multimesh->color_offset_cache;
uint16_t raw_data[4];
memcpy(raw_data, oldptr, 2 * 4);
@ -2178,7 +2180,7 @@ Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
newptr[3] = Math::half_to_float(raw_data[3]);
}
if (multimesh->uses_custom_data) {
float *newptr = w + i * new_stride + (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12) + (multimesh->uses_colors ? 4 : 0);
float *newptr = w + i * new_stride + (multimesh->xform_format == RSE::MULTIMESH_TRANSFORM_2D ? 8 : 12) + (multimesh->uses_colors ? 4 : 0);
const float *oldptr = r + i * multimesh->stride_cache + multimesh->custom_data_offset_cache;
uint16_t raw_data[4];
memcpy(raw_data, oldptr, 2 * 4);

View file

@ -36,6 +36,8 @@
#include "core/templates/rid_owner.h"
#include "core/templates/self_list.h"
#include "drivers/gles3/shaders/skeleton.glsl.gen.h"
#include "servers/rendering/renderer_compositor.h"
#include "servers/rendering/rendering_server_enums.h"
#include "servers/rendering/rendering_server_globals.h"
#include "servers/rendering/storage/mesh_storage.h"
#include "servers/rendering/storage/utilities.h"
@ -57,7 +59,7 @@ struct Mesh {
GLsizei stride;
uint32_t offset;
};
RS::PrimitiveType primitive = RS::PRIMITIVE_POINTS;
RSE::PrimitiveType primitive = RSE::PRIMITIVE_POINTS;
uint64_t format = 0;
GLuint vertex_buffer = 0;
@ -76,7 +78,7 @@ struct Mesh {
uint32_t prev_vertex_buffer = 0;
GLuint vertex_array = 0;
Attrib attribs[RS::ARRAY_MAX];
Attrib attribs[RSE::ARRAY_MAX];
};
SpinLock version_lock; //needed to access versions
@ -127,7 +129,7 @@ struct Mesh {
};
uint32_t blend_shape_count = 0;
RS::BlendShapeMode blend_shape_mode = RS::BLEND_SHAPE_MODE_NORMALIZED;
RSE::BlendShapeMode blend_shape_mode = RSE::BLEND_SHAPE_MODE_NORMALIZED;
Surface **surfaces = nullptr;
uint32_t surface_count = 0;
@ -192,7 +194,7 @@ struct MeshInstance {
struct MultiMesh {
RID mesh;
int instances = 0;
RS::MultimeshTransformFormat xform_format = RS::MULTIMESH_TRANSFORM_3D;
RSE::MultimeshTransformFormat xform_format = RSE::MULTIMESH_TRANSFORM_3D;
bool uses_colors = false;
bool uses_custom_data = false;
int visible_instances = -1;
@ -303,12 +305,12 @@ public:
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) override;
virtual bool mesh_needs_instance(RID p_mesh, bool p_has_skeleton) override;
virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) override;
virtual void mesh_add_surface(RID p_mesh, const RenderingServerTypes::SurfaceData &p_surface) override;
virtual int mesh_get_blend_shape_count(RID p_mesh) const override;
virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) override;
virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const override;
virtual void mesh_set_blend_shape_mode(RID p_mesh, RSE::BlendShapeMode p_mode) override;
virtual RSE::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const override;
virtual void mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) override;
virtual void mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) override;
@ -318,7 +320,7 @@ public:
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) override;
virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const override;
virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override;
virtual RenderingServerTypes::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const override;
virtual int mesh_get_surface_count(RID p_mesh) const override;
virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) override;
@ -332,7 +334,7 @@ public:
virtual void mesh_clear(RID p_mesh) override;
virtual void mesh_surface_remove(RID p_mesh, int p_surface) override;
virtual void mesh_debug_usage(List<RS::MeshInfo> *r_info) override {}
virtual void mesh_debug_usage(List<RenderingServerTypes::MeshInfo> *r_info) override {}
_FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) {
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
@ -366,7 +368,7 @@ public:
return mesh->shadow_mesh;
}
_FORCE_INLINE_ RS::PrimitiveType mesh_surface_get_primitive(void *p_surface) {
_FORCE_INLINE_ RSE::PrimitiveType mesh_surface_get_primitive(void *p_surface) {
Mesh::Surface *surface = reinterpret_cast<Mesh::Surface *>(p_surface);
return surface->primitive;
}
@ -525,7 +527,7 @@ public:
virtual RID _multimesh_allocate() override;
virtual void _multimesh_initialize(RID p_rid) override;
virtual void _multimesh_free(RID p_rid) override;
virtual void _multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false, bool p_use_indirect = false) override;
virtual void _multimesh_allocate_data(RID p_multimesh, int p_instances, RSE::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false, bool p_use_indirect = false) override;
virtual int _multimesh_get_instance_count(RID p_multimesh) const override;
virtual void _multimesh_set_mesh(RID p_multimesh, RID p_mesh) override;
@ -558,9 +560,9 @@ public:
void multimesh_vertex_attrib_setup(GLuint p_instance_buffer, uint32_t p_stride, bool p_uses_format_2d, bool p_has_color_or_custom_data, int p_attrib_base_index);
_FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
_FORCE_INLINE_ RSE::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_NULL_V(multimesh, RS::MULTIMESH_TRANSFORM_3D);
ERR_FAIL_NULL_V(multimesh, RSE::MULTIMESH_TRANSFORM_3D);
return multimesh->xform_format;
}

View file

@ -108,7 +108,7 @@ void ParticlesStorage::particles_free(RID p_rid) {
particles_owner.free(p_rid);
}
void ParticlesStorage::particles_set_mode(RID p_particles, RS::ParticlesMode p_mode) {
void ParticlesStorage::particles_set_mode(RID p_particles, RSE::ParticlesMode p_mode) {
Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL(particles);
if (particles->mode == p_mode) {
@ -316,7 +316,7 @@ void ParticlesStorage::particles_set_collision_base_size(RID p_particles, real_t
particles->collision_base_size = p_size;
}
void ParticlesStorage::particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) {
void ParticlesStorage::particles_set_transform_align(RID p_particles, RSE::ParticlesTransformAlign p_transform_align) {
Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL(particles);
@ -338,7 +338,7 @@ RID ParticlesStorage::particles_get_process_material(RID p_particles) const {
return particles->process_material;
}
void ParticlesStorage::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {
void ParticlesStorage::particles_set_draw_order(RID p_particles, RSE::ParticlesDrawOrder p_order) {
Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL(particles);
@ -626,7 +626,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
Vector3 scale = to_collider.basis.get_scale();
to_collider.basis.orthonormalize();
if (pc->type <= RS::PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT) {
if (pc->type <= RSE::PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT) {
//attractor
if (frame_params.attractor_count >= ParticlesFrameParams::MAX_ATTRACTORS) {
continue;
@ -640,7 +640,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
attr.directionality = pc->attractor_directionality;
switch (pc->type) {
case RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT: {
case RSE::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT: {
attr.type = ParticlesFrameParams::ATTRACTOR_TYPE_SPHERE;
float radius = pc->radius;
radius *= (scale.x + scale.y + scale.z) / 3.0;
@ -648,14 +648,14 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
attr.extents[1] = radius;
attr.extents[2] = radius;
} break;
case RS::PARTICLES_COLLISION_TYPE_BOX_ATTRACT: {
case RSE::PARTICLES_COLLISION_TYPE_BOX_ATTRACT: {
attr.type = ParticlesFrameParams::ATTRACTOR_TYPE_BOX;
Vector3 extents = pc->extents * scale;
attr.extents[0] = extents.x;
attr.extents[1] = extents.y;
attr.extents[2] = extents.z;
} break;
case RS::PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT: {
case RSE::PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT: {
WARN_PRINT_ONCE_ED("Vector field particle attractors are not available in the Compatibility renderer.");
} break;
default: {
@ -673,7 +673,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
GLES3::MaterialStorage::store_transform(to_collider, col.transform);
switch (pc->type) {
case RS::PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE: {
case RSE::PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE: {
col.type = ParticlesFrameParams::COLLISION_TYPE_SPHERE;
float radius = pc->radius;
radius *= (scale.x + scale.y + scale.z) / 3.0;
@ -681,17 +681,17 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
col.extents[1] = radius;
col.extents[2] = radius;
} break;
case RS::PARTICLES_COLLISION_TYPE_BOX_COLLIDE: {
case RSE::PARTICLES_COLLISION_TYPE_BOX_COLLIDE: {
col.type = ParticlesFrameParams::COLLISION_TYPE_BOX;
Vector3 extents = pc->extents * scale;
col.extents[0] = extents.x;
col.extents[1] = extents.y;
col.extents[2] = extents.z;
} break;
case RS::PARTICLES_COLLISION_TYPE_SDF_COLLIDE: {
case RSE::PARTICLES_COLLISION_TYPE_SDF_COLLIDE: {
WARN_PRINT_ONCE_ED("SDF Particle Colliders are not available in the Compatibility renderer.");
} break;
case RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE: {
case RSE::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE: {
if (collision_heightmap_texture != 0) { //already taken
continue;
}
@ -732,9 +732,9 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
}
// Get shader and set shader uniforms;
ParticleProcessMaterialData *m = static_cast<ParticleProcessMaterialData *>(material_storage->material_get_data(p_particles->process_material, RS::SHADER_PARTICLES));
ParticleProcessMaterialData *m = static_cast<ParticleProcessMaterialData *>(material_storage->material_get_data(p_particles->process_material, RSE::SHADER_PARTICLES));
if (!m) {
m = static_cast<ParticleProcessMaterialData *>(material_storage->material_get_data(particles_shader.default_material, RS::SHADER_PARTICLES));
m = static_cast<ParticleProcessMaterialData *>(material_storage->material_get_data(particles_shader.default_material, RSE::SHADER_PARTICLES));
}
ERR_FAIL_NULL(m);
@ -748,7 +748,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
}
}
if (p_particles->mode == RS::ParticlesMode::PARTICLES_MODE_3D) {
if (p_particles->mode == RSE::ParticlesMode::PARTICLES_MODE_3D) {
specialization |= ParticlesShaderGLES3::MODE_3D;
}
@ -792,7 +792,7 @@ void ParticlesStorage::particles_set_view_axis(RID p_particles, const Vector3 &p
Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL(particles);
if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) {
if (particles->draw_order != RSE::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RSE::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RSE::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) {
return;
}
@ -809,7 +809,7 @@ void ParticlesStorage::particles_set_view_axis(RID p_particles, const Vector3 &p
// Sort will be done on CPU since we don't have compute shaders.
// If the sort_buffer has valid data
// Use a buffer that is 2 frames out of date to avoid stalls.
if (particles->draw_order == RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->sort_buffer_filled) {
if (particles->draw_order == RSE::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->sort_buffer_filled) {
glBindBuffer(GL_ARRAY_BUFFER, particles->sort_buffer);
ParticleInstanceData3D *particle_array;
@ -844,7 +844,7 @@ void ParticlesStorage::_particles_update_buffers(Particles *particles) {
uint32_t userdata_count = 0;
if (particles->process_material.is_valid()) {
GLES3::ParticleProcessMaterialData *material_data = static_cast<GLES3::ParticleProcessMaterialData *>(material_storage->material_get_data(particles->process_material, RS::SHADER_PARTICLES));
GLES3::ParticleProcessMaterialData *material_data = static_cast<GLES3::ParticleProcessMaterialData *>(material_storage->material_get_data(particles->process_material, RSE::SHADER_PARTICLES));
if (material_data && material_data->shader_data->version.is_valid() && material_data->shader_data->valid) {
userdata_count = material_data->shader_data->userdata_count;
}
@ -860,7 +860,7 @@ void ParticlesStorage::_particles_update_buffers(Particles *particles) {
particles->userdata_count = userdata_count;
uint32_t xform_size = particles->mode == RS::PARTICLES_MODE_2D ? 2 : 3;
uint32_t xform_size = particles->mode == RSE::PARTICLES_MODE_2D ? 2 : 3;
particles->instance_buffer_stride_cache = sizeof(float) * 4 * (xform_size + 1);
particles->instance_buffer_size_cache = particles->instance_buffer_stride_cache * total_amount;
particles->num_attrib_arrays_cache = 5 + userdata_count + (xform_size - 2);
@ -932,7 +932,7 @@ void ParticlesStorage::_particles_update_instance_buffer(Particles *particles, c
ParticlesCopyShaderGLES3::ShaderVariant variant = ParticlesCopyShaderGLES3::MODE_DEFAULT;
uint64_t specialization = 0;
if (particles->mode == RS::ParticlesMode::PARTICLES_MODE_3D) {
if (particles->mode == RSE::ParticlesMode::PARTICLES_MODE_3D) {
specialization |= ParticlesCopyShaderGLES3::MODE_3D;
}
@ -965,7 +965,7 @@ void ParticlesStorage::_particles_update_instance_buffer(Particles *particles, c
glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, particles->front_instance_buffer, 0, particles->instance_buffer_size_cache);
glBeginTransformFeedback(GL_POINTS);
if (particles->draw_order == RS::PARTICLES_DRAW_ORDER_LIFETIME) {
if (particles->draw_order == RSE::PARTICLES_DRAW_ORDER_LIFETIME) {
uint32_t lifetime_split = (MIN(int(particles->amount * particles->phase), particles->amount - 1) + 1) % particles->amount;
uint32_t stride = particles->process_buffer_stride_cache;
@ -983,7 +983,7 @@ void ParticlesStorage::_particles_update_instance_buffer(Particles *particles, c
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(stride * lifetime_split + sizeof(float) * 4 * 3));
glEnableVertexAttribArray(4); // Xform2.
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(stride * lifetime_split + sizeof(float) * 4 * 4));
if (particles->mode == RS::PARTICLES_MODE_3D) {
if (particles->mode == RSE::PARTICLES_MODE_3D) {
glEnableVertexAttribArray(5); // Xform3.
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(stride * lifetime_split + sizeof(float) * 4 * 5));
}
@ -1074,7 +1074,7 @@ void ParticlesStorage::update_particles() {
// Copy the instance buffer that was last used into the last_frame buffer.
// sort_buffer should now be 2 frames out of date.
if (particles->draw_order == RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH || particles->draw_order == RS::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME) {
if (particles->draw_order == RSE::PARTICLES_DRAW_ORDER_VIEW_DEPTH || particles->draw_order == RSE::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME) {
_particles_allocate_history_buffers(particles);
SWAP(particles->last_frame_buffer, particles->sort_buffer);
@ -1155,11 +1155,11 @@ void ParticlesStorage::update_particles() {
// Copy particles to instance buffer and pack Color/Custom.
// We don't have camera information here, so don't copy here if we need camera information for view depth or align mode.
if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) {
if (particles->draw_order != RSE::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RSE::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RSE::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) {
_particles_update_instance_buffer(particles, Vector3(0.0, 0.0, 0.0), Vector3(0.0, 0.0, 0.0));
if (particles->draw_order == RS::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME && particles->sort_buffer_filled) {
if (particles->mode == RS::ParticlesMode::PARTICLES_MODE_2D) {
if (particles->draw_order == RSE::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME && particles->sort_buffer_filled) {
if (particles->mode == RSE::ParticlesMode::PARTICLES_MODE_2D) {
_particles_reverse_lifetime_sort<ParticleInstanceData2D>(particles);
} else {
_particles_reverse_lifetime_sort<ParticleInstanceData3D>(particles);
@ -1250,11 +1250,11 @@ void ParticlesStorage::particles_collision_free(RID p_rid) {
GLuint ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const {
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_NULL_V(particles_collision, 0);
ERR_FAIL_COND_V(particles_collision->type != RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE, 0);
ERR_FAIL_COND_V(particles_collision->type != RSE::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE, 0);
if (particles_collision->heightfield_texture == 0) {
//create
const int resolutions[RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 };
const int resolutions[RSE::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 };
Size2i size;
if (particles_collision->extents.x > particles_collision->extents.z) {
size.x = resolutions[particles_collision->heightfield_resolution];
@ -1296,7 +1296,7 @@ GLuint ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_p
return particles_collision->heightfield_fb;
}
void ParticlesStorage::particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) {
void ParticlesStorage::particles_collision_set_collision_type(RID p_particles_collision, RSE::ParticlesCollisionType p_type) {
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_NULL(particles_collision);
@ -1375,10 +1375,10 @@ void ParticlesStorage::particles_collision_height_field_update(RID p_particles_c
particles_collision->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
}
void ParticlesStorage::particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) {
void ParticlesStorage::particles_collision_set_height_field_resolution(RID p_particles_collision, RSE::ParticlesCollisionHeightfieldResolution p_resolution) {
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_NULL(particles_collision);
ERR_FAIL_INDEX(p_resolution, RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);
ERR_FAIL_INDEX(p_resolution, RSE::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);
if (particles_collision->heightfield_resolution == p_resolution) {
return;
@ -1399,8 +1399,8 @@ AABB ParticlesStorage::particles_collision_get_aabb(RID p_particles_collision) c
ERR_FAIL_NULL_V(particles_collision, AABB());
switch (particles_collision->type) {
case RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT:
case RS::PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE: {
case RSE::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT:
case RSE::PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE: {
AABB aabb;
aabb.position = -Vector3(1, 1, 1) * particles_collision->radius;
aabb.size = Vector3(2, 2, 2) * particles_collision->radius;
@ -1424,7 +1424,7 @@ Vector3 ParticlesStorage::particles_collision_get_extents(RID p_particles_collis
bool ParticlesStorage::particles_collision_is_heightfield(RID p_particles_collision) const {
const ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_NULL_V(particles_collision, false);
return particles_collision->type == RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE;
return particles_collision->type == RSE::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE;
}
uint32_t ParticlesStorage::particles_collision_get_height_field_mask(RID p_particles_collision) const {

View file

@ -147,7 +147,7 @@ private:
static_assert(sizeof(ParticlesFrameParams) < 16384, "ParticlesFrameParams must be 16384 bytes or smaller");
struct Particles {
RS::ParticlesMode mode = RS::PARTICLES_MODE_3D;
RSE::ParticlesMode mode = RSE::PARTICLES_MODE_3D;
bool inactive = true;
double inactive_time = 0.0;
bool emitting = false;
@ -171,9 +171,9 @@ private:
RID process_material;
uint32_t frame_counter = 0;
RS::ParticlesTransformAlign transform_align = RS::PARTICLES_TRANSFORM_ALIGN_DISABLED;
RSE::ParticlesTransformAlign transform_align = RSE::PARTICLES_TRANSFORM_ALIGN_DISABLED;
RS::ParticlesDrawOrder draw_order = RS::PARTICLES_DRAW_ORDER_INDEX;
RSE::ParticlesDrawOrder draw_order = RSE::PARTICLES_DRAW_ORDER_INDEX;
Vector<RID> draw_passes;
@ -277,7 +277,7 @@ private:
/* Particles Collision */
struct ParticlesCollision {
RS::ParticlesCollisionType type = RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT;
RSE::ParticlesCollisionType type = RSE::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT;
uint32_t cull_mask = 0xFFFFFFFF;
float radius = 1.0;
Vector3 extents = Vector3(1, 1, 1);
@ -290,7 +290,7 @@ private:
Size2i heightfield_fb_size;
uint32_t heightfield_mask = (1 << 20) - 1;
RS::ParticlesCollisionHeightfieldResolution heightfield_resolution = RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024;
RSE::ParticlesCollisionHeightfieldResolution heightfield_resolution = RSE::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024;
Dependency dependency;
};
@ -321,7 +321,7 @@ public:
virtual void particles_initialize(RID p_rid) override;
virtual void particles_free(RID p_rid) override;
virtual void particles_set_mode(RID p_particles, RS::ParticlesMode p_mode) override;
virtual void particles_set_mode(RID p_particles, RSE::ParticlesMode p_mode) override;
virtual void particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) override;
virtual void particles_set_emitting(RID p_particles, bool p_emitting) override;
virtual void particles_set_amount(RID p_particles, int p_amount) override;
@ -344,7 +344,7 @@ public:
virtual void particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis) override;
virtual void particles_set_collision_base_size(RID p_particles, real_t p_size) override;
virtual void particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) override;
virtual void particles_set_transform_align(RID p_particles, RSE::ParticlesTransformAlign p_transform_align) override;
virtual void particles_set_seed(RID p_particles, uint32_t p_seed) override;
virtual void particles_set_trails(RID p_particles, bool p_enable, double p_length) override;
@ -352,7 +352,7 @@ public:
virtual void particles_restart(RID p_particles) override;
virtual void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) override;
virtual void particles_set_draw_order(RID p_particles, RSE::ParticlesDrawOrder p_order) override;
virtual void particles_set_draw_passes(RID p_particles, int p_count) override;
virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) override;
@ -377,9 +377,9 @@ public:
virtual void update_particles() override;
virtual bool particles_is_inactive(RID p_particles) const override;
_FORCE_INLINE_ RS::ParticlesMode particles_get_mode(RID p_particles) {
_FORCE_INLINE_ RSE::ParticlesMode particles_get_mode(RID p_particles) {
Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL_V(particles, RS::PARTICLES_MODE_2D);
ERR_FAIL_NULL_V(particles, RSE::PARTICLES_MODE_2D);
return particles->mode;
}
@ -393,7 +393,7 @@ public:
_FORCE_INLINE_ GLuint particles_get_gl_buffer(RID p_particles) {
Particles *particles = particles_owner.get_or_null(p_particles);
if ((particles->draw_order == RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH || particles->draw_order == RS::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME) && particles->sort_buffer_filled) {
if ((particles->draw_order == RSE::PARTICLES_DRAW_ORDER_VIEW_DEPTH || particles->draw_order == RSE::PARTICLES_DRAW_ORDER_REVERSE_LIFETIME) && particles->sort_buffer_filled) {
return particles->sort_buffer;
}
return particles->back_instance_buffer;
@ -436,7 +436,7 @@ public:
virtual void particles_collision_initialize(RID p_rid) override;
virtual void particles_collision_free(RID p_rid) override;
virtual void particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) override;
virtual void particles_collision_set_collision_type(RID p_particles_collision, RSE::ParticlesCollisionType p_type) override;
virtual void particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) override;
virtual void particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) override;
virtual void particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) override;
@ -445,7 +445,7 @@ public:
virtual void particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) override;
virtual void particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) override;
virtual void particles_collision_height_field_update(RID p_particles_collision) override;
virtual void particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) override;
virtual void particles_collision_set_height_field_resolution(RID p_particles_collision, RSE::ParticlesCollisionHeightfieldResolution p_resolution) override;
virtual AABB particles_collision_get_aabb(RID p_particles_collision) const override;
Vector3 particles_collision_get_extents(RID p_particles_collision) const;
virtual bool particles_collision_is_heightfield(RID p_particles_collision) const override;
@ -457,7 +457,7 @@ public:
_FORCE_INLINE_ Size2i particles_collision_get_heightfield_size(RID p_particles_collision) const {
ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_NULL_V(particles_collision, Size2i());
ERR_FAIL_COND_V(particles_collision->type != RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE, Size2i());
ERR_FAIL_COND_V(particles_collision->type != RSE::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE, Size2i());
return particles_collision->heightfield_fb_size;
}

View file

@ -156,28 +156,28 @@ void RenderSceneBuffersGLES3::configure(const RenderSceneBuffersConfiguration *p
}
// Check our scaling mode
if (scaling_3d_mode != RS::VIEWPORT_SCALING_3D_MODE_OFF && internal_size.x == 0 && internal_size.y == 0) {
if (scaling_3d_mode != RSE::VIEWPORT_SCALING_3D_MODE_OFF && internal_size.x == 0 && internal_size.y == 0) {
// Disable, no size set.
scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
} else if (scaling_3d_mode != RS::VIEWPORT_SCALING_3D_MODE_OFF && internal_size == target_size) {
scaling_3d_mode = RSE::VIEWPORT_SCALING_3D_MODE_OFF;
} else if (scaling_3d_mode != RSE::VIEWPORT_SCALING_3D_MODE_OFF && internal_size == target_size) {
// If size matches, we won't use scaling.
scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
} else if (scaling_3d_mode != RS::VIEWPORT_SCALING_3D_MODE_OFF && scaling_3d_mode != RS::VIEWPORT_SCALING_3D_MODE_BILINEAR) {
scaling_3d_mode = RSE::VIEWPORT_SCALING_3D_MODE_OFF;
} else if (scaling_3d_mode != RSE::VIEWPORT_SCALING_3D_MODE_OFF && scaling_3d_mode != RSE::VIEWPORT_SCALING_3D_MODE_BILINEAR) {
// We only support bilinear scaling atm.
WARN_PRINT_ONCE("GLES only supports bilinear scaling.");
scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_BILINEAR;
scaling_3d_mode = RSE::VIEWPORT_SCALING_3D_MODE_BILINEAR;
}
// Check if we support MSAA.
if (msaa3d.mode != RS::VIEWPORT_MSAA_DISABLED && internal_size.x == 0 && internal_size.y == 0) {
if (msaa3d.mode != RSE::VIEWPORT_MSAA_DISABLED && internal_size.x == 0 && internal_size.y == 0) {
// Disable, no size set.
msaa3d.mode = RS::VIEWPORT_MSAA_DISABLED;
} else if (!use_multiview && msaa3d.mode != RS::VIEWPORT_MSAA_DISABLED && !config->msaa_supported && !config->rt_msaa_supported) {
msaa3d.mode = RSE::VIEWPORT_MSAA_DISABLED;
} else if (!use_multiview && msaa3d.mode != RSE::VIEWPORT_MSAA_DISABLED && !config->msaa_supported && !config->rt_msaa_supported) {
WARN_PRINT_ONCE("MSAA is not supported on this device.");
msaa3d.mode = RS::VIEWPORT_MSAA_DISABLED;
} else if (use_multiview && msaa3d.mode != RS::VIEWPORT_MSAA_DISABLED && !config->msaa_multiview_supported && !config->rt_msaa_multiview_supported) {
msaa3d.mode = RSE::VIEWPORT_MSAA_DISABLED;
} else if (use_multiview && msaa3d.mode != RSE::VIEWPORT_MSAA_DISABLED && !config->msaa_multiview_supported && !config->rt_msaa_multiview_supported) {
WARN_PRINT_ONCE("Multiview MSAA is not supported on this device.");
msaa3d.mode = RS::VIEWPORT_MSAA_DISABLED;
msaa3d.mode = RSE::VIEWPORT_MSAA_DISABLED;
}
// We don't create our buffers right away because post effects can be made active at any time and change our buffer configuration.
@ -189,7 +189,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
ERR_FAIL_COND(view_count == 0);
bool use_internal_buffer = scaling_3d_mode != RS::VIEWPORT_SCALING_3D_MODE_OFF || apply_color_adjustments_in_post;
bool use_internal_buffer = scaling_3d_mode != RSE::VIEWPORT_SCALING_3D_MODE_OFF || apply_color_adjustments_in_post;
GLenum depth_format = GL_DEPTH24_STENCIL8;
uint32_t depth_format_size = 4;
bool use_multiview = view_count > 1;
@ -198,7 +198,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
_clear_intermediate_buffers();
}
if ((!use_internal_buffer || internal3d.color != 0) && (msaa3d.mode == RS::VIEWPORT_MSAA_DISABLED || msaa3d.color != 0)) {
if ((!use_internal_buffer || internal3d.color != 0) && (msaa3d.mode == RSE::VIEWPORT_MSAA_DISABLED || msaa3d.color != 0)) {
// already setup!
return;
}
@ -268,7 +268,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo);
}
if (msaa3d.mode != RS::VIEWPORT_MSAA_DISABLED && msaa3d.color == 0) {
if (msaa3d.mode != RSE::VIEWPORT_MSAA_DISABLED && msaa3d.color == 0) {
// Setup MSAA.
const GLsizei samples[] = { 1, 2, 4, 8 };
msaa3d.samples = samples[msaa3d.mode];
@ -311,7 +311,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
_clear_msaa3d_buffers();
msaa3d.mode = RS::VIEWPORT_MSAA_DISABLED;
msaa3d.mode = RSE::VIEWPORT_MSAA_DISABLED;
WARN_PRINT("Could not create 3D MSAA buffers, status: " + texture_storage->get_framebuffer_error(status));
}
@ -357,7 +357,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
_clear_msaa3d_buffers();
msaa3d.mode = RS::VIEWPORT_MSAA_DISABLED;
msaa3d.mode = RSE::VIEWPORT_MSAA_DISABLED;
WARN_PRINT("Could not create 3D MSAA buffers, status: " + texture_storage->get_framebuffer_error(status));
}
@ -386,7 +386,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
_clear_msaa3d_buffers();
msaa3d.mode = RS::VIEWPORT_MSAA_DISABLED;
msaa3d.mode = RSE::VIEWPORT_MSAA_DISABLED;
WARN_PRINT("Could not create 3D MSAA framebuffer, status: " + texture_storage->get_framebuffer_error(status));
}
@ -395,7 +395,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
} else {
// HUH? how did we get here?
WARN_PRINT_ONCE("MSAA is not supported on this device.");
msaa3d.mode = RS::VIEWPORT_MSAA_DISABLED;
msaa3d.mode = RSE::VIEWPORT_MSAA_DISABLED;
msaa3d.samples = 1;
msaa3d.check_fbo_cache = false;
}
@ -408,7 +408,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
void RenderSceneBuffersGLES3::configure_for_probe(Size2i p_size) {
internal_size = p_size;
target_size = p_size;
scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
scaling_3d_mode = RSE::VIEWPORT_SCALING_3D_MODE_OFF;
view_count = 1;
}

View file

@ -43,9 +43,9 @@ class RenderSceneBuffersGLES3 : public RenderSceneBuffers {
public:
Size2i internal_size; // Size of the buffer we render 3D content to.
Size2i target_size; // Size of our output buffer (render target).
RS::ViewportScaling3DMode scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
RSE::ViewportScaling3DMode scaling_3d_mode = RSE::VIEWPORT_SCALING_3D_MODE_OFF;
//float fsr_sharpness = 0.2f;
//RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED;
//RSE::ViewportScreenSpaceAA screen_space_aa = RSE::VIEWPORT_SCREEN_SPACE_AA_DISABLED;
//bool use_taa = false;
//bool use_debanding = false;
uint32_t view_count = 1;
@ -66,7 +66,7 @@ public:
};
struct RTMSAA3D {
RS::ViewportMSAA mode = RS::VIEWPORT_MSAA_DISABLED;
RSE::ViewportMSAA mode = RSE::VIEWPORT_MSAA_DISABLED;
bool needs_resolve = false;
GLsizei samples = 1;
GLuint color = 0;
@ -102,7 +102,7 @@ public:
virtual void configure(const RenderSceneBuffersConfiguration *p_config) override;
void configure_for_probe(Size2i p_size);
virtual void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) override {}
virtual void set_anisotropic_filtering_level(RSE::ViewportAnisotropicFiltering p_anisotropic_filtering_level) override {}
virtual void set_fsr_sharpness(float p_fsr_sharpness) override {}
virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) override {}
virtual void set_use_debanding(bool p_use_debanding) override {}
@ -154,10 +154,10 @@ public:
_FORCE_INLINE_ uint32_t get_view_count() const { return view_count; }
_FORCE_INLINE_ Size2i get_internal_size() const { return internal_size; }
_FORCE_INLINE_ Size2i get_target_size() const { return target_size; }
_FORCE_INLINE_ RS::ViewportScaling3DMode get_scaling_3d_mode() const { return scaling_3d_mode; }
_FORCE_INLINE_ RSE::ViewportScaling3DMode get_scaling_3d_mode() const { return scaling_3d_mode; }
//_FORCE_INLINE_ float get_fsr_sharpness() const { return fsr_sharpness; }
_FORCE_INLINE_ RS::ViewportMSAA get_msaa_3d() const { return msaa3d.mode; }
//_FORCE_INLINE_ RS::ViewportScreenSpaceAA get_screen_space_aa() const { return screen_space_aa; }
_FORCE_INLINE_ RSE::ViewportMSAA get_msaa_3d() const { return msaa3d.mode; }
//_FORCE_INLINE_ RSE::ViewportScreenSpaceAA get_screen_space_aa() const { return screen_space_aa; }
//_FORCE_INLINE_ bool get_use_taa() const { return use_taa; }
//_FORCE_INLINE_ bool get_use_debanding() const { return use_debanding; }
};

View file

@ -72,14 +72,14 @@ TextureStorage::TextureStorage() {
images.push_back(image);
default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_WHITE] = texture_allocate();
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_WHITE], images, RS::TEXTURE_LAYERED_2D_ARRAY);
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_WHITE], images, RSE::TEXTURE_LAYERED_2D_ARRAY);
for (int i = 0; i < 5; i++) {
images.push_back(image);
}
default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_WHITE] = texture_allocate();
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_WHITE], images, RS::TEXTURE_LAYERED_CUBEMAP);
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_WHITE], images, RSE::TEXTURE_LAYERED_CUBEMAP);
}
{
@ -106,13 +106,13 @@ TextureStorage::TextureStorage() {
images.push_back(image);
default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_BLACK] = texture_allocate();
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_BLACK], images, RS::TEXTURE_LAYERED_2D_ARRAY);
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_BLACK], images, RSE::TEXTURE_LAYERED_2D_ARRAY);
for (int i = 0; i < 5; i++) {
images.push_back(image);
}
default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_BLACK] = texture_allocate();
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_BLACK], images, RS::TEXTURE_LAYERED_CUBEMAP);
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_BLACK], images, RSE::TEXTURE_LAYERED_CUBEMAP);
}
{
@ -139,14 +139,14 @@ TextureStorage::TextureStorage() {
images.push_back(image);
default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_TRANSPARENT] = texture_allocate();
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_TRANSPARENT], images, RS::TEXTURE_LAYERED_2D_ARRAY);
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_2D_ARRAY_TRANSPARENT], images, RSE::TEXTURE_LAYERED_2D_ARRAY);
for (int i = 0; i < 5; i++) {
images.push_back(image);
}
default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_TRANSPARENT] = texture_allocate();
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_TRANSPARENT], images, RS::TEXTURE_LAYERED_CUBEMAP);
texture_2d_layered_initialize(default_gl_textures[DEFAULT_GL_TEXTURE_CUBEMAP_TRANSPARENT], images, RSE::TEXTURE_LAYERED_CUBEMAP);
}
{
@ -207,7 +207,7 @@ TextureStorage::TextureStorage() {
glBindTexture(GL_TEXTURE_2D, texture.tex_id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, 4, 4, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, pixel_data);
GLES3::Utilities::get_singleton()->texture_allocated_data(texture.tex_id, 4 * 4 * 4, "Default uint texture");
texture.gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
texture.gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
}
{
uint16_t pixel_data[4 * 4];
@ -229,7 +229,7 @@ TextureStorage::TextureStorage() {
glBindTexture(GL_TEXTURE_2D, texture.tex_id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, 4, 4, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, pixel_data);
GLES3::Utilities::get_singleton()->texture_allocated_data(texture.tex_id, 4 * 4 * 2, "Default depth texture");
texture.gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
texture.gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
}
}
@ -371,8 +371,8 @@ void blit() {
glGenVertexArrays(1, &tex_blit_quad_array);
glBindVertexArray(tex_blit_quad_array);
glBindBuffer(GL_ARRAY_BUFFER, tex_blit_quad);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RSE::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(RSE::ARRAY_VERTEX);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}
@ -406,18 +406,18 @@ void TextureStorage::canvas_texture_free(RID p_rid) {
canvas_texture_owner.free(p_rid);
}
void TextureStorage::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) {
void TextureStorage::canvas_texture_set_channel(RID p_canvas_texture, RSE::CanvasTextureChannel p_channel, RID p_texture) {
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ERR_FAIL_NULL(ct);
switch (p_channel) {
case RS::CANVAS_TEXTURE_CHANNEL_DIFFUSE: {
case RSE::CANVAS_TEXTURE_CHANNEL_DIFFUSE: {
ct->diffuse = p_texture;
} break;
case RS::CANVAS_TEXTURE_CHANNEL_NORMAL: {
case RSE::CANVAS_TEXTURE_CHANNEL_NORMAL: {
ct->normal_map = p_texture;
} break;
case RS::CANVAS_TEXTURE_CHANNEL_SPECULAR: {
case RSE::CANVAS_TEXTURE_CHANNEL_SPECULAR: {
ct->specular = p_texture;
} break;
}
@ -433,14 +433,14 @@ void TextureStorage::canvas_texture_set_shading_parameters(RID p_canvas_texture,
ct->specular_color.a = p_shininess;
}
void TextureStorage::canvas_texture_set_texture_filter(RID p_canvas_texture, RS::CanvasItemTextureFilter p_filter) {
void TextureStorage::canvas_texture_set_texture_filter(RID p_canvas_texture, RSE::CanvasItemTextureFilter p_filter) {
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ERR_FAIL_NULL(ct);
ct->texture_filter = p_filter;
}
void TextureStorage::canvas_texture_set_texture_repeat(RID p_canvas_texture, RS::CanvasItemTextureRepeat p_repeat) {
void TextureStorage::canvas_texture_set_texture_repeat(RID p_canvas_texture, RSE::CanvasItemTextureRepeat p_repeat) {
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ERR_FAIL_NULL(ct);
@ -1097,11 +1097,11 @@ void TextureStorage::texture_external_initialize(RID p_texture, int p_width, int
glBindTexture(texture.target, 0);
}
void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) {
void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RSE::TextureLayeredType p_layered_type) {
ERR_FAIL_COND(p_layers.is_empty());
ERR_FAIL_COND(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP && p_layers.size() != 6);
ERR_FAIL_COND_MSG(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP_ARRAY, "Cubemap Arrays are not supported in the Compatibility renderer.");
ERR_FAIL_COND(p_layered_type == RSE::TEXTURE_LAYERED_CUBEMAP && p_layers.size() != 6);
ERR_FAIL_COND_MSG(p_layered_type == RSE::TEXTURE_LAYERED_CUBEMAP_ARRAY, "Cubemap Arrays are not supported in the Compatibility renderer.");
const Ref<Image> &image = p_layers[0];
{
@ -1136,7 +1136,7 @@ void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vector<R
texture.format = image->get_format();
texture.type = Texture::TYPE_LAYERED;
texture.layered_type = p_layered_type;
texture.target = p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D_ARRAY;
texture.target = p_layered_type == RSE::TEXTURE_LAYERED_CUBEMAP ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D_ARRAY;
texture.layers = p_layers.size();
_get_gl_image_and_format(Ref<Image>(), texture.format, texture.real_format, texture.gl_format_cache, texture.gl_internal_format_cache, texture.gl_type_cache, texture.compressed, false);
texture.total_data_size = p_layers[0]->get_image_data_size(texture.width, texture.height, texture.format, texture.mipmaps) * texture.layers;
@ -1202,7 +1202,7 @@ void TextureStorage::texture_proxy_initialize(RID p_texture, RID p_base) {
texture_owner.initialize_rid(p_texture, proxy_tex);
}
void TextureStorage::texture_drawable_initialize(RID p_texture, int p_width, int p_height, RS::TextureDrawableFormat p_format, const Color &p_color, bool p_with_mipmaps) {
void TextureStorage::texture_drawable_initialize(RID p_texture, int p_width, int p_height, RSE::TextureDrawableFormat p_format, const Color &p_color, bool p_with_mipmaps) {
// Behaves identically to Texture_2D_Initialize by generating a white image based on parameters.
// GUARDRAIL: Bad Widths/Heights
@ -1211,16 +1211,16 @@ void TextureStorage::texture_drawable_initialize(RID p_texture, int p_width, int
Image::Format format;
switch (p_format) {
case RS::TEXTURE_DRAWABLE_FORMAT_RGBA8:
case RSE::TEXTURE_DRAWABLE_FORMAT_RGBA8:
format = Image::FORMAT_RGBA8;
break;
case RS::TEXTURE_DRAWABLE_FORMAT_RGBA8_SRGB:
case RSE::TEXTURE_DRAWABLE_FORMAT_RGBA8_SRGB:
format = Image::FORMAT_RGBA8;
break;
case RS::TEXTURE_DRAWABLE_FORMAT_RGBAH:
case RSE::TEXTURE_DRAWABLE_FORMAT_RGBAH:
format = Image::FORMAT_RGBAH;
break;
case RS::TEXTURE_DRAWABLE_FORMAT_RGBAF:
case RSE::TEXTURE_DRAWABLE_FORMAT_RGBAF:
format = Image::FORMAT_RGBAF;
break;
default:
@ -1247,21 +1247,21 @@ void TextureStorage::texture_drawable_initialize(RID p_texture, int p_width, int
texture_set_data(p_texture, image);
}
RID TextureStorage::texture_create_from_native_handle(RS::TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers, RS::TextureLayeredType p_layered_type) {
RID TextureStorage::texture_create_from_native_handle(RSE::TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers, RSE::TextureLayeredType p_layered_type) {
Texture texture;
texture.active = true;
texture.is_from_native_handle = true;
switch (p_type) {
case RS::TEXTURE_TYPE_2D: {
case RSE::TEXTURE_TYPE_2D: {
texture.type = Texture::TYPE_2D;
texture.target = GL_TEXTURE_2D;
} break;
case RS::TEXTURE_TYPE_3D: {
case RSE::TEXTURE_TYPE_3D: {
texture.type = Texture::TYPE_3D;
texture.target = GL_TEXTURE_3D;
} break;
case RS::TEXTURE_TYPE_LAYERED: {
case RSE::TEXTURE_TYPE_LAYERED: {
texture.type = Texture::TYPE_LAYERED;
texture.target = GL_TEXTURE_2D_ARRAY;
} break;
@ -1371,9 +1371,9 @@ void TextureStorage::texture_drawable_blit_rect(const TypedArray<RID> &p_texture
ERR_FAIL_COND_MSG(p_textures.size() == 0 || p_source_textures.size() == 0, "Blit Rect texture output and source arrays must contain at least 1 texture.");
GLES3::MaterialStorage *material_storage = GLES3::MaterialStorage::get_singleton();
TexBlitMaterialData *m = static_cast<TexBlitMaterialData *>(material_storage->material_get_data(p_material, RS::SHADER_TEXTURE_BLIT));
TexBlitMaterialData *m = static_cast<TexBlitMaterialData *>(material_storage->material_get_data(p_material, RSE::SHADER_TEXTURE_BLIT));
if (!m) {
m = static_cast<TexBlitMaterialData *>(material_storage->material_get_data(tex_blit_shader.default_material, RS::SHADER_TEXTURE_BLIT));
m = static_cast<TexBlitMaterialData *>(material_storage->material_get_data(tex_blit_shader.default_material, RSE::SHADER_TEXTURE_BLIT));
}
// GUARDRAIL: p_material MUST BE ShaderType TextureBlit
ERR_FAIL_NULL(m);
@ -1412,7 +1412,7 @@ void TextureStorage::texture_drawable_blit_rect(const TypedArray<RID> &p_texture
draw_buffers.push_back(GL_COLOR_ATTACHMENT0 + i);
ERR_FAIL_COND_MSG(p_to_mipmap >= tar_textures[i]->mipmaps, vformat("Drawable Texture Target does not have mipmap level %d.", p_to_mipmap));
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, tar_textures[i]->tex_id, p_to_mipmap);
convert_to_srgb_mask += tar_textures[i]->drawable_type == RS::TEXTURE_DRAWABLE_FORMAT_RGBA8_SRGB ? srgbMaskArray[i] : 0;
convert_to_srgb_mask += tar_textures[i]->drawable_type == RSE::TEXTURE_DRAWABLE_FORMAT_RGBA8_SRGB ? srgbMaskArray[i] : 0;
}
// Bind Sources to buffer. Use placeholder Black Texture if source is bad.
@ -1498,8 +1498,8 @@ void TextureStorage::texture_2d_placeholder_initialize(RID p_texture) {
texture_2d_initialize(p_texture, texture_2d_placeholder);
}
void TextureStorage::texture_2d_layered_placeholder_initialize(RID p_texture, RS::TextureLayeredType p_layered_type) {
if (p_layered_type == RS::TEXTURE_LAYERED_2D_ARRAY) {
void TextureStorage::texture_2d_layered_placeholder_initialize(RID p_texture, RSE::TextureLayeredType p_layered_type) {
if (p_layered_type == RSE::TEXTURE_LAYERED_2D_ARRAY) {
texture_2d_layered_initialize(p_texture, texture_2d_array_placeholder, p_layered_type);
} else {
texture_2d_layered_initialize(p_texture, cubemap_placeholder, p_layered_type);
@ -1883,7 +1883,7 @@ String TextureStorage::texture_get_path(RID p_texture) const {
return texture->path;
}
void TextureStorage::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
void TextureStorage::texture_set_detect_3d_callback(RID p_texture, RenderingServerTypes::TextureDetectCallback p_callback, void *p_userdata) {
Texture *texture = texture_owner.get_or_null(p_texture);
ERR_FAIL_NULL(texture);
@ -1891,10 +1891,10 @@ void TextureStorage::texture_set_detect_3d_callback(RID p_texture, RS::TextureDe
texture->detect_3d_callback_ud = p_userdata;
}
void TextureStorage::texture_set_detect_srgb_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
void TextureStorage::texture_set_detect_srgb_callback(RID p_texture, RenderingServerTypes::TextureDetectCallback p_callback, void *p_userdata) {
}
void TextureStorage::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
void TextureStorage::texture_set_detect_normal_callback(RID p_texture, RenderingServerTypes::TextureDetectCallback p_callback, void *p_userdata) {
Texture *texture = texture_owner.get_or_null(p_texture);
ERR_FAIL_NULL(texture);
@ -1902,7 +1902,7 @@ void TextureStorage::texture_set_detect_normal_callback(RID p_texture, RS::Textu
texture->detect_normal_callback_ud = p_userdata;
}
void TextureStorage::texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
void TextureStorage::texture_set_detect_roughness_callback(RID p_texture, RenderingServerTypes::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
Texture *texture = texture_owner.get_or_null(p_texture);
ERR_FAIL_NULL(texture);
@ -1910,19 +1910,19 @@ void TextureStorage::texture_set_detect_roughness_callback(RID p_texture, RS::Te
texture->detect_roughness_callback_ud = p_userdata;
}
void TextureStorage::texture_debug_usage(List<RS::TextureInfo> *r_info) {
void TextureStorage::texture_debug_usage(List<RenderingServerTypes::TextureInfo> *r_info) {
for (const RID &rid : texture_owner.get_owned_list()) {
Texture *t = texture_owner.get_or_null(rid);
if (!t) {
continue;
}
RS::TextureInfo tinfo;
RenderingServerTypes::TextureInfo tinfo;
tinfo.path = t->path;
tinfo.format = t->format;
tinfo.width = t->alloc_width;
tinfo.height = t->alloc_height;
tinfo.bytes = t->total_data_size;
tinfo.type = static_cast<RenderingServer::TextureType>(t->type);
tinfo.type = static_cast<RSE::TextureType>(t->type);
switch (t->type) {
case Texture::TYPE_3D:
@ -1960,7 +1960,7 @@ Size2 TextureStorage::texture_size_with_proxy(RID p_texture) {
}
}
void TextureStorage::texture_rd_initialize(RID p_texture, const RID &p_rd_texture, const RS::TextureLayeredType p_layer_type) {
void TextureStorage::texture_rd_initialize(RID p_texture, const RID &p_rd_texture, const RSE::TextureLayeredType p_layer_type) {
}
RID TextureStorage::texture_get_rd_texture(RID p_texture, bool p_srgb) const {
@ -2034,12 +2034,12 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &p_image,
// Set filtering and repeat state to default.
if (mipmaps > 1) {
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
texture->gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
} else {
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
texture->gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
}
texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
texture->gl_set_repeat(RSE::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
int w = img->get_width();
int h = img->get_height();
@ -2114,12 +2114,12 @@ void TextureStorage::_texture_set_3d_data(RID p_texture, const Vector<Ref<Image>
// Set filtering and repeat state to default.
if (texture->mipmaps > 1) {
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
texture->gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
} else {
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
texture->gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
}
texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
texture->gl_set_repeat(RSE::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
Vector<Ref<Image>> images;
images.resize(p_data.size());
@ -2503,7 +2503,7 @@ void TextureStorage::decal_initialize(RID p_rid) {
void TextureStorage::decal_set_size(RID p_decal, const Vector3 &p_size) {
}
void TextureStorage::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) {
void TextureStorage::decal_set_texture(RID p_decal, RSE::DecalTexture p_type, RID p_texture) {
}
void TextureStorage::decal_set_emission_energy(RID p_decal, float p_energy) {
@ -2603,8 +2603,8 @@ void TextureStorage::_update_render_target_color(RenderTarget *rt) {
glTexImage2D(texture_target, 0, rt->color_internal_format, rt->size.x, rt->size.y, 0, rt->color_format, rt->color_type, nullptr);
}
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
texture->gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
texture->gl_set_repeat(RSE::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
GLES3::Utilities::get_singleton()->texture_allocated_data(rt->color, rt->size.x * rt->size.y * rt->view_count * rt->color_format_size, "Render target color texture");
}
@ -2853,8 +2853,8 @@ void TextureStorage::_clear_render_target(RenderTarget *rt) {
tex->active = false;
tex->render_target = nullptr;
tex->is_render_target = false;
tex->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_MAX);
tex->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX);
tex->gl_set_filter(RSE::CANVAS_ITEM_TEXTURE_FILTER_MAX);
tex->gl_set_repeat(RSE::CANVAS_ITEM_TEXTURE_REPEAT_MAX);
}
} else {
Texture *tex = get_texture(rt->overridden.color);
@ -3197,7 +3197,7 @@ void TextureStorage::render_target_clear_used(RID p_render_target) {
rt->used_in_frame = false;
}
void TextureStorage::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) {
void TextureStorage::render_target_set_msaa(RID p_render_target, RSE::ViewportMSAA p_msaa) {
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_NULL(rt);
ERR_FAIL_COND(rt->direct_to_screen);
@ -3214,9 +3214,9 @@ void TextureStorage::render_target_set_msaa(RID p_render_target, RS::ViewportMSA
}
}
RS::ViewportMSAA TextureStorage::render_target_get_msaa(RID p_render_target) const {
RSE::ViewportMSAA TextureStorage::render_target_get_msaa(RID p_render_target) const {
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_NULL_V(rt, RS::VIEWPORT_MSAA_DISABLED);
ERR_FAIL_NULL_V(rt, RSE::VIEWPORT_MSAA_DISABLED);
return rt->msaa;
}
@ -3364,7 +3364,7 @@ bool TextureStorage::render_target_is_reattach_textures(RID p_render_target) con
return rt->reattach_textures;
}
void TextureStorage::render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) {
void TextureStorage::render_target_set_sdf_size_and_scale(RID p_render_target, RSE::ViewportSDFOversize p_size, RSE::ViewportSDFScale p_scale) {
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_NULL(rt);
if (rt->sdf_oversize == p_size && rt->sdf_scale == p_scale) {
@ -3381,16 +3381,16 @@ Rect2i TextureStorage::_render_target_get_sdf_rect(const RenderTarget *rt) const
Size2i margin;
int scale;
switch (rt->sdf_oversize) {
case RS::VIEWPORT_SDF_OVERSIZE_100_PERCENT: {
case RSE::VIEWPORT_SDF_OVERSIZE_100_PERCENT: {
scale = 100;
} break;
case RS::VIEWPORT_SDF_OVERSIZE_120_PERCENT: {
case RSE::VIEWPORT_SDF_OVERSIZE_120_PERCENT: {
scale = 120;
} break;
case RS::VIEWPORT_SDF_OVERSIZE_150_PERCENT: {
case RSE::VIEWPORT_SDF_OVERSIZE_150_PERCENT: {
scale = 150;
} break;
case RS::VIEWPORT_SDF_OVERSIZE_200_PERCENT: {
case RSE::VIEWPORT_SDF_OVERSIZE_200_PERCENT: {
scale = 200;
} break;
default: {
@ -3463,13 +3463,13 @@ void TextureStorage::_render_target_allocate_sdf(RenderTarget *rt) {
int scale;
switch (rt->sdf_scale) {
case RS::VIEWPORT_SDF_SCALE_100_PERCENT: {
case RSE::VIEWPORT_SDF_SCALE_100_PERCENT: {
scale = 100;
} break;
case RS::VIEWPORT_SDF_SCALE_50_PERCENT: {
case RSE::VIEWPORT_SDF_SCALE_50_PERCENT: {
scale = 50;
} break;
case RS::VIEWPORT_SDF_SCALE_25_PERCENT: {
case RSE::VIEWPORT_SDF_SCALE_25_PERCENT: {
scale = 25;
} break;
default: {
@ -3555,13 +3555,13 @@ void TextureStorage::render_target_sdf_process(RID p_render_target) {
bool shrink = false;
switch (rt->sdf_scale) {
case RS::VIEWPORT_SDF_SCALE_50_PERCENT: {
case RSE::VIEWPORT_SDF_SCALE_50_PERCENT: {
size[0] >>= 1;
size[1] >>= 1;
shift = 1;
shrink = true;
} break;
case RS::VIEWPORT_SDF_SCALE_25_PERCENT: {
case RSE::VIEWPORT_SDF_SCALE_25_PERCENT: {
size[0] >>= 2;
size[1] >>= 2;
shift = 2;

View file

@ -37,6 +37,8 @@
#include "core/templates/rid_owner.h"
#include "drivers/gles3/shaders/canvas_sdf.glsl.gen.h"
#include "drivers/gles3/storage/config.h"
#include "servers/rendering/rendering_server_enums.h"
#include "servers/rendering/rendering_server_types.h"
#include "servers/rendering/storage/texture_storage.h"
#include "platform_gl.h"
@ -145,8 +147,8 @@ struct CanvasTexture {
Color specular_color = Color(1, 1, 1, 1);
float shininess = 1.0;
RS::CanvasItemTextureFilter texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
RS::CanvasItemTextureRepeat texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
RSE::CanvasItemTextureFilter texture_filter = RSE::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
RSE::CanvasItemTextureRepeat texture_repeat = RSE::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
};
struct RenderTarget;
@ -179,8 +181,8 @@ struct Texture {
};
Type type = TYPE_2D;
RS::TextureLayeredType layered_type = RS::TEXTURE_LAYERED_2D_ARRAY;
RS::TextureDrawableFormat drawable_type = RS::TEXTURE_DRAWABLE_FORMAT_RGBA8;
RSE::TextureLayeredType layered_type = RSE::TEXTURE_LAYERED_2D_ARRAY;
RSE::TextureDrawableFormat drawable_type = RSE::TEXTURE_DRAWABLE_FORMAT_RGBA8;
GLenum target = GL_TEXTURE_2D;
GLenum gl_format_cache = 0;
@ -205,13 +207,13 @@ struct Texture {
bool redraw_if_visible = false;
RS::TextureDetectCallback detect_3d_callback = nullptr;
RenderingServerTypes::TextureDetectCallback detect_3d_callback = nullptr;
void *detect_3d_callback_ud = nullptr;
RS::TextureDetectCallback detect_normal_callback = nullptr;
RenderingServerTypes::TextureDetectCallback detect_normal_callback = nullptr;
void *detect_normal_callback_ud = nullptr;
RS::TextureDetectRoughnessCallback detect_roughness_callback = nullptr;
RenderingServerTypes::TextureDetectRoughnessCallback detect_roughness_callback = nullptr;
void *detect_roughness_callback_ud = nullptr;
CanvasTexture *canvas_texture = nullptr;
@ -247,7 +249,7 @@ struct Texture {
}
// texture state
void gl_set_filter(RS::CanvasItemTextureFilter p_filter) {
void gl_set_filter(RSE::CanvasItemTextureFilter p_filter) {
if (p_filter == state_filter) {
return;
}
@ -258,21 +260,21 @@ struct Texture {
GLint max_lod = 0;
GLfloat anisotropy = 1.0f;
switch (state_filter) {
case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: {
case RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: {
pmin = GL_NEAREST;
pmag = GL_NEAREST;
max_lod = 0;
} break;
case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR: {
case RSE::CANVAS_ITEM_TEXTURE_FILTER_LINEAR: {
pmin = GL_LINEAR;
pmag = GL_LINEAR;
max_lod = 0;
} break;
case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: {
case RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: {
anisotropy = config->anisotropic_level;
};
[[fallthrough]];
case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: {
case RSE::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: {
pmag = GL_NEAREST;
if (mipmaps <= 1) {
pmin = GL_NEAREST;
@ -285,11 +287,11 @@ struct Texture {
max_lod = mipmaps - 1;
}
} break;
case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: {
case RSE::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: {
anisotropy = config->anisotropic_level;
};
[[fallthrough]];
case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: {
case RSE::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: {
pmag = GL_LINEAR;
if (mipmaps <= 1) {
pmin = GL_LINEAR;
@ -314,20 +316,20 @@ struct Texture {
glTexParameterf(target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
}
}
void gl_set_repeat(RS::CanvasItemTextureRepeat p_repeat) {
void gl_set_repeat(RSE::CanvasItemTextureRepeat p_repeat) {
if (p_repeat == state_repeat) {
return;
}
state_repeat = p_repeat;
GLenum prep = GL_CLAMP_TO_EDGE;
switch (state_repeat) {
case RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: {
case RSE::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: {
prep = GL_CLAMP_TO_EDGE;
} break;
case RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: {
case RSE::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: {
prep = GL_REPEAT;
} break;
case RS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: {
case RSE::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: {
prep = GL_MIRRORED_REPEAT;
} break;
default: {
@ -340,8 +342,8 @@ struct Texture {
}
private:
RS::CanvasItemTextureFilter state_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RS::CanvasItemTextureRepeat state_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX;
RSE::CanvasItemTextureFilter state_filter = RSE::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RSE::CanvasItemTextureRepeat state_repeat = RSE::CANVAS_ITEM_TEXTURE_REPEAT_MAX;
};
struct RenderTarget {
@ -371,8 +373,8 @@ struct RenderTarget {
GLuint sdf_texture_write_fb = 0;
GLuint sdf_texture_process[2] = { 0, 0 };
GLuint sdf_texture_read = 0;
RS::ViewportSDFOversize sdf_oversize = RS::VIEWPORT_SDF_OVERSIZE_120_PERCENT;
RS::ViewportSDFScale sdf_scale = RS::VIEWPORT_SDF_SCALE_50_PERCENT;
RSE::ViewportSDFOversize sdf_oversize = RSE::VIEWPORT_SDF_OVERSIZE_120_PERCENT;
RSE::ViewportSDFScale sdf_scale = RSE::VIEWPORT_SDF_SCALE_50_PERCENT;
Size2i process_size;
bool sdf_enabled = false;
@ -380,7 +382,7 @@ struct RenderTarget {
bool direct_to_screen = false;
bool used_in_frame = false;
RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED;
RSE::ViewportMSAA msaa = RSE::VIEWPORT_MSAA_DISABLED;
bool reattach_textures = false;
Rect2i render_region;
@ -521,11 +523,11 @@ public:
virtual void canvas_texture_initialize(RID p_rid) override;
virtual void canvas_texture_free(RID p_rid) override;
virtual void canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) override;
virtual void canvas_texture_set_channel(RID p_canvas_texture, RSE::CanvasTextureChannel p_channel, RID p_texture) override;
virtual void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) override;
virtual void canvas_texture_set_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) override;
virtual void canvas_texture_set_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) override;
virtual void canvas_texture_set_texture_filter(RID p_item, RSE::CanvasItemTextureFilter p_filter) override;
virtual void canvas_texture_set_texture_repeat(RID p_item, RSE::CanvasItemTextureRepeat p_repeat) override;
/* Texture API */
@ -546,13 +548,13 @@ public:
virtual void texture_free(RID p_rid) override;
virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override;
virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) override;
virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RSE::TextureLayeredType p_layered_type) override;
virtual void texture_3d_initialize(RID p_texture, Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) override;
virtual void texture_external_initialize(RID p_texture, int p_width, int p_height, uint64_t p_external_buffer) override;
virtual void texture_proxy_initialize(RID p_texture, RID p_base) override; //all slices, then all the mipmaps, must be coherent
virtual void texture_drawable_initialize(RID p_texture, int p_width, int p_height, RS::TextureDrawableFormat p_format, const Color &p_color, bool p_with_mipmaps) override;
virtual void texture_drawable_initialize(RID p_texture, int p_width, int p_height, RSE::TextureDrawableFormat p_format, const Color &p_color, bool p_with_mipmaps) override;
virtual RID texture_create_from_native_handle(RS::TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers = 1, RS::TextureLayeredType p_layered_type = RS::TEXTURE_LAYERED_2D_ARRAY) override;
virtual RID texture_create_from_native_handle(RSE::TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers = 1, RSE::TextureLayeredType p_layered_type = RSE::TEXTURE_LAYERED_2D_ARRAY) override;
virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) override;
virtual void texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) override;
@ -569,7 +571,7 @@ public:
//these two APIs can be used together or in combination with the others.
virtual void texture_2d_placeholder_initialize(RID p_texture) override;
virtual void texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) override;
virtual void texture_2d_layered_placeholder_initialize(RID p_texture, RSE::TextureLayeredType p_layered_type) override;
virtual void texture_3d_placeholder_initialize(RID p_texture) override;
virtual Ref<Image> texture_2d_get(RID p_texture) const override;
@ -585,18 +587,18 @@ public:
virtual void texture_set_path(RID p_texture, const String &p_path) override;
virtual String texture_get_path(RID p_texture) const override;
virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) override;
void texture_set_detect_srgb_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata);
virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) override;
virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) override;
virtual void texture_set_detect_3d_callback(RID p_texture, RenderingServerTypes::TextureDetectCallback p_callback, void *p_userdata) override;
void texture_set_detect_srgb_callback(RID p_texture, RenderingServerTypes::TextureDetectCallback p_callback, void *p_userdata);
virtual void texture_set_detect_normal_callback(RID p_texture, RenderingServerTypes::TextureDetectCallback p_callback, void *p_userdata) override;
virtual void texture_set_detect_roughness_callback(RID p_texture, RenderingServerTypes::TextureDetectRoughnessCallback p_callback, void *p_userdata) override;
virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) override;
virtual void texture_debug_usage(List<RenderingServerTypes::TextureInfo> *r_info) override;
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) override;
virtual Size2 texture_size_with_proxy(RID p_proxy) override;
virtual void texture_rd_initialize(RID p_texture, const RID &p_rd_texture, const RS::TextureLayeredType p_layer_type = RS::TEXTURE_LAYERED_2D_ARRAY) override;
virtual void texture_rd_initialize(RID p_texture, const RID &p_rd_texture, const RSE::TextureLayeredType p_layer_type = RSE::TEXTURE_LAYERED_2D_ARRAY) override;
virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const override;
virtual uint64_t texture_get_native_handle(RID p_texture, bool p_srgb = false) const override;
@ -635,7 +637,7 @@ public:
virtual void decal_free(RID p_rid) override {}
virtual void decal_set_size(RID p_decal, const Vector3 &p_size) override;
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) override;
virtual void decal_set_texture(RID p_decal, RSE::DecalTexture p_type, RID p_texture) override;
virtual void decal_set_emission_energy(RID p_decal, float p_energy) override;
virtual void decal_set_albedo_mix(RID p_decal, float p_mix) override;
virtual void decal_set_modulate(RID p_decal, const Color &p_modulate) override;
@ -677,8 +679,8 @@ public:
virtual bool render_target_get_direct_to_screen(RID p_render_target) const override;
virtual bool render_target_was_used(RID p_render_target) const override;
void render_target_clear_used(RID p_render_target);
virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) override;
virtual RS::ViewportMSAA render_target_get_msaa(RID p_render_target) const override;
virtual void render_target_set_msaa(RID p_render_target, RSE::ViewportMSAA p_msaa) override;
virtual RSE::ViewportMSAA render_target_get_msaa(RID p_render_target) const override;
virtual void render_target_set_msaa_needs_resolve(RID p_render_target, bool p_needs_resolve) override {}
virtual bool render_target_get_msaa_needs_resolve(RID p_render_target) const override { return false; }
virtual void render_target_do_msaa_resolve(RID p_render_target) override {}
@ -710,7 +712,7 @@ public:
void render_target_set_reattach_textures(RID p_render_target, bool p_reattach_textures) const;
bool render_target_is_reattach_textures(RID p_render_target) const;
virtual void render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) override;
virtual void render_target_set_sdf_size_and_scale(RID p_render_target, RSE::ViewportSDFOversize p_size, RSE::ViewportSDFScale p_scale) override;
virtual Rect2i render_target_get_sdf_rect(RID p_render_target) const override;
GLuint render_target_get_sdf_texture(RID p_render_target);
GLuint render_target_get_sdf_framebuffer(RID p_render_target);
@ -722,10 +724,10 @@ public:
void render_target_clear_back_buffer(RID p_render_target, const Rect2i &p_region, const Color &p_color);
void render_target_gen_back_buffer_mipmaps(RID p_render_target, const Rect2i &p_region);
virtual void render_target_set_vrs_mode(RID p_render_target, RS::ViewportVRSMode p_mode) override {}
virtual RS::ViewportVRSMode render_target_get_vrs_mode(RID p_render_target) const override { return RS::VIEWPORT_VRS_DISABLED; }
virtual void render_target_set_vrs_update_mode(RID p_render_target, RS::ViewportVRSUpdateMode p_mode) override {}
virtual RS::ViewportVRSUpdateMode render_target_get_vrs_update_mode(RID p_render_target) const override { return RS::VIEWPORT_VRS_UPDATE_DISABLED; }
virtual void render_target_set_vrs_mode(RID p_render_target, RSE::ViewportVRSMode p_mode) override {}
virtual RSE::ViewportVRSMode render_target_get_vrs_mode(RID p_render_target) const override { return RSE::VIEWPORT_VRS_DISABLED; }
virtual void render_target_set_vrs_update_mode(RID p_render_target, RSE::ViewportVRSUpdateMode p_mode) override {}
virtual RSE::ViewportVRSUpdateMode render_target_get_vrs_update_mode(RID p_render_target) const override { return RSE::VIEWPORT_VRS_UPDATE_DISABLED; }
virtual void render_target_set_vrs_texture(RID p_render_target, RID p_texture) override {}
virtual RID render_target_get_vrs_texture(RID p_render_target) const override { return RID(); }

View file

@ -145,25 +145,25 @@ Vector<uint8_t> Utilities::buffer_get_data(GLenum p_target, GLuint p_buffer, uin
/* INSTANCES */
RS::InstanceType Utilities::get_base_type(RID p_rid) const {
RSE::InstanceType Utilities::get_base_type(RID p_rid) const {
if (GLES3::MeshStorage::get_singleton()->owns_mesh(p_rid)) {
return RS::INSTANCE_MESH;
return RSE::INSTANCE_MESH;
} else if (GLES3::MeshStorage::get_singleton()->owns_multimesh(p_rid)) {
return RS::INSTANCE_MULTIMESH;
return RSE::INSTANCE_MULTIMESH;
} else if (GLES3::LightStorage::get_singleton()->owns_light(p_rid)) {
return RS::INSTANCE_LIGHT;
return RSE::INSTANCE_LIGHT;
} else if (GLES3::LightStorage::get_singleton()->owns_lightmap(p_rid)) {
return RS::INSTANCE_LIGHTMAP;
return RSE::INSTANCE_LIGHTMAP;
} else if (GLES3::ParticlesStorage::get_singleton()->owns_particles(p_rid)) {
return RS::INSTANCE_PARTICLES;
return RSE::INSTANCE_PARTICLES;
} else if (GLES3::LightStorage::get_singleton()->owns_reflection_probe(p_rid)) {
return RS::INSTANCE_REFLECTION_PROBE;
return RSE::INSTANCE_REFLECTION_PROBE;
} else if (GLES3::ParticlesStorage::get_singleton()->owns_particles_collision(p_rid)) {
return RS::INSTANCE_PARTICLES_COLLISION;
return RSE::INSTANCE_PARTICLES_COLLISION;
} else if (owns_visibility_notifier(p_rid)) {
return RS::INSTANCE_VISIBLITY_NOTIFIER;
return RSE::INSTANCE_VISIBLITY_NOTIFIER;
}
return RS::INSTANCE_NONE;
return RSE::INSTANCE_NONE;
}
bool Utilities::free(RID p_rid) {
@ -431,12 +431,12 @@ bool Utilities::has_os_feature(const String &p_feature) const {
void Utilities::update_memory_info() {
}
uint64_t Utilities::get_rendering_info(RS::RenderingInfo p_info) {
if (p_info == RS::RENDERING_INFO_TEXTURE_MEM_USED) {
uint64_t Utilities::get_rendering_info(RSE::RenderingInfo p_info) {
if (p_info == RSE::RENDERING_INFO_TEXTURE_MEM_USED) {
return texture_mem_cache + render_buffer_mem_cache; // Add render buffer memory to our texture mem.
} else if (p_info == RS::RENDERING_INFO_BUFFER_MEM_USED) {
} else if (p_info == RSE::RENDERING_INFO_BUFFER_MEM_USED) {
return buffer_mem_cache;
} else if (p_info == RS::RENDERING_INFO_VIDEO_MEM_USED) {
} else if (p_info == RSE::RENDERING_INFO_VIDEO_MEM_USED) {
return texture_mem_cache + buffer_mem_cache + render_buffer_mem_cache;
}
return 0;

View file

@ -33,7 +33,6 @@
#ifdef GLES3_ENABLED
#include "core/templates/rid_owner.h"
#include "servers/rendering/storage/utilities.h"
#include "platform_gl.h"
@ -157,7 +156,7 @@ public:
/* INSTANCES */
virtual RS::InstanceType get_base_type(RID p_rid) const override;
virtual RSE::InstanceType get_base_type(RID p_rid) const override;
virtual bool free(RID p_rid) override;
/* DEPENDENCIES */
@ -220,7 +219,7 @@ public:
virtual void update_memory_info() override;
virtual uint64_t get_rendering_info(RS::RenderingInfo p_info) override;
virtual uint64_t get_rendering_info(RSE::RenderingInfo p_info) override;
virtual String get_video_adapter_name() const override;
virtual String get_video_adapter_vendor() const override;
virtual RenderingDeviceEnums::DeviceType get_video_adapter_type() const override;

View file

@ -40,7 +40,6 @@
#include "drivers/unix/file_access_unix_pipe.h"
#include "drivers/unix/net_socket_unix.h"
#include "drivers/unix/thread_posix.h"
#include "servers/rendering/rendering_server.h"
#if defined(__APPLE__)
#include <mach-o/dyld.h>

View file

@ -1727,7 +1727,7 @@ void AnimationPlayerEditor::_allocate_onion_layers() {
onion.captures[i] = RS::get_singleton()->viewport_create();
RS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height);
RS::get_singleton()->viewport_set_update_mode(onion.captures[i], RS::VIEWPORT_UPDATE_ALWAYS);
RS::get_singleton()->viewport_set_update_mode(onion.captures[i], RSE::VIEWPORT_UPDATE_ALWAYS);
RS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present);
RS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas);
}
@ -1828,7 +1828,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2_prolog() {
RID root_vp = get_tree()->get_root()->get_viewport_rid();
onion.temp.screen_rect = Rect2(Vector2(), DisplayServer::get_singleton()->window_get_size(DisplayServer::MAIN_WINDOW_ID));
RS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2(), DisplayServer::INVALID_WINDOW_ID);
RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_ALWAYS);
RS::get_singleton()->viewport_set_update_mode(root_vp, RSE::VIEWPORT_UPDATE_ALWAYS);
RID present_rid;
if (onion.differences_only) {
@ -1914,7 +1914,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2_epilog() {
RID root_vp = get_tree()->get_root()->get_viewport_rid();
RS::get_singleton()->viewport_set_parent_viewport(root_vp, RID());
RS::get_singleton()->viewport_attach_to_screen(root_vp, onion.temp.screen_rect, DisplayServer::MAIN_WINDOW_ID);
RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_WHEN_VISIBLE);
RS::get_singleton()->viewport_set_update_mode(root_vp, RSE::VIEWPORT_UPDATE_WHEN_VISIBLE);
// Restore animation state.
// Here we're combine the power of seeking back to the original position and

View file

@ -40,6 +40,7 @@
#include "scene/3d/sprite_3d.h"
#include "scene/animation/animation_player.h"
#include "servers/audio/audio_stream.h"
#include "servers/rendering/rendering_server.h"
/// BOOL ///
int AnimationTrackEditBool::get_key_height() const {

View file

@ -35,6 +35,7 @@
#include "editor/settings/editor_settings.h"
#include "editor/themes/editor_scale.h"
#include "scene/resources/audio_stream_wav.h"
#include "servers/rendering/rendering_server.h"
// AudioStreamEditor

View file

@ -30,6 +30,8 @@
#pragma once
#include "core/object/ref_counted.h"
#include "core/object/script_language.h"
#include "scene/gui/control.h"
class ScriptEditorDebugger;

View file

@ -30,6 +30,7 @@
#pragma once
#include "core/doc_data.h"
#include "core/templates/rb_set.h"
#include "editor/plugins/editor_plugin.h"
#include "scene/gui/dialogs.h"

View file

@ -61,6 +61,7 @@
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/theme.h"
#include "servers/rendering/rendering_server.h"
EditorInterface *EditorInterface::singleton = nullptr;
@ -148,7 +149,7 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
RID scenario = RS::get_singleton()->scenario_create();
RID viewport = RS::get_singleton()->viewport_create();
RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS);
RS::get_singleton()->viewport_set_update_mode(viewport, RSE::VIEWPORT_UPDATE_ALWAYS);
RS::get_singleton()->viewport_set_scenario(viewport, scenario);
RS::get_singleton()->viewport_set_size(viewport, size, size);
RS::get_singleton()->viewport_set_transparent_background(viewport, true);

View file

@ -45,36 +45,6 @@
#include "core/string/print_string.h"
#include "core/string/translation_server.h"
#include "core/version.h"
#include "editor/editor_string_names.h"
#include "editor/inspector/editor_context_menu_plugin.h"
#include "editor/plugins/editor_plugin_list.h"
#include "main/main.h"
#include "scene/2d/node_2d.h"
#include "scene/3d/bone_attachment_3d.h"
#include "scene/animation/animation_tree.h"
#include "scene/gui/color_picker.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/menu_bar.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
#include "scene/gui/popup.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/main/timer.h"
#include "scene/main/window.h"
#include "scene/property_utils.h"
#include "scene/resources/dpi_texture.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/portable_compressed_texture.h"
#include "scene/theme/theme_db.h"
#include "servers/display/display_server.h"
#include "servers/navigation_2d/navigation_server_2d.h"
#include "servers/navigation_3d/navigation_server_3d.h"
#include "servers/rendering/rendering_server.h"
#include "editor/animation/animation_player_editor_plugin.h"
#include "editor/asset_library/asset_library_editor_plugin.h"
#include "editor/audio/audio_stream_preview.h"
@ -95,6 +65,7 @@
#include "editor/editor_interface.h"
#include "editor/editor_log.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/export/dedicated_server_export_plugin.h"
#include "editor/export/editor_export.h"
@ -133,6 +104,7 @@
#include "editor/import/resource_importer_texture.h"
#include "editor/import/resource_importer_texture_atlas.h"
#include "editor/import/resource_importer_wav.h"
#include "editor/inspector/editor_context_menu_plugin.h"
#include "editor/inspector/editor_inspector.h"
#include "editor/inspector/editor_preview_plugins.h"
#include "editor/inspector/editor_properties.h"
@ -141,6 +113,7 @@
#include "editor/inspector/editor_resource_preview.h"
#include "editor/inspector/multi_node_edit.h"
#include "editor/plugins/editor_plugin.h"
#include "editor/plugins/editor_plugin_list.h"
#include "editor/plugins/editor_resource_conversion_plugin.h"
#include "editor/plugins/plugin_config_dialog.h"
#include "editor/project_upgrade/project_upgrade_tool.h"
@ -173,6 +146,32 @@
#include "editor/translations/editor_translation_parser.h"
#include "editor/translations/packed_scene_translation_parser_plugin.h"
#include "editor/version_control/version_control_editor_plugin.h"
#include "main/main.h"
#include "scene/2d/node_2d.h"
#include "scene/3d/bone_attachment_3d.h"
#include "scene/animation/animation_tree.h"
#include "scene/gui/color_picker.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/menu_bar.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
#include "scene/gui/popup.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/main/timer.h"
#include "scene/main/window.h"
#include "scene/property_utils.h"
#include "scene/resources/dpi_texture.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/portable_compressed_texture.h"
#include "scene/theme/theme_db.h"
#include "servers/display/display_server.h"
#include "servers/navigation_2d/navigation_server_2d.h"
#include "servers/navigation_3d/navigation_server_3d.h"
#include "servers/rendering/rendering_server.h"
#ifdef VULKAN_ENABLED
#include "editor/shader/shader_baker/shader_baker_export_plugin_platform_vulkan.h"
@ -186,8 +185,6 @@
#include "editor/shader/shader_baker/shader_baker_export_plugin_platform_metal.h"
#endif
#include "modules/modules_enabled.gen.h" // For gdscript, mono.
#ifndef PHYSICS_2D_DISABLED
#include "servers/physics_2d/physics_server_2d.h"
#endif // PHYSICS_2D_DISABLED
@ -200,6 +197,8 @@
#include "editor/gui/touch_actions_panel.h"
#endif // ANDROID_ENABLED
#include "modules/modules_enabled.gen.h" // For gdscript, mono.
#include <cstdlib>
EditorNode *EditorNode::singleton = nullptr;
@ -488,18 +487,18 @@ void EditorNode::_update_from_settings() {
scene_root->propagate_notification(Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED);
}
RS::DOFBokehShape dof_shape = RS::DOFBokehShape(int(GLOBAL_GET("rendering/camera/depth_of_field/depth_of_field_bokeh_shape")));
RSE::DOFBokehShape dof_shape = RSE::DOFBokehShape(int(GLOBAL_GET("rendering/camera/depth_of_field/depth_of_field_bokeh_shape")));
RS::get_singleton()->camera_attributes_set_dof_blur_bokeh_shape(dof_shape);
RS::DOFBlurQuality dof_quality = RS::DOFBlurQuality(int(GLOBAL_GET("rendering/camera/depth_of_field/depth_of_field_bokeh_quality")));
RSE::DOFBlurQuality dof_quality = RSE::DOFBlurQuality(int(GLOBAL_GET("rendering/camera/depth_of_field/depth_of_field_bokeh_quality")));
bool dof_jitter = GLOBAL_GET("rendering/camera/depth_of_field/depth_of_field_use_jitter");
RS::get_singleton()->camera_attributes_set_dof_blur_quality(dof_quality, dof_jitter);
RS::get_singleton()->environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/environment/ssao/quality"))), GLOBAL_GET("rendering/environment/ssao/half_size"), GLOBAL_GET("rendering/environment/ssao/adaptive_target"), GLOBAL_GET("rendering/environment/ssao/blur_passes"), GLOBAL_GET("rendering/environment/ssao/fadeout_from"), GLOBAL_GET("rendering/environment/ssao/fadeout_to"));
RS::get_singleton()->environment_set_ssao_quality(RSE::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/environment/ssao/quality"))), GLOBAL_GET("rendering/environment/ssao/half_size"), GLOBAL_GET("rendering/environment/ssao/adaptive_target"), GLOBAL_GET("rendering/environment/ssao/blur_passes"), GLOBAL_GET("rendering/environment/ssao/fadeout_from"), GLOBAL_GET("rendering/environment/ssao/fadeout_to"));
RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/anti_aliasing/screen_space_roughness_limiter/enabled"), GLOBAL_GET("rendering/anti_aliasing/screen_space_roughness_limiter/amount"), GLOBAL_GET("rendering/anti_aliasing/screen_space_roughness_limiter/limit"));
bool glow_bicubic = int(GLOBAL_GET("rendering/environment/glow/upscale_mode")) > 0;
RS::get_singleton()->environment_set_ssil_quality(RS::EnvironmentSSILQuality(int(GLOBAL_GET("rendering/environment/ssil/quality"))), GLOBAL_GET("rendering/environment/ssil/half_size"), GLOBAL_GET("rendering/environment/ssil/adaptive_target"), GLOBAL_GET("rendering/environment/ssil/blur_passes"), GLOBAL_GET("rendering/environment/ssil/fadeout_from"), GLOBAL_GET("rendering/environment/ssil/fadeout_to"));
RS::get_singleton()->environment_set_ssil_quality(RSE::EnvironmentSSILQuality(int(GLOBAL_GET("rendering/environment/ssil/quality"))), GLOBAL_GET("rendering/environment/ssil/half_size"), GLOBAL_GET("rendering/environment/ssil/adaptive_target"), GLOBAL_GET("rendering/environment/ssil/blur_passes"), GLOBAL_GET("rendering/environment/ssil/fadeout_from"), GLOBAL_GET("rendering/environment/ssil/fadeout_to"));
RS::get_singleton()->environment_glow_set_use_bicubic_upscale(glow_bicubic);
RS::get_singleton()->environment_set_ssr_half_size(GLOBAL_GET("rendering/environment/screen_space_reflection/half_size"));
RS::SubSurfaceScatteringQuality sss_quality = RS::SubSurfaceScatteringQuality(int(GLOBAL_GET("rendering/environment/subsurface_scattering/subsurface_scattering_quality")));
RSE::SubSurfaceScatteringQuality sss_quality = RSE::SubSurfaceScatteringQuality(int(GLOBAL_GET("rendering/environment/subsurface_scattering/subsurface_scattering_quality")));
RS::get_singleton()->sub_surface_scattering_set_quality(sss_quality);
float sss_scale = GLOBAL_GET("rendering/environment/subsurface_scattering/subsurface_scattering_scale");
float sss_depth_scale = GLOBAL_GET("rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale");
@ -509,17 +508,17 @@ void EditorNode::_update_from_settings() {
uint32_t directional_shadow_16_bits = GLOBAL_GET("rendering/lights_and_shadows/directional_shadow/16_bits");
RS::get_singleton()->directional_shadow_atlas_set_size(directional_shadow_size, directional_shadow_16_bits);
RS::ShadowQuality shadows_quality = RS::ShadowQuality(int(GLOBAL_GET("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality")));
RSE::ShadowQuality shadows_quality = RSE::ShadowQuality(int(GLOBAL_GET("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality")));
RS::get_singleton()->positional_soft_shadow_filter_set_quality(shadows_quality);
RS::ShadowQuality directional_shadow_quality = RS::ShadowQuality(int(GLOBAL_GET("rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality")));
RSE::ShadowQuality directional_shadow_quality = RSE::ShadowQuality(int(GLOBAL_GET("rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality")));
RS::get_singleton()->directional_soft_shadow_filter_set_quality(directional_shadow_quality);
float probe_update_speed = GLOBAL_GET("rendering/lightmapping/probe_capture/update_speed");
RS::get_singleton()->lightmap_set_probe_capture_update_speed(probe_update_speed);
RS::EnvironmentSDFGIFramesToConverge frames_to_converge = RS::EnvironmentSDFGIFramesToConverge(int(GLOBAL_GET("rendering/global_illumination/sdfgi/frames_to_converge")));
RSE::EnvironmentSDFGIFramesToConverge frames_to_converge = RSE::EnvironmentSDFGIFramesToConverge(int(GLOBAL_GET("rendering/global_illumination/sdfgi/frames_to_converge")));
RS::get_singleton()->environment_set_sdfgi_frames_to_converge(frames_to_converge);
RS::EnvironmentSDFGIRayCount ray_count = RS::EnvironmentSDFGIRayCount(int(GLOBAL_GET("rendering/global_illumination/sdfgi/probe_ray_count")));
RSE::EnvironmentSDFGIRayCount ray_count = RSE::EnvironmentSDFGIRayCount(int(GLOBAL_GET("rendering/global_illumination/sdfgi/probe_ray_count")));
RS::get_singleton()->environment_set_sdfgi_ray_count(ray_count);
RS::VoxelGIQuality voxel_gi_quality = RS::VoxelGIQuality(int(GLOBAL_GET("rendering/global_illumination/voxel_gi/quality")));
RSE::VoxelGIQuality voxel_gi_quality = RSE::VoxelGIQuality(int(GLOBAL_GET("rendering/global_illumination/voxel_gi/quality")));
RS::get_singleton()->voxel_gi_set_quality(voxel_gi_quality);
RS::get_singleton()->environment_set_volumetric_fog_volume_size(GLOBAL_GET("rendering/environment/volumetric_fog/volume_size"), GLOBAL_GET("rendering/environment/volumetric_fog/volume_depth"));
RS::get_singleton()->environment_set_volumetric_fog_filter_active(bool(GLOBAL_GET("rendering/environment/volumetric_fog/use_filter")));
@ -561,8 +560,8 @@ void EditorNode::_update_from_settings() {
float mesh_lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels");
scene_root->set_mesh_lod_threshold(mesh_lod_threshold);
RS::get_singleton()->decals_set_filter(RS::DecalFilter(int(GLOBAL_GET("rendering/textures/decals/filter"))));
RS::get_singleton()->light_projectors_set_filter(RS::LightProjectorFilter(int(GLOBAL_GET("rendering/textures/light_projectors/filter"))));
RS::get_singleton()->decals_set_filter(RSE::DecalFilter(int(GLOBAL_GET("rendering/textures/decals/filter"))));
RS::get_singleton()->light_projectors_set_filter(RSE::LightProjectorFilter(int(GLOBAL_GET("rendering/textures/light_projectors/filter"))));
RS::get_singleton()->lightmaps_set_bicubic_filter(GLOBAL_GET("rendering/lightmapping/lightmap_gi/use_bicubic_filter"));
RS::get_singleton()->material_set_use_debanding(GLOBAL_GET("rendering/anti_aliasing/quality/use_debanding"));
@ -982,7 +981,7 @@ void EditorNode::_notification(int p_what) {
default_layout->set_value("docks", "dock_9", String(",").join(bottom_docks));
RenderingServer::get_singleton()->viewport_set_disable_2d(get_scene_root()->get_viewport_rid(), true);
RenderingServer::get_singleton()->viewport_set_environment_mode(get_viewport()->get_viewport_rid(), RenderingServer::VIEWPORT_ENVIRONMENT_DISABLED);
RenderingServer::get_singleton()->viewport_set_environment_mode(get_viewport()->get_viewport_rid(), RSE::VIEWPORT_ENVIRONMENT_DISABLED);
DisplayServer::get_singleton()->screen_set_keep_on(EDITOR_GET("interface/editor/keep_screen_on"));
feature_profile_manager->notify_changed();

View file

@ -32,6 +32,7 @@
#include "core/config/project_settings.h"
#include "core/io/dir_access.h"
#include "core/string/string_builder.h"
#include "core/version.h"
#include "editor/editor_node.h"
#include "scene/3d/label_3d.h"

View file

@ -31,7 +31,6 @@
#include "progress_dialog.h"
#include "core/os/os.h"
#include "editor/editor_interface.h"
#include "editor/editor_node.h"
#include "editor/themes/editor_scale.h"
#include "main/main.h"
@ -286,7 +285,7 @@ ProgressDialog::ProgressDialog() {
// We want to cover the entire screen to prevent the user from interacting with the Editor.
set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
// Be sure it's the top most component.
set_z_index(RS::CANVAS_ITEM_Z_MAX);
set_z_index(RSE::CANVAS_ITEM_Z_MAX);
singleton = this;
hide();

View file

@ -920,7 +920,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
uint64_t mesh_flags = 0;
if (p_use_compression) {
mesh_flags = RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
mesh_flags = RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}
// We can't generate tangents without UVs, so create dummy tangents.
@ -958,10 +958,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
if (has_weights) {
Vector<float> weights;
Vector<int> bones;
weights.resize(RS::ARRAY_WEIGHTS_SIZE);
bones.resize(RS::ARRAY_WEIGHTS_SIZE);
weights.resize(RSE::ARRAY_WEIGHTS_SIZE);
bones.resize(RSE::ARRAY_WEIGHTS_SIZE);
//float sum=0.0;
for (int l = 0; l < RS::ARRAY_WEIGHTS_SIZE; l++) {
for (int l = 0; l < RSE::ARRAY_WEIGHTS_SIZE; l++) {
if (l < vertex_array[k].weights.size()) {
weights.write[l] = vertex_array[k].weights[l].weight;
bones.write[l] = vertex_array[k].weights[l].bone_idx;
@ -1005,7 +1005,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
if (p_mesh->get_blend_shape_count() != 0 || p_skin_controller || is_mesh_2d) {
// Can't compress if attributes missing or if using vertex weights.
mesh_flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
mesh_flags &= ~RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}
////////////////////////////
@ -1013,9 +1013,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
////////////////////////////
Array d = surftool->commit_to_arrays();
d.resize(RS::ARRAY_MAX);
d.resize(RSE::ARRAY_MAX);
if (mesh_flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && (generate_dummy_tangents || generate_tangents)) {
if (mesh_flags & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES && (generate_dummy_tangents || generate_tangents)) {
// Compression is enabled, so let's validate that the normals and tangents are correct.
Vector<Vector3> normals = d[Mesh::ARRAY_NORMAL];
Vector<float> tangents = d[Mesh::ARRAY_TANGENT];
@ -1023,7 +1023,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]);
if (std::abs(tan.dot(normals[vert])) > 0.0001) {
// Tangent is not perpendicular to the normal, so we can't use compression.
mesh_flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
mesh_flags &= ~RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}
}
}

View file

@ -399,7 +399,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
}
}
} else if (/*l.begins_with("g ") ||*/ l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh
uint64_t mesh_flags = RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
uint64_t mesh_flags = RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
if (p_disable_compression) {
mesh_flags = 0;
@ -445,7 +445,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
Array array = surf_tool->commit_to_arrays();
if (mesh_flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && generate_tangents && uses_uvs) {
if (mesh_flags & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES && generate_tangents && uses_uvs) {
// Compression is enabled, so let's validate that the normals and generated tangents are correct.
Vector<Vector3> norms = array[Mesh::ARRAY_NORMAL];
Vector<float> tangents = array[Mesh::ARRAY_TANGENT];
@ -454,7 +454,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]);
if (std::abs(tan.dot(norms[vert])) > 0.0001) {
// Tangent is not perpendicular to the normal, so we can't use compression.
mesh_flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
mesh_flags &= ~RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}
}
}

View file

@ -35,6 +35,7 @@
#include "editor/file_system/editor_file_system.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/check_box.h"
#include "servers/rendering/rendering_server.h"
AudioStreamImportSettingsDialog *AudioStreamImportSettingsDialog::singleton = nullptr;

View file

@ -42,7 +42,7 @@
#include "editor/themes/editor_theme_manager.h"
#include "scene/resources/compressed_texture.h"
void ResourceImporterTexture::_texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) {
void ResourceImporterTexture::_texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RSE::TextureDetectRoughnessChannel p_channel) {
ERR_FAIL_COND(p_tex.is_null());
MutexLock lock(singleton->mutex);

View file

@ -33,7 +33,7 @@
#include "core/io/file_access.h"
#include "core/io/image.h"
#include "core/io/resource_importer.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_enums.h"
class CompressedTexture2D;
@ -74,12 +74,12 @@ protected:
struct MakeInfo {
int flags = 0;
String normal_path_for_roughness;
RS::TextureDetectRoughnessChannel channel_for_roughness = RS::TEXTURE_DETECT_ROUGHNESS_R;
RSE::TextureDetectRoughnessChannel channel_for_roughness = RSE::TEXTURE_DETECT_ROUGHNESS_R;
};
HashMap<StringName, MakeInfo> make_flags;
static void _texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel);
static void _texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RSE::TextureDetectRoughnessChannel p_channel);
static void _texture_reimport_3d(const Ref<CompressedTexture2D> &p_tex);
static void _texture_reimport_normal(const Ref<CompressedTexture2D> &p_tex);

View file

@ -59,6 +59,7 @@
#include "scene/resources/packed_scene.h"
#include "scene/resources/style_box_flat.h"
#include "scene/scene_string_names.h"
#include "servers/rendering/rendering_server.h"
void EditorInspectorActionButton::_notification(int p_what) {
switch (p_what) {

View file

@ -45,6 +45,7 @@
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "servers/audio/audio_stream.h"
#include "servers/rendering/rendering_server.h"
void post_process_preview(Ref<Image> p_image) {
if (p_image->get_format() != Image::FORMAT_RGBA8) {
@ -361,7 +362,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
scenario = RS::get_singleton()->scenario_create();
viewport = RS::get_singleton()->viewport_create();
RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED);
RS::get_singleton()->viewport_set_update_mode(viewport, RSE::VIEWPORT_UPDATE_DISABLED);
RS::get_singleton()->viewport_set_scenario(viewport, scenario);
RS::get_singleton()->viewport_set_size(viewport, 128, 128);
RS::get_singleton()->viewport_set_transparent_background(viewport, true);
@ -465,12 +466,12 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
}
Array arr;
arr.resize(RS::ARRAY_MAX);
arr[RS::ARRAY_VERTEX] = vertices;
arr[RS::ARRAY_NORMAL] = normals;
arr[RS::ARRAY_TANGENT] = tangents;
arr[RS::ARRAY_TEX_UV] = uvs;
RS::get_singleton()->mesh_add_surface_from_arrays(sphere, RS::PRIMITIVE_TRIANGLES, arr);
arr.resize(RSE::ARRAY_MAX);
arr[RSE::ARRAY_VERTEX] = vertices;
arr[RSE::ARRAY_NORMAL] = normals;
arr[RSE::ARRAY_TANGENT] = tangents;
arr[RSE::ARRAY_TEX_UV] = uvs;
RS::get_singleton()->mesh_add_surface_from_arrays(sphere, RSE::PRIMITIVE_TRIANGLES, arr);
}
EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() {
@ -781,7 +782,7 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
scenario = RS::get_singleton()->scenario_create();
viewport = RS::get_singleton()->viewport_create();
RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED);
RS::get_singleton()->viewport_set_update_mode(viewport, RSE::VIEWPORT_UPDATE_DISABLED);
RS::get_singleton()->viewport_set_scenario(viewport, scenario);
RS::get_singleton()->viewport_set_size(viewport, 128, 128);
RS::get_singleton()->viewport_set_transparent_background(viewport, true);
@ -806,7 +807,7 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
light2 = RS::get_singleton()->directional_light_create();
RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
//RS::get_singleton()->light_set_color(light2, RS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
//RS::get_singleton()->light_set_color(light2, RSE::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
RS::get_singleton()->instance_set_transform(light_instance2, Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
@ -897,7 +898,7 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate(const Ref<Resource> &p_from, co
EditorFontPreviewPlugin::EditorFontPreviewPlugin() {
viewport = RS::get_singleton()->viewport_create();
RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED);
RS::get_singleton()->viewport_set_update_mode(viewport, RSE::VIEWPORT_UPDATE_DISABLED);
RS::get_singleton()->viewport_set_size(viewport, 128, 128);
RS::get_singleton()->viewport_set_active(viewport, true);
viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);

View file

@ -50,6 +50,7 @@
#include "scene/property_utils.h"
#include "scene/resources/gradient_texture.h"
#include "scene/resources/image_texture.h"
#include "servers/rendering/rendering_server.h"
static bool _has_sub_resources(const Ref<Resource> &p_res) {
List<PropertyInfo> property_list;

View file

@ -42,6 +42,8 @@
#include "editor/themes/editor_scale.h"
#include "scene/main/window.h"
#include "scene/resources/image_texture.h"
#include "servers/rendering/renderer_compositor.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_globals.h"
bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
@ -102,7 +104,7 @@ void EditorResourcePreviewGenerator::DrawRequester::request_and_wait(RID p_viewp
RID root_vp = st->get_root()->get_viewport_rid();
RenderingServer::get_singleton()->viewport_set_active(root_vp, false);
RS::get_singleton()->viewport_set_update_mode(p_viewport, RS::VIEWPORT_UPDATE_ONCE);
RS::get_singleton()->viewport_set_update_mode(p_viewport, RSE::VIEWPORT_UPDATE_ONCE);
RS::get_singleton()->draw(false);
// Let main viewport and children be drawn again.
@ -122,7 +124,7 @@ void EditorResourcePreviewGenerator::request_draw_and_wait(RID viewport) const {
}
void EditorResourcePreviewGenerator::DrawRequester::_prepare_draw(RID p_viewport) {
RS::get_singleton()->viewport_set_update_mode(p_viewport, RS::VIEWPORT_UPDATE_ONCE);
RS::get_singleton()->viewport_set_update_mode(p_viewport, RSE::VIEWPORT_UPDATE_ONCE);
RS::get_singleton()->request_frame_drawn_callback(callable_mp(this, &EditorResourcePreviewGenerator::DrawRequester::_post_semaphore));
}

View file

@ -48,6 +48,7 @@
#include "scene/gui/option_button.h"
#include "scene/gui/separator.h"
#include "scene/gui/texture_rect.h"
#include "servers/rendering/rendering_server.h"
void ProjectDialog::_set_message(const String &p_msg, MessageType p_type, InputType p_input_type) {
msg->set_text(p_msg);

View file

@ -132,6 +132,8 @@
#include "editor/shader/shader_file_editor_plugin.h"
#include "editor/translations/editor_translation_parser.h"
#include "editor/version_control/editor_vcs_interface.h"
#include "servers/rendering/rendering_server.h"
#ifndef DISABLE_DEPRECATED
#include "editor/scene/2d/parallax_background_editor_plugin.h"
#include "editor/scene/3d/skeleton_ik_3d_editor_plugin.h"

View file

@ -39,6 +39,7 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/menu_button.h"
#include "scene/resources/mesh.h"
#include "servers/rendering/rendering_server.h"
void Path2DEditor::_notification(int p_what) {
switch (p_what) {
@ -501,7 +502,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
handles_array[Mesh::ARRAY_VERTEX] = Vector<Vector2>(debug_handle_lines);
rs->mesh_add_surface_from_arrays(debug_mesh_rid, RS::PRIMITIVE_LINES, handles_array, Array(), Dictionary(), RS::ARRAY_FLAG_USE_2D_VERTICES);
rs->mesh_add_surface_from_arrays(debug_mesh_rid, RSE::PRIMITIVE_LINES, handles_array, Array(), Dictionary(), RSE::ARRAY_FLAG_USE_2D_VERTICES);
rs->canvas_item_add_mesh(vpc->get_canvas_item(), debug_mesh_rid, Transform2D(), Color(0.5, 0.5, 0.5, 1.0));
}
@ -516,7 +517,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
rs->multimesh_set_visible_instances(debug_handle_curve_multimesh_rid, 0);
if (handle_curve_count > 0) {
if (rs->multimesh_get_instance_count(debug_handle_curve_multimesh_rid) != int(handle_curve_count)) {
rs->multimesh_allocate_data(debug_handle_curve_multimesh_rid, handle_curve_count, RS::MULTIMESH_TRANSFORM_2D);
rs->multimesh_allocate_data(debug_handle_curve_multimesh_rid, handle_curve_count, RSE::MULTIMESH_TRANSFORM_2D);
}
Vector<float> multimesh_buffer;
@ -549,7 +550,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
rs->multimesh_set_visible_instances(debug_handle_sharp_multimesh_rid, 0);
if (handle_sharp_count > 0) {
if (rs->multimesh_get_instance_count(debug_handle_sharp_multimesh_rid) != int(handle_sharp_count)) {
rs->multimesh_allocate_data(debug_handle_sharp_multimesh_rid, handle_sharp_count, RS::MULTIMESH_TRANSFORM_2D);
rs->multimesh_allocate_data(debug_handle_sharp_multimesh_rid, handle_sharp_count, RSE::MULTIMESH_TRANSFORM_2D);
}
Vector<float> multimesh_buffer;
@ -582,7 +583,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
rs->multimesh_set_visible_instances(debug_handle_smooth_multimesh_rid, 0);
if (handle_smooth_count > 0) {
if (rs->multimesh_get_instance_count(debug_handle_smooth_multimesh_rid) != int(handle_smooth_count)) {
rs->multimesh_allocate_data(debug_handle_smooth_multimesh_rid, handle_smooth_count, RS::MULTIMESH_TRANSFORM_2D);
rs->multimesh_allocate_data(debug_handle_smooth_multimesh_rid, handle_smooth_count, RSE::MULTIMESH_TRANSFORM_2D);
}
Vector<float> multimesh_buffer;
@ -957,12 +958,12 @@ Path2DEditor::Path2DEditor() {
index_array_ptrw[5] = 3;
Array mesh_arrays;
mesh_arrays.resize(RS::ARRAY_MAX);
mesh_arrays[RS::ARRAY_VERTEX] = vertex_array;
mesh_arrays[RS::ARRAY_TEX_UV] = uv_array;
mesh_arrays[RS::ARRAY_INDEX] = index_array;
mesh_arrays.resize(RSE::ARRAY_MAX);
mesh_arrays[RSE::ARRAY_VERTEX] = vertex_array;
mesh_arrays[RSE::ARRAY_TEX_UV] = uv_array;
mesh_arrays[RSE::ARRAY_INDEX] = index_array;
rs->mesh_add_surface_from_arrays(debug_handle_mesh_rid, RS::PRIMITIVE_TRIANGLES, mesh_arrays, Array(), Dictionary(), RS::ARRAY_FLAG_USE_2D_VERTICES);
rs->mesh_add_surface_from_arrays(debug_handle_mesh_rid, RSE::PRIMITIVE_TRIANGLES, mesh_arrays, Array(), Dictionary(), RSE::ARRAY_FLAG_USE_2D_VERTICES);
debug_handle_curve_multimesh_rid = rs->multimesh_create();
debug_handle_sharp_multimesh_rid = rs->multimesh_create();

View file

@ -53,6 +53,7 @@
#include "scene/gui/spin_box.h"
#include "scene/gui/split_container.h"
#include "scene/gui/view_panner.h"
#include "servers/rendering/rendering_server.h"
Node2D *Polygon2DEditor::_get_node() const {
return node;

View file

@ -37,6 +37,8 @@
#include "scene/gui/label.h"
#include "scene/gui/panel.h"
#include "scene/gui/view_panner.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_enums.h"
void TileAtlasView::gui_input(const Ref<InputEvent> &p_event) {
if (panner->gui_input(p_event, get_global_rect())) {
@ -308,7 +310,7 @@ RID TileAtlasView::_get_canvas_item_to_draw(const TileData *p_for_data, const Ca
RID ci_rid = RS::get_singleton()->canvas_item_create();
RS::get_singleton()->canvas_item_set_parent(ci_rid, p_base_item->get_canvas_item());
RS::get_singleton()->canvas_item_set_material(ci_rid, mat->get_rid());
RS::get_singleton()->canvas_item_set_default_texture_filter(ci_rid, RS::CanvasItemTextureFilter(p_base_item->get_texture_filter_in_tree()));
RS::get_singleton()->canvas_item_set_default_texture_filter(ci_rid, RSE::CanvasItemTextureFilter(p_base_item->get_texture_filter_in_tree()));
p_material_map[mat] = ci_rid;
return ci_rid;
}

View file

@ -51,6 +51,7 @@
#include "scene/gui/spin_box.h"
#include "servers/navigation_2d/navigation_server_2d.h"
#include "servers/rendering/rendering_server.h"
void TileDataEditor::_tile_set_changed_plan_update() {
_tile_set_changed_update_needed = true;

View file

@ -49,6 +49,7 @@
#include "scene/gui/control.h"
#include "scene/resources/2d/tile_set.h"
#include "scene/resources/image_texture.h"
#include "servers/rendering/rendering_server.h"
TilesEditorUtils *TilesEditorUtils::singleton = nullptr;
TileMapEditorPlugin *tile_map_plugin_singleton = nullptr;
@ -290,7 +291,7 @@ void TilesEditorUtils::draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect
p_ci->draw_set_transform(p_rect.position, 0, Vector2(1, 1) / scale);
RS::get_singleton()->canvas_item_add_nine_patch(
p_ci->get_canvas_item(), Rect2(Vector2(), p_rect.size * scale), Rect2(), selection_texture->get_rid(),
Vector2(2, 2), Vector2(2, 2), RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, false, p_color);
Vector2(2, 2), Vector2(2, 2), RSE::NINE_PATCH_STRETCH, RSE::NINE_PATCH_STRETCH, false, p_color);
p_ci->draw_set_transform_matrix(Transform2D());
}

View file

@ -36,6 +36,7 @@
#include "scene/gui/foldable_container.h"
#include "scene/gui/subviewport_container.h"
#include "scene/main/viewport.h"
#include "servers/rendering/rendering_server.h"
void Camera3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {

View file

@ -94,7 +94,7 @@ void FogVolumeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
if (fog_volume->get_shape() != RS::FOG_VOLUME_SHAPE_WORLD) {
if (fog_volume->get_shape() != RSE::FOG_VOLUME_SHAPE_WORLD) {
const Ref<Material> material =
get_material("shape_material", p_gizmo);
const Ref<Material> material_internal =

View file

@ -209,10 +209,10 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
Array array;
array.resize(RS::ARRAY_MAX);
array[RS::ARRAY_VERTEX] = Vector<Vector3>(vertices);
array[RS::ARRAY_INDEX] = Vector<int>(indices);
array[RS::ARRAY_COLOR] = Vector<Color>(colors);
array.resize(RSE::ARRAY_MAX);
array[RSE::ARRAY_VERTEX] = Vector<Vector3>(vertices);
array[RSE::ARRAY_INDEX] = Vector<int>(indices);
array[RSE::ARRAY_COLOR] = Vector<Color>(colors);
Ref<ArrayMesh> mesh;
mesh.instantiate();

View file

@ -88,7 +88,7 @@ Marker3DGizmoPlugin::Marker3DGizmoPlugin() {
mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
Array d;
d.resize(RS::ARRAY_MAX);
d.resize(RSE::ARRAY_MAX);
d[Mesh::ARRAY_VERTEX] = cursor_points;
d[Mesh::ARRAY_COLOR] = cursor_colors;
pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d);

View file

@ -224,9 +224,9 @@ void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Array a;
a.resize(Mesh::ARRAY_MAX);
a[RS::ARRAY_VERTEX] = verts;
a[RS::ARRAY_COLOR] = colors;
a[RS::ARRAY_INDEX] = indices;
a[RSE::ARRAY_VERTEX] = verts;
a[RSE::ARRAY_COLOR] = colors;
a[RSE::ARRAY_INDEX] = indices;
array_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a);
p_gizmo->add_mesh(array_mesh, material_arraymesh);

View file

@ -33,6 +33,7 @@
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_file_dialog.h"
#include "servers/rendering/rendering_server.h"
#include "modules/modules_enabled.gen.h" // For lightmapper_rd.

View file

@ -33,6 +33,7 @@
#include "editor/scene/material_editor_plugin.h"
#include "scene/resources/3d/fog_material.h"
#include "scene/resources/3d/sky_material.h"
#include "servers/rendering/rendering_server.h"
String StandardMaterial3DConversionPlugin::converts_to() const {
return "ShaderMaterial";

View file

@ -157,19 +157,19 @@ void MeshLibraryEditor::_import_scene_parse_node(Ref<MeshLibrary> p_library, Has
GeometryInstance3D::ShadowCastingSetting gi3d_cast_shadows_setting = mesh_instance_node->get_cast_shadows_setting();
switch (gi3d_cast_shadows_setting) {
case GeometryInstance3D::ShadowCastingSetting::SHADOW_CASTING_SETTING_OFF: {
p_library->set_item_mesh_cast_shadow(item_id, RS::ShadowCastingSetting::SHADOW_CASTING_SETTING_OFF);
p_library->set_item_mesh_cast_shadow(item_id, RSE::ShadowCastingSetting::SHADOW_CASTING_SETTING_OFF);
} break;
case GeometryInstance3D::ShadowCastingSetting::SHADOW_CASTING_SETTING_ON: {
p_library->set_item_mesh_cast_shadow(item_id, RS::ShadowCastingSetting::SHADOW_CASTING_SETTING_ON);
p_library->set_item_mesh_cast_shadow(item_id, RSE::ShadowCastingSetting::SHADOW_CASTING_SETTING_ON);
} break;
case GeometryInstance3D::ShadowCastingSetting::SHADOW_CASTING_SETTING_DOUBLE_SIDED: {
p_library->set_item_mesh_cast_shadow(item_id, RS::ShadowCastingSetting::SHADOW_CASTING_SETTING_DOUBLE_SIDED);
p_library->set_item_mesh_cast_shadow(item_id, RSE::ShadowCastingSetting::SHADOW_CASTING_SETTING_DOUBLE_SIDED);
} break;
case GeometryInstance3D::ShadowCastingSetting::SHADOW_CASTING_SETTING_SHADOWS_ONLY: {
p_library->set_item_mesh_cast_shadow(item_id, RS::ShadowCastingSetting::SHADOW_CASTING_SETTING_SHADOWS_ONLY);
p_library->set_item_mesh_cast_shadow(item_id, RSE::ShadowCastingSetting::SHADOW_CASTING_SETTING_SHADOWS_ONLY);
} break;
default: {
p_library->set_item_mesh_cast_shadow(item_id, RS::ShadowCastingSetting::SHADOW_CASTING_SETTING_ON);
p_library->set_item_mesh_cast_shadow(item_id, RSE::ShadowCastingSetting::SHADOW_CASTING_SETTING_ON);
} break;
}

View file

@ -37,6 +37,7 @@
#include "editor/scene/3d/node_3d_editor_plugin.h"
#include "editor/settings/editor_settings.h"
#include "scene/resources/3d/primitive_meshes.h"
#include "servers/rendering/rendering_server.h"
#define HANDLE_HALF_SIZE 9.5
@ -218,11 +219,11 @@ void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden)
if (extra_margin) {
RS::get_singleton()->instance_set_extra_visibility_margin(instance, 1);
}
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, RSE::SHADOW_CASTING_SETTING_OFF);
int layer = p_hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER;
RS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26
RS::get_singleton()->instance_geometry_set_flag(instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(instance, RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(instance, RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(instance, RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
}
void EditorNode3DGizmo::add_mesh(const Ref<Mesh> &p_mesh, const Ref<Material> &p_material, const Transform3D &p_xform, const Ref<SkinReference> &p_skin_reference) {
@ -417,8 +418,8 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
Ref<ArrayMesh> mesh = memnew(ArrayMesh);
Array a;
a.resize(RS::ARRAY_MAX);
a[RS::ARRAY_VERTEX] = p_handles;
a.resize(RSE::ARRAY_MAX);
a[RSE::ARRAY_VERTEX] = p_handles;
Vector<Color> colors;
{
colors.resize(p_handles.size());
@ -438,7 +439,7 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
w[i] = col;
}
}
a[RS::ARRAY_COLOR] = colors;
a[RSE::ARRAY_COLOR] = colors;
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, a);
mesh->surface_set_material(0, p_material);
@ -479,17 +480,17 @@ void EditorNode3DGizmo::add_solid_box(const Ref<Material> &p_material, Vector3 p
ERR_FAIL_NULL(spatial_node);
Array arrays;
arrays.resize(RS::ARRAY_MAX);
arrays.resize(RSE::ARRAY_MAX);
BoxMesh::create_mesh_array(arrays, p_size);
PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX];
PackedVector3Array vertex = arrays[RSE::ARRAY_VERTEX];
Vector3 *w = vertex.ptrw();
for (int i = 0; i < vertex.size(); ++i) {
w[i] += p_position;
}
arrays[RS::ARRAY_VERTEX] = vertex;
arrays[RSE::ARRAY_VERTEX] = vertex;
Ref<ArrayMesh> m;
m.instantiate();

View file

@ -106,6 +106,7 @@
#include "scene/resources/packed_scene.h"
#include "scene/resources/sky.h"
#include "scene/resources/surface_tool.h"
#include "servers/rendering/rendering_server.h"
constexpr real_t DISTANCE_DEFAULT = 4;
@ -4460,37 +4461,37 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
RS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid());
RS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer);
RS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i], RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i], RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i], RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
move_plane_gizmo_instance[i] = RS::get_singleton()->instance_create();
RS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid());
RS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer);
RS::get_singleton()->instance_geometry_set_flag(move_plane_gizmo_instance[i], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(move_plane_gizmo_instance[i], RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(move_plane_gizmo_instance[i], RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(move_plane_gizmo_instance[i], RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
scale_gizmo_instance[i] = RS::get_singleton()->instance_create();
RS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid());
RS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer);
RS::get_singleton()->instance_geometry_set_flag(scale_gizmo_instance[i], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(scale_gizmo_instance[i], RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(scale_gizmo_instance[i], RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(scale_gizmo_instance[i], RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
scale_plane_gizmo_instance[i] = RS::get_singleton()->instance_create();
RS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid());
RS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer);
RS::get_singleton()->instance_geometry_set_flag(scale_plane_gizmo_instance[i], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(scale_plane_gizmo_instance[i], RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(scale_plane_gizmo_instance[i], RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(scale_plane_gizmo_instance[i], RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
axis_gizmo_instance[i] = RS::get_singleton()->instance_create();
}
@ -4499,10 +4500,10 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
RS::get_singleton()->instance_set_base(axis_gizmo_instance[i], spatial_editor->get_axis_gizmo(i)->get_rid());
RS::get_singleton()->instance_set_scenario(axis_gizmo_instance[i], get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_visible(axis_gizmo_instance[i], true);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(axis_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(axis_gizmo_instance[i], RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(axis_gizmo_instance[i], layer);
RS::get_singleton()->instance_geometry_set_flag(axis_gizmo_instance[i], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(axis_gizmo_instance[i], RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(axis_gizmo_instance[i], RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(axis_gizmo_instance[i], RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
}
for (int i = 0; i < 4; i++) {
@ -4510,10 +4511,10 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
RS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid());
RS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer);
RS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i], RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i], RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i], RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
}
// Create trackball sphere instance
@ -4521,10 +4522,10 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
RS::get_singleton()->instance_set_base(trackball_sphere_instance, spatial_editor->get_trackball_sphere_gizmo()->get_rid());
RS::get_singleton()->instance_set_scenario(trackball_sphere_instance, get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_visible(trackball_sphere_instance, false);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(trackball_sphere_instance, RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(trackball_sphere_instance, RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(trackball_sphere_instance, layer);
RS::get_singleton()->instance_geometry_set_flag(trackball_sphere_instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(trackball_sphere_instance, RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(trackball_sphere_instance, RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(trackball_sphere_instance, RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
}
void Node3DEditorViewport::_finish_gizmo_instances() {
@ -7083,18 +7084,18 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) {
sp->get_world_3d()->get_scenario());
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(
si->sbox_instance,
RS::SHADOW_CASTING_SETTING_OFF);
RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(
si->sbox_instance_offset,
RS::SHADOW_CASTING_SETTING_OFF);
RSE::SHADOW_CASTING_SETTING_OFF);
// Use the Edit layer to hide the selection box when View Gizmos is disabled, since it is a bit distracting.
// It's still possible to approximately guess what is selected by looking at the manipulation gizmo position.
RS::get_singleton()->instance_set_layer_mask(si->sbox_instance, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER);
RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_offset, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_offset, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_offset, RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_offset, RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_offset, RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
si->sbox_instance_xray = RenderingServer::get_singleton()->instance_create2(
selection_box_xray->get_rid(),
sp->get_world_3d()->get_scenario());
@ -7103,18 +7104,18 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) {
sp->get_world_3d()->get_scenario());
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(
si->sbox_instance_xray,
RS::SHADOW_CASTING_SETTING_OFF);
RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(
si->sbox_instance_xray_offset,
RS::SHADOW_CASTING_SETTING_OFF);
RSE::SHADOW_CASTING_SETTING_OFF);
// Use the Edit layer to hide the selection box when View Gizmos is disabled, since it is a bit distracting.
// It's still possible to approximately guess what is selected by looking at the manipulation gizmo position.
RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_xray, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER);
RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_xray_offset, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray, RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray_offset, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray_offset, RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray, RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray, RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray_offset, RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance_xray_offset, RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
return si;
}
@ -7866,17 +7867,17 @@ void fragment() {
origin_points.set(5, Vector3(0.0, 0.5, 0.0));
Array d;
d.resize(RS::ARRAY_MAX);
d[RenderingServer::ARRAY_VERTEX] = origin_points;
d.resize(RSE::ARRAY_MAX);
d[RSE::ARRAY_VERTEX] = origin_points;
origin_mesh = RenderingServer::get_singleton()->mesh_create();
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(origin_mesh, RenderingServer::PRIMITIVE_TRIANGLES, d);
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(origin_mesh, RSE::PRIMITIVE_TRIANGLES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(origin_mesh, 0, origin_mat->get_rid());
origin_multimesh = RenderingServer::get_singleton()->multimesh_create();
RenderingServer::get_singleton()->multimesh_set_mesh(origin_multimesh, origin_mesh);
RenderingServer::get_singleton()->multimesh_allocate_data(origin_multimesh, 12, RS::MultimeshTransformFormat::MULTIMESH_TRANSFORM_3D, true, false);
RenderingServer::get_singleton()->multimesh_allocate_data(origin_multimesh, 12, RSE::MultimeshTransformFormat::MULTIMESH_TRANSFORM_3D, true, false);
RenderingServer::get_singleton()->multimesh_set_visible_instances(origin_multimesh, -1);
LocalVector<float> distances;
@ -7923,10 +7924,10 @@ void fragment() {
origin_instance = RenderingServer::get_singleton()->instance_create2(origin_multimesh, get_tree()->get_root()->get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << Node3DEditorViewport::GIZMO_GRID_LAYER);
RS::get_singleton()->instance_geometry_set_flag(origin_instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(origin_instance, RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(origin_instance, RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(origin_instance, RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, RS::SHADOW_CASTING_SETTING_OFF);
RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, RSE::SHADOW_CASTING_SETTING_OFF);
Ref<Shader> grid_shader = memnew(Shader);
grid_shader->set_code(R"(
@ -8655,20 +8656,20 @@ void Node3DEditor::_init_grid() {
// Create a mesh from the pushed vector points and colors.
grid[c] = RenderingServer::get_singleton()->mesh_create();
Array d;
d.resize(RS::ARRAY_MAX);
d[RenderingServer::ARRAY_VERTEX] = (Vector<Vector3>)grid_points[c];
d[RenderingServer::ARRAY_COLOR] = (Vector<Color>)grid_colors[c];
d[RenderingServer::ARRAY_NORMAL] = (Vector<Vector3>)grid_normals[c];
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[c], RenderingServer::PRIMITIVE_LINES, d);
d.resize(RSE::ARRAY_MAX);
d[RSE::ARRAY_VERTEX] = (Vector<Vector3>)grid_points[c];
d[RSE::ARRAY_COLOR] = (Vector<Color>)grid_colors[c];
d[RSE::ARRAY_NORMAL] = (Vector<Vector3>)grid_normals[c];
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[c], RSE::PRIMITIVE_LINES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(grid[c], 0, grid_mat[c]->get_rid());
grid_instance[c] = RenderingServer::get_singleton()->instance_create2(grid[c], get_tree()->get_root()->get_world_3d()->get_scenario());
// Yes, the end of this line is supposed to be a.
RenderingServer::get_singleton()->instance_set_visible(grid_instance[c], grid_visible[a]);
RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[c], RS::SHADOW_CASTING_SETTING_OFF);
RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[c], RSE::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(grid_instance[c], 1 << Node3DEditorViewport::GIZMO_GRID_LAYER);
RS::get_singleton()->instance_geometry_set_flag(grid_instance[c], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(grid_instance[c], RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
RS::get_singleton()->instance_geometry_set_flag(grid_instance[c], RSE::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
RS::get_singleton()->instance_geometry_set_flag(grid_instance[c], RSE::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
}
}

View file

@ -69,6 +69,7 @@
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/style_box_texture.h"
#include "servers/rendering/rendering_server.h"
#define DRAG_THRESHOLD (8 * EDSCALE)
constexpr real_t SCALE_HANDLE_DISTANCE = 25;
@ -6132,13 +6133,13 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) {
canvas_item_editor->show();
canvas_item_editor->set_process(true);
RenderingServer::get_singleton()->viewport_set_disable_2d(EditorNode::get_singleton()->get_scene_root()->get_viewport_rid(), false);
RenderingServer::get_singleton()->viewport_set_environment_mode(EditorNode::get_singleton()->get_scene_root()->get_viewport_rid(), RS::VIEWPORT_ENVIRONMENT_ENABLED);
RenderingServer::get_singleton()->viewport_set_environment_mode(EditorNode::get_singleton()->get_scene_root()->get_viewport_rid(), RSE::VIEWPORT_ENVIRONMENT_ENABLED);
} else {
canvas_item_editor->hide();
canvas_item_editor->set_process(false);
RenderingServer::get_singleton()->viewport_set_disable_2d(EditorNode::get_singleton()->get_scene_root()->get_viewport_rid(), true);
RenderingServer::get_singleton()->viewport_set_environment_mode(EditorNode::get_singleton()->get_scene_root()->get_viewport_rid(), RS::VIEWPORT_ENVIRONMENT_DISABLED);
RenderingServer::get_singleton()->viewport_set_environment_mode(EditorNode::get_singleton()->get_scene_root()->get_viewport_rid(), RSE::VIEWPORT_ENVIRONMENT_DISABLED);
}
}

View file

@ -46,6 +46,7 @@
#include "scene/resources/canvas_item_material.h"
#include "scene/resources/particle_process_material.h"
#include "scene/resources/sky.h"
#include "servers/rendering/rendering_server.h"
// 3D.
#include "scene/3d/camera_3d.h"

View file

@ -47,6 +47,7 @@
#include "scene/gui/view_panner.h"
#include "scene/resources/atlas_texture.h"
#include "scene/resources/style_box_texture.h"
#include "servers/rendering/rendering_server.h"
Transform2D TextureRegionEditor::_get_offset_transform() const {
Transform2D mtx;

View file

@ -55,6 +55,7 @@
#include "scene/gui/rich_text_label.h"
#include "scene/gui/split_container.h"
#include "scene/resources/style_box_flat.h"
#include "servers/rendering/rendering_server.h"
void ConnectionInfoDialog::ok_pressed() {
}

View file

@ -34,7 +34,9 @@
#include "editor/settings/editor_settings.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/code_edit.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/tab_container.h"
#include "scene/resources/syntax_highlighter.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/shader_language.h"
void EditorNativeShaderSourceVisualizer::_load_theme_settings() {
@ -77,7 +79,7 @@ void EditorNativeShaderSourceVisualizer::_inspect_shader(RID p_shader) {
versions = nullptr;
}
RS::ShaderNativeSourceCode nsc = RS::get_singleton()->shader_get_native_source_code(p_shader);
RenderingServerTypes::ShaderNativeSourceCode nsc = RS::get_singleton()->shader_get_native_source_code(p_shader);
_load_theme_settings();

View file

@ -31,8 +31,9 @@
#pragma once
#include "scene/gui/dialogs.h"
#include "scene/gui/tab_container.h"
#include "scene/resources/syntax_highlighter.h"
class CodeHighlighter;
class TabContainer;
class EditorNativeShaderSourceVisualizer : public AcceptDialog {
GDCLASS(EditorNativeShaderSourceVisualizer, AcceptDialog)

View file

@ -37,9 +37,10 @@
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/margin_container.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/shader_language.h"
static const char *global_var_type_names[RS::GLOBAL_VAR_TYPE_MAX] = {
static const char *global_var_type_names[RSE::GLOBAL_VAR_TYPE_MAX] = {
"bool",
"bvec2",
"bvec3",
@ -80,10 +81,10 @@ class ShaderGlobalsEditorInterface : public Object {
undo_redo->create_action(TTR("Set Shader Global Variable"));
undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_set", p_name, p_value);
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_set", p_name, p_prev_value);
RS::GlobalShaderParameterType type = RS::get_singleton()->global_shader_parameter_get_type(p_name);
RSE::GlobalShaderParameterType type = RS::get_singleton()->global_shader_parameter_get_type(p_name);
Dictionary gv;
gv["type"] = global_var_type_names[type];
if (type >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) {
if (type >= RSE::GLOBAL_VAR_TYPE_SAMPLER2D) {
Ref<Resource> res = p_value;
if (res.is_valid()) {
gv["value"] = res->get_path();
@ -138,105 +139,105 @@ protected:
pinfo.name = variables[i];
switch (RS::get_singleton()->global_shader_parameter_get_type(variables[i])) {
case RS::GLOBAL_VAR_TYPE_BOOL: {
case RSE::GLOBAL_VAR_TYPE_BOOL: {
pinfo.type = Variant::BOOL;
} break;
case RS::GLOBAL_VAR_TYPE_BVEC2: {
case RSE::GLOBAL_VAR_TYPE_BVEC2: {
pinfo.type = Variant::INT;
pinfo.hint = PROPERTY_HINT_FLAGS;
pinfo.hint_string = "x,y";
} break;
case RS::GLOBAL_VAR_TYPE_BVEC3: {
case RSE::GLOBAL_VAR_TYPE_BVEC3: {
pinfo.type = Variant::INT;
pinfo.hint = PROPERTY_HINT_FLAGS;
pinfo.hint_string = "x,y,z";
} break;
case RS::GLOBAL_VAR_TYPE_BVEC4: {
case RSE::GLOBAL_VAR_TYPE_BVEC4: {
pinfo.type = Variant::INT;
pinfo.hint = PROPERTY_HINT_FLAGS;
pinfo.hint_string = "x,y,z,w";
} break;
case RS::GLOBAL_VAR_TYPE_INT: {
case RSE::GLOBAL_VAR_TYPE_INT: {
pinfo.type = Variant::INT;
} break;
case RS::GLOBAL_VAR_TYPE_IVEC2: {
case RSE::GLOBAL_VAR_TYPE_IVEC2: {
pinfo.type = Variant::VECTOR2I;
} break;
case RS::GLOBAL_VAR_TYPE_IVEC3: {
case RSE::GLOBAL_VAR_TYPE_IVEC3: {
pinfo.type = Variant::VECTOR3I;
} break;
case RS::GLOBAL_VAR_TYPE_IVEC4: {
case RSE::GLOBAL_VAR_TYPE_IVEC4: {
pinfo.type = Variant::VECTOR4I;
} break;
case RS::GLOBAL_VAR_TYPE_RECT2I: {
case RSE::GLOBAL_VAR_TYPE_RECT2I: {
pinfo.type = Variant::RECT2I;
} break;
case RS::GLOBAL_VAR_TYPE_UINT: {
case RSE::GLOBAL_VAR_TYPE_UINT: {
pinfo.type = Variant::INT;
} break;
case RS::GLOBAL_VAR_TYPE_UVEC2: {
case RSE::GLOBAL_VAR_TYPE_UVEC2: {
pinfo.type = Variant::VECTOR2I;
} break;
case RS::GLOBAL_VAR_TYPE_UVEC3: {
case RSE::GLOBAL_VAR_TYPE_UVEC3: {
pinfo.type = Variant::VECTOR3I;
} break;
case RS::GLOBAL_VAR_TYPE_UVEC4: {
case RSE::GLOBAL_VAR_TYPE_UVEC4: {
pinfo.type = Variant::VECTOR4I;
} break;
case RS::GLOBAL_VAR_TYPE_FLOAT: {
case RSE::GLOBAL_VAR_TYPE_FLOAT: {
pinfo.type = Variant::FLOAT;
} break;
case RS::GLOBAL_VAR_TYPE_VEC2: {
case RSE::GLOBAL_VAR_TYPE_VEC2: {
pinfo.type = Variant::VECTOR2;
} break;
case RS::GLOBAL_VAR_TYPE_VEC3: {
case RSE::GLOBAL_VAR_TYPE_VEC3: {
pinfo.type = Variant::VECTOR3;
} break;
case RS::GLOBAL_VAR_TYPE_VEC4: {
case RSE::GLOBAL_VAR_TYPE_VEC4: {
pinfo.type = Variant::VECTOR4;
} break;
case RS::GLOBAL_VAR_TYPE_RECT2: {
case RSE::GLOBAL_VAR_TYPE_RECT2: {
pinfo.type = Variant::RECT2;
} break;
case RS::GLOBAL_VAR_TYPE_COLOR: {
case RSE::GLOBAL_VAR_TYPE_COLOR: {
pinfo.type = Variant::COLOR;
} break;
case RS::GLOBAL_VAR_TYPE_MAT2: {
case RSE::GLOBAL_VAR_TYPE_MAT2: {
pinfo.type = Variant::PACKED_FLOAT32_ARRAY;
} break;
case RS::GLOBAL_VAR_TYPE_MAT3: {
case RSE::GLOBAL_VAR_TYPE_MAT3: {
pinfo.type = Variant::BASIS;
} break;
case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
case RSE::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
pinfo.type = Variant::TRANSFORM2D;
} break;
case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
case RSE::GLOBAL_VAR_TYPE_TRANSFORM: {
pinfo.type = Variant::TRANSFORM3D;
} break;
case RS::GLOBAL_VAR_TYPE_MAT4: {
case RSE::GLOBAL_VAR_TYPE_MAT4: {
pinfo.type = Variant::PROJECTION;
} break;
case RS::GLOBAL_VAR_TYPE_SAMPLER2D: {
case RSE::GLOBAL_VAR_TYPE_SAMPLER2D: {
pinfo.type = Variant::OBJECT;
pinfo.hint = PROPERTY_HINT_RESOURCE_TYPE;
pinfo.hint_string = "Texture2D";
} break;
case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: {
case RSE::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: {
pinfo.type = Variant::OBJECT;
pinfo.hint = PROPERTY_HINT_RESOURCE_TYPE;
pinfo.hint_string = "Texture2DArray,CompressedTexture2DArray";
} break;
case RS::GLOBAL_VAR_TYPE_SAMPLER3D: {
case RSE::GLOBAL_VAR_TYPE_SAMPLER3D: {
pinfo.type = Variant::OBJECT;
pinfo.hint = PROPERTY_HINT_RESOURCE_TYPE;
pinfo.hint_string = "Texture3D";
} break;
case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE: {
case RSE::GLOBAL_VAR_TYPE_SAMPLERCUBE: {
pinfo.type = Variant::OBJECT;
pinfo.hint = PROPERTY_HINT_RESOURCE_TYPE;
pinfo.hint_string = "Cubemap,CompressedCubemap";
} break;
case RS::GLOBAL_VAR_TYPE_SAMPLEREXT: {
case RSE::GLOBAL_VAR_TYPE_SAMPLEREXT: {
pinfo.type = Variant::OBJECT;
pinfo.hint = PROPERTY_HINT_RESOURCE_TYPE;
pinfo.hint_string = "ExternalTexture";
@ -256,66 +257,66 @@ public:
}
};
static Variant create_var(RS::GlobalShaderParameterType p_type) {
static Variant create_var(RSE::GlobalShaderParameterType p_type) {
switch (p_type) {
case RS::GLOBAL_VAR_TYPE_BOOL: {
case RSE::GLOBAL_VAR_TYPE_BOOL: {
return false;
}
case RS::GLOBAL_VAR_TYPE_BVEC2: {
case RSE::GLOBAL_VAR_TYPE_BVEC2: {
return 0; //bits
}
case RS::GLOBAL_VAR_TYPE_BVEC3: {
case RSE::GLOBAL_VAR_TYPE_BVEC3: {
return 0; //bits
}
case RS::GLOBAL_VAR_TYPE_BVEC4: {
case RSE::GLOBAL_VAR_TYPE_BVEC4: {
return 0; //bits
}
case RS::GLOBAL_VAR_TYPE_INT: {
case RSE::GLOBAL_VAR_TYPE_INT: {
return 0; //bits
}
case RS::GLOBAL_VAR_TYPE_IVEC2: {
case RSE::GLOBAL_VAR_TYPE_IVEC2: {
return Vector2i();
}
case RS::GLOBAL_VAR_TYPE_IVEC3: {
case RSE::GLOBAL_VAR_TYPE_IVEC3: {
return Vector3i();
}
case RS::GLOBAL_VAR_TYPE_IVEC4: {
case RSE::GLOBAL_VAR_TYPE_IVEC4: {
return Vector4i();
}
case RS::GLOBAL_VAR_TYPE_RECT2I: {
case RSE::GLOBAL_VAR_TYPE_RECT2I: {
return Rect2i();
}
case RS::GLOBAL_VAR_TYPE_UINT: {
case RSE::GLOBAL_VAR_TYPE_UINT: {
return 0;
}
case RS::GLOBAL_VAR_TYPE_UVEC2: {
case RSE::GLOBAL_VAR_TYPE_UVEC2: {
return Vector2i();
}
case RS::GLOBAL_VAR_TYPE_UVEC3: {
case RSE::GLOBAL_VAR_TYPE_UVEC3: {
return Vector3i();
}
case RS::GLOBAL_VAR_TYPE_UVEC4: {
case RSE::GLOBAL_VAR_TYPE_UVEC4: {
return Vector4i();
}
case RS::GLOBAL_VAR_TYPE_FLOAT: {
case RSE::GLOBAL_VAR_TYPE_FLOAT: {
return 0.0;
}
case RS::GLOBAL_VAR_TYPE_VEC2: {
case RSE::GLOBAL_VAR_TYPE_VEC2: {
return Vector2();
}
case RS::GLOBAL_VAR_TYPE_VEC3: {
case RSE::GLOBAL_VAR_TYPE_VEC3: {
return Vector3();
}
case RS::GLOBAL_VAR_TYPE_VEC4: {
case RSE::GLOBAL_VAR_TYPE_VEC4: {
return Vector4();
}
case RS::GLOBAL_VAR_TYPE_RECT2: {
case RSE::GLOBAL_VAR_TYPE_RECT2: {
return Rect2();
}
case RS::GLOBAL_VAR_TYPE_COLOR: {
case RSE::GLOBAL_VAR_TYPE_COLOR: {
return Color();
}
case RS::GLOBAL_VAR_TYPE_MAT2: {
case RSE::GLOBAL_VAR_TYPE_MAT2: {
Vector<float> xform;
xform.resize(4);
xform.write[0] = 1;
@ -324,31 +325,31 @@ static Variant create_var(RS::GlobalShaderParameterType p_type) {
xform.write[3] = 1;
return xform;
}
case RS::GLOBAL_VAR_TYPE_MAT3: {
case RSE::GLOBAL_VAR_TYPE_MAT3: {
return Basis();
}
case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
case RSE::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
return Transform2D();
}
case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
case RSE::GLOBAL_VAR_TYPE_TRANSFORM: {
return Transform3D();
}
case RS::GLOBAL_VAR_TYPE_MAT4: {
case RSE::GLOBAL_VAR_TYPE_MAT4: {
return Projection();
}
case RS::GLOBAL_VAR_TYPE_SAMPLER2D: {
case RSE::GLOBAL_VAR_TYPE_SAMPLER2D: {
return "";
}
case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: {
case RSE::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: {
return "";
}
case RS::GLOBAL_VAR_TYPE_SAMPLER3D: {
case RSE::GLOBAL_VAR_TYPE_SAMPLER3D: {
return "";
}
case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE: {
case RSE::GLOBAL_VAR_TYPE_SAMPLERCUBE: {
return "";
}
case RS::GLOBAL_VAR_TYPE_SAMPLEREXT: {
case RSE::GLOBAL_VAR_TYPE_SAMPLEREXT: {
return "";
}
default: {
@ -397,10 +398,10 @@ void ShaderGlobalsEditor::_variable_added() {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
Variant value = create_var(RS::GlobalShaderParameterType(variable_type->get_selected()));
Variant value = create_var(RSE::GlobalShaderParameterType(variable_type->get_selected()));
undo_redo->create_action(TTR("Add Shader Global Parameter"));
undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_add", var, RS::GlobalShaderParameterType(variable_type->get_selected()), value);
undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_add", var, RSE::GlobalShaderParameterType(variable_type->get_selected()), value);
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_remove", var);
Dictionary gv;
gv["type"] = global_var_type_names[variable_type->get_selected()];
@ -479,7 +480,7 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
variable_type->set_h_size_flags(SIZE_EXPAND_FILL);
add_menu_hb->add_child(variable_type);
for (int i = 0; i < RS::GLOBAL_VAR_TYPE_MAX; i++) {
for (int i = 0; i < RSE::GLOBAL_VAR_TYPE_MAX; i++) {
variable_type->add_item(global_var_type_names[i]);
}

View file

@ -39,6 +39,7 @@
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/gui/split_container.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/shader_preprocessor.h"
#include "servers/rendering/shader_types.h"
@ -261,15 +262,15 @@ void ShaderTextEditor::_load_theme_settings() {
List<String> built_ins;
if (shader_inc.is_valid()) {
for (int i = 0; i < RenderingServer::SHADER_MAX; i++) {
for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(i))) {
for (int i = 0; i < RSE::SHADER_MAX; i++) {
for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RSE::ShaderMode(i))) {
for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) {
built_ins.push_back(F.key);
}
}
{
const Vector<ShaderLanguage::ModeInfo> &render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i));
const Vector<ShaderLanguage::ModeInfo> &render_modes = ShaderTypes::get_singleton()->get_modes(RSE::ShaderMode(i));
for (const ShaderLanguage::ModeInfo &mode_info : render_modes) {
if (!mode_info.options.is_empty()) {
@ -283,7 +284,7 @@ void ShaderTextEditor::_load_theme_settings() {
}
{
const Vector<ShaderLanguage::ModeInfo> &stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RenderingServer::ShaderMode(i));
const Vector<ShaderLanguage::ModeInfo> &stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RSE::ShaderMode(i));
for (const ShaderLanguage::ModeInfo &mode_info : stencil_modes) {
if (!mode_info.options.is_empty()) {
@ -297,14 +298,14 @@ void ShaderTextEditor::_load_theme_settings() {
}
}
} else if (shader.is_valid()) {
for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()))) {
for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RSE::ShaderMode(shader->get_mode()))) {
for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) {
built_ins.push_back(F.key);
}
}
{
const Vector<ShaderLanguage::ModeInfo> &shader_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
const Vector<ShaderLanguage::ModeInfo> &shader_modes = ShaderTypes::get_singleton()->get_modes(RSE::ShaderMode(shader->get_mode()));
for (const ShaderLanguage::ModeInfo &mode_info : shader_modes) {
if (!mode_info.options.is_empty()) {
@ -318,7 +319,7 @@ void ShaderTextEditor::_load_theme_settings() {
}
{
const Vector<ShaderLanguage::ModeInfo> &stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RenderingServer::ShaderMode(shader->get_mode()));
const Vector<ShaderLanguage::ModeInfo> &stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RSE::ShaderMode(shader->get_mode()));
for (const ShaderLanguage::ModeInfo &mode_info : stencil_modes) {
if (!mode_info.options.is_empty()) {
@ -394,7 +395,7 @@ void ShaderTextEditor::_check_shader_mode() {
}
static ShaderLanguage::DataType _get_global_shader_uniform_type(const StringName &p_variable) {
RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable);
RSE::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable);
return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
}
@ -457,9 +458,9 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa
return;
}
_check_shader_mode();
comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()));
comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
comp_info.stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RenderingServer::ShaderMode(shader->get_mode()));
comp_info.functions = ShaderTypes::get_singleton()->get_functions(RSE::ShaderMode(shader->get_mode()));
comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RSE::ShaderMode(shader->get_mode()));
comp_info.stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RSE::ShaderMode(shader->get_mode()));
comp_info.shader_types = ShaderTypes::get_singleton()->get_types();
sl.complete(code, comp_info, r_options, calltip);
@ -569,9 +570,9 @@ void ShaderTextEditor::_validate_script() {
comp_info.is_include = true;
} else {
Shader::Mode mode = shader->get_mode();
comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode));
comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode));
comp_info.stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RenderingServer::ShaderMode(mode));
comp_info.functions = ShaderTypes::get_singleton()->get_functions(RSE::ShaderMode(mode));
comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RSE::ShaderMode(mode));
comp_info.stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RSE::ShaderMode(mode));
comp_info.shader_types = ShaderTypes::get_singleton()->get_types();
}

View file

@ -74,6 +74,7 @@
#include "scene/resources/visual_shader_nodes.h"
#include "scene/resources/visual_shader_particle_nodes.h"
#include "servers/display/display_server.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/shader_preprocessor.h"
#include "servers/rendering/shader_types.h"
@ -6388,7 +6389,7 @@ void VisualShaderEditor::_preview_close_requested() {
}
static ShaderLanguage::DataType _visual_shader_editor_get_global_shader_uniform_type(const StringName &p_variable) {
RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable);
RSE::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable);
return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
}
@ -6403,9 +6404,9 @@ void VisualShaderEditor::_update_preview() {
preview_text->set_text(code);
ShaderLanguage::ShaderCompileInfo info;
info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode()));
info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode()));
info.stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RenderingServer::ShaderMode(visual_shader->get_mode()));
info.functions = ShaderTypes::get_singleton()->get_functions(RSE::ShaderMode(visual_shader->get_mode()));
info.render_modes = ShaderTypes::get_singleton()->get_modes(RSE::ShaderMode(visual_shader->get_mode()));
info.stencil_modes = ShaderTypes::get_singleton()->get_stencil_modes(RSE::ShaderMode(visual_shader->get_mode()));
info.shader_types = ShaderTypes::get_singleton()->get_types();
info.global_shader_uniform_type_func = _visual_shader_editor_get_global_shader_uniform_type;

View file

@ -75,6 +75,7 @@
#include "servers/movie_writer/movie_writer.h"
#include "servers/register_server_types.h"
#include "servers/rendering/rendering_device.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_default.h"
#include "servers/text/text_server.h"
#include "servers/text/text_server_dummy.h"
@ -3813,7 +3814,7 @@ void Main::setup_boot_logo() {
if (show_logo) { //boot logo!
const bool boot_logo_image = GLOBAL_DEF_BASIC("application/boot_splash/show_image", true);
const RenderingServer::SplashStretchMode boot_stretch_mode = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "application/boot_splash/stretch_mode", PROPERTY_HINT_ENUM, "Disabled,Keep,Keep Width,Keep Height,Cover,Ignore"), 1);
const RSE::SplashStretchMode boot_stretch_mode = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "application/boot_splash/stretch_mode", PROPERTY_HINT_ENUM, "Disabled,Keep,Keep Width,Keep Height,Cover,Ignore"), 1);
const bool boot_logo_filter = GLOBAL_DEF_BASIC("application/boot_splash/use_filter", true);
String boot_logo_path = GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/boot_splash/image", PROPERTY_HINT_FILE, "*.png"), String());
@ -3867,7 +3868,7 @@ void Main::setup_boot_logo() {
MAIN_PRINT("Main: ClearColor");
RenderingServer::get_singleton()->set_default_clear_color(boot_bg_color);
MAIN_PRINT("Main: Image");
RenderingServer::get_singleton()->set_boot_image_with_stretch(splash, boot_bg_color, RenderingServer::SPLASH_STRETCH_MODE_DISABLED);
RenderingServer::get_singleton()->set_boot_image_with_stretch(splash, boot_bg_color, RSE::SPLASH_STRETCH_MODE_DISABLED);
#endif
}

View file

@ -261,27 +261,27 @@ double Performance::get_monitor(Monitor p_monitor) const {
case OBJECT_ORPHAN_NODE_COUNT:
return _get_orphan_node_count();
case RENDER_TOTAL_OBJECTS_IN_FRAME:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME);
case RENDER_TOTAL_PRIMITIVES_IN_FRAME:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME);
case RENDER_TOTAL_DRAW_CALLS_IN_FRAME:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME);
case RENDER_VIDEO_MEM_USED:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_VIDEO_MEM_USED);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_VIDEO_MEM_USED);
case RENDER_TEXTURE_MEM_USED:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_TEXTURE_MEM_USED);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_TEXTURE_MEM_USED);
case RENDER_BUFFER_MEM_USED:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_BUFFER_MEM_USED);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_BUFFER_MEM_USED);
case PIPELINE_COMPILATIONS_CANVAS:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_PIPELINE_COMPILATIONS_CANVAS);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_PIPELINE_COMPILATIONS_CANVAS);
case PIPELINE_COMPILATIONS_MESH:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_PIPELINE_COMPILATIONS_MESH);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_PIPELINE_COMPILATIONS_MESH);
case PIPELINE_COMPILATIONS_SURFACE:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_PIPELINE_COMPILATIONS_SURFACE);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_PIPELINE_COMPILATIONS_SURFACE);
case PIPELINE_COMPILATIONS_DRAW:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_PIPELINE_COMPILATIONS_DRAW);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_PIPELINE_COMPILATIONS_DRAW);
case PIPELINE_COMPILATIONS_SPECIALIZATION:
return RS::get_singleton()->get_rendering_info(RS::RENDERING_INFO_PIPELINE_COMPILATIONS_SPECIALIZATION);
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_PIPELINE_COMPILATIONS_SPECIALIZATION);
#ifndef PHYSICS_2D_DISABLED
case PHYSICS_2D_ACTIVE_OBJECTS:
return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_ACTIVE_OBJECTS);

View file

@ -30,8 +30,6 @@
#include "image_compress_betsy.h"
#include "core/config/project_settings.h"
#include "betsy_bc1.h"
#include "alpha_stitch.glsl.gen.h"
@ -39,7 +37,19 @@
#include "bc4.glsl.gen.h"
#include "bc6h.glsl.gen.h"
#include "rgb_to_rgba.glsl.gen.h"
#include "core/config/project_settings.h"
#include "servers/display/display_server.h"
#include "servers/rendering/rendering_context_driver.h"
#include "servers/rendering/rendering_device.h"
#include "servers/rendering/rendering_server.h"
#if defined(VULKAN_ENABLED)
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
#endif
#if defined(METAL_ENABLED)
#include "drivers/metal/rendering_context_driver_metal.h"
#endif
static Mutex betsy_mutex;
static BetsyCompressor *betsy = nullptr;

View file

@ -32,18 +32,11 @@
#include "core/io/image.h"
#include "core/object/worker_thread_pool.h"
#include "core/os/thread.h"
#include "core/templates/command_queue_mt.h"
#include "servers/rendering/rendering_device_binds.h" // RDShaderFile
#include "servers/rendering/rendering_device_binds.h"
#include "servers/rendering/rendering_server_default.h"
#if defined(VULKAN_ENABLED)
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
#endif
#if defined(METAL_ENABLED)
#include "drivers/metal/rendering_context_driver_metal.h"
#endif
class RenderingDevice;
class RenderingContextDriver;
enum BetsyFormat {
BETSY_FORMAT_BC1,

View file

@ -30,12 +30,15 @@
#include "csg_shape.h"
#ifdef DEV_ENABLED
#include "core/io/json.h"
#endif // DEV_ENABLED
#include "core/math/geometry_2d.h"
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/navigation_mesh.h"
#include "servers/rendering/rendering_server.h"
#ifdef DEV_ENABLED
#include "core/io/json.h"
#endif // DEV_ENABLED
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_3d/navigation_server_3d.h"
#endif // NAVIGATION_3D_DISABLED

View file

@ -1436,7 +1436,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) {
TypedArray<Material> instance_materials;
for (int j = 0; j < primitives.size(); j++) {
uint64_t flags = RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
uint64_t flags = RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
Dictionary mesh_prim = primitives[j];
Array array;
@ -1745,7 +1745,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) {
}
if (p_state->force_disable_compression || is_mesh_2d || !a.has("POSITION") || !a.has("NORMAL") || mesh_prim.has("targets") || (a.has("JOINTS_0") || a.has("JOINTS_1"))) {
flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
flags &= ~RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}
Ref<SurfaceTool> mesh_surface_tool;
@ -1761,19 +1761,19 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) {
}
array = mesh_surface_tool->commit_to_arrays();
if ((flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && a.has("NORMAL") && (a.has("TANGENT") || generate_tangents)) {
if ((flags & RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && a.has("NORMAL") && (a.has("TANGENT") || generate_tangents)) {
// Compression is enabled, so let's validate that the normals and tangents are correct.
Vector<Vector3> normals = array[Mesh::ARRAY_NORMAL];
Vector<float> tangents = array[Mesh::ARRAY_TANGENT];
if (unlikely(tangents.size() < normals.size() * 4)) {
ERR_PRINT("glTF import: Mesh " + itos(i) + " has invalid tangents.");
flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
flags &= ~RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
} else {
for (int vert = 0; vert < normals.size(); vert++) {
Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]);
if (std::abs(tan.dot(normals[vert])) > 0.0001) {
// Tangent is not perpendicular to the normal, so we can't use compression.
flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
flags &= ~RSE::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}
}
}

View file

@ -32,6 +32,7 @@
#include "../gltf_defines.h"
#include "core/variant/typed_array.h"
#include "scene/resources/3d/importer_mesh.h"
class GLTFMesh : public Resource {

View file

@ -143,8 +143,8 @@ void GodotSoftBody3D::set_mesh(RID p_mesh) {
Array arrays = RenderingServer::get_singleton()->mesh_surface_get_arrays(soft_mesh, 0);
ERR_FAIL_COND(arrays.is_empty());
const Vector<int> &indices = arrays[RenderingServer::ARRAY_INDEX];
const Vector<Vector3> &vertices = arrays[RenderingServer::ARRAY_VERTEX];
const Vector<int> &indices = arrays[RSE::ARRAY_INDEX];
const Vector<Vector3> &vertices = arrays[RSE::ARRAY_VERTEX];
ERR_FAIL_COND_MSG(indices.is_empty(), "Soft body's mesh needs to have indices");
ERR_FAIL_COND_MSG(vertices.is_empty(), "Soft body's mesh needs to have vertices");

View file

@ -54,6 +54,7 @@
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
#include "scene/main/window.h"
#include "servers/rendering/rendering_server.h"
void GridMapEditor::_configure() {
if (!node) {
@ -1206,10 +1207,10 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
}
Array d;
d.resize(RS::ARRAY_MAX);
d[RS::ARRAY_VERTEX] = grid_points[i];
d[RS::ARRAY_COLOR] = grid_colors[i];
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d);
d.resize(RSE::ARRAY_MAX);
d[RSE::ARRAY_VERTEX] = grid_points[i];
d[RSE::ARRAY_COLOR] = grid_colors[i];
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RSE::PRIMITIVE_LINES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
}
}
@ -1335,7 +1336,7 @@ void GridMapEditor::_update_cursor_instance() {
Ref<Mesh> mesh = node->get_mesh_library()->get_item_mesh(selected_palette);
if (mesh.is_valid() && mesh->get_rid().is_valid()) {
cursor_instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), scenario);
RS::ShadowCastingSetting cast_shadows = (RS::ShadowCastingSetting)node->get_mesh_library()->get_item_mesh_cast_shadow(selected_palette);
RSE::ShadowCastingSetting cast_shadows = (RSE::ShadowCastingSetting)node->get_mesh_library()->get_item_mesh_cast_shadow(selected_palette);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(cursor_instance, cast_shadows);
}
}
@ -1741,7 +1742,7 @@ GridMapEditor::GridMapEditor() {
}
Array d;
d.resize(RS::ARRAY_MAX);
d.resize(RSE::ARRAY_MAX);
default_color = Color(0.0, 0.565, 1.0); // blue 0.7, 0.7, 1.0
erase_color = Color(1.0, 0.2, 0.2); // red
@ -1779,34 +1780,34 @@ GridMapEditor::GridMapEditor() {
selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
selection_floor_mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
d[RS::ARRAY_VERTEX] = triangles;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh, RS::PRIMITIVE_TRIANGLES, d);
d[RSE::ARRAY_VERTEX] = triangles;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh, RSE::PRIMITIVE_TRIANGLES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(cursor_mesh, 0, cursor_inner_mat->get_rid());
d[RS::ARRAY_VERTEX] = lines;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh, RS::PRIMITIVE_LINES, d);
d[RSE::ARRAY_VERTEX] = lines;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh, RSE::PRIMITIVE_LINES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(cursor_mesh, 1, cursor_outer_mat->get_rid());
d[RS::ARRAY_VERTEX] = triangles;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_TRIANGLES, d);
d[RSE::ARRAY_VERTEX] = triangles;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RSE::PRIMITIVE_TRIANGLES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
d[RS::ARRAY_VERTEX] = lines;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_LINES, d);
d[RSE::ARRAY_VERTEX] = lines;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RSE::PRIMITIVE_LINES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid());
d[RS::ARRAY_VERTEX] = triangles;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_TRIANGLES, d);
d[RSE::ARRAY_VERTEX] = triangles;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RSE::PRIMITIVE_TRIANGLES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 0, inner_mat->get_rid());
d[RS::ARRAY_VERTEX] = lines;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_LINES, d);
d[RSE::ARRAY_VERTEX] = lines;
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RSE::PRIMITIVE_LINES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 1, outer_mat->get_rid());
for (int i = 0; i < 3; i++) {
d[RS::ARRAY_VERTEX] = square[i];
d[RSE::ARRAY_VERTEX] = square[i];
selection_level_mesh[i] = RS::get_singleton()->mesh_create();
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], RS::PRIMITIVE_LINES, d);
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], RSE::PRIMITIVE_LINES, d);
RenderingServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid());
}
}

View file

@ -792,7 +792,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
Octant::MultimeshInstance mmi;
RID mm = RS::get_singleton()->multimesh_create();
RS::get_singleton()->multimesh_allocate_data(mm, E.value.size(), RS::MULTIMESH_TRANSFORM_3D);
RS::get_singleton()->multimesh_allocate_data(mm, E.value.size(), RSE::MULTIMESH_TRANSFORM_3D);
RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E.key)->get_rid());
int idx = 0;
@ -819,7 +819,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
RS::get_singleton()->instance_set_transform(instance, get_global_transform());
}
RS::ShadowCastingSetting cast_shadows = (RS::ShadowCastingSetting)mesh_library->get_item_mesh_cast_shadow(E.key);
RSE::ShadowCastingSetting cast_shadows = (RSE::ShadowCastingSetting)mesh_library->get_item_mesh_cast_shadow(E.key);
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, cast_shadows);
mmi.multimesh = mm;
@ -840,11 +840,11 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
Array arr;
arr.resize(RS::ARRAY_MAX);
arr[RS::ARRAY_VERTEX] = col_debug;
arr[RS::ARRAY_COLOR] = colors;
arr.resize(RSE::ARRAY_MAX);
arr[RSE::ARRAY_VERTEX] = col_debug;
arr[RSE::ARRAY_COLOR] = colors;
RS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, RS::PRIMITIVE_LINES, arr);
RS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, RSE::PRIMITIVE_LINES, arr);
if (st) {
RS::get_singleton()->mesh_surface_set_material(g.collision_debug, 0, st->get_debug_collision_material()->get_rid());
}
@ -1540,14 +1540,14 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
case PhysicsServer3D::SHAPE_SPHERE: {
real_t radius = data;
Array arr;
arr.resize(RS::ARRAY_MAX);
arr.resize(RSE::ARRAY_MAX);
SphereMesh::create_mesh_array(arr, radius, radius * 2.0);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;
case PhysicsServer3D::SHAPE_BOX: {
Vector3 extents = data;
Array arr;
arr.resize(RS::ARRAY_MAX);
arr.resize(RSE::ARRAY_MAX);
BoxMesh::create_mesh_array(arr, extents * 2.0);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;
@ -1556,7 +1556,7 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
real_t radius = dict["radius"];
real_t height = dict["height"];
Array arr;
arr.resize(RS::ARRAY_MAX);
arr.resize(RSE::ARRAY_MAX);
CapsuleMesh::create_mesh_array(arr, radius, height);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;
@ -1565,7 +1565,7 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
real_t radius = dict["radius"];
real_t height = dict["height"];
Array arr;
arr.resize(RS::ARRAY_MAX);
arr.resize(RSE::ARRAY_MAX);
CylinderMesh::create_mesh_array(arr, radius, radius, height);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;

View file

@ -190,10 +190,10 @@ class GridMap : public Node3D {
void _recreate_octant_data();
struct BakeLight {
RS::LightType type = RS::LightType::LIGHT_DIRECTIONAL;
RSE::LightType type = RSE::LightType::LIGHT_DIRECTIONAL;
Vector3 pos;
Vector3 dir;
float param[RS::LIGHT_PARAM_MAX] = {};
float param[RSE::LIGHT_PARAM_MAX] = {};
};
_FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const {

View file

@ -130,10 +130,10 @@ JPH::SoftBodySharedSettings *JoltSoftBody3D::_create_shared_settings() {
const Array mesh_data = rendering->mesh_surface_get_arrays(mesh, 0);
ERR_FAIL_COND_V(mesh_data.is_empty(), nullptr);
const PackedInt32Array mesh_indices = mesh_data[RenderingServer::ARRAY_INDEX];
const PackedInt32Array mesh_indices = mesh_data[RSE::ARRAY_INDEX];
ERR_FAIL_COND_V(mesh_indices.is_empty(), nullptr);
const PackedVector3Array mesh_vertices = mesh_data[RenderingServer::ARRAY_VERTEX];
const PackedVector3Array mesh_vertices = mesh_data[RSE::ARRAY_VERTEX];
ERR_FAIL_COND_V(mesh_vertices.is_empty(), nullptr);
JPH::SoftBodySharedSettings *settings = new JPH::SoftBodySharedSettings();

View file

@ -33,6 +33,7 @@
#include "core/io/file_access.h"
#include "core/io/file_access_memory.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/texture.h"
#include "servers/rendering/rendering_server.h"
#include <ktx.h>

View file

@ -31,7 +31,6 @@
#pragma once
#include "core/io/resource_loader.h"
#include "scene/resources/texture.h"
class ResourceFormatKTX : public ResourceFormatLoader {
GDSOFTCLASS(ResourceFormatKTX, ResourceFormatLoader);

View file

@ -41,7 +41,9 @@
#include "core/math/geometry_3d.h"
#include "editor/file_system/editor_paths.h"
#include "editor/settings/editor_settings.h"
#include "servers/rendering/rendering_device.h"
#include "servers/rendering/rendering_device_binds.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_globals.h"
#if defined(VULKAN_ENABLED)
@ -496,7 +498,7 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
t.max_bounds[1] = taabb.position.y + MAX(taabb.size.y, 0.0001);
t.max_bounds[2] = taabb.position.z + MAX(taabb.size.z, 0.0001);
t.cull_mode = RS::CULL_MODE_BACK;
t.cull_mode = RSE::CULL_MODE_BACK;
RID material = mi.data.material[i];
if (material.is_valid()) {

View file

@ -33,7 +33,7 @@
#include "core/input/input.h"
#include "core/os/os.h"
#include "servers/display/display_server.h"
#include "servers/rendering/renderer_compositor.h"
#include "servers/rendering/rendering_server_types.h"
StringName MobileVRInterface::get_name() const {
return "Native mobile";
@ -509,10 +509,10 @@ Projection MobileVRInterface::get_projection_for_view(uint32_t p_view, double p_
return eye;
}
Vector<BlitToScreen> MobileVRInterface::post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) {
Vector<RenderingServerTypes::BlitToScreen> MobileVRInterface::post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) {
_THREAD_SAFE_METHOD_
Vector<BlitToScreen> blit_to_screen;
Vector<RenderingServerTypes::BlitToScreen> blit_to_screen;
// We must have a valid render target.
ERR_FAIL_COND_V(!p_render_target.is_valid(), blit_to_screen);
@ -528,7 +528,7 @@ Vector<BlitToScreen> MobileVRInterface::post_draw_viewport(RID p_render_target,
Rect2 modified_screen_rect = Rect2(p_screen_rect.position + offset_rect.position * p_screen_rect.size, p_screen_rect.size * offset_rect.size);
// and add our blits
BlitToScreen blit;
RenderingServerTypes::BlitToScreen blit;
blit.render_target = p_render_target;
blit.multi_view.use_layer = true;
blit.lens_distortion.apply = true;

View file

@ -165,7 +165,7 @@ public:
virtual Transform3D get_camera_transform() override;
virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override;
virtual Projection get_projection_for_view(uint32_t p_view, double p_aspect, double p_z_near, double p_z_far) override;
virtual Vector<BlitToScreen> post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) override;
virtual Vector<RenderingServerTypes::BlitToScreen> post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) override;
virtual void process() override;

View file

@ -41,6 +41,7 @@
#include "scene/gui/button.h"
#include "scene/gui/dialogs.h"
#include "servers/navigation_3d/navigation_server_3d.h"
#include "servers/rendering/rendering_server.h"
bool NavigationObstacle3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<NavigationObstacle3D>(p_spatial) != nullptr;
@ -753,7 +754,7 @@ void NavigationObstacle3DEditorPlugin::redraw() {
point_lines_mesh_array[Mesh::ARRAY_VERTEX] = point_lines_mesh_vertices;
rs->mesh_add_surface_from_arrays(point_lines_mesh_rid, RS::PRIMITIVE_LINES, point_lines_mesh_array);
rs->mesh_add_surface_from_arrays(point_lines_mesh_rid, RSE::PRIMITIVE_LINES, point_lines_mesh_array);
rs->instance_set_surface_override_material(point_lines_instance_rid, 0, line_material->get_rid());
const Vector3 safe_scale = obstacle_node->get_global_basis().get_scale().abs().maxf(0.001);
const Transform3D gt = Transform3D(Basis().scaled(safe_scale).rotated(Vector3(0.0, 1.0, 0.0), obstacle_node->get_global_rotation().y), obstacle_node->get_global_position());
@ -780,7 +781,7 @@ void NavigationObstacle3DEditorPlugin::redraw() {
point_handle_mesh_array[Mesh::ARRAY_VERTEX] = point_handle_mesh_vertices;
rs->mesh_add_surface_from_arrays(point_handle_mesh_rid, RS::PRIMITIVE_POINTS, point_handle_mesh_array);
rs->mesh_add_surface_from_arrays(point_handle_mesh_rid, RSE::PRIMITIVE_POINTS, point_handle_mesh_array);
rs->instance_set_surface_override_material(point_handles_instance_rid, 0, handle_material->get_rid());
rs->instance_set_transform(point_handles_instance_rid, gt);
}

View file

@ -30,18 +30,77 @@
#include "openxr_composition_layer_extension.h"
#include "openxr_fb_update_swapchain_extension.h"
#include "platform/android/api/java_class_wrapper.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_globals.h"
#include "servers/xr/xr_server.h"
#ifdef ANDROID_ENABLED
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
#endif
#include "openxr_fb_update_swapchain_extension.h"
#include "platform/android/api/java_class_wrapper.h"
#include "servers/rendering/rendering_server_globals.h"
////////////////////////////////////////////////////////////////////////////
// OpenXRCompositionLayerExtension
#define OPENXR_LAYER_FUNC1_IMPL(m_name, m_arg1) \
void OpenXRCompositionLayerExtension::_composition_layer_##m_name##_rt(RID p_layer, m_arg1 p1) { \
CompositionLayer *layer = composition_layer_owner.get_or_null(p_layer); \
ERR_FAIL_NULL(layer); \
layer->m_name(p1); \
} \
void OpenXRCompositionLayerExtension::composition_layer_##m_name(RID p_layer, m_arg1 p1) { \
RenderingServer::get_singleton()->call_on_render_thread(callable_mp(this, &OpenXRCompositionLayerExtension::_composition_layer_##m_name##_rt).bind(p_layer, p1)); \
}
#define OPENXR_LAYER_FUNC2_IMPL(m_name, m_arg1, m_arg2) \
void OpenXRCompositionLayerExtension::_composition_layer_##m_name##_rt(RID p_layer, m_arg1 p1, m_arg2 p2) { \
CompositionLayer *layer = composition_layer_owner.get_or_null(p_layer); \
ERR_FAIL_NULL(layer); \
layer->m_name(p1, p2); \
} \
void OpenXRCompositionLayerExtension::composition_layer_##m_name(RID p_layer, m_arg1 p1, m_arg2 p2) { \
RenderingServer::get_singleton()->call_on_render_thread(callable_mp(this, &OpenXRCompositionLayerExtension::_composition_layer_##m_name##_rt).bind(p_layer, p1, p2)); \
}
OPENXR_LAYER_FUNC2_IMPL(set_viewport, RID, const Size2i &);
OPENXR_LAYER_FUNC2_IMPL(set_use_android_surface, bool, const Size2i &);
OPENXR_LAYER_FUNC1_IMPL(set_sort_order, int);
OPENXR_LAYER_FUNC1_IMPL(set_alpha_blend, bool);
OPENXR_LAYER_FUNC1_IMPL(set_transform, const Transform3D &);
OPENXR_LAYER_FUNC1_IMPL(set_protected_content, bool);
OPENXR_LAYER_FUNC1_IMPL(set_extension_property_values, Dictionary);
OPENXR_LAYER_FUNC1_IMPL(set_min_filter, Filter);
OPENXR_LAYER_FUNC1_IMPL(set_mag_filter, Filter);
OPENXR_LAYER_FUNC1_IMPL(set_mipmap_mode, MipmapMode);
OPENXR_LAYER_FUNC1_IMPL(set_horizontal_wrap, Wrap);
OPENXR_LAYER_FUNC1_IMPL(set_vertical_wrap, Wrap);
OPENXR_LAYER_FUNC1_IMPL(set_red_swizzle, Swizzle);
OPENXR_LAYER_FUNC1_IMPL(set_blue_swizzle, Swizzle);
OPENXR_LAYER_FUNC1_IMPL(set_green_swizzle, Swizzle);
OPENXR_LAYER_FUNC1_IMPL(set_alpha_swizzle, Swizzle);
OPENXR_LAYER_FUNC1_IMPL(set_max_anisotropy, float);
OPENXR_LAYER_FUNC1_IMPL(set_border_color, const Color &);
OPENXR_LAYER_FUNC1_IMPL(set_pose_space, PoseSpace);
OPENXR_LAYER_FUNC1_IMPL(set_eye_visibility, EyeVisibility);
OPENXR_LAYER_FUNC1_IMPL(set_quad_size, const Size2 &);
OPENXR_LAYER_FUNC1_IMPL(set_cylinder_radius, float);
OPENXR_LAYER_FUNC1_IMPL(set_cylinder_aspect_ratio, float);
OPENXR_LAYER_FUNC1_IMPL(set_cylinder_central_angle, float);
OPENXR_LAYER_FUNC1_IMPL(set_equirect_radius, float);
OPENXR_LAYER_FUNC1_IMPL(set_equirect_central_horizontal_angle, float);
OPENXR_LAYER_FUNC1_IMPL(set_equirect_upper_vertical_angle, float);
OPENXR_LAYER_FUNC1_IMPL(set_equirect_lower_vertical_angle, float);
#undef OPENXR_LAYER_FUNC1_IMPL
#undef OPENXR_LAYER_FUNC2_IMPL
OpenXRCompositionLayerExtension *OpenXRCompositionLayerExtension::singleton = nullptr;
OpenXRCompositionLayerExtension *OpenXRCompositionLayerExtension::get_singleton() {
@ -496,10 +555,10 @@ void OpenXRCompositionLayerExtension::CompositionLayer::on_pre_render() {
OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
if (subviewport.viewport.is_valid() && openxr_api && openxr_api->is_running()) {
RS::ViewportUpdateMode update_mode = rs->viewport_get_update_mode(subviewport.viewport);
if (update_mode == RS::VIEWPORT_UPDATE_ONCE || update_mode == RS::VIEWPORT_UPDATE_ALWAYS) {
RSE::ViewportUpdateMode update_mode = rs->viewport_get_update_mode(subviewport.viewport);
if (update_mode == RSE::VIEWPORT_UPDATE_ONCE || update_mode == RSE::VIEWPORT_UPDATE_ALWAYS) {
// Update our XR swapchain
if (update_and_acquire_swapchain(update_mode == RS::VIEWPORT_UPDATE_ONCE)) {
if (update_and_acquire_swapchain(update_mode == RSE::VIEWPORT_UPDATE_ONCE)) {
// Render to our XR swapchain image.
RID rt = rs->viewport_get_render_target(subviewport.viewport);
RSG::texture_storage->render_target_set_override(rt, get_current_swapchain_texture(), RID(), RID(), RID());

Some files were not shown because too many files have changed in this diff Show more