Make Servers truly Thread Safe

-Rendering server now uses a split RID allocate/initialize internally, this allows generating RIDs immediately but initialization to happen later on the proper thread (as rendering APIs generally requiere to call on the right thread).
-RenderingServerWrapMT is no more, multithreading is done in RenderingServerDefault.
-Some functions like texture or mesh creation, when renderer supports it, can register and return immediately (so no waiting for server API to flush, and saving staging and command buffer memory).
-3D physics server changed to be made multithread friendly.
-Added PhysicsServer3DWrapMT to use 3D physics server from multiple threads.
-Disablet Bullet (too much effort to make multithread friendly, this needs to be fixed eventually).
This commit is contained in:
reduz 2021-02-09 13:19:03 -03:00
parent f3d15771bf
commit 8b19ffd810
74 changed files with 2844 additions and 2748 deletions

View file

@ -97,7 +97,7 @@ void _collect_ysort_children(RendererCanvasCull::Item *p_canvas_item, Transform2
}
}
void _mark_ysort_dirty(RendererCanvasCull::Item *ysort_owner, RID_PtrOwner<RendererCanvasCull::Item> &canvas_item_owner) {
void _mark_ysort_dirty(RendererCanvasCull::Item *ysort_owner, RID_PtrOwner<RendererCanvasCull::Item, true> &canvas_item_owner) {
do {
ysort_owner->ysort_children_count = -1;
ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : nullptr;
@ -356,12 +356,12 @@ bool RendererCanvasCull::was_sdf_used() {
return sdf_used;
}
RID RendererCanvasCull::canvas_create() {
RID RendererCanvasCull::canvas_allocate() {
return canvas_owner.allocate_rid();
}
void RendererCanvasCull::canvas_initialize(RID p_rid) {
Canvas *canvas = memnew(Canvas);
ERR_FAIL_COND_V(!canvas, RID());
RID rid = canvas_owner.make_rid(canvas);
return rid;
canvas_owner.initialize_rid(p_rid, canvas);
}
void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
@ -393,11 +393,12 @@ void RendererCanvasCull::canvas_set_parent(RID p_canvas, RID p_parent, float p_s
canvas->parent_scale = p_scale;
}
RID RendererCanvasCull::canvas_item_create() {
RID RendererCanvasCull::canvas_item_allocate() {
return canvas_item_owner.allocate_rid();
}
void RendererCanvasCull::canvas_item_initialize(RID p_rid) {
Item *canvas_item = memnew(Item);
ERR_FAIL_COND_V(!canvas_item, RID());
return canvas_item_owner.make_rid(canvas_item);
canvas_item_owner.initialize_rid(p_rid, canvas_item);
}
void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
@ -1075,10 +1076,13 @@ void RendererCanvasCull::canvas_item_set_canvas_group_mode(RID p_item, RS::Canva
}
}
RID RendererCanvasCull::canvas_light_create() {
RID RendererCanvasCull::canvas_light_allocate() {
return canvas_light_owner.allocate_rid();
}
void RendererCanvasCull::canvas_light_initialize(RID p_rid) {
RendererCanvasRender::Light *clight = memnew(RendererCanvasRender::Light);
clight->light_internal = RSG::canvas_render->light_create();
return canvas_light_owner.make_rid(clight);
return canvas_light_owner.initialize_rid(p_rid, clight);
}
void RendererCanvasCull::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) {
@ -1268,10 +1272,13 @@ void RendererCanvasCull::canvas_light_set_shadow_smooth(RID p_light, float p_smo
clight->shadow_smooth = p_smooth;
}
RID RendererCanvasCull::canvas_light_occluder_create() {
RID RendererCanvasCull::canvas_light_occluder_allocate() {
return canvas_light_occluder_owner.allocate_rid();
}
void RendererCanvasCull::canvas_light_occluder_initialize(RID p_rid) {
RendererCanvasRender::LightOccluderInstance *occluder = memnew(RendererCanvasRender::LightOccluderInstance);
return canvas_light_occluder_owner.make_rid(occluder);
return canvas_light_occluder_owner.initialize_rid(p_rid, occluder);
}
void RendererCanvasCull::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
@ -1349,10 +1356,13 @@ void RendererCanvasCull::canvas_light_occluder_set_light_mask(RID p_occluder, in
occluder->light_mask = p_mask;
}
RID RendererCanvasCull::canvas_occluder_polygon_create() {
RID RendererCanvasCull::canvas_occluder_polygon_allocate() {
return canvas_light_occluder_polygon_owner.allocate_rid();
}
void RendererCanvasCull::canvas_occluder_polygon_initialize(RID p_rid) {
LightOccluderPolygon *occluder_poly = memnew(LightOccluderPolygon);
occluder_poly->occluder = RSG::canvas_render->occluder_polygon_create();
return canvas_light_occluder_polygon_owner.make_rid(occluder_poly);
return canvas_light_occluder_polygon_owner.initialize_rid(p_rid, occluder_poly);
}
void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
@ -1393,8 +1403,11 @@ void RendererCanvasCull::canvas_set_shadow_texture_size(int p_size) {
RSG::canvas_render->set_shadow_texture_size(p_size);
}
RID RendererCanvasCull::canvas_texture_create() {
return RSG::storage->canvas_texture_create();
RID RendererCanvasCull::canvas_texture_allocate() {
return RSG::storage->canvas_texture_allocate();
}
void RendererCanvasCull::canvas_texture_initialize(RID p_rid) {
RSG::storage->canvas_texture_initialize(p_rid);
}
void RendererCanvasCull::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) {

View file

@ -101,9 +101,9 @@ public:
}
};
RID_PtrOwner<LightOccluderPolygon> canvas_light_occluder_polygon_owner;
RID_PtrOwner<LightOccluderPolygon, true> canvas_light_occluder_polygon_owner;
RID_PtrOwner<RendererCanvasRender::LightOccluderInstance> canvas_light_occluder_owner;
RID_PtrOwner<RendererCanvasRender::LightOccluderInstance, true> canvas_light_occluder_owner;
struct Canvas : public RendererViewport::CanvasBase {
Set<RID> viewports;
@ -148,9 +148,9 @@ public:
}
};
mutable RID_PtrOwner<Canvas> canvas_owner;
RID_PtrOwner<Item> canvas_item_owner;
RID_PtrOwner<RendererCanvasRender::Light> canvas_light_owner;
mutable RID_PtrOwner<Canvas, true> canvas_owner;
RID_PtrOwner<Item, true> canvas_item_owner;
RID_PtrOwner<RendererCanvasRender::Light, true> canvas_light_owner;
bool disable_scale;
bool sdf_used = false;
@ -168,13 +168,17 @@ public:
bool was_sdf_used();
RID canvas_create();
RID canvas_allocate();
void canvas_initialize(RID p_rid);
void canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring);
void canvas_set_modulate(RID p_canvas, const Color &p_color);
void canvas_set_parent(RID p_canvas, RID p_parent, float p_scale);
void canvas_set_disable_scale(bool p_disable);
RID canvas_item_create();
RID canvas_item_allocate();
void canvas_item_initialize(RID p_rid);
void canvas_item_set_parent(RID p_item, RID p_parent);
void canvas_item_set_visible(RID p_item, bool p_visible);
@ -222,7 +226,9 @@ public:
void canvas_item_set_canvas_group_mode(RID p_item, RS::CanvasGroupMode p_mode, float p_clear_margin = 5.0, bool p_fit_empty = false, float p_fit_margin = 0.0, bool p_blur_mipmaps = false);
RID canvas_light_create();
RID canvas_light_allocate();
void canvas_light_initialize(RID p_rid);
void canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode);
void canvas_light_attach_to_canvas(RID p_light, RID p_canvas);
void canvas_light_set_enabled(RID p_light, bool p_enabled);
@ -246,7 +252,9 @@ public:
void canvas_light_set_shadow_color(RID p_light, const Color &p_color);
void canvas_light_set_shadow_smooth(RID p_light, float p_smooth);
RID canvas_light_occluder_create();
RID canvas_light_occluder_allocate();
void canvas_light_occluder_initialize(RID p_rid);
void canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas);
void canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled);
void canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon);
@ -254,14 +262,18 @@ public:
void canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform);
void canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask);
RID canvas_occluder_polygon_create();
RID canvas_occluder_polygon_allocate();
void canvas_occluder_polygon_initialize(RID p_rid);
void canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed);
void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode);
void canvas_set_shadow_texture_size(int p_size);
RID canvas_texture_create();
RID canvas_texture_allocate();
void canvas_texture_initialize(RID p_rid);
void canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture);
void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess);

View file

@ -2695,7 +2695,8 @@ RendererCanvasRenderRD::RendererCanvasRenderRD(RendererStorageRD *p_storage) {
state.default_transforms_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, shader.default_version_rd_shader, TRANSFORMS_UNIFORM_SET);
}
default_canvas_texture = storage->canvas_texture_create();
default_canvas_texture = storage->canvas_texture_allocate();
storage->canvas_texture_initialize(default_canvas_texture);
state.shadow_texture_size = GLOBAL_GET("rendering/quality/2d_shadow_atlas/size");
@ -2706,9 +2707,14 @@ RendererCanvasRenderRD::RendererCanvasRenderRD(RendererStorageRD *p_storage) {
state.time = 0;
{
default_canvas_group_shader = storage->shader_create();
default_canvas_group_shader = storage->shader_allocate();
storage->shader_initialize(default_canvas_group_shader);
storage->shader_set_code(default_canvas_group_shader, "shader_type canvas_item; \nvoid fragment() {\n\tvec4 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0); if (c.a > 0.0001) c.rgb/=c.a; COLOR *= c; \n}\n");
default_canvas_group_material = storage->material_create();
default_canvas_group_material = storage->material_allocate();
storage->material_initialize(default_canvas_group_material);
storage->material_set_shader(default_canvas_group_material, default_canvas_group_shader);
}

View file

@ -3574,9 +3574,11 @@ RendererSceneRenderForward::RendererSceneRenderForward(RendererStorageRD *p_stor
{
//default material and shader
default_shader = storage->shader_create();
default_shader = storage->shader_allocate();
storage->shader_initialize(default_shader);
storage->shader_set_code(default_shader, "shader_type spatial; void vertex() { ROUGHNESS = 0.8; } void fragment() { ALBEDO=vec3(0.6); ROUGHNESS=0.8; METALLIC=0.2; } \n");
default_material = storage->material_create();
default_material = storage->material_allocate();
storage->material_initialize(default_material);
storage->material_set_shader(default_material, default_shader);
MaterialData *md = (MaterialData *)storage->material_get_data(default_material, RendererStorageRD::SHADER_TYPE_3D);
@ -3587,14 +3589,18 @@ RendererSceneRenderForward::RendererSceneRenderForward(RendererStorageRD *p_stor
}
{
overdraw_material_shader = storage->shader_create();
overdraw_material_shader = storage->shader_allocate();
storage->shader_initialize(overdraw_material_shader);
storage->shader_set_code(overdraw_material_shader, "shader_type spatial;\nrender_mode blend_add,unshaded;\n void fragment() { ALBEDO=vec3(0.4,0.8,0.8); ALPHA=0.2; }");
overdraw_material = storage->material_create();
overdraw_material = storage->material_allocate();
storage->material_initialize(overdraw_material);
storage->material_set_shader(overdraw_material, overdraw_material_shader);
wireframe_material_shader = storage->shader_create();
wireframe_material_shader = storage->shader_allocate();
storage->shader_initialize(wireframe_material_shader);
storage->shader_set_code(wireframe_material_shader, "shader_type spatial;\nrender_mode wireframe,unshaded;\n void fragment() { ALBEDO=vec3(0.0,0.0,0.0); }");
wireframe_material = storage->material_create();
wireframe_material = storage->material_allocate();
storage->material_initialize(wireframe_material);
storage->material_set_shader(wireframe_material, wireframe_material_shader);
}

View file

@ -1881,8 +1881,11 @@ void RendererSceneRenderRD::_process_gi(RID p_render_buffers, RID p_normal_rough
RD::get_singleton()->draw_command_end_label();
}
RID RendererSceneRenderRD::sky_create() {
return sky_owner.make_rid(Sky());
RID RendererSceneRenderRD::sky_allocate() {
return sky_owner.allocate_rid();
}
void RendererSceneRenderRD::sky_initialize(RID p_rid) {
sky_owner.initialize_rid(p_rid, Sky());
}
void RendererSceneRenderRD::_sky_invalidate(Sky *p_sky) {
@ -2906,8 +2909,11 @@ RendererStorageRD::MaterialData *RendererSceneRenderRD::_create_sky_material_fun
return material_data;
}
RID RendererSceneRenderRD::environment_create() {
return environment_owner.make_rid(Environment());
RID RendererSceneRenderRD::environment_allocate() {
return environment_owner.allocate_rid();
}
void RendererSceneRenderRD::environment_initialize(RID p_rid) {
environment_owner.initialize_rid(p_rid, Environment());
}
void RendererSceneRenderRD::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
@ -3991,8 +3997,11 @@ int RendererSceneRenderRD::get_directional_light_shadow_size(RID p_light_intance
//////////////////////////////////////////////////
RID RendererSceneRenderRD::camera_effects_create() {
return camera_effects_owner.make_rid(CameraEffects());
RID RendererSceneRenderRD::camera_effects_allocate() {
return camera_effects_owner.allocate_rid();
}
void RendererSceneRenderRD::camera_effects_initialize(RID p_rid) {
camera_effects_owner.initialize_rid(p_rid, CameraEffects());
}
void RendererSceneRenderRD::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {
@ -8589,9 +8598,14 @@ RendererSceneRenderRD::RendererSceneRenderRD(RendererStorageRD *p_storage) {
{
// default material and shader for sky shader
sky_shader.default_shader = storage->shader_create();
sky_shader.default_shader = storage->shader_allocate();
storage->shader_initialize(sky_shader.default_shader);
storage->shader_set_code(sky_shader.default_shader, "shader_type sky; void fragment() { COLOR = vec3(0.0); } \n");
sky_shader.default_material = storage->material_create();
sky_shader.default_material = storage->material_allocate();
storage->material_initialize(sky_shader.default_material);
storage->material_set_shader(sky_shader.default_material, sky_shader.default_shader);
SkyMaterialData *md = (SkyMaterialData *)storage->material_get_data(sky_shader.default_material, RendererStorageRD::SHADER_TYPE_SKY);
@ -8665,9 +8679,13 @@ RendererSceneRenderRD::RendererSceneRenderRD(RendererStorageRD *p_storage) {
{
// Need defaults for using fog with clear color
sky_scene_state.fog_shader = storage->shader_create();
sky_scene_state.fog_shader = storage->shader_allocate();
storage->shader_initialize(sky_scene_state.fog_shader);
storage->shader_set_code(sky_scene_state.fog_shader, "shader_type sky; uniform vec4 clear_color; void fragment() { COLOR = clear_color.rgb; } \n");
sky_scene_state.fog_material = storage->material_create();
sky_scene_state.fog_material = storage->material_allocate();
storage->material_initialize(sky_scene_state.fog_material);
storage->material_set_shader(sky_scene_state.fog_material, sky_scene_state.fog_shader);
Vector<RD::Uniform> uniforms;

View file

@ -333,7 +333,7 @@ private:
uint32_t sky_ggx_samples_quality;
bool sky_use_cubemap_array;
mutable RID_Owner<Sky> sky_owner;
mutable RID_Owner<Sky, true> sky_owner;
/* REFLECTION ATLAS */
@ -809,7 +809,7 @@ private:
static uint64_t auto_exposure_counter;
mutable RID_Owner<Environment> environment_owner;
mutable RID_Owner<Environment, true> environment_owner;
/* CAMERA EFFECTS */
@ -835,7 +835,7 @@ private:
float sss_scale = 0.05;
float sss_depth_scale = 0.01;
mutable RID_Owner<CameraEffects> camera_effects_owner;
mutable RID_Owner<CameraEffects, true> camera_effects_owner;
/* RENDER BUFFERS */
@ -1654,7 +1654,9 @@ public:
RID sdfgi_get_ubo() const { return gi.sdfgi_ubo; }
/* SKY API */
RID sky_create();
virtual RID sky_allocate();
virtual void sky_initialize(RID p_rid);
void sky_set_radiance_size(RID p_sky, int p_radiance_size);
void sky_set_mode(RID p_sky, RS::SkyMode p_mode);
void sky_set_material(RID p_sky, RID p_material);
@ -1666,7 +1668,8 @@ public:
/* ENVIRONMENT API */
RID environment_create();
virtual RID environment_allocate();
virtual void environment_initialize(RID p_rid);
void environment_set_background(RID p_env, RS::EnvironmentBG p_bg);
void environment_set_sky(RID p_env, RID p_sky);
@ -1734,7 +1737,8 @@ public:
virtual Ref<Image> environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size);
virtual RID camera_effects_create();
virtual RID camera_effects_allocate();
virtual void camera_effects_initialize(RID p_rid);
virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter);
virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape);

View file

@ -36,6 +36,10 @@
#include "renderer_compositor_rd.h"
#include "servers/rendering/shader_language.h"
bool RendererStorageRD::can_create_resources_async() const {
return true;
}
Ref<Image> RendererStorageRD::_validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format) {
Ref<Image> image = p_image->duplicate();
@ -535,9 +539,13 @@ Ref<Image> RendererStorageRD::_validate_texture_format(const Ref<Image> &p_image
return image;
}
RID RendererStorageRD::texture_2d_create(const Ref<Image> &p_image) {
ERR_FAIL_COND_V(p_image.is_null(), RID());
ERR_FAIL_COND_V(p_image->is_empty(), RID());
RID RendererStorageRD::texture_allocate() {
return texture_owner.allocate_rid();
}
void RendererStorageRD::texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) {
ERR_FAIL_COND(p_image.is_null());
ERR_FAIL_COND(p_image->is_empty());
TextureToRDFormat ret_format;
Ref<Image> image = _validate_texture_format(p_image, ret_format);
@ -585,13 +593,13 @@ RID RendererStorageRD::texture_2d_create(const Ref<Image> &p_image) {
Vector<Vector<uint8_t>> data_slices;
data_slices.push_back(data);
texture.rd_texture = RD::get_singleton()->texture_create(rd_format, rd_view, data_slices);
ERR_FAIL_COND_V(texture.rd_texture.is_null(), RID());
ERR_FAIL_COND(texture.rd_texture.is_null());
if (texture.rd_format_srgb != RD::DATA_FORMAT_MAX) {
rd_view.format_override = texture.rd_format_srgb;
texture.rd_texture_srgb = RD::get_singleton()->texture_create_shared(rd_view, texture.rd_texture);
if (texture.rd_texture_srgb.is_null()) {
RD::get_singleton()->free(texture.rd_texture);
ERR_FAIL_COND_V(texture.rd_texture_srgb.is_null(), RID());
ERR_FAIL_COND(texture.rd_texture_srgb.is_null());
}
}
@ -602,14 +610,14 @@ RID RendererStorageRD::texture_2d_create(const Ref<Image> &p_image) {
texture.rd_view = rd_view;
texture.is_proxy = false;
return texture_owner.make_rid(texture);
texture_owner.initialize_rid(p_texture, texture);
}
RID RendererStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) {
ERR_FAIL_COND_V(p_layers.size() == 0, RID());
void RendererStorageRD::texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) {
ERR_FAIL_COND(p_layers.size() == 0);
ERR_FAIL_COND_V(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP && p_layers.size() != 6, RID());
ERR_FAIL_COND_V(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP_ARRAY && (p_layers.size() < 6 || (p_layers.size() % 6) != 0), RID());
ERR_FAIL_COND(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP && p_layers.size() != 6);
ERR_FAIL_COND(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP_ARRAY && (p_layers.size() < 6 || (p_layers.size() % 6) != 0));
TextureToRDFormat ret_format;
Vector<Ref<Image>> images;
@ -620,7 +628,7 @@ RID RendererStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_lay
Image::Format valid_format = Image::FORMAT_MAX;
for (int i = 0; i < p_layers.size(); i++) {
ERR_FAIL_COND_V(p_layers[i]->is_empty(), RID());
ERR_FAIL_COND(p_layers[i]->is_empty());
if (i == 0) {
valid_width = p_layers[i]->get_width();
@ -628,10 +636,10 @@ RID RendererStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_lay
valid_format = p_layers[i]->get_format();
valid_mipmaps = p_layers[i]->has_mipmaps();
} else {
ERR_FAIL_COND_V(p_layers[i]->get_width() != valid_width, RID());
ERR_FAIL_COND_V(p_layers[i]->get_height() != valid_height, RID());
ERR_FAIL_COND_V(p_layers[i]->get_format() != valid_format, RID());
ERR_FAIL_COND_V(p_layers[i]->has_mipmaps() != valid_mipmaps, RID());
ERR_FAIL_COND(p_layers[i]->get_width() != valid_width);
ERR_FAIL_COND(p_layers[i]->get_height() != valid_height);
ERR_FAIL_COND(p_layers[i]->get_format() != valid_format);
ERR_FAIL_COND(p_layers[i]->has_mipmaps() != valid_mipmaps);
}
images.push_back(_validate_texture_format(p_layers[i], ret_format));
@ -695,13 +703,13 @@ RID RendererStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_lay
data_slices.push_back(data);
}
texture.rd_texture = RD::get_singleton()->texture_create(rd_format, rd_view, data_slices);
ERR_FAIL_COND_V(texture.rd_texture.is_null(), RID());
ERR_FAIL_COND(texture.rd_texture.is_null());
if (texture.rd_format_srgb != RD::DATA_FORMAT_MAX) {
rd_view.format_override = texture.rd_format_srgb;
texture.rd_texture_srgb = RD::get_singleton()->texture_create_shared(rd_view, texture.rd_texture);
if (texture.rd_texture_srgb.is_null()) {
RD::get_singleton()->free(texture.rd_texture);
ERR_FAIL_COND_V(texture.rd_texture_srgb.is_null(), RID());
ERR_FAIL_COND(texture.rd_texture_srgb.is_null());
}
}
@ -712,14 +720,14 @@ RID RendererStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_lay
texture.rd_view = rd_view;
texture.is_proxy = false;
return texture_owner.make_rid(texture);
texture_owner.initialize_rid(p_texture, texture);
}
RID RendererStorageRD::texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) {
ERR_FAIL_COND_V(p_data.size() == 0, RID());
void RendererStorageRD::texture_3d_initialize(RID p_texture, Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) {
ERR_FAIL_COND(p_data.size() == 0);
Image::Image3DValidateError verr = Image::validate_3d_image(p_format, p_width, p_height, p_depth, p_mipmaps, p_data);
if (verr != Image::VALIDATE_3D_OK) {
ERR_FAIL_V_MSG(RID(), Image::get_3d_image_validation_error_text(verr));
ERR_FAIL_MSG(Image::get_3d_image_validation_error_text(verr));
}
TextureToRDFormat ret_format;
@ -811,13 +819,13 @@ RID RendererStorageRD::texture_3d_create(Image::Format p_format, int p_width, in
data_slices.push_back(all_data); //one slice
texture.rd_texture = RD::get_singleton()->texture_create(rd_format, rd_view, data_slices);
ERR_FAIL_COND_V(texture.rd_texture.is_null(), RID());
ERR_FAIL_COND(texture.rd_texture.is_null());
if (texture.rd_format_srgb != RD::DATA_FORMAT_MAX) {
rd_view.format_override = texture.rd_format_srgb;
texture.rd_texture_srgb = RD::get_singleton()->texture_create_shared(rd_view, texture.rd_texture);
if (texture.rd_texture_srgb.is_null()) {
RD::get_singleton()->free(texture.rd_texture);
ERR_FAIL_COND_V(texture.rd_texture_srgb.is_null(), RID());
ERR_FAIL_COND(texture.rd_texture_srgb.is_null());
}
}
@ -828,12 +836,12 @@ RID RendererStorageRD::texture_3d_create(Image::Format p_format, int p_width, in
texture.rd_view = rd_view;
texture.is_proxy = false;
return texture_owner.make_rid(texture);
texture_owner.initialize_rid(p_texture, texture);
}
RID RendererStorageRD::texture_proxy_create(RID p_base) {
void RendererStorageRD::texture_proxy_initialize(RID p_texture, RID p_base) {
Texture *tex = texture_owner.getornull(p_base);
ERR_FAIL_COND_V(!tex, RID());
ERR_FAIL_COND(!tex);
Texture proxy_tex = *tex;
proxy_tex.rd_view.format_override = tex->rd_format;
@ -847,11 +855,9 @@ RID RendererStorageRD::texture_proxy_create(RID p_base) {
proxy_tex.is_proxy = true;
proxy_tex.proxies.clear();
RID rid = texture_owner.make_rid(proxy_tex);
texture_owner.initialize_rid(p_texture, proxy_tex);
tex->proxies.push_back(rid);
return rid;
tex->proxies.push_back(p_texture);
}
void RendererStorageRD::_texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate) {
@ -961,7 +967,7 @@ void RendererStorageRD::texture_proxy_update(RID p_texture, RID p_proxy_to) {
}
//these two APIs can be used together or in combination with the others.
RID RendererStorageRD::texture_2d_placeholder_create() {
void RendererStorageRD::texture_2d_placeholder_initialize(RID p_texture) {
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
@ -974,10 +980,10 @@ RID RendererStorageRD::texture_2d_placeholder_create() {
}
}
return texture_2d_create(image);
texture_2d_initialize(p_texture, image);
}
RID RendererStorageRD::texture_2d_layered_placeholder_create(RS::TextureLayeredType p_layered_type) {
void RendererStorageRD::texture_2d_layered_placeholder_initialize(RID p_texture, RS::TextureLayeredType p_layered_type) {
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
@ -1000,10 +1006,10 @@ RID RendererStorageRD::texture_2d_layered_placeholder_create(RS::TextureLayeredT
}
}
return texture_2d_layered_create(images, p_layered_type);
texture_2d_layered_initialize(p_texture, images, p_layered_type);
}
RID RendererStorageRD::texture_3d_placeholder_create() {
void RendererStorageRD::texture_3d_placeholder_initialize(RID p_texture) {
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
@ -1022,7 +1028,7 @@ RID RendererStorageRD::texture_3d_placeholder_create() {
images.push_back(image);
}
return texture_3d_create(Image::FORMAT_RGBA8, 4, 4, 4, false, images);
texture_3d_initialize(p_texture, Image::FORMAT_RGBA8, 4, 4, 4, false, images);
}
Ref<Image> RendererStorageRD::texture_2d_get(RID p_texture) const {
@ -1223,8 +1229,11 @@ RendererStorageRD::CanvasTexture::~CanvasTexture() {
clear_sets();
}
RID RendererStorageRD::canvas_texture_create() {
return canvas_texture_owner.make_rid(memnew(CanvasTexture));
RID RendererStorageRD::canvas_texture_allocate() {
return canvas_texture_owner.allocate_rid();
}
void RendererStorageRD::canvas_texture_initialize(RID p_rid) {
canvas_texture_owner.initialize_rid(p_rid, memnew(CanvasTexture));
}
void RendererStorageRD::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) {
@ -1365,12 +1374,15 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
/* SHADER API */
RID RendererStorageRD::shader_create() {
RID RendererStorageRD::shader_allocate() {
return shader_owner.allocate_rid();
}
void RendererStorageRD::shader_initialize(RID p_rid) {
Shader shader;
shader.data = nullptr;
shader.type = SHADER_TYPE_MAX;
return shader_owner.make_rid(shader);
shader_owner.initialize_rid(p_rid, shader);
}
void RendererStorageRD::shader_set_code(RID p_shader, const String &p_code) {
@ -1510,7 +1522,10 @@ RS::ShaderNativeSourceCode RendererStorageRD::shader_get_native_source_code(RID
/* COMMON MATERIAL API */
RID RendererStorageRD::material_create() {
RID RendererStorageRD::material_allocate() {
return material_owner.allocate_rid();
}
void RendererStorageRD::material_initialize(RID p_rid) {
Material material;
material.data = nullptr;
material.shader = nullptr;
@ -1520,12 +1535,8 @@ RID RendererStorageRD::material_create() {
material.uniform_dirty = false;
material.texture_dirty = false;
material.priority = 0;
RID id = material_owner.make_rid(material);
{
Material *material_ptr = material_owner.getornull(id);
material_ptr->self = id;
}
return id;
material.self = p_rid;
material_owner.initialize_rid(p_rid, material);
}
void RendererStorageRD::_material_queue_update(Material *material, bool p_uniform, bool p_texture) {
@ -2399,8 +2410,11 @@ void RendererStorageRD::_update_queued_materials() {
/* MESH API */
RID RendererStorageRD::mesh_create() {
return mesh_owner.make_rid(Mesh());
RID RendererStorageRD::mesh_allocate() {
return mesh_owner.allocate_rid();
}
void RendererStorageRD::mesh_initialize(RID p_rid) {
mesh_owner.initialize_rid(p_rid, Mesh());
}
void RendererStorageRD::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) {
@ -3298,11 +3312,14 @@ void RendererStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Surf
////////////////// MULTIMESH
RID RendererStorageRD::multimesh_create() {
return multimesh_owner.make_rid(MultiMesh());
RID RendererStorageRD::multimesh_allocate() {
return multimesh_owner.allocate_rid();
}
void RendererStorageRD::multimesh_initialize(RID p_rid) {
multimesh_owner.initialize_rid(p_rid, MultiMesh());
}
void RendererStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
void RendererStorageRD::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
@ -3849,8 +3866,11 @@ void RendererStorageRD::_update_dirty_multimeshes() {
/* PARTICLES */
RID RendererStorageRD::particles_create() {
return particles_owner.make_rid(Particles());
RID RendererStorageRD::particles_allocate() {
return particles_owner.allocate_rid();
}
void RendererStorageRD::particles_initialize(RID p_rid) {
particles_owner.initialize_rid(p_rid, Particles());
}
void RendererStorageRD::particles_set_emitting(RID p_particles, bool p_emitting) {
@ -4984,8 +5004,11 @@ RendererStorageRD::MaterialData *RendererStorageRD::_create_particles_material_f
/* PARTICLES COLLISION API */
RID RendererStorageRD::particles_collision_create() {
return particles_collision_owner.make_rid(ParticlesCollision());
RID RendererStorageRD::particles_collision_allocate() {
return particles_collision_owner.allocate_rid();
}
void RendererStorageRD::particles_collision_initialize(RID p_rid) {
particles_collision_owner.initialize_rid(p_rid, ParticlesCollision());
}
RID RendererStorageRD::particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const {
@ -5164,8 +5187,11 @@ void RendererStorageRD::particles_collision_instance_set_active(RID p_collision_
/* SKELETON API */
RID RendererStorageRD::skeleton_create() {
return skeleton_owner.make_rid(Skeleton());
RID RendererStorageRD::skeleton_allocate() {
return skeleton_owner.allocate_rid();
}
void RendererStorageRD::skeleton_initialize(RID p_rid) {
skeleton_owner.initialize_rid(p_rid, Skeleton());
}
void RendererStorageRD::_skeleton_make_dirty(Skeleton *skeleton) {
@ -5176,7 +5202,7 @@ void RendererStorageRD::_skeleton_make_dirty(Skeleton *skeleton) {
}
}
void RendererStorageRD::skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
void RendererStorageRD::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_COND(p_bones < 0);
@ -5350,7 +5376,7 @@ void RendererStorageRD::_update_dirty_skeletons() {
/* LIGHT */
RID RendererStorageRD::light_create(RS::LightType p_type) {
void RendererStorageRD::_light_initialize(RID p_light, RS::LightType p_type) {
Light light;
light.type = p_type;
@ -5374,7 +5400,28 @@ RID RendererStorageRD::light_create(RS::LightType p_type) {
light.param[RS::LIGHT_PARAM_SHADOW_VOLUMETRIC_FOG_FADE] = 0.1;
light.param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS] = 0.05;
return light_owner.make_rid(light);
light_owner.initialize_rid(p_light, light);
}
RID RendererStorageRD::directional_light_allocate() {
return light_owner.allocate_rid();
}
void RendererStorageRD::directional_light_initialize(RID p_light) {
_light_initialize(p_light, RS::LIGHT_DIRECTIONAL);
}
RID RendererStorageRD::omni_light_allocate() {
return light_owner.allocate_rid();
}
void RendererStorageRD::omni_light_initialize(RID p_light) {
_light_initialize(p_light, RS::LIGHT_OMNI);
}
RID RendererStorageRD::spot_light_allocate() {
return light_owner.allocate_rid();
}
void RendererStorageRD::spot_light_initialize(RID p_light) {
_light_initialize(p_light, RS::LIGHT_SPOT);
}
void RendererStorageRD::light_set_color(RID p_light, const Color &p_color) {
@ -5612,8 +5659,11 @@ AABB RendererStorageRD::light_get_aabb(RID p_light) const {
/* REFLECTION PROBE */
RID RendererStorageRD::reflection_probe_create() {
return reflection_probe_owner.make_rid(ReflectionProbe());
RID RendererStorageRD::reflection_probe_allocate() {
return reflection_probe_owner.allocate_rid();
}
void RendererStorageRD::reflection_probe_initialize(RID p_reflection_probe) {
reflection_probe_owner.initialize_rid(p_reflection_probe, ReflectionProbe());
}
void RendererStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
@ -5835,8 +5885,11 @@ float RendererStorageRD::reflection_probe_get_ambient_color_energy(RID p_probe)
return reflection_probe->ambient_color_energy;
}
RID RendererStorageRD::decal_create() {
return decal_owner.make_rid(Decal());
RID RendererStorageRD::decal_allocate() {
return decal_owner.allocate_rid();
}
void RendererStorageRD::decal_initialize(RID p_decal) {
decal_owner.initialize_rid(p_decal, Decal());
}
void RendererStorageRD::decal_set_extents(RID p_decal, const Vector3 &p_extents) {
@ -5923,11 +5976,14 @@ AABB RendererStorageRD::decal_get_aabb(RID p_decal) const {
return AABB(-decal->extents, decal->extents * 2.0);
}
RID RendererStorageRD::gi_probe_create() {
return gi_probe_owner.make_rid(GIProbe());
RID RendererStorageRD::gi_probe_allocate() {
return gi_probe_owner.allocate_rid();
}
void RendererStorageRD::gi_probe_initialize(RID p_gi_probe) {
gi_probe_owner.initialize_rid(p_gi_probe, GIProbe());
}
void RendererStorageRD::gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {
void RendererStorageRD::gi_probe_allocate_data(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND(!gi_probe);
@ -6276,8 +6332,12 @@ RID RendererStorageRD::gi_probe_get_sdf_texture(RID p_gi_probe) {
/* LIGHTMAP API */
RID RendererStorageRD::lightmap_create() {
return lightmap_owner.make_rid(Lightmap());
RID RendererStorageRD::lightmap_allocate() {
return lightmap_owner.allocate_rid();
}
void RendererStorageRD::lightmap_initialize(RID p_lightmap) {
lightmap_owner.initialize_rid(p_lightmap, Lightmap());
}
void RendererStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) {
@ -6480,7 +6540,8 @@ void RendererStorageRD::_clear_render_target(RenderTarget *rt) {
void RendererStorageRD::_update_render_target(RenderTarget *rt) {
if (rt->texture.is_null()) {
//create a placeholder until updated
rt->texture = texture_2d_placeholder_create();
rt->texture = texture_allocate();
texture_2d_placeholder_initialize(rt->texture);
Texture *tex = texture_owner.getornull(rt->texture);
tex->is_render_target = true;
}
@ -8217,13 +8278,13 @@ bool RendererStorageRD::free(RID p_rid) {
} else if (multimesh_owner.owns(p_rid)) {
_update_dirty_multimeshes();
multimesh_allocate(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D);
multimesh_allocate_data(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D);
MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
multimesh->dependency.deleted_notify(p_rid);
multimesh_owner.free(p_rid);
} else if (skeleton_owner.owns(p_rid)) {
_update_dirty_skeletons();
skeleton_allocate(p_rid, 0);
skeleton_allocate_data(p_rid, 0);
Skeleton *skeleton = skeleton_owner.getornull(p_rid);
skeleton->dependency.deleted_notify(p_rid);
skeleton_owner.free(p_rid);
@ -8241,7 +8302,7 @@ bool RendererStorageRD::free(RID p_rid) {
decal->dependency.deleted_notify(p_rid);
decal_owner.free(p_rid);
} else if (gi_probe_owner.owns(p_rid)) {
gi_probe_allocate(p_rid, Transform(), AABB(), Vector3i(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<int>()); //deallocate
gi_probe_allocate_data(p_rid, Transform(), AABB(), Vector3i(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<int>()); //deallocate
GIProbe *gi_probe = gi_probe_owner.getornull(p_rid);
gi_probe->dependency.deleted_notify(p_rid);
gi_probe_owner.free(p_rid);
@ -8847,9 +8908,11 @@ RendererStorageRD::RendererStorageRD() {
{
// default material and shader for particles shader
particles_shader.default_shader = shader_create();
particles_shader.default_shader = shader_allocate();
shader_initialize(particles_shader.default_shader);
shader_set_code(particles_shader.default_shader, "shader_type particles; void compute() { COLOR = vec4(1.0); } \n");
particles_shader.default_material = material_create();
particles_shader.default_material = material_allocate();
material_initialize(particles_shader.default_material);
material_set_shader(particles_shader.default_material, particles_shader.default_shader);
ParticlesMaterialData *md = (ParticlesMaterialData *)material_get_data(particles_shader.default_material, RendererStorageRD::SHADER_TYPE_PARTICLES);

View file

@ -221,7 +221,7 @@ private:
~CanvasTexture();
};
RID_PtrOwner<CanvasTexture> canvas_texture_owner;
RID_PtrOwner<CanvasTexture, true> canvas_texture_owner;
/* TEXTURE API */
struct Texture {
@ -367,7 +367,7 @@ private:
};
ShaderDataRequestFunction shader_data_request_func[SHADER_TYPE_MAX];
mutable RID_Owner<Shader> shader_owner;
mutable RID_Owner<Shader, true> shader_owner;
/* Material */
@ -389,7 +389,7 @@ private:
};
MaterialDataRequestFunction material_data_request_func[SHADER_TYPE_MAX];
mutable RID_Owner<Material> material_owner;
mutable RID_Owner<Material, true> material_owner;
Material *material_update_list;
void _material_queue_update(Material *material, bool p_uniform, bool p_texture);
@ -484,7 +484,7 @@ private:
Dependency dependency;
};
mutable RID_Owner<Mesh> mesh_owner;
mutable RID_Owner<Mesh, true> mesh_owner;
struct MeshInstance {
Mesh *mesh;
@ -587,7 +587,7 @@ private:
Dependency dependency;
};
mutable RID_Owner<MultiMesh> multimesh_owner;
mutable RID_Owner<MultiMesh, true> multimesh_owner;
MultiMesh *multimesh_dirty_list = nullptr;
@ -893,7 +893,7 @@ private:
void update_particles();
mutable RID_Owner<Particles> particles_owner;
mutable RID_Owner<Particles, true> particles_owner;
/* Particles Collision */
@ -915,7 +915,7 @@ private:
Dependency dependency;
};
mutable RID_Owner<ParticlesCollision> particles_collision_owner;
mutable RID_Owner<ParticlesCollision, true> particles_collision_owner;
struct ParticlesCollisionInstance {
RID collision;
@ -945,7 +945,7 @@ private:
Dependency dependency;
};
mutable RID_Owner<Skeleton> skeleton_owner;
mutable RID_Owner<Skeleton, true> skeleton_owner;
_FORCE_INLINE_ void _skeleton_make_dirty(Skeleton *skeleton);
@ -977,7 +977,7 @@ private:
Dependency dependency;
};
mutable RID_Owner<Light> light_owner;
mutable RID_Owner<Light, true> light_owner;
/* REFLECTION PROBE */
@ -1000,7 +1000,7 @@ private:
Dependency dependency;
};
mutable RID_Owner<ReflectionProbe> reflection_probe_owner;
mutable RID_Owner<ReflectionProbe, true> reflection_probe_owner;
/* DECAL */
@ -1021,7 +1021,7 @@ private:
Dependency dependency;
};
mutable RID_Owner<Decal> decal_owner;
mutable RID_Owner<Decal, true> decal_owner;
/* GI PROBE */
@ -1064,7 +1064,7 @@ private:
RID giprobe_sdf_shader_version_shader;
RID giprobe_sdf_shader_pipeline;
mutable RID_Owner<GIProbe> gi_probe_owner;
mutable RID_Owner<GIProbe, true> gi_probe_owner;
/* REFLECTION PROBE */
@ -1095,7 +1095,7 @@ private:
uint64_t lightmap_array_version = 0;
mutable RID_Owner<Lightmap> lightmap_owner;
mutable RID_Owner<Lightmap, true> lightmap_owner;
float lightmap_probe_capture_update_speed = 4;
@ -1249,12 +1249,16 @@ private:
EffectsRD effects;
public:
virtual bool can_create_resources_async() const;
/* TEXTURE API */
virtual RID texture_2d_create(const Ref<Image> &p_image);
virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type);
virtual RID texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data); //all slices, then all the mipmaps, must be coherent
virtual RID texture_proxy_create(RID p_base);
virtual RID texture_allocate();
virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image);
virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type);
virtual void texture_3d_initialize(RID p_texture, Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data); //all slices, then all the mipmaps, must be coherent
virtual void texture_proxy_initialize(RID p_texture, RID p_base);
virtual void _texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate);
@ -1264,9 +1268,9 @@ public:
virtual void texture_proxy_update(RID p_texture, RID p_proxy_to);
//these two APIs can be used together or in combination with the others.
virtual RID texture_2d_placeholder_create();
virtual RID texture_2d_layered_placeholder_create(RenderingServer::TextureLayeredType p_layered_type);
virtual RID texture_3d_placeholder_create();
virtual void texture_2d_placeholder_initialize(RID p_texture);
virtual void texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type);
virtual void texture_3d_placeholder_initialize(RID p_texture);
virtual Ref<Image> texture_2d_get(RID p_texture) const;
virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const;
@ -1338,7 +1342,8 @@ public:
/* CANVAS TEXTURE API */
virtual RID canvas_texture_create();
RID canvas_texture_allocate();
void canvas_texture_initialize(RID p_canvas_texture);
virtual void canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture);
virtual void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_specular_color, float p_shininess);
@ -1350,7 +1355,8 @@ public:
/* SHADER API */
RID shader_create();
RID shader_allocate();
void shader_initialize(RID p_shader);
void shader_set_code(RID p_shader, const String &p_code);
String shader_get_code(RID p_shader) const;
@ -1365,7 +1371,8 @@ public:
/* COMMON MATERIAL API */
RID material_create();
RID material_allocate();
void material_initialize(RID p_material);
void material_set_shader(RID p_material, RID p_shader);
@ -1401,7 +1408,8 @@ public:
/* MESH API */
virtual RID mesh_create();
RID mesh_allocate();
void mesh_initialize(RID p_mesh);
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count);
@ -1622,9 +1630,10 @@ public:
/* MULTIMESH API */
RID multimesh_create();
RID multimesh_allocate();
void multimesh_initialize(RID p_multimesh);
void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false);
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);
int multimesh_get_instance_count(RID p_multimesh) const;
void multimesh_set_mesh(RID p_multimesh, RID p_mesh);
@ -1688,24 +1697,28 @@ public:
/* IMMEDIATE API */
RID immediate_create() { return RID(); }
void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {}
void immediate_normal(RID p_immediate, const Vector3 &p_normal) {}
void immediate_tangent(RID p_immediate, const Plane &p_tangent) {}
void immediate_color(RID p_immediate, const Color &p_color) {}
void immediate_uv(RID p_immediate, const Vector2 &tex_uv) {}
void immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {}
void immediate_end(RID p_immediate) {}
void immediate_clear(RID p_immediate) {}
void immediate_set_material(RID p_immediate, RID p_material) {}
RID immediate_get_material(RID p_immediate) const { return RID(); }
AABB immediate_get_aabb(RID p_immediate) const { return AABB(); }
RID immediate_allocate() { return RID(); }
void immediate_initialize(RID p_immediate) {}
virtual void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {}
virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal) {}
virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent) {}
virtual void immediate_color(RID p_immediate, const Color &p_color) {}
virtual void immediate_uv(RID p_immediate, const Vector2 &tex_uv) {}
virtual void immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {}
virtual void immediate_end(RID p_immediate) {}
virtual void immediate_clear(RID p_immediate) {}
virtual void immediate_set_material(RID p_immediate, RID p_material) {}
virtual RID immediate_get_material(RID p_immediate) const { return RID(); }
virtual AABB immediate_get_aabb(RID p_immediate) const { return AABB(); }
/* SKELETON API */
RID skeleton_create();
void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false);
RID skeleton_allocate();
void skeleton_initialize(RID p_skeleton);
void skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton = false);
void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform);
void skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform);
int skeleton_get_bone_count(RID p_skeleton) const;
@ -1739,11 +1752,16 @@ public:
}
/* Light API */
RID light_create(RS::LightType p_type);
void _light_initialize(RID p_rid, RS::LightType p_type);
RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); }
RID omni_light_create() { return light_create(RS::LIGHT_OMNI); }
RID spot_light_create() { return light_create(RS::LIGHT_SPOT); }
RID directional_light_allocate();
void directional_light_initialize(RID p_light);
RID omni_light_allocate();
void omni_light_initialize(RID p_light);
RID spot_light_allocate();
void spot_light_initialize(RID p_light);
void light_set_color(RID p_light, const Color &p_color);
void light_set_param(RID p_light, RS::LightParam p_param, float p_value);
@ -1846,7 +1864,8 @@ public:
/* PROBE API */
RID reflection_probe_create();
RID reflection_probe_allocate();
void reflection_probe_initialize(RID p_reflection_probe);
void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode);
void reflection_probe_set_intensity(RID p_probe, float p_intensity);
@ -1886,7 +1905,9 @@ public:
/* DECAL API */
virtual RID decal_create();
RID decal_allocate();
void decal_initialize(RID p_decal);
virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents);
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture);
virtual void decal_set_emission_energy(RID p_decal, float p_energy);
@ -1961,9 +1982,10 @@ public:
/* GI PROBE API */
RID gi_probe_create();
RID gi_probe_allocate();
void gi_probe_initialize(RID p_gi_probe);
void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts);
void gi_probe_allocate_data(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts);
AABB gi_probe_get_bounds(RID p_gi_probe) const;
Vector3i gi_probe_get_octree_size(RID p_gi_probe) const;
@ -2014,7 +2036,8 @@ public:
/* LIGHTMAP CAPTURE */
virtual RID lightmap_create();
RID lightmap_allocate();
void lightmap_initialize(RID p_lightmap);
virtual void lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics);
virtual void lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds);
@ -2063,7 +2086,8 @@ public:
/* PARTICLES */
RID particles_create();
RID particles_allocate();
void particles_initialize(RID p_particles_collision);
void particles_set_emitting(RID p_particles, bool p_emitting);
void particles_set_amount(RID p_particles, int p_amount);
@ -2141,7 +2165,9 @@ public:
/* PARTICLES COLLISION */
virtual RID particles_collision_create();
RID particles_collision_allocate();
void particles_collision_initialize(RID p_particles_collision);
virtual void particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type);
virtual void particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask);
virtual void particles_collision_set_sphere_radius(RID p_particles_collision, float p_radius); //for spheres

View file

@ -36,7 +36,8 @@
class RendererScene {
public:
virtual RID camera_create() = 0;
virtual RID camera_allocate() = 0;
virtual void camera_initialize(RID p_rid) = 0;
virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) = 0;
virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) = 0;
@ -48,7 +49,8 @@ public:
virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable) = 0;
virtual bool is_camera(RID p_camera) const = 0;
virtual RID scenario_create() = 0;
virtual RID scenario_allocate() = 0;
virtual void scenario_initialize(RID p_rid) = 0;
virtual void scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode) = 0;
virtual void scenario_set_environment(RID p_scenario, RID p_environment) = 0;
@ -58,7 +60,8 @@ public:
virtual bool is_scenario(RID p_scenario) const = 0;
virtual RID scenario_get_environment(RID p_scenario) = 0;
virtual RID instance_create() = 0;
virtual RID instance_allocate() = 0;
virtual void instance_initialize(RID p_rid) = 0;
virtual void instance_set_base(RID p_instance, RID p_base) = 0;
virtual void instance_set_scenario(RID p_instance, RID p_scenario) = 0;
@ -99,7 +102,9 @@ public:
/* SKY API */
virtual RID sky_create() = 0;
virtual RID sky_allocate() = 0;
virtual void sky_initialize(RID p_rid) = 0;
virtual void sky_set_radiance_size(RID p_sky, int p_radiance_size) = 0;
virtual void sky_set_mode(RID p_sky, RS::SkyMode p_samples) = 0;
virtual void sky_set_material(RID p_sky, RID p_material) = 0;
@ -107,7 +112,8 @@ public:
/* ENVIRONMENT API */
virtual RID environment_create() = 0;
virtual RID environment_allocate() = 0;
virtual void environment_initialize(RID p_rid) = 0;
virtual void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) = 0;
virtual void environment_set_sky(RID p_env, RID p_sky) = 0;
@ -159,7 +165,8 @@ public:
/* Camera Effects */
virtual RID camera_effects_create() = 0;
virtual RID camera_effects_allocate() = 0;
virtual void camera_effects_initialize(RID p_rid) = 0;
virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) = 0;
virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) = 0;
@ -177,6 +184,7 @@ public:
/* Render Buffers */
virtual RID render_buffers_create() = 0;
virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding) = 0;
virtual void gi_set_use_half_resolution(bool p_enable) = 0;

View file

@ -39,9 +39,11 @@
/* CAMERA API */
RID RendererSceneCull::camera_create() {
Camera *camera = memnew(Camera);
return camera_owner.make_rid(camera);
RID RendererSceneCull::camera_allocate() {
return camera_owner.allocate_rid();
}
void RendererSceneCull::camera_initialize(RID p_rid) {
camera_owner.initialize_rid(p_rid, memnew(Camera));
}
void RendererSceneCull::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
@ -290,11 +292,12 @@ void RendererSceneCull::_instance_unpair(Instance *p_A, Instance *p_B) {
}
}
RID RendererSceneCull::scenario_create() {
RID RendererSceneCull::scenario_allocate() {
return scenario_owner.allocate_rid();
}
void RendererSceneCull::scenario_initialize(RID p_rid) {
Scenario *scenario = memnew(Scenario);
ERR_FAIL_COND_V(!scenario, RID());
RID scenario_rid = scenario_owner.make_rid(scenario);
scenario->self = scenario_rid;
scenario->self = p_rid;
scenario->reflection_probe_shadow_atlas = scene_render->shadow_atlas_create();
scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest
@ -307,7 +310,7 @@ RID RendererSceneCull::scenario_create() {
scenario->instance_aabbs.set_page_pool(&instance_aabb_page_pool);
scenario->instance_data.set_page_pool(&instance_data_page_pool);
return scenario_rid;
scenario_owner.initialize_rid(p_rid, scenario);
}
void RendererSceneCull::scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode) {
@ -367,14 +370,14 @@ void RendererSceneCull::_instance_queue_update(Instance *p_instance, bool p_upda
_instance_update_list.add(&p_instance->update_item);
}
RID RendererSceneCull::instance_create() {
RID RendererSceneCull::instance_allocate() {
return instance_owner.allocate_rid();
}
void RendererSceneCull::instance_initialize(RID p_rid) {
Instance *instance = memnew(Instance);
ERR_FAIL_COND_V(!instance, RID());
instance->self = p_rid;
RID instance_rid = instance_owner.make_rid(instance);
instance->self = instance_rid;
return instance_rid;
instance_owner.initialize_rid(p_rid, instance);
}
void RendererSceneCull::_instance_update_mesh_instance(Instance *p_instance) {

View file

@ -94,9 +94,11 @@ public:
}
};
mutable RID_PtrOwner<Camera> camera_owner;
mutable RID_PtrOwner<Camera, true> camera_owner;
virtual RID camera_allocate();
virtual void camera_initialize(RID p_rid);
virtual RID camera_create();
virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far);
virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far);
virtual void camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far);
@ -296,14 +298,15 @@ public:
int indexer_update_iterations = 0;
mutable RID_PtrOwner<Scenario> scenario_owner;
mutable RID_PtrOwner<Scenario, true> scenario_owner;
static void _instance_pair(Instance *p_A, Instance *p_B);
static void _instance_unpair(Instance *p_A, Instance *p_B);
void _instance_update_mesh_instance(Instance *p_instance);
virtual RID scenario_create();
virtual RID scenario_allocate();
virtual void scenario_initialize(RID p_rid);
virtual void scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode);
virtual void scenario_set_environment(RID p_scenario, RID p_environment);
@ -824,11 +827,12 @@ public:
uint32_t thread_cull_threshold = 200;
RID_PtrOwner<Instance> instance_owner;
RID_PtrOwner<Instance, true> instance_owner;
uint32_t geometry_instance_pair_mask; // used in traditional forward, unnecesary on clustered
virtual RID instance_create();
virtual RID instance_allocate();
virtual void instance_initialize(RID p_rid);
virtual void instance_set_base(RID p_instance, RID p_base);
virtual void instance_set_scenario(RID p_instance, RID p_scenario);
@ -957,13 +961,16 @@ public:
/* SKY API */
PASS0R(RID, sky_create)
PASS0R(RID, sky_allocate)
PASS1(sky_initialize, RID)
PASS2(sky_set_radiance_size, RID, int)
PASS2(sky_set_mode, RID, RS::SkyMode)
PASS2(sky_set_material, RID, RID)
PASS4R(Ref<Image>, sky_bake_panorama, RID, float, bool, const Size2i &)
PASS0R(RID, environment_create)
PASS0R(RID, environment_allocate)
PASS1(environment_initialize, RID)
PASS1RC(bool, is_environment, RID)
@ -1012,7 +1019,8 @@ public:
/* CAMERA EFFECTS */
PASS0R(RID, camera_effects_create)
PASS0R(RID, camera_effects_allocate)
PASS1(camera_effects_initialize, RID)
PASS2(camera_effects_set_dof_blur_quality, RS::DOFBlurQuality, bool)
PASS1(camera_effects_set_dof_blur_bokeh_shape, RS::DOFBokehShape)

View file

@ -71,8 +71,7 @@ public:
/* SHADOW ATLAS API */
virtual RID
shadow_atlas_create() = 0;
virtual RID shadow_atlas_create() = 0;
virtual void shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits = false) = 0;
virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) = 0;
virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) = 0;
@ -90,7 +89,9 @@ public:
/* SKY API */
virtual RID sky_create() = 0;
virtual RID sky_allocate() = 0;
virtual void sky_initialize(RID p_rid) = 0;
virtual void sky_set_radiance_size(RID p_sky, int p_radiance_size) = 0;
virtual void sky_set_mode(RID p_sky, RS::SkyMode p_samples) = 0;
virtual void sky_set_material(RID p_sky, RID p_material) = 0;
@ -98,7 +99,8 @@ public:
/* ENVIRONMENT API */
virtual RID environment_create() = 0;
virtual RID environment_allocate() = 0;
virtual void environment_initialize(RID p_rid) = 0;
virtual void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) = 0;
virtual void environment_set_sky(RID p_env, RID p_sky) = 0;
@ -146,7 +148,8 @@ public:
virtual RS::EnvironmentBG environment_get_background(RID p_env) const = 0;
virtual int environment_get_canvas_max_layer(RID p_env) const = 0;
virtual RID camera_effects_create() = 0;
virtual RID camera_effects_allocate() = 0;
virtual void camera_effects_initialize(RID p_rid) = 0;
virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) = 0;
virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) = 0;

View file

@ -119,12 +119,15 @@ public:
Set<Dependency *> dependencies;
};
virtual bool can_create_resources_async() const = 0;
/* TEXTURE API */
virtual RID texture_2d_create(const Ref<Image> &p_image) = 0;
virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) = 0;
virtual RID texture_3d_create(Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) = 0;
virtual RID texture_proxy_create(RID p_base) = 0; //all slices, then all the mipmaps, must be coherent
virtual RID texture_allocate() = 0;
virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) = 0;
virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) = 0;
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) = 0;
virtual void texture_proxy_initialize(RID p_texture, RID p_base) = 0; //all slices, then all the mipmaps, must be coherent
virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0; //mostly used for video and streaming
virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0;
@ -132,9 +135,9 @@ public:
virtual void texture_proxy_update(RID p_proxy, RID p_base) = 0;
//these two APIs can be used together or in combination with the others.
virtual RID texture_2d_placeholder_create() = 0;
virtual RID texture_2d_layered_placeholder_create(RenderingServer::TextureLayeredType p_layered_type) = 0;
virtual RID texture_3d_placeholder_create() = 0;
virtual void texture_2d_placeholder_initialize(RID p_texture) = 0;
virtual void texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) = 0;
virtual void texture_3d_placeholder_initialize(RID p_texture) = 0;
virtual Ref<Image> texture_2d_get(RID p_texture) const = 0;
virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const = 0;
@ -161,7 +164,9 @@ public:
/* CANVAS TEXTURE API */
virtual RID canvas_texture_create() = 0;
virtual RID canvas_texture_allocate() = 0;
virtual void canvas_texture_initialize(RID p_rid) = 0;
virtual void canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) = 0;
virtual void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) = 0;
@ -170,7 +175,8 @@ public:
/* SHADER API */
virtual RID shader_create() = 0;
virtual RID shader_allocate() = 0;
virtual void shader_initialize(RID p_rid) = 0;
virtual void shader_set_code(RID p_shader, const String &p_code) = 0;
virtual String shader_get_code(RID p_shader) const = 0;
@ -184,7 +190,8 @@ public:
/* COMMON MATERIAL API */
virtual RID material_create() = 0;
virtual RID material_allocate() = 0;
virtual void material_initialize(RID p_rid) = 0;
virtual void material_set_render_priority(RID p_material, int priority) = 0;
virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0;
@ -209,7 +216,8 @@ public:
/* MESH API */
virtual RID mesh_create() = 0;
virtual RID mesh_allocate() = 0;
virtual void mesh_initialize(RID p_rid) = 0;
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) = 0;
@ -251,9 +259,10 @@ public:
/* MULTIMESH API */
virtual RID multimesh_create() = 0;
virtual RID multimesh_allocate() = 0;
virtual void multimesh_initialize(RID p_rid) = 0;
virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0;
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) = 0;
virtual int multimesh_get_instance_count(RID p_multimesh) const = 0;
@ -280,7 +289,9 @@ public:
/* IMMEDIATE API */
virtual RID immediate_create() = 0;
virtual RID immediate_allocate() = 0;
virtual void immediate_initialize(RID p_rid) = 0;
virtual void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) = 0;
virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) = 0;
virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal) = 0;
@ -296,8 +307,10 @@ public:
/* SKELETON API */
virtual RID skeleton_create() = 0;
virtual void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) = 0;
virtual RID skeleton_allocate() = 0;
virtual void skeleton_initialize(RID p_rid) = 0;
virtual void skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) = 0;
virtual int skeleton_get_bone_count(RID p_skeleton) const = 0;
virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) = 0;
virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const = 0;
@ -307,11 +320,14 @@ public:
/* Light API */
virtual RID light_create(RS::LightType p_type) = 0;
virtual RID directional_light_allocate() = 0;
virtual void directional_light_initialize(RID p_rid) = 0;
RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); }
RID omni_light_create() { return light_create(RS::LIGHT_OMNI); }
RID spot_light_create() { return light_create(RS::LIGHT_SPOT); }
virtual RID omni_light_allocate() = 0;
virtual void omni_light_initialize(RID p_rid) = 0;
virtual RID spot_light_allocate() = 0;
virtual void spot_light_initialize(RID p_rid) = 0;
virtual void light_set_color(RID p_light, const Color &p_color) = 0;
virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value) = 0;
@ -349,7 +365,8 @@ public:
/* PROBE API */
virtual RID reflection_probe_create() = 0;
virtual RID reflection_probe_allocate() = 0;
virtual void reflection_probe_initialize(RID p_rid) = 0;
virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) = 0;
virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0;
@ -380,7 +397,9 @@ public:
/* DECAL API */
virtual RID decal_create() = 0;
virtual RID decal_allocate() = 0;
virtual void decal_initialize(RID p_rid) = 0;
virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents) = 0;
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) = 0;
virtual void decal_set_emission_energy(RID p_decal, float p_energy) = 0;
@ -395,9 +414,10 @@ public:
/* GI PROBE API */
virtual RID gi_probe_create() = 0;
virtual RID gi_probe_allocate() = 0;
virtual void gi_probe_initialize(RID p_rid) = 0;
virtual void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) = 0;
virtual void gi_probe_allocate_data(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) = 0;
virtual AABB gi_probe_get_bounds(RID p_gi_probe) const = 0;
virtual Vector3i gi_probe_get_octree_size(RID p_gi_probe) const = 0;
@ -440,9 +460,10 @@ public:
virtual uint32_t gi_probe_get_version(RID p_probe) = 0;
/* LIGHTMAP CAPTURE */
/* LIGHTMAP */
virtual RID lightmap_create() = 0;
virtual RID lightmap_allocate() = 0;
virtual void lightmap_initialize(RID p_rid) = 0;
virtual void lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) = 0;
virtual void lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) = 0;
@ -460,7 +481,8 @@ public:
/* PARTICLES */
virtual RID particles_create() = 0;
virtual RID particles_allocate() = 0;
virtual void particles_initialize(RID p_rid) = 0;
virtual void particles_set_emitting(RID p_particles, bool p_emitting) = 0;
virtual bool particles_get_emitting(RID p_particles) = 0;
@ -507,7 +529,9 @@ public:
/* PARTICLES COLLISION */
virtual RID particles_collision_create() = 0;
virtual RID particles_collision_allocate() = 0;
virtual void particles_collision_initialize(RID p_rid) = 0;
virtual void particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) = 0;
virtual void particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) = 0;
virtual void particles_collision_set_sphere_radius(RID p_particles_collision, float p_radius) = 0; //for spheres

View file

@ -608,19 +608,20 @@ void RendererViewport::draw_viewports() {
}
}
RID RendererViewport::viewport_create() {
RID RendererViewport::viewport_allocate() {
return viewport_owner.allocate_rid();
}
void RendererViewport::viewport_initialize(RID p_rid) {
Viewport *viewport = memnew(Viewport);
RID rid = viewport_owner.make_rid(viewport);
viewport->self = rid;
viewport->self = p_rid;
viewport->hide_scenario = false;
viewport->hide_canvas = false;
viewport->render_target = RSG::storage->render_target_create();
viewport->shadow_atlas = RSG::scene->shadow_atlas_create();
viewport->viewport_render_direct_to_screen = false;
return rid;
viewport_owner.initialize_rid(p_rid, viewport);
}
void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
@ -1019,5 +1020,10 @@ void RendererViewport::set_default_clear_color(const Color &p_color) {
RSG::storage->set_default_clear_color(p_color);
}
//workaround for setting this on thread
void RendererViewport::call_set_use_vsync(bool p_enable) {
DisplayServer::get_singleton()->_set_use_vsync(p_enable);
}
RendererViewport::RendererViewport() {
}

View file

@ -165,7 +165,7 @@ public:
uint64_t draw_viewports_pass = 0;
mutable RID_PtrOwner<Viewport> viewport_owner;
mutable RID_PtrOwner<Viewport, true> viewport_owner;
struct ViewportSort {
_FORCE_INLINE_ bool operator()(const Viewport *p_left, const Viewport *p_right) const {
@ -186,7 +186,8 @@ private:
void _draw_viewport(Viewport *p_viewport, XRInterface::Eyes p_eye = XRInterface::EYE_MONO);
public:
RID viewport_create();
RID viewport_allocate();
void viewport_initialize(RID p_rid);
void viewport_set_use_xr(RID p_viewport, bool p_use_xr);
@ -249,6 +250,9 @@ public:
bool free(RID p_rid);
//workaround for setting this on thread
void call_set_use_vsync(bool p_enable);
RendererViewport();
virtual ~RendererViewport() {}
};

View file

@ -64,7 +64,7 @@ void RenderingServerDefault::_draw_margins() {
/* FREE */
void RenderingServerDefault::free(RID p_rid) {
void RenderingServerDefault::_free(RID p_rid) {
if (RSG::storage->free(p_rid)) {
return;
}
@ -91,7 +91,7 @@ void RenderingServerDefault::request_frame_drawn_callback(Object *p_where, const
frame_drawn_callbacks.push_back(fdc);
}
void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) {
void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
//needs to be done before changes is reset to 0, to not force the editor to redraw
RS::get_singleton()->emit_signal("frame_pre_draw");
@ -213,18 +213,15 @@ float RenderingServerDefault::get_frame_setup_time_cpu() const {
return frame_setup_time;
}
void RenderingServerDefault::sync() {
}
bool RenderingServerDefault::has_changed() const {
return changes > 0;
}
void RenderingServerDefault::init() {
void RenderingServerDefault::_init() {
RSG::rasterizer->initialize();
}
void RenderingServerDefault::finish() {
void RenderingServerDefault::_finish() {
if (test_cube.is_valid()) {
free(test_cube);
}
@ -232,6 +229,32 @@ void RenderingServerDefault::finish() {
RSG::rasterizer->finalize();
}
void RenderingServerDefault::init() {
if (create_thread) {
print_verbose("RenderingServerWrapMT: Creating render thread");
DisplayServer::get_singleton()->release_rendering_thread();
if (create_thread) {
thread.start(_thread_callback, this);
print_verbose("RenderingServerWrapMT: Starting render thread");
}
while (!draw_thread_up) {
OS::get_singleton()->delay_usec(1000);
}
print_verbose("RenderingServerWrapMT: Finished render thread");
} else {
_init();
}
}
void RenderingServerDefault::finish() {
if (create_thread) {
command_queue.push(this, &RenderingServerDefault::_thread_exit);
thread.wait_to_finish();
} else {
_finish();
}
}
/* STATUS INFORMATION */
int RenderingServerDefault::get_render_info(RenderInfo p_info) {
@ -297,10 +320,6 @@ void RenderingServerDefault::set_debug_generate_wireframes(bool p_generate) {
RSG::storage->set_debug_generate_wireframes(p_generate);
}
void RenderingServerDefault::call_set_use_vsync(bool p_enable) {
DisplayServer::get_singleton()->_set_use_vsync(p_enable);
}
bool RenderingServerDefault::is_low_end() const {
// FIXME: Commented out when rebasing vulkan branch on master,
// causes a crash, it seems rasterizer is not initialized yet the
@ -309,7 +328,77 @@ bool RenderingServerDefault::is_low_end() const {
return false;
}
RenderingServerDefault::RenderingServerDefault() {
void RenderingServerDefault::_thread_exit() {
exit = true;
}
void RenderingServerDefault::_thread_draw(bool p_swap_buffers, double frame_step) {
if (!atomic_decrement(&draw_pending)) {
_draw(p_swap_buffers, frame_step);
}
}
void RenderingServerDefault::_thread_flush() {
atomic_decrement(&draw_pending);
}
void RenderingServerDefault::_thread_callback(void *_instance) {
RenderingServerDefault *vsmt = reinterpret_cast<RenderingServerDefault *>(_instance);
vsmt->_thread_loop();
}
void RenderingServerDefault::_thread_loop() {
server_thread = Thread::get_caller_id();
DisplayServer::get_singleton()->make_rendering_thread();
_init();
exit = false;
draw_thread_up = true;
while (!exit) {
// flush commands one by one, until exit is requested
command_queue.wait_and_flush_one();
}
command_queue.flush_all(); // flush all
_finish();
}
/* EVENT QUEUING */
void RenderingServerDefault::sync() {
if (create_thread) {
atomic_increment(&draw_pending);
command_queue.push_and_sync(this, &RenderingServerDefault::_thread_flush);
} else {
command_queue.flush_all(); //flush all pending from other threads
}
}
void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) {
if (create_thread) {
atomic_increment(&draw_pending);
command_queue.push(this, &RenderingServerDefault::_thread_draw, p_swap_buffers, frame_step);
} else {
_draw(p_swap_buffers, frame_step);
}
}
RenderingServerDefault::RenderingServerDefault(bool p_create_thread) :
command_queue(p_create_thread) {
create_thread = p_create_thread;
draw_pending = 0;
draw_thread_up = false;
if (!p_create_thread) {
server_thread = Thread::get_caller_id();
} else {
server_thread = 0;
}
RSG::canvas = memnew(RendererCanvasCull);
RSG::viewport = memnew(RendererViewport);
RendererSceneCull *sr = memnew(RendererSceneCull);

File diff suppressed because it is too large Load diff

View file

@ -1,174 +0,0 @@
/*************************************************************************/
/* rendering_server_wrap_mt.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rendering_server_wrap_mt.h"
#include "core/config/project_settings.h"
#include "core/os/os.h"
#include "servers/display_server.h"
void RenderingServerWrapMT::thread_exit() {
exit = true;
}
void RenderingServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) {
if (!atomic_decrement(&draw_pending)) {
rendering_server->draw(p_swap_buffers, frame_step);
}
}
void RenderingServerWrapMT::thread_flush() {
atomic_decrement(&draw_pending);
}
void RenderingServerWrapMT::_thread_callback(void *_instance) {
RenderingServerWrapMT *vsmt = reinterpret_cast<RenderingServerWrapMT *>(_instance);
vsmt->thread_loop();
}
void RenderingServerWrapMT::thread_loop() {
server_thread = Thread::get_caller_id();
DisplayServer::get_singleton()->make_rendering_thread();
rendering_server->init();
exit = false;
draw_thread_up = true;
while (!exit) {
// flush commands one by one, until exit is requested
command_queue.wait_and_flush_one();
}
command_queue.flush_all(); // flush all
rendering_server->finish();
}
/* EVENT QUEUING */
void RenderingServerWrapMT::sync() {
if (create_thread) {
atomic_increment(&draw_pending);
command_queue.push_and_sync(this, &RenderingServerWrapMT::thread_flush);
} else {
command_queue.flush_all(); //flush all pending from other threads
}
}
void RenderingServerWrapMT::draw(bool p_swap_buffers, double frame_step) {
if (create_thread) {
atomic_increment(&draw_pending);
command_queue.push(this, &RenderingServerWrapMT::thread_draw, p_swap_buffers, frame_step);
} else {
rendering_server->draw(p_swap_buffers, frame_step);
}
}
void RenderingServerWrapMT::init() {
if (create_thread) {
print_verbose("RenderingServerWrapMT: Creating render thread");
DisplayServer::get_singleton()->release_rendering_thread();
if (create_thread) {
thread.start(_thread_callback, this);
print_verbose("RenderingServerWrapMT: Starting render thread");
}
while (!draw_thread_up) {
OS::get_singleton()->delay_usec(1000);
}
print_verbose("RenderingServerWrapMT: Finished render thread");
} else {
rendering_server->init();
}
}
void RenderingServerWrapMT::finish() {
sky_free_cached_ids();
shader_free_cached_ids();
material_free_cached_ids();
mesh_free_cached_ids();
multimesh_free_cached_ids();
immediate_free_cached_ids();
skeleton_free_cached_ids();
directional_light_free_cached_ids();
omni_light_free_cached_ids();
spot_light_free_cached_ids();
reflection_probe_free_cached_ids();
gi_probe_free_cached_ids();
lightmap_free_cached_ids();
particles_free_cached_ids();
particles_collision_free_cached_ids();
camera_free_cached_ids();
viewport_free_cached_ids();
environment_free_cached_ids();
camera_effects_free_cached_ids();
scenario_free_cached_ids();
instance_free_cached_ids();
canvas_free_cached_ids();
canvas_item_free_cached_ids();
canvas_light_occluder_free_cached_ids();
canvas_occluder_polygon_free_cached_ids();
if (create_thread) {
command_queue.push(this, &RenderingServerWrapMT::thread_exit);
thread.wait_to_finish();
} else {
rendering_server->finish();
}
}
void RenderingServerWrapMT::set_use_vsync_callback(bool p_enable) {
singleton_mt->call_set_use_vsync(p_enable);
}
RenderingServerWrapMT *RenderingServerWrapMT::singleton_mt = nullptr;
RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread) :
command_queue(p_create_thread) {
singleton_mt = this;
DisplayServer::switch_vsync_function = set_use_vsync_callback; //as this goes to another thread, make sure it goes properly
rendering_server = p_contained;
create_thread = p_create_thread;
draw_pending = 0;
draw_thread_up = false;
pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
if (!p_create_thread) {
server_thread = Thread::get_caller_id();
} else {
server_thread = 0;
}
}
RenderingServerWrapMT::~RenderingServerWrapMT() {
memdelete(rendering_server);
//finish();
}

View file

@ -1,808 +0,0 @@
/*************************************************************************/
/* rendering_server_wrap_mt.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef RENDERING_SERVER_WRAP_MT_H
#define RENDERING_SERVER_WRAP_MT_H
#include "core/os/thread.h"
#include "core/templates/command_queue_mt.h"
#include "servers/rendering_server.h"
class RenderingServerWrapMT : public RenderingServer {
// the real visual server
mutable RenderingServer *rendering_server;
mutable CommandQueueMT command_queue;
static void _thread_callback(void *_instance);
void thread_loop();
Thread::ID server_thread;
volatile bool exit;
Thread thread;
volatile bool draw_thread_up;
bool create_thread;
uint64_t draw_pending;
void thread_draw(bool p_swap_buffers, double frame_step);
void thread_flush();
void thread_exit();
Mutex alloc_mutex;
int pool_max_size;
//#define DEBUG_SYNC
static RenderingServerWrapMT *singleton_mt;
#ifdef DEBUG_SYNC
#define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__));
#else
#define SYNC_DEBUG
#endif
public:
#define ServerName RenderingServer
#define ServerNameWrapMT RenderingServerWrapMT
#define server_name rendering_server
#include "servers/server_wrap_mt_common.h"
//these go pass-through, as they can be called from any thread
virtual RID texture_2d_create(const Ref<Image> &p_image) { return rendering_server->texture_2d_create(p_image); }
virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, TextureLayeredType p_layered_type) { return rendering_server->texture_2d_layered_create(p_layers, p_layered_type); }
virtual RID texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) { return rendering_server->texture_3d_create(p_format, p_width, p_height, p_depth, p_mipmaps, p_data); }
virtual RID texture_proxy_create(RID p_base) { return rendering_server->texture_proxy_create(p_base); }
//goes pass-through
virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) { rendering_server->texture_2d_update_immediate(p_texture, p_image, p_layer); }
//these go through command queue if they are in another thread
FUNC3(texture_2d_update, RID, const Ref<Image> &, int)
FUNC2(texture_3d_update, RID, const Vector<Ref<Image>> &)
FUNC2(texture_proxy_update, RID, RID)
//these also go pass-through
virtual RID texture_2d_placeholder_create() { return rendering_server->texture_2d_placeholder_create(); }
virtual RID texture_2d_layered_placeholder_create(TextureLayeredType p_type) { return rendering_server->texture_2d_layered_placeholder_create(p_type); }
virtual RID texture_3d_placeholder_create() { return rendering_server->texture_3d_placeholder_create(); }
FUNC1RC(Ref<Image>, texture_2d_get, RID)
FUNC2RC(Ref<Image>, texture_2d_layer_get, RID, int)
FUNC1RC(Vector<Ref<Image>>, texture_3d_get, RID)
FUNC2(texture_replace, RID, RID)
FUNC3(texture_set_size_override, RID, int, int)
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
FUNC2(texture_bind, RID, uint32_t)
#endif
FUNC3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *)
FUNC3(texture_set_detect_normal_callback, RID, TextureDetectCallback, void *)
FUNC3(texture_set_detect_roughness_callback, RID, TextureDetectRoughnessCallback, void *)
FUNC2(texture_set_path, RID, const String &)
FUNC1RC(String, texture_get_path, RID)
FUNC1S(texture_debug_usage, List<TextureInfo> *)
FUNC2(texture_set_force_redraw_if_visible, RID, bool)
/* SHADER API */
FUNCRID(shader)
FUNC2(shader_set_code, RID, const String &)
FUNC1RC(String, shader_get_code, RID)
FUNC2SC(shader_get_param_list, RID, List<PropertyInfo> *)
FUNC3(shader_set_default_texture_param, RID, const StringName &, RID)
FUNC2RC(RID, shader_get_default_texture_param, RID, const StringName &)
FUNC2RC(Variant, shader_get_param_default, RID, const StringName &)
FUNC1RC(ShaderNativeSourceCode, shader_get_native_source_code, RID)
/* COMMON MATERIAL API */
FUNCRID(material)
FUNC2(material_set_shader, RID, RID)
FUNC3(material_set_param, RID, const StringName &, const Variant &)
FUNC2RC(Variant, material_get_param, RID, const StringName &)
FUNC2(material_set_render_priority, RID, int)
FUNC2(material_set_next_pass, RID, RID)
/* MESH API */
virtual RID mesh_create_from_surfaces(const Vector<SurfaceData> &p_surfaces, int p_blend_shape_count = 0) {
return rendering_server->mesh_create_from_surfaces(p_surfaces, p_blend_shape_count);
}
FUNC2(mesh_set_blend_shape_count, RID, int)
FUNCRID(mesh)
FUNC2(mesh_add_surface, RID, const SurfaceData &)
FUNC1RC(int, mesh_get_blend_shape_count, RID)
FUNC2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
FUNC1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
FUNC4(mesh_surface_update_region, RID, int, int, const Vector<uint8_t> &)
FUNC3(mesh_surface_set_material, RID, int, RID)
FUNC2RC(RID, mesh_surface_get_material, RID, int)
FUNC2RC(SurfaceData, mesh_get_surface, RID, int)
FUNC1RC(int, mesh_get_surface_count, RID)
FUNC2(mesh_set_custom_aabb, RID, const AABB &)
FUNC1RC(AABB, mesh_get_custom_aabb, RID)
FUNC2(mesh_set_shadow_mesh, RID, RID)
FUNC1(mesh_clear, RID)
/* MULTIMESH API */
FUNCRID(multimesh)
FUNC5(multimesh_allocate, RID, int, MultimeshTransformFormat, bool, bool)
FUNC1RC(int, multimesh_get_instance_count, RID)
FUNC2(multimesh_set_mesh, RID, RID)
FUNC3(multimesh_instance_set_transform, RID, int, const Transform &)
FUNC3(multimesh_instance_set_transform_2d, RID, int, const Transform2D &)
FUNC3(multimesh_instance_set_color, RID, int, const Color &)
FUNC3(multimesh_instance_set_custom_data, RID, int, const Color &)
FUNC1RC(RID, multimesh_get_mesh, RID)
FUNC1RC(AABB, multimesh_get_aabb, RID)
FUNC2RC(Transform, multimesh_instance_get_transform, RID, int)
FUNC2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int)
FUNC2RC(Color, multimesh_instance_get_color, RID, int)
FUNC2RC(Color, multimesh_instance_get_custom_data, RID, int)
FUNC2(multimesh_set_buffer, RID, const Vector<float> &)
FUNC1RC(Vector<float>, multimesh_get_buffer, RID)
FUNC2(multimesh_set_visible_instances, RID, int)
FUNC1RC(int, multimesh_get_visible_instances, RID)
/* IMMEDIATE API */
FUNCRID(immediate)
FUNC3(immediate_begin, RID, PrimitiveType, RID)
FUNC2(immediate_vertex, RID, const Vector3 &)
FUNC2(immediate_normal, RID, const Vector3 &)
FUNC2(immediate_tangent, RID, const Plane &)
FUNC2(immediate_color, RID, const Color &)
FUNC2(immediate_uv, RID, const Vector2 &)
FUNC2(immediate_uv2, RID, const Vector2 &)
FUNC1(immediate_end, RID)
FUNC1(immediate_clear, RID)
FUNC2(immediate_set_material, RID, RID)
FUNC1RC(RID, immediate_get_material, RID)
/* SKELETON API */
FUNCRID(skeleton)
FUNC3(skeleton_allocate, RID, int, bool)
FUNC1RC(int, skeleton_get_bone_count, RID)
FUNC3(skeleton_bone_set_transform, RID, int, const Transform &)
FUNC2RC(Transform, skeleton_bone_get_transform, RID, int)
FUNC3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &)
FUNC2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int)
FUNC2(skeleton_set_base_transform_2d, RID, const Transform2D &)
/* Light API */
FUNCRID(directional_light)
FUNCRID(omni_light)
FUNCRID(spot_light)
FUNC2(light_set_color, RID, const Color &)
FUNC3(light_set_param, RID, LightParam, float)
FUNC2(light_set_shadow, RID, bool)
FUNC2(light_set_shadow_color, RID, const Color &)
FUNC2(light_set_projector, RID, RID)
FUNC2(light_set_negative, RID, bool)
FUNC2(light_set_cull_mask, RID, uint32_t)
FUNC2(light_set_reverse_cull_face_mode, RID, bool)
FUNC2(light_set_bake_mode, RID, LightBakeMode)
FUNC2(light_set_max_sdfgi_cascade, RID, uint32_t)
FUNC2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
FUNC2(light_directional_set_shadow_mode, RID, LightDirectionalShadowMode)
FUNC2(light_directional_set_blend_splits, RID, bool)
FUNC2(light_directional_set_sky_only, RID, bool)
FUNC2(light_directional_set_shadow_depth_range_mode, RID, LightDirectionalShadowDepthRangeMode)
/* PROBE API */
FUNCRID(reflection_probe)
FUNC2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode)
FUNC2(reflection_probe_set_intensity, RID, float)
FUNC2(reflection_probe_set_ambient_color, RID, const Color &)
FUNC2(reflection_probe_set_ambient_energy, RID, float)
FUNC2(reflection_probe_set_ambient_mode, RID, ReflectionProbeAmbientMode)
FUNC2(reflection_probe_set_max_distance, RID, float)
FUNC2(reflection_probe_set_extents, RID, const Vector3 &)
FUNC2(reflection_probe_set_origin_offset, RID, const Vector3 &)
FUNC2(reflection_probe_set_as_interior, RID, bool)
FUNC2(reflection_probe_set_enable_box_projection, RID, bool)
FUNC2(reflection_probe_set_enable_shadows, RID, bool)
FUNC2(reflection_probe_set_cull_mask, RID, uint32_t)
FUNC2(reflection_probe_set_resolution, RID, int)
FUNC2(reflection_probe_set_lod_threshold, RID, float)
/* DECAL API */
FUNCRID(decal)
FUNC2(decal_set_extents, RID, const Vector3 &)
FUNC3(decal_set_texture, RID, DecalTexture, RID)
FUNC2(decal_set_emission_energy, RID, float)
FUNC2(decal_set_albedo_mix, RID, float)
FUNC2(decal_set_modulate, RID, const Color &)
FUNC2(decal_set_cull_mask, RID, uint32_t)
FUNC4(decal_set_distance_fade, RID, bool, float, float)
FUNC3(decal_set_fade, RID, float, float)
FUNC2(decal_set_normal_fade, RID, float)
/* BAKED LIGHT API */
FUNCRID(gi_probe)
FUNC8(gi_probe_allocate, RID, const Transform &, const AABB &, const Vector3i &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<int> &)
FUNC1RC(AABB, gi_probe_get_bounds, RID)
FUNC1RC(Vector3i, gi_probe_get_octree_size, RID)
FUNC1RC(Vector<uint8_t>, gi_probe_get_octree_cells, RID)
FUNC1RC(Vector<uint8_t>, gi_probe_get_data_cells, RID)
FUNC1RC(Vector<uint8_t>, gi_probe_get_distance_field, RID)
FUNC1RC(Vector<int>, gi_probe_get_level_counts, RID)
FUNC1RC(Transform, gi_probe_get_to_cell_xform, RID)
FUNC2(gi_probe_set_dynamic_range, RID, float)
FUNC1RC(float, gi_probe_get_dynamic_range, RID)
FUNC2(gi_probe_set_propagation, RID, float)
FUNC1RC(float, gi_probe_get_propagation, RID)
FUNC2(gi_probe_set_energy, RID, float)
FUNC1RC(float, gi_probe_get_energy, RID)
FUNC2(gi_probe_set_ao, RID, float)
FUNC1RC(float, gi_probe_get_ao, RID)
FUNC2(gi_probe_set_ao_size, RID, float)
FUNC1RC(float, gi_probe_get_ao_size, RID)
FUNC2(gi_probe_set_bias, RID, float)
FUNC1RC(float, gi_probe_get_bias, RID)
FUNC2(gi_probe_set_normal_bias, RID, float)
FUNC1RC(float, gi_probe_get_normal_bias, RID)
FUNC2(gi_probe_set_interior, RID, bool)
FUNC1RC(bool, gi_probe_is_interior, RID)
FUNC2(gi_probe_set_use_two_bounces, RID, bool)
FUNC1RC(bool, gi_probe_is_using_two_bounces, RID)
FUNC2(gi_probe_set_anisotropy_strength, RID, float)
FUNC1RC(float, gi_probe_get_anisotropy_strength, RID)
FUNC1(gi_probe_set_quality, GIProbeQuality)
/* LIGHTMAP CAPTURE */
FUNCRID(lightmap)
FUNC3(lightmap_set_textures, RID, RID, bool)
FUNC2(lightmap_set_probe_bounds, RID, const AABB &)
FUNC2(lightmap_set_probe_interior, RID, bool)
FUNC5(lightmap_set_probe_capture_data, RID, const PackedVector3Array &, const PackedColorArray &, const PackedInt32Array &, const PackedInt32Array &)
FUNC1RC(PackedVector3Array, lightmap_get_probe_capture_points, RID)
FUNC1RC(PackedColorArray, lightmap_get_probe_capture_sh, RID)
FUNC1RC(PackedInt32Array, lightmap_get_probe_capture_tetrahedra, RID)
FUNC1RC(PackedInt32Array, lightmap_get_probe_capture_bsp_tree, RID)
FUNC1(lightmap_set_probe_capture_update_speed, float)
/* PARTICLES */
FUNCRID(particles)
FUNC2(particles_set_emitting, RID, bool)
FUNC1R(bool, particles_get_emitting, RID)
FUNC2(particles_set_amount, RID, int)
FUNC2(particles_set_lifetime, RID, float)
FUNC2(particles_set_one_shot, RID, bool)
FUNC2(particles_set_pre_process_time, RID, float)
FUNC2(particles_set_explosiveness_ratio, RID, float)
FUNC2(particles_set_randomness_ratio, RID, float)
FUNC2(particles_set_custom_aabb, RID, const AABB &)
FUNC2(particles_set_speed_scale, RID, float)
FUNC2(particles_set_use_local_coordinates, RID, bool)
FUNC2(particles_set_process_material, RID, RID)
FUNC2(particles_set_fixed_fps, RID, int)
FUNC2(particles_set_fractional_delta, RID, bool)
FUNC2(particles_set_collision_base_size, RID, float)
FUNC1R(bool, particles_is_inactive, RID)
FUNC1(particles_request_process, RID)
FUNC1(particles_restart, RID)
FUNC6(particles_emit, RID, const Transform &, const Vector3 &, const Color &, const Color &, uint32_t)
FUNC2(particles_set_draw_order, RID, RS::ParticlesDrawOrder)
FUNC2(particles_set_draw_passes, RID, int)
FUNC3(particles_set_draw_pass_mesh, RID, int, RID)
FUNC2(particles_set_emission_transform, RID, const Transform &)
FUNC2(particles_set_subemitter, RID, RID)
FUNC1R(AABB, particles_get_current_aabb, RID)
/* PARTICLES COLLISION */
FUNCRID(particles_collision)
FUNC2(particles_collision_set_collision_type, RID, ParticlesCollisionType)
FUNC2(particles_collision_set_cull_mask, RID, uint32_t)
FUNC2(particles_collision_set_sphere_radius, RID, float)
FUNC2(particles_collision_set_box_extents, RID, const Vector3 &)
FUNC2(particles_collision_set_attractor_strength, RID, float)
FUNC2(particles_collision_set_attractor_directionality, RID, float)
FUNC2(particles_collision_set_attractor_attenuation, RID, float)
FUNC2(particles_collision_set_field_texture, RID, RID)
FUNC1(particles_collision_height_field_update, RID)
FUNC2(particles_collision_set_height_field_resolution, RID, ParticlesCollisionHeightfieldResolution)
/* CAMERA API */
FUNCRID(camera)
FUNC4(camera_set_perspective, RID, float, float, float)
FUNC4(camera_set_orthogonal, RID, float, float, float)
FUNC5(camera_set_frustum, RID, float, Vector2, float, float)
FUNC2(camera_set_transform, RID, const Transform &)
FUNC2(camera_set_cull_mask, RID, uint32_t)
FUNC2(camera_set_environment, RID, RID)
FUNC2(camera_set_camera_effects, RID, RID)
FUNC2(camera_set_use_vertical_aspect, RID, bool)
/* VIEWPORT TARGET API */
FUNCRID(viewport)
FUNC2(viewport_set_use_xr, RID, bool)
FUNC3(viewport_set_size, RID, int, int)
FUNC2(viewport_set_active, RID, bool)
FUNC2(viewport_set_parent_viewport, RID, RID)
FUNC2(viewport_set_clear_mode, RID, ViewportClearMode)
FUNC3(viewport_attach_to_screen, RID, const Rect2 &, DisplayServer::WindowID)
FUNC2(viewport_set_render_direct_to_screen, RID, bool)
FUNC2(viewport_set_update_mode, RID, ViewportUpdateMode)
FUNC1RC(RID, viewport_get_texture, RID)
FUNC2(viewport_set_hide_scenario, RID, bool)
FUNC2(viewport_set_hide_canvas, RID, bool)
FUNC2(viewport_set_disable_environment, RID, bool)
FUNC2(viewport_attach_camera, RID, RID)
FUNC2(viewport_set_scenario, RID, RID)
FUNC2(viewport_attach_canvas, RID, RID)
FUNC2(viewport_remove_canvas, RID, RID)
FUNC3(viewport_set_canvas_transform, RID, RID, const Transform2D &)
FUNC2(viewport_set_transparent_background, RID, bool)
FUNC2(viewport_set_snap_2d_transforms_to_pixel, RID, bool)
FUNC2(viewport_set_snap_2d_vertices_to_pixel, RID, bool)
FUNC2(viewport_set_default_canvas_item_texture_filter, RID, CanvasItemTextureFilter)
FUNC2(viewport_set_default_canvas_item_texture_repeat, RID, CanvasItemTextureRepeat)
FUNC2(viewport_set_global_canvas_transform, RID, const Transform2D &)
FUNC4(viewport_set_canvas_stacking, RID, RID, int, int)
FUNC3(viewport_set_shadow_atlas_size, RID, int, bool)
FUNC3(viewport_set_sdf_oversize_and_scale, RID, ViewportSDFOversize, ViewportSDFScale)
FUNC3(viewport_set_shadow_atlas_quadrant_subdivision, RID, int, int)
FUNC2(viewport_set_msaa, RID, ViewportMSAA)
FUNC2(viewport_set_screen_space_aa, RID, ViewportScreenSpaceAA)
FUNC2(viewport_set_use_debanding, RID, bool)
FUNC2(viewport_set_lod_threshold, RID, float)
//this passes directly to avoid stalling, but it's pretty dangerous, so don't call after freeing a viewport
virtual int viewport_get_render_info(RID p_viewport, ViewportRenderInfo p_info) {
return rendering_server->viewport_get_render_info(p_viewport, p_info);
}
FUNC2(viewport_set_debug_draw, RID, ViewportDebugDraw)
FUNC2(viewport_set_measure_render_time, RID, bool)
virtual float viewport_get_measured_render_time_cpu(RID p_viewport) const {
return rendering_server->viewport_get_measured_render_time_cpu(p_viewport);
}
virtual float viewport_get_measured_render_time_gpu(RID p_viewport) const {
return rendering_server->viewport_get_measured_render_time_gpu(p_viewport);
}
FUNC2(directional_shadow_atlas_set_size, int, bool)
/* SKY API */
FUNCRID(sky)
FUNC2(sky_set_radiance_size, RID, int)
FUNC2(sky_set_mode, RID, SkyMode)
FUNC2(sky_set_material, RID, RID)
FUNC4R(Ref<Image>, sky_bake_panorama, RID, float, bool, const Size2i &)
/* ENVIRONMENT API */
FUNCRID(environment)
FUNC2(environment_set_background, RID, EnvironmentBG)
FUNC2(environment_set_sky, RID, RID)
FUNC2(environment_set_sky_custom_fov, RID, float)
FUNC2(environment_set_sky_orientation, RID, const Basis &)
FUNC2(environment_set_bg_color, RID, const Color &)
FUNC2(environment_set_bg_energy, RID, float)
FUNC2(environment_set_canvas_max_layer, RID, int)
FUNC7(environment_set_ambient_light, RID, const Color &, EnvironmentAmbientSource, float, float, EnvironmentReflectionSource, const Color &)
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
FUNC2(environment_set_camera_feed_id, RID, int)
#endif
FUNC6(environment_set_ssr, RID, bool, int, float, float, float)
FUNC1(environment_set_ssr_roughness_quality, EnvironmentSSRRoughnessQuality)
FUNC10(environment_set_ssao, RID, bool, float, float, float, float, float, float, float, float)
FUNC6(environment_set_ssao_quality, EnvironmentSSAOQuality, bool, float, int, float, float)
FUNC11(environment_set_sdfgi, RID, bool, EnvironmentSDFGICascades, float, EnvironmentSDFGIYScale, bool, float, bool, float, float, float)
FUNC1(environment_set_sdfgi_ray_count, EnvironmentSDFGIRayCount)
FUNC1(environment_set_sdfgi_frames_to_converge, EnvironmentSDFGIFramesToConverge)
FUNC1(environment_set_sdfgi_frames_to_update_light, EnvironmentSDFGIFramesToUpdateLight)
FUNC11(environment_set_glow, RID, bool, Vector<float>, float, float, float, float, EnvironmentGlowBlendMode, float, float, float)
FUNC1(environment_glow_set_use_bicubic_upscale, bool)
FUNC1(environment_glow_set_use_high_quality, bool)
FUNC9(environment_set_tonemap, RID, EnvironmentToneMapper, float, float, bool, float, float, float, float)
FUNC7(environment_set_adjustment, RID, bool, float, float, float, bool, RID)
FUNC9(environment_set_fog, RID, bool, const Color &, float, float, float, float, float, float)
FUNC10(environment_set_volumetric_fog, RID, bool, float, const Color &, float, float, float, float, bool, float)
FUNC2(environment_set_volumetric_fog_volume_size, int, int)
FUNC1(environment_set_volumetric_fog_filter_active, bool)
FUNC3R(Ref<Image>, environment_bake_panorama, RID, bool, const Size2i &)
FUNC3(screen_space_roughness_limiter_set_active, bool, float, float)
FUNC1(sub_surface_scattering_set_quality, SubSurfaceScatteringQuality)
FUNC2(sub_surface_scattering_set_scale, float, float)
FUNCRID(camera_effects)
FUNC2(camera_effects_set_dof_blur_quality, DOFBlurQuality, bool)
FUNC1(camera_effects_set_dof_blur_bokeh_shape, DOFBokehShape)
FUNC8(camera_effects_set_dof_blur, RID, bool, float, float, bool, float, float, float)
FUNC3(camera_effects_set_custom_exposure, RID, bool, float)
FUNC1(shadows_quality_set, ShadowQuality);
FUNC1(directional_shadow_quality_set, ShadowQuality);
FUNCRID(scenario)
FUNC2(scenario_set_debug, RID, ScenarioDebugMode)
FUNC2(scenario_set_environment, RID, RID)
FUNC2(scenario_set_camera_effects, RID, RID)
FUNC2(scenario_set_fallback_environment, RID, RID)
/* INSTANCING API */
FUNCRID(instance)
FUNC2(instance_set_base, RID, RID)
FUNC2(instance_set_scenario, RID, RID)
FUNC2(instance_set_layer_mask, RID, uint32_t)
FUNC2(instance_set_transform, RID, const Transform &)
FUNC2(instance_attach_object_instance_id, RID, ObjectID)
FUNC3(instance_set_blend_shape_weight, RID, int, float)
FUNC3(instance_set_surface_material, RID, int, RID)
FUNC2(instance_set_visible, RID, bool)
FUNC2(instance_set_custom_aabb, RID, AABB)
FUNC2(instance_attach_skeleton, RID, RID)
FUNC2(instance_set_exterior, RID, bool)
FUNC2(instance_set_extra_visibility_margin, RID, real_t)
// don't use these in a game!
FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID)
FUNC3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID)
FUNC2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID)
FUNC3(instance_geometry_set_flag, RID, InstanceFlags, bool)
FUNC2(instance_geometry_set_cast_shadows_setting, RID, ShadowCastingSetting)
FUNC2(instance_geometry_set_material_override, RID, RID)
FUNC5(instance_geometry_set_draw_range, RID, float, float, float, float)
FUNC2(instance_geometry_set_as_instance_lod, RID, RID)
FUNC4(instance_geometry_set_lightmap, RID, RID, const Rect2 &, int)
FUNC2(instance_geometry_set_lod_bias, RID, float)
FUNC3(instance_geometry_set_shader_parameter, RID, const StringName &, const Variant &)
FUNC2RC(Variant, instance_geometry_get_shader_parameter, RID, const StringName &)
FUNC2RC(Variant, instance_geometry_get_shader_parameter_default_value, RID, const StringName &)
FUNC2SC(instance_geometry_get_shader_parameter_list, RID, List<PropertyInfo> *)
/* BAKE */
FUNC3R(TypedArray<Image>, bake_render_uv2, RID, const Vector<RID> &, const Size2i &)
/* CANVAS (2D) */
FUNCRID(canvas)
FUNC3(canvas_set_item_mirroring, RID, RID, const Point2 &)
FUNC2(canvas_set_modulate, RID, const Color &)
FUNC3(canvas_set_parent, RID, RID, float)
FUNC1(canvas_set_disable_scale, bool)
FUNCRID(canvas_texture)
FUNC3(canvas_texture_set_channel, RID, CanvasTextureChannel, RID)
FUNC3(canvas_texture_set_shading_parameters, RID, const Color &, float)
FUNC2(canvas_texture_set_texture_filter, RID, CanvasItemTextureFilter)
FUNC2(canvas_texture_set_texture_repeat, RID, CanvasItemTextureRepeat)
FUNCRID(canvas_item)
FUNC2(canvas_item_set_parent, RID, RID)
FUNC2(canvas_item_set_default_texture_filter, RID, CanvasItemTextureFilter)
FUNC2(canvas_item_set_default_texture_repeat, RID, CanvasItemTextureRepeat)
FUNC2(canvas_item_set_visible, RID, bool)
FUNC2(canvas_item_set_light_mask, RID, int)
FUNC2(canvas_item_set_update_when_visible, RID, bool)
FUNC2(canvas_item_set_transform, RID, const Transform2D &)
FUNC2(canvas_item_set_clip, RID, bool)
FUNC2(canvas_item_set_distance_field_mode, RID, bool)
FUNC3(canvas_item_set_custom_rect, RID, bool, const Rect2 &)
FUNC2(canvas_item_set_modulate, RID, const Color &)
FUNC2(canvas_item_set_self_modulate, RID, const Color &)
FUNC2(canvas_item_set_draw_behind_parent, RID, bool)
FUNC5(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float)
FUNC5(canvas_item_add_polyline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
FUNC4(canvas_item_add_multiline, RID, const Vector<Point2> &, const Vector<Color> &, float)
FUNC3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
FUNC4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
FUNC6(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool)
FUNC7(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, bool)
FUNC10(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &)
FUNC6(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float)
FUNC5(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID)
FUNC9(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int)
FUNC5(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID)
FUNC3(canvas_item_add_multimesh, RID, RID, RID)
FUNC3(canvas_item_add_particles, RID, RID, RID)
FUNC2(canvas_item_add_set_transform, RID, const Transform2D &)
FUNC2(canvas_item_add_clip_ignore, RID, bool)
FUNC2(canvas_item_set_sort_children_by_y, RID, bool)
FUNC2(canvas_item_set_z_index, RID, int)
FUNC2(canvas_item_set_z_as_relative_to_parent, RID, bool)
FUNC3(canvas_item_set_copy_to_backbuffer, RID, bool, const Rect2 &)
FUNC2(canvas_item_attach_skeleton, RID, RID)
FUNC1(canvas_item_clear, RID)
FUNC2(canvas_item_set_draw_index, RID, int)
FUNC2(canvas_item_set_material, RID, RID)
FUNC2(canvas_item_set_use_parent_material, RID, bool)
FUNC6(canvas_item_set_canvas_group_mode, RID, CanvasGroupMode, float, bool, float, bool)
FUNC0R(RID, canvas_light_create)
FUNC2(canvas_light_set_mode, RID, CanvasLightMode)
FUNC2(canvas_light_attach_to_canvas, RID, RID)
FUNC2(canvas_light_set_enabled, RID, bool)
FUNC2(canvas_light_set_texture_scale, RID, float)
FUNC2(canvas_light_set_transform, RID, const Transform2D &)
FUNC2(canvas_light_set_texture, RID, RID)
FUNC2(canvas_light_set_texture_offset, RID, const Vector2 &)
FUNC2(canvas_light_set_color, RID, const Color &)
FUNC2(canvas_light_set_height, RID, float)
FUNC2(canvas_light_set_energy, RID, float)
FUNC3(canvas_light_set_z_range, RID, int, int)
FUNC3(canvas_light_set_layer_range, RID, int, int)
FUNC2(canvas_light_set_item_cull_mask, RID, int)
FUNC2(canvas_light_set_item_shadow_cull_mask, RID, int)
FUNC2(canvas_light_set_directional_distance, RID, float)
FUNC2(canvas_light_set_blend_mode, RID, CanvasLightBlendMode)
FUNC2(canvas_light_set_shadow_enabled, RID, bool)
FUNC2(canvas_light_set_shadow_filter, RID, CanvasLightShadowFilter)
FUNC2(canvas_light_set_shadow_color, RID, const Color &)
FUNC2(canvas_light_set_shadow_smooth, RID, float)
FUNCRID(canvas_light_occluder)
FUNC2(canvas_light_occluder_attach_to_canvas, RID, RID)
FUNC2(canvas_light_occluder_set_enabled, RID, bool)
FUNC2(canvas_light_occluder_set_polygon, RID, RID)
FUNC2(canvas_light_occluder_set_as_sdf_collision, RID, bool)
FUNC2(canvas_light_occluder_set_transform, RID, const Transform2D &)
FUNC2(canvas_light_occluder_set_light_mask, RID, int)
FUNCRID(canvas_occluder_polygon)
FUNC3(canvas_occluder_polygon_set_shape, RID, const Vector<Vector2> &, bool)
FUNC2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
FUNC1(canvas_set_shadow_texture_size, int)
/* GLOBAL VARIABLES */
FUNC3(global_variable_add, const StringName &, GlobalVariableType, const Variant &)
FUNC1(global_variable_remove, const StringName &)
FUNC0RC(Vector<StringName>, global_variable_get_list)
FUNC2(global_variable_set, const StringName &, const Variant &)
FUNC2(global_variable_set_override, const StringName &, const Variant &)
FUNC1RC(GlobalVariableType, global_variable_get_type, const StringName &)
FUNC1RC(Variant, global_variable_get, const StringName &)
FUNC1(global_variables_load_settings, bool)
FUNC0(global_variables_clear)
/* BLACK BARS */
FUNC4(black_bars_set_margins, int, int, int, int)
FUNC4(black_bars_set_images, RID, RID, RID, RID)
/* FREE */
FUNC1(free, RID)
/* EVENT QUEUING */
FUNC3(request_frame_drawn_callback, Object *, const StringName &, const Variant &)
virtual void init();
virtual void finish();
virtual void draw(bool p_swap_buffers, double frame_step);
virtual void sync();
FUNC0RC(bool, has_changed)
/* RENDER INFO */
//this passes directly to avoid stalling
virtual int get_render_info(RenderInfo p_info) {
return rendering_server->get_render_info(p_info);
}
virtual String get_video_adapter_name() const {
return rendering_server->get_video_adapter_name();
}
virtual String get_video_adapter_vendor() const {
return rendering_server->get_video_adapter_vendor();
}
FUNC1(gi_set_use_half_resolution, bool)
FUNC4(set_boot_image, const Ref<Image> &, const Color &, bool, bool)
FUNC1(set_default_clear_color, const Color &)
FUNC0R(RID, get_test_cube)
FUNC1(set_debug_generate_wireframes, bool)
virtual bool has_feature(Features p_feature) const {
return rendering_server->has_feature(p_feature);
}
virtual bool has_os_feature(const String &p_feature) const {
return rendering_server->has_os_feature(p_feature);
}
FUNC1(call_set_use_vsync, bool)
static void set_use_vsync_callback(bool p_enable);
virtual bool is_low_end() const {
return rendering_server->is_low_end();
}
virtual uint64_t get_frame_profile_frame() {
return rendering_server->get_frame_profile_frame();
}
virtual void set_frame_profiling_enabled(bool p_enabled) {
rendering_server->set_frame_profiling_enabled(p_enabled);
}
virtual Vector<FrameProfileArea> get_frame_profile() {
return rendering_server->get_frame_profile();
}
virtual float get_frame_setup_time_cpu() const {
return rendering_server->get_frame_setup_time_cpu();
}
virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) {
rendering_server->sdfgi_set_debug_probe_select(p_position, p_dir);
}
virtual void set_print_gpu_profile(bool p_enable) {
rendering_server->set_print_gpu_profile(p_enable);
}
RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread);
~RenderingServerWrapMT();
#undef ServerName
#undef ServerNameWrapMT
#undef server_name
};
#ifdef DEBUG_SYNC
#undef DEBUG_SYNC
#endif
#undef SYNC_DEBUG
#endif