summaryrefslogtreecommitdiff
path: root/drivers/gles3
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-06-10 12:38:51 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 11:53:26 +0100
commit4f163972bbd9c7379b01a1f9aa5310646ca7865e (patch)
tree3bbf4693663d8fc071912c114af782736ea17168 /drivers/gles3
parent1522d8c3ee6ddf43267f124940f4e43612058407 (diff)
Refactored RID/RID_Owner to always use O(1) allocation.
* Implements a growing chunked allocator * Removed redudant methods get and getptr, only getornull is supported now.
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp12
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.h4
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp2
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp78
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h24
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp154
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h56
7 files changed, 167 insertions, 163 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index b7b31c66aa..9e1b302a03 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -1402,7 +1402,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
{
//skeleton handling
if (ci->skeleton.is_valid() && storage->skeleton_owner.owns(ci->skeleton)) {
- skeleton = storage->skeleton_owner.get(ci->skeleton);
+ skeleton = storage->skeleton_owner.getornull(ci->skeleton);
if (!skeleton->use_2d) {
skeleton = NULL;
} else {
@@ -1697,11 +1697,13 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
}
}
- glBindBufferBase(GL_UNIFORM_BUFFER, 1, static_cast<LightInternal *>(light->light_internal.get_data())->ubo);
+ LightInternal *light_internal = light_internal_owner.getornull(light->light_internal);
+
+ glBindBufferBase(GL_UNIFORM_BUFFER, 1, light_internal->ubo);
if (has_shadow) {
- RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
+ RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(light->shadow_buffer);
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
glBindTexture(GL_TEXTURE_2D, cls->distance);
@@ -1807,7 +1809,7 @@ void RasterizerCanvasGLES3::canvas_debug_viewport_shadows(Light *p_lights_with_s
while (light) {
if (light->shadow_buffer.is_valid()) {
- RasterizerStorageGLES3::CanvasLightShadow *sb = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
+ RasterizerStorageGLES3::CanvasLightShadow *sb = storage->canvas_light_shadow_owner.getornull(light->shadow_buffer);
if (sb) {
glBindTexture(GL_TEXTURE_2D, sb->distance);
draw_generic_textured_rect(Rect2(h, ofs, w - h * 2, h), Rect2(0, 0, 1, 1));
@@ -1823,7 +1825,7 @@ void RasterizerCanvasGLES3::canvas_debug_viewport_shadows(Light *p_lights_with_s
void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
- RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer);
+ RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(p_buffer);
ERR_FAIL_COND(!cls);
glDisable(GL_BLEND);
diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h
index 929867337d..8e7a3ae873 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.h
+++ b/drivers/gles3/rasterizer_canvas_gles3.h
@@ -96,7 +96,7 @@ public:
RasterizerStorageGLES3 *storage;
- struct LightInternal : public RID_Data {
+ struct LightInternal {
struct UBOData {
@@ -117,7 +117,7 @@ public:
GLuint ubo;
};
- RID_Owner<LightInternal> light_internal_owner;
+ RID_PtrOwner<LightInternal> light_internal_owner;
virtual RID light_internal_create();
virtual void light_internal_update(RID p_rid, Light *p_light);
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index e06cc55423..ef6f2854bc 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -320,7 +320,7 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c
screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
}
- RasterizerStorageGLES3::Texture *t = storage->texture_owner.get(texture);
+ RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull(texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, t->tex_id);
canvas->draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 27173d317b..27992ea5b9 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -351,7 +351,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in
if (sh->owner.is_valid()) {
//is taken, but is invalid, erasing it
shadow_atlas->shadow_owners.erase(sh->owner);
- LightInstance *sli = light_instance_owner.get(sh->owner);
+ LightInstance *sli = light_instance_owner.getornull(sh->owner);
sli->shadow_atlases.erase(p_atlas);
}
@@ -391,7 +391,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in
if (sh->owner.is_valid()) {
//is taken, but is invalid, erasing it
shadow_atlas->shadow_owners.erase(sh->owner);
- LightInstance *sli = light_instance_owner.get(sh->owner);
+ LightInstance *sli = light_instance_owner.getornull(sh->owner);
sli->shadow_atlases.erase(p_atlas);
}
@@ -1170,7 +1170,7 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
GLenum target = GL_TEXTURE_2D;
GLuint tex = 0;
- RasterizerStorageGLES3::Texture *t = storage->texture_owner.getptr(textures[i]);
+ RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull(textures[i]);
if (t) {
@@ -1606,7 +1606,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
if (c.texture.is_valid() && storage->texture_owner.owns(c.texture)) {
- RasterizerStorageGLES3::Texture *t = storage->texture_owner.get(c.texture);
+ RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull(c.texture);
if (t->redraw_if_visible) {
VisualServerRaster::redraw_request();
@@ -1884,7 +1884,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
const RID *reflections = e->instance->reflection_probe_instances.ptr();
for (int i = 0; i < rc; i++) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getptr(reflections[i]);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(reflections[i]);
if (rpi->last_pass != render_pass) //not visible
continue;
@@ -1903,7 +1903,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
if (gi_probe_count) {
const RID *ridp = e->instance->gi_probe_instances.ptr();
- GIProbeInstance *gipi = gi_probe_instance_owner.getptr(ridp[0]);
+ GIProbeInstance *gipi = gi_probe_instance_owner.getornull(ridp[0]);
float bias_scale = e->instance->baked_light ? 1 : 0;
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 9);
@@ -1917,7 +1917,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE1, gipi->cell_size_cache);
if (gi_probe_count > 1) {
- GIProbeInstance *gipi2 = gi_probe_instance_owner.getptr(ridp[1]);
+ GIProbeInstance *gipi2 = gi_probe_instance_owner.getornull(ridp[1]);
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 10);
glBindTexture(GL_TEXTURE_3D, gipi2->tex_cache);
@@ -2286,7 +2286,7 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
}
if (!m) {
- m = storage->material_owner.getptr(default_material);
+ m = storage->material_owner.getornull(default_material);
}
ERR_FAIL_COND(!m);
@@ -2337,11 +2337,11 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
//shader does not use discard and does not write a vertex position, use generic material
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
- p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
+ p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
no_cull = true;
mirror = false;
} else {
- p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
+ p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
}
}
@@ -2792,7 +2792,7 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c
ERR_BREAK(i >= render_list.max_lights);
- LightInstance *li = light_instance_owner.getptr(p_light_cull_result[i]);
+ LightInstance *li = light_instance_owner.getornull(p_light_cull_result[i]);
LightDataUBO ubo_data; //used for filling
@@ -3142,7 +3142,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
case VS::INSTANCE_MESH: {
- RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getptr(inst->base);
+ RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getornull(inst->base);
ERR_CONTINUE(!mesh);
int ssize = mesh->surfaces.size();
@@ -3159,13 +3159,13 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
} break;
case VS::INSTANCE_MULTIMESH: {
- RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.getptr(inst->base);
+ RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.getornull(inst->base);
ERR_CONTINUE(!multi_mesh);
if (multi_mesh->size == 0 || multi_mesh->visible_instances == 0)
continue;
- RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getptr(multi_mesh->mesh);
+ RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getornull(multi_mesh->mesh);
if (!mesh)
continue; //mesh not assigned
@@ -3180,7 +3180,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
} break;
case VS::INSTANCE_IMMEDIATE: {
- RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getptr(inst->base);
+ RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base);
ERR_CONTINUE(!immediate);
_add_geometry(immediate, inst, NULL, -1, p_depth_pass, p_shadow_pass);
@@ -3188,7 +3188,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
} break;
case VS::INSTANCE_PARTICLES: {
- RasterizerStorageGLES3::Particles *particles = storage->particles_owner.getptr(inst->base);
+ RasterizerStorageGLES3::Particles *particles = storage->particles_owner.getornull(inst->base);
ERR_CONTINUE(!particles);
for (int j = 0; j < particles->draw_passes.size(); j++) {
@@ -3196,7 +3196,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
RID pmesh = particles->draw_passes[j];
if (!pmesh.is_valid())
continue;
- RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.get(pmesh);
+ RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getornull(pmesh);
if (!mesh)
continue; //mesh not assigned
@@ -4155,7 +4155,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
ERR_BREAK(i >= render_list.max_lights);
- LightInstance *li = light_instance_owner.getptr(p_light_cull_result[i]);
+ LightInstance *li = light_instance_owner.getornull(p_light_cull_result[i]);
if (li->light_ptr->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] > CMP_EPSILON) {
state.used_contact_shadows = true;
}
@@ -4229,7 +4229,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
if (probe) {
- ReflectionAtlas *ref_atlas = reflection_atlas_owner.getptr(probe->atlas);
+ ReflectionAtlas *ref_atlas = reflection_atlas_owner.getornull(probe->atlas);
ERR_FAIL_COND(!ref_atlas);
int target_size = ref_atlas->size / ref_atlas->subdiv;
@@ -4914,11 +4914,11 @@ bool RasterizerSceneGLES3::free(RID p_rid) {
if (light_instance_owner.owns(p_rid)) {
- LightInstance *light_instance = light_instance_owner.getptr(p_rid);
+ LightInstance *light_instance = light_instance_owner.getornull(p_rid);
//remove from shadow atlases..
for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.get(E->get());
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(E->get());
ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
uint32_t key = shadow_atlas->shadow_owners[p_rid];
uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
@@ -4933,19 +4933,19 @@ bool RasterizerSceneGLES3::free(RID p_rid) {
} else if (shadow_atlas_owner.owns(p_rid)) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.get(p_rid);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_rid);
shadow_atlas_set_size(p_rid, 0);
shadow_atlas_owner.free(p_rid);
memdelete(shadow_atlas);
} else if (reflection_atlas_owner.owns(p_rid)) {
- ReflectionAtlas *reflection_atlas = reflection_atlas_owner.get(p_rid);
+ ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_rid);
reflection_atlas_set_size(p_rid, 0);
reflection_atlas_owner.free(p_rid);
memdelete(reflection_atlas);
} else if (reflection_probe_instance_owner.owns(p_rid)) {
- ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.get(p_rid);
+ ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.getornull(p_rid);
reflection_probe_release_atlas_index(p_rid);
reflection_probe_instance_owner.free(p_rid);
@@ -4953,14 +4953,14 @@ bool RasterizerSceneGLES3::free(RID p_rid) {
} else if (environment_owner.owns(p_rid)) {
- Environment *environment = environment_owner.get(p_rid);
+ Environment *environment = environment_owner.getornull(p_rid);
environment_owner.free(p_rid);
memdelete(environment);
} else if (gi_probe_instance_owner.owns(p_rid)) {
- GIProbeInstance *gi_probe_instance = gi_probe_instance_owner.get(p_rid);
+ GIProbeInstance *gi_probe_instance = gi_probe_instance_owner.getornull(p_rid);
gi_probe_instance_owner.free(p_rid);
memdelete(gi_probe_instance);
@@ -5320,6 +5320,19 @@ void RasterizerSceneGLES3::iteration() {
}
void RasterizerSceneGLES3::finalize() {
+
+ storage->free(default_material);
+ storage->free(default_material_twosided);
+ storage->free(default_shader);
+ storage->free(default_shader_twosided);
+
+ storage->free(default_worldcoord_material);
+ storage->free(default_worldcoord_material_twosided);
+ storage->free(default_worldcoord_shader);
+ storage->free(default_worldcoord_shader_twosided);
+
+ storage->free(default_overdraw_material);
+ storage->free(default_overdraw_shader);
}
RasterizerSceneGLES3::RasterizerSceneGLES3() {
@@ -5327,19 +5340,6 @@ RasterizerSceneGLES3::RasterizerSceneGLES3() {
RasterizerSceneGLES3::~RasterizerSceneGLES3() {
- memdelete(default_material.get_data());
- memdelete(default_material_twosided.get_data());
- memdelete(default_shader.get_data());
- memdelete(default_shader_twosided.get_data());
-
- memdelete(default_worldcoord_material.get_data());
- memdelete(default_worldcoord_material_twosided.get_data());
- memdelete(default_worldcoord_shader.get_data());
- memdelete(default_worldcoord_shader_twosided.get_data());
-
- memdelete(default_overdraw_material.get_data());
- memdelete(default_overdraw_shader.get_data());
-
memfree(state.spot_array_tmp);
memfree(state.omni_array_tmp);
memfree(state.reflection_array_tmp);
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 7885d7c1b7..474bbce1d6 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -216,7 +216,7 @@ public:
/* SHADOW ATLAS API */
- struct ShadowAtlas : public RID_Data {
+ struct ShadowAtlas {
enum {
QUADRANT_SHIFT = 27,
@@ -267,7 +267,7 @@ public:
Vector<ShadowCubeMap> shadow_cubemaps;
- RID_Owner<ShadowAtlas> shadow_atlas_owner;
+ RID_PtrOwner<ShadowAtlas> shadow_atlas_owner;
RID shadow_atlas_create();
void shadow_atlas_set_size(RID p_atlas, int p_size);
@@ -288,7 +288,7 @@ public:
/* REFLECTION PROBE ATLAS API */
- struct ReflectionAtlas : public RID_Data {
+ struct ReflectionAtlas {
int subdiv;
int size;
@@ -304,7 +304,7 @@ public:
Vector<Reflection> reflections;
};
- mutable RID_Owner<ReflectionAtlas> reflection_atlas_owner;
+ mutable RID_PtrOwner<ReflectionAtlas> reflection_atlas_owner;
virtual RID reflection_atlas_create();
virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size);
@@ -324,7 +324,7 @@ public:
/* REFLECTION PROBE INSTANCE */
- struct ReflectionProbeInstance : public RID_Data {
+ struct ReflectionProbeInstance {
RasterizerStorageGLES3::ReflectionProbe *probe_ptr;
RID probe;
@@ -352,7 +352,7 @@ public:
//notes: for ambientblend, use distance to edge to blend between already existing global environment
};
- mutable RID_Owner<ReflectionProbeInstance> reflection_probe_instance_owner;
+ mutable RID_PtrOwner<ReflectionProbeInstance> reflection_probe_instance_owner;
virtual RID reflection_probe_instance_create(RID p_probe);
virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform);
@@ -364,7 +364,7 @@ public:
/* ENVIRONMENT API */
- struct Environment : public RID_Data {
+ struct Environment {
VS::EnvironmentBG bg_mode;
@@ -533,7 +533,7 @@ public:
}
};
- RID_Owner<Environment> environment_owner;
+ RID_PtrOwner<Environment> environment_owner;
virtual RID environment_create();
@@ -590,7 +590,7 @@ public:
float shadow_split_offsets[4];
};
- struct LightInstance : public RID_Data {
+ struct LightInstance {
struct ShadowTransform {
@@ -630,7 +630,7 @@ public:
LightInstance() {}
};
- mutable RID_Owner<LightInstance> light_instance_owner;
+ mutable RID_PtrOwner<LightInstance> light_instance_owner;
virtual RID light_instance_create(RID p_light);
virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);
@@ -639,7 +639,7 @@ public:
/* REFLECTION INSTANCE */
- struct GIProbeInstance : public RID_Data {
+ struct GIProbeInstance {
RID data;
RasterizerStorageGLES3::GIProbe *probe;
GLuint tex_cache;
@@ -653,7 +653,7 @@ public:
}
};
- mutable RID_Owner<GIProbeInstance> gi_probe_instance_owner;
+ mutable RID_PtrOwner<GIProbeInstance> gi_probe_instance_owner;
virtual RID gi_probe_instance_create();
virtual void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index e5a7fcce07..2a25c1d6cc 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -647,7 +647,7 @@ void RasterizerStorageGLES3::texture_allocate(RID p_texture, int p_width, int p_
}
#endif
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
texture->width = p_width;
texture->height = p_height;
@@ -750,7 +750,7 @@ void RasterizerStorageGLES3::texture_allocate(RID p_texture, int p_width, int p_
void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
ERR_FAIL_COND(!texture->active);
@@ -978,7 +978,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
// TODO If we want this to be usable without pre-filling pixels with a full image, we have to call glTexImage2D() with null data.
void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
ERR_FAIL_COND(!texture->active);
@@ -1064,7 +1064,7 @@ void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<I
Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Ref<Image>());
ERR_FAIL_COND_V(!texture->active, Ref<Image>());
@@ -1347,7 +1347,7 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
if (texture->render_target) {
@@ -1423,7 +1423,7 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags)
}
uint32_t RasterizerStorageGLES3::texture_get_flags(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, 0);
@@ -1431,7 +1431,7 @@ uint32_t RasterizerStorageGLES3::texture_get_flags(RID p_texture) const {
}
Image::Format RasterizerStorageGLES3::texture_get_format(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Image::FORMAT_L8);
@@ -1439,7 +1439,7 @@ Image::Format RasterizerStorageGLES3::texture_get_format(RID p_texture) const {
}
VisualServer::TextureType RasterizerStorageGLES3::texture_get_type(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, VS::TEXTURE_TYPE_2D);
@@ -1447,7 +1447,7 @@ VisualServer::TextureType RasterizerStorageGLES3::texture_get_type(RID p_texture
}
uint32_t RasterizerStorageGLES3::texture_get_texid(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, 0);
@@ -1464,7 +1464,7 @@ void RasterizerStorageGLES3::texture_bind(RID p_texture, uint32_t p_texture_no)
}
uint32_t RasterizerStorageGLES3::texture_get_width(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, 0);
@@ -1472,7 +1472,7 @@ uint32_t RasterizerStorageGLES3::texture_get_width(RID p_texture) const {
}
uint32_t RasterizerStorageGLES3::texture_get_height(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, 0);
@@ -1481,7 +1481,7 @@ uint32_t RasterizerStorageGLES3::texture_get_height(RID p_texture) const {
uint32_t RasterizerStorageGLES3::texture_get_depth(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, 0);
@@ -1490,7 +1490,7 @@ uint32_t RasterizerStorageGLES3::texture_get_depth(RID p_texture) const {
void RasterizerStorageGLES3::texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
ERR_FAIL_COND(texture->render_target);
@@ -1503,7 +1503,7 @@ void RasterizerStorageGLES3::texture_set_size_override(RID p_texture, int p_widt
}
void RasterizerStorageGLES3::texture_set_path(RID p_texture, const String &p_path) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
texture->path = p_path;
@@ -1511,7 +1511,7 @@ void RasterizerStorageGLES3::texture_set_path(RID p_texture, const String &p_pat
String RasterizerStorageGLES3::texture_get_path(RID p_texture) const {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, String());
return texture->path;
}
@@ -1522,7 +1522,7 @@ void RasterizerStorageGLES3::texture_debug_usage(List<VS::TextureInfo> *r_info)
for (List<RID>::Element *E = textures.front(); E; E = E->next()) {
- Texture *t = texture_owner.get(E->get());
+ Texture *t = texture_owner.getornull(E->get());
if (!t)
continue;
VS::TextureInfo tinfo;
@@ -1548,7 +1548,7 @@ void RasterizerStorageGLES3::textures_keep_original(bool p_enable) {
void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
texture->detect_3d = p_callback;
@@ -1556,7 +1556,7 @@ void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture, Visua
}
void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
texture->detect_srgb = p_callback;
@@ -1564,7 +1564,7 @@ void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture, Vis
}
void RasterizerStorageGLES3::texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
texture->detect_normal = p_callback;
@@ -1573,7 +1573,7 @@ void RasterizerStorageGLES3::texture_set_detect_normal_callback(RID p_texture, V
RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_resolution) const {
- Texture *texture = texture_owner.get(p_source);
+ Texture *texture = texture_owner.getornull(p_source);
ERR_FAIL_COND_V(!texture, RID());
ERR_FAIL_COND_V(texture->type != VS::TEXTURE_TYPE_CUBEMAP, RID());
@@ -1729,7 +1729,7 @@ Size2 RasterizerStorageGLES3::texture_size_with_proxy(RID p_texture) const {
void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
if (texture->proxy) {
@@ -1738,7 +1738,7 @@ void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
}
if (p_proxy.is_valid()) {
- Texture *proxy = texture_owner.get(p_proxy);
+ Texture *proxy = texture_owner.getornull(p_proxy);
ERR_FAIL_COND(!proxy);
ERR_FAIL_COND(proxy == texture);
proxy->proxy_owners.insert(texture);
@@ -1748,7 +1748,7 @@ void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
void RasterizerStorageGLES3::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {
- Texture *texture = texture_owner.get(p_texture);
+ Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
texture->redraw_if_visible = p_enable;
}
@@ -2194,7 +2194,7 @@ void RasterizerStorageGLES3::_shader_make_dirty(Shader *p_shader) {
void RasterizerStorageGLES3::shader_set_code(RID p_shader, const String &p_code) {
- Shader *shader = shader_owner.get(p_shader);
+ Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
shader->code = p_code;
@@ -2234,7 +2234,7 @@ void RasterizerStorageGLES3::shader_set_code(RID p_shader, const String &p_code)
}
String RasterizerStorageGLES3::shader_get_code(RID p_shader) const {
- const Shader *shader = shader_owner.get(p_shader);
+ const Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND_V(!shader, String());
return shader->code;
@@ -2387,7 +2387,7 @@ void RasterizerStorageGLES3::update_dirty_shaders() {
void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
- Shader *shader = shader_owner.get(p_shader);
+ Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
if (shader->dirty_list.in_list())
@@ -2502,7 +2502,7 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyIn
void RasterizerStorageGLES3::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
- Shader *shader = shader_owner.get(p_shader);
+ Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
@@ -2515,7 +2515,7 @@ void RasterizerStorageGLES3::shader_set_default_texture_param(RID p_shader, cons
}
RID RasterizerStorageGLES3::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
- const Shader *shader = shader_owner.get(p_shader);
+ const Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND_V(!shader, RID());
const Map<StringName, RID>::Element *E = shader->default_textures.find(p_name);
@@ -2543,7 +2543,7 @@ RID RasterizerStorageGLES3::material_create() {
void RasterizerStorageGLES3::material_set_shader(RID p_material, RID p_shader) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
Shader *shader = shader_owner.getornull(p_shader);
@@ -2563,7 +2563,7 @@ void RasterizerStorageGLES3::material_set_shader(RID p_material, RID p_shader) {
RID RasterizerStorageGLES3::material_get_shader(RID p_material) const {
- const Material *material = material_owner.get(p_material);
+ const Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, RID());
if (material->shader)
@@ -2574,7 +2574,7 @@ RID RasterizerStorageGLES3::material_get_shader(RID p_material) const {
void RasterizerStorageGLES3::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
if (p_value.get_type() == Variant::NIL)
@@ -2586,7 +2586,7 @@ void RasterizerStorageGLES3::material_set_param(RID p_material, const StringName
}
Variant RasterizerStorageGLES3::material_get_param(RID p_material, const StringName &p_param) const {
- const Material *material = material_owner.get(p_material);
+ const Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, Variant());
if (material->params.has(p_param))
@@ -2596,7 +2596,7 @@ Variant RasterizerStorageGLES3::material_get_param(RID p_material, const StringN
}
Variant RasterizerStorageGLES3::material_get_param_default(RID p_material, const StringName &p_param) const {
- const Material *material = material_owner.get(p_material);
+ const Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, Variant());
if (material->shader) {
@@ -2611,7 +2611,7 @@ Variant RasterizerStorageGLES3::material_get_param_default(RID p_material, const
void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_width) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
material->line_width = p_width;
@@ -2619,7 +2619,7 @@ void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_wid
void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_material) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
material->next_pass = p_next_material;
@@ -2627,7 +2627,7 @@ void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_m
bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, false);
if (material->dirty_list.in_list()) {
_update_material(material);
@@ -2641,7 +2641,7 @@ bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
}
bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, false);
if (material->dirty_list.in_list()) {
_update_material(material);
@@ -2658,7 +2658,7 @@ bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
Map<RasterizerScene::InstanceBase *, int>::Element *E = material->instance_owners.find(p_instance);
@@ -2671,7 +2671,7 @@ void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, Rasteri
void RasterizerStorageGLES3::material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
Map<RasterizerScene::InstanceBase *, int>::Element *E = material->instance_owners.find(p_instance);
@@ -2688,7 +2688,7 @@ void RasterizerStorageGLES3::material_set_render_priority(RID p_material, int pr
ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN);
ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX);
- Material *material = material_owner.get(p_material);
+ Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
material->render_priority = priority;
@@ -4136,7 +4136,7 @@ AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const {
AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
- Mesh *mesh = mesh_owner.get(p_mesh);
+ Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, AABB());
if (mesh->custom_aabb != AABB()) {
@@ -4145,7 +4145,7 @@ AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
Skeleton *sk = NULL;
if (p_skeleton.is_valid()) {
- sk = skeleton_owner.get(p_skeleton);
+ sk = skeleton_owner.getornull(p_skeleton);
}
AABB aabb;
@@ -5047,7 +5047,7 @@ RID RasterizerStorageGLES3::immediate_create() {
void RasterizerStorageGLES3::immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture) {
ERR_FAIL_INDEX(p_primitive, (int)VS::PRIMITIVE_MAX);
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(im->building);
@@ -5060,7 +5060,7 @@ void RasterizerStorageGLES3::immediate_begin(RID p_immediate, VS::PrimitiveType
}
void RasterizerStorageGLES3::immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
@@ -5090,7 +5090,7 @@ void RasterizerStorageGLES3::immediate_vertex(RID p_immediate, const Vector3 &p_
void RasterizerStorageGLES3::immediate_normal(RID p_immediate, const Vector3 &p_normal) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
@@ -5099,7 +5099,7 @@ void RasterizerStorageGLES3::immediate_normal(RID p_immediate, const Vector3 &p_
}
void RasterizerStorageGLES3::immediate_tangent(RID p_immediate, const Plane &p_tangent) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
@@ -5108,7 +5108,7 @@ void RasterizerStorageGLES3::immediate_tangent(RID p_immediate, const Plane &p_t
}
void RasterizerStorageGLES3::immediate_color(RID p_immediate, const Color &p_color) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
@@ -5117,7 +5117,7 @@ void RasterizerStorageGLES3::immediate_color(RID p_immediate, const Color &p_col
}
void RasterizerStorageGLES3::immediate_uv(RID p_immediate, const Vector2 &tex_uv) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
@@ -5126,7 +5126,7 @@ void RasterizerStorageGLES3::immediate_uv(RID p_immediate, const Vector2 &tex_uv
}
void RasterizerStorageGLES3::immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
@@ -5136,7 +5136,7 @@ void RasterizerStorageGLES3::immediate_uv2(RID p_immediate, const Vector2 &tex_u
void RasterizerStorageGLES3::immediate_end(RID p_immediate) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
@@ -5146,7 +5146,7 @@ void RasterizerStorageGLES3::immediate_end(RID p_immediate) {
}
void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(im->building);
@@ -5156,14 +5156,14 @@ void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND_V(!im, AABB());
return im->aabb;
}
void RasterizerStorageGLES3::immediate_set_material(RID p_immediate, RID p_material) {
- Immediate *im = immediate_owner.get(p_immediate);
+ Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
im->material = p_material;
im->instance_change_notify(false, true);
@@ -5171,7 +5171,7 @@ void RasterizerStorageGLES3::immediate_set_material(RID p_immediate, RID p_mater
RID RasterizerStorageGLES3::immediate_get_material(RID p_immediate) const {
- const Immediate *im = immediate_owner.get(p_immediate);
+ const Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND_V(!im, RID());
return im->material;
}
@@ -6999,7 +6999,7 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
glDeleteFramebuffers(1, &rt->external.fbo);
// clean up our texture
- Texture *t = texture_owner.get(rt->external.texture);
+ Texture *t = texture_owner.getornull(rt->external.texture);
t->alloc_height = 0;
t->alloc_width = 0;
t->width = 0;
@@ -7011,7 +7011,7 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
rt->external.fbo = 0;
}
- Texture *tex = texture_owner.get(rt->texture);
+ Texture *tex = texture_owner.getornull(rt->texture);
tex->alloc_height = 0;
tex->alloc_width = 0;
tex->width = 0;
@@ -7117,7 +7117,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
- Texture *tex = texture_owner.get(rt->texture);
+ Texture *tex = texture_owner.getornull(rt->texture);
tex->format = image_format;
tex->gl_format_cache = color_format;
tex->gl_type_cache = color_type;
@@ -7487,7 +7487,7 @@ void RasterizerStorageGLES3::render_target_set_external_texture(RID p_render_tar
glDeleteFramebuffers(1, &rt->external.fbo);
// clean up our texture
- Texture *t = texture_owner.get(rt->external.texture);
+ Texture *t = texture_owner.getornull(rt->external.texture);
t->alloc_height = 0;
t->alloc_width = 0;
t->width = 0;
@@ -7536,7 +7536,7 @@ void RasterizerStorageGLES3::render_target_set_external_texture(RID p_render_tar
glBindFramebuffer(GL_FRAMEBUFFER, rt->external.fbo);
// find our texture
- t = texture_owner.get(rt->external.texture);
+ t = texture_owner.getornull(rt->external.texture);
}
// set our texture
@@ -7678,7 +7678,7 @@ RID RasterizerStorageGLES3::canvas_light_occluder_create() {
void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {
- CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
+ CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!co);
co->lines = p_lines;
@@ -7818,7 +7818,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
RenderTarget *rt = render_target_owner.getornull(p_rid);
_render_target_clear(rt);
- Texture *t = texture_owner.get(rt->texture);
+ Texture *t = texture_owner.getornull(rt->texture);
texture_owner.free(rt->texture);
memdelete(t);
render_target_owner.free(p_rid);
@@ -7826,7 +7826,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (texture_owner.owns(p_rid)) {
// delete the texture
- Texture *texture = texture_owner.get(p_rid);
+ Texture *texture = texture_owner.getornull(p_rid);
ERR_FAIL_COND_V(texture->render_target, true); //can't free the render target texture, dude
info.texture_mem -= texture->total_data_size;
texture_owner.free(p_rid);
@@ -7834,7 +7834,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (sky_owner.owns(p_rid)) {
// delete the sky
- Sky *sky = sky_owner.get(p_rid);
+ Sky *sky = sky_owner.getornull(p_rid);
sky_set_texture(p_rid, RID(), 256);
sky_owner.free(p_rid);
memdelete(sky);
@@ -7842,7 +7842,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (shader_owner.owns(p_rid)) {
// delete the texture
- Shader *shader = shader_owner.get(p_rid);
+ Shader *shader = shader_owner.getornull(p_rid);
if (shader->shader && shader->custom_code_id)
shader->shader->free_custom_shader(shader->custom_code_id);
@@ -7867,7 +7867,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (material_owner.owns(p_rid)) {
// delete the texture
- Material *material = material_owner.get(p_rid);
+ Material *material = material_owner.getornull(p_rid);
if (material->shader) {
material->shader->materials.remove(&material->list);
@@ -7902,7 +7902,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (skeleton_owner.owns(p_rid)) {
// delete the texture
- Skeleton *skeleton = skeleton_owner.get(p_rid);
+ Skeleton *skeleton = skeleton_owner.getornull(p_rid);
if (skeleton->update_list.in_list()) {
skeleton_update_list.remove(&skeleton->update_list);
}
@@ -7920,7 +7920,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (mesh_owner.owns(p_rid)) {
// delete the texture
- Mesh *mesh = mesh_owner.get(p_rid);
+ Mesh *mesh = mesh_owner.getornull(p_rid);
mesh->instance_remove_deps();
mesh_clear(p_rid);
@@ -7941,7 +7941,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (multimesh_owner.owns(p_rid)) {
// delete the texture
- MultiMesh *multimesh = multimesh_owner.get(p_rid);
+ MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
multimesh->instance_remove_deps();
if (multimesh->mesh.is_valid()) {
@@ -7958,7 +7958,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
memdelete(multimesh);
} else if (immediate_owner.owns(p_rid)) {
- Immediate *immediate = immediate_owner.get(p_rid);
+ Immediate *immediate = immediate_owner.getornull(p_rid);
immediate->instance_remove_deps();
immediate_owner.free(p_rid);
@@ -7966,7 +7966,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (light_owner.owns(p_rid)) {
// delete the texture
- Light *light = light_owner.get(p_rid);
+ Light *light = light_owner.getornull(p_rid);
light->instance_remove_deps();
light_owner.free(p_rid);
@@ -7975,7 +7975,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (reflection_probe_owner.owns(p_rid)) {
// delete the texture
- ReflectionProbe *reflection_probe = reflection_probe_owner.get(p_rid);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid);
reflection_probe->instance_remove_deps();
reflection_probe_owner.free(p_rid);
@@ -7984,7 +7984,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (gi_probe_owner.owns(p_rid)) {
// delete the texture
- GIProbe *gi_probe = gi_probe_owner.get(p_rid);
+ GIProbe *gi_probe = gi_probe_owner.getornull(p_rid);
gi_probe->instance_remove_deps();
gi_probe_owner.free(p_rid);
@@ -7992,7 +7992,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (gi_probe_data_owner.owns(p_rid)) {
// delete the texture
- GIProbeData *gi_probe_data = gi_probe_data_owner.get(p_rid);
+ GIProbeData *gi_probe_data = gi_probe_data_owner.getornull(p_rid);
glDeleteTextures(1, &gi_probe_data->tex_id);
gi_probe_data_owner.free(p_rid);
@@ -8000,7 +8000,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (lightmap_capture_data_owner.owns(p_rid)) {
// delete the texture
- LightmapCapture *lightmap_capture = lightmap_capture_data_owner.get(p_rid);
+ LightmapCapture *lightmap_capture = lightmap_capture_data_owner.getornull(p_rid);
lightmap_capture->instance_remove_deps();
lightmap_capture_data_owner.free(p_rid);
@@ -8008,7 +8008,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (canvas_occluder_owner.owns(p_rid)) {
- CanvasOccluder *co = canvas_occluder_owner.get(p_rid);
+ CanvasOccluder *co = canvas_occluder_owner.getornull(p_rid);
if (co->index_id)
glDeleteBuffers(1, &co->index_id);
if (co->vertex_id)
@@ -8021,14 +8021,14 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
} else if (canvas_light_shadow_owner.owns(p_rid)) {
- CanvasLightShadow *cls = canvas_light_shadow_owner.get(p_rid);
+ CanvasLightShadow *cls = canvas_light_shadow_owner.getornull(p_rid);
glDeleteFramebuffers(1, &cls->fbo);
glDeleteRenderbuffers(1, &cls->depth);
glDeleteTextures(1, &cls->distance);
canvas_light_shadow_owner.free(p_rid);
memdelete(cls);
} else if (particles_owner.owns(p_rid)) {
- Particles *particles = particles_owner.get(p_rid);
+ Particles *particles = particles_owner.getornull(p_rid);
particles->instance_remove_deps();
particles_owner.free(p_rid);
memdelete(particles);
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index bd853852fe..1953a2e809 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -43,6 +43,8 @@
#include "shaders/cubemap_filter.glsl.gen.h"
#include "shaders/particles.glsl.gen.h"
+#include "core/rid_owner.h"
+
// WebGL 2.0 has no MapBufferRange/UnmapBuffer, but offers a non-ES style BufferSubData API instead.
#ifdef __EMSCRIPTEN__
void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
@@ -179,7 +181,7 @@ public:
//////////////////////////////////DATA///////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
- struct Instantiable : public RID_Data {
+ struct Instantiable {
SelfList<RasterizerScene::InstanceBase>::List instance_list;
@@ -242,7 +244,7 @@ public:
struct RenderTarget;
- struct Texture : public RID_Data {
+ struct Texture {
Texture *proxy;
Set<Texture *> proxy_owners;
@@ -342,7 +344,7 @@ public:
}
};
- mutable RID_Owner<Texture> texture_owner;
+ mutable RID_PtrOwner<Texture> texture_owner;
Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &r_srgb, bool p_force_decompress) const;
@@ -384,7 +386,7 @@ public:
/* SKY API */
- struct Sky : public RID_Data {
+ struct Sky {
RID panorama;
GLuint radiance;
@@ -392,7 +394,7 @@ public:
int radiance_size;
};
- mutable RID_Owner<Sky> sky_owner;
+ mutable RID_PtrOwner<Sky> sky_owner;
virtual RID sky_create();
virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size);
@@ -401,7 +403,7 @@ public:
struct Material;
- struct Shader : public RID_Data {
+ struct Shader {
RID self;
@@ -522,7 +524,7 @@ public:
mutable SelfList<Shader>::List _shader_dirty_list;
void _shader_make_dirty(Shader *p_shader);
- mutable RID_Owner<Shader> shader_owner;
+ mutable RID_PtrOwner<Shader> shader_owner;
virtual RID shader_create();
@@ -539,7 +541,7 @@ public:
/* COMMON MATERIAL API */
- struct Material : public RID_Data {
+ struct Material {
Shader *shader;
GLuint ubo_id;
@@ -582,7 +584,7 @@ public:
void _material_add_geometry(RID p_material, Geometry *p_geometry);
void _material_remove_geometry(RID p_material, Geometry *p_geometry);
- mutable RID_Owner<Material> material_owner;
+ mutable RID_PtrOwner<Material> material_owner;
virtual RID material_create();
@@ -724,7 +726,7 @@ public:
}
};
- mutable RID_Owner<Mesh> mesh_owner;
+ mutable RID_PtrOwner<Mesh> mesh_owner;
virtual RID mesh_create();
@@ -804,7 +806,7 @@ public:
}
};
- mutable RID_Owner<MultiMesh> multimesh_owner;
+ mutable RID_PtrOwner<MultiMesh> multimesh_owner;
SelfList<MultiMesh>::List multimesh_update_list;
@@ -869,7 +871,7 @@ public:
Vector2 chunk_uv;
Vector2 chunk_uv2;
- mutable RID_Owner<Immediate> immediate_owner;
+ mutable RID_PtrOwner<Immediate> immediate_owner;
virtual RID immediate_create();
virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture = RID());
@@ -887,7 +889,7 @@ public:
/* SKELETON API */
- struct Skeleton : RID_Data {
+ struct Skeleton {
bool use_2d;
int size;
Vector<float> skel_texture;
@@ -904,7 +906,7 @@ public:
}
};
- mutable RID_Owner<Skeleton> skeleton_owner;
+ mutable RID_PtrOwner<Skeleton> skeleton_owner;
SelfList<Skeleton>::List skeleton_update_list;
@@ -941,7 +943,7 @@ public:
uint64_t version;
};
- mutable RID_Owner<Light> light_owner;
+ mutable RID_PtrOwner<Light> light_owner;
virtual RID light_create(VS::LightType p_type);
@@ -996,7 +998,7 @@ public:
uint32_t cull_mask;
};
- mutable RID_Owner<ReflectionProbe> reflection_probe_owner;
+ mutable RID_PtrOwner<ReflectionProbe> reflection_probe_owner;
virtual RID reflection_probe_create();
@@ -1044,7 +1046,7 @@ public:
PoolVector<int> dynamic_data;
};
- mutable RID_Owner<GIProbe> gi_probe_owner;
+ mutable RID_PtrOwner<GIProbe> gi_probe_owner;
virtual RID gi_probe_create();
@@ -1083,7 +1085,7 @@ public:
virtual uint32_t gi_probe_get_version(RID p_probe);
- struct GIProbeData : public RID_Data {
+ struct GIProbeData {
int width;
int height;
@@ -1096,7 +1098,7 @@ public:
}
};
- mutable RID_Owner<GIProbeData> gi_probe_data_owner;
+ mutable RID_PtrOwner<GIProbeData> gi_probe_data_owner;
virtual GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const;
virtual RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression);
@@ -1132,7 +1134,7 @@ public:
}
};
- mutable RID_Owner<LightmapCapture> lightmap_capture_data_owner;
+ mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner;
/* PARTICLES */
@@ -1228,7 +1230,7 @@ public:
void update_particles();
- mutable RID_Owner<Particles> particles_owner;
+ mutable RID_PtrOwner<Particles> particles_owner;
virtual RID particles_create();
@@ -1277,7 +1279,7 @@ public:
/* RENDER TARGET */
- struct RenderTarget : public RID_Data {
+ struct RenderTarget {
GLuint fbo;
GLuint color;
@@ -1389,7 +1391,7 @@ public:
}
};
- mutable RID_Owner<RenderTarget> render_target_owner;
+ mutable RID_PtrOwner<RenderTarget> render_target_owner;
void _render_target_clear(RenderTarget *rt);
void _render_target_allocate(RenderTarget *rt);
@@ -1407,7 +1409,7 @@ public:
/* CANVAS SHADOW */
- struct CanvasLightShadow : public RID_Data {
+ struct CanvasLightShadow {
int size;
int height;
@@ -1416,13 +1418,13 @@ public:
GLuint distance; //for older devices
};
- RID_Owner<CanvasLightShadow> canvas_light_shadow_owner;
+ RID_PtrOwner<CanvasLightShadow> canvas_light_shadow_owner;
virtual RID canvas_light_shadow_buffer_create(int p_width);
/* LIGHT SHADOW MAPPING */
- struct CanvasOccluder : public RID_Data {
+ struct CanvasOccluder {
GLuint array_id; // 0 means, unconfigured
GLuint vertex_id; // 0 means, unconfigured
@@ -1431,7 +1433,7 @@ public:
int len;
};
- RID_Owner<CanvasOccluder> canvas_occluder_owner;
+ RID_PtrOwner<CanvasOccluder> canvas_occluder_owner;
virtual RID canvas_light_occluder_create();
virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines);