Changed storage structs to private
This commit is contained in:
parent
6d599ed90b
commit
81c6f73109
|
@ -146,10 +146,11 @@ void VRS::update_vrs_texture(RID p_vrs_fb, RID p_render_target) {
|
|||
if (vrs_mode == RS::VIEWPORT_VRS_TEXTURE) {
|
||||
RID vrs_texture = texture_storage->render_target_get_vrs_texture(p_render_target);
|
||||
if (vrs_texture.is_valid()) {
|
||||
Texture *texture = texture_storage->get_texture(vrs_texture);
|
||||
if (texture) {
|
||||
RID rd_texture = texture_storage->texture_get_rd_texture(vrs_texture);
|
||||
int layers = texture_storage->texture_get_layers(vrs_texture);
|
||||
if (rd_texture.is_valid()) {
|
||||
// Copy into our density buffer
|
||||
copy_vrs(texture->rd_texture, p_vrs_fb, texture->layers > 1);
|
||||
copy_vrs(rd_texture, p_vrs_fb, layers > 1);
|
||||
}
|
||||
}
|
||||
} else if (vrs_mode == RS::VIEWPORT_VRS_XR) {
|
||||
|
@ -157,10 +158,12 @@ void VRS::update_vrs_texture(RID p_vrs_fb, RID p_render_target) {
|
|||
if (interface.is_valid()) {
|
||||
RID vrs_texture = interface->get_vrs_texture();
|
||||
if (vrs_texture.is_valid()) {
|
||||
Texture *texture = texture_storage->get_texture(vrs_texture);
|
||||
if (texture) {
|
||||
RID rd_texture = texture_storage->texture_get_rd_texture(vrs_texture);
|
||||
int layers = texture_storage->texture_get_layers(vrs_texture);
|
||||
|
||||
if (rd_texture.is_valid()) {
|
||||
// Copy into our density buffer
|
||||
copy_vrs(texture->rd_texture, p_vrs_fb, texture->layers > 1);
|
||||
copy_vrs(rd_texture, p_vrs_fb, layers > 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,23 +145,23 @@ Fog::FogMaterialData::~FogMaterialData() {
|
|||
free_parameters_uniform_set(uniform_set);
|
||||
}
|
||||
|
||||
RendererRD::ShaderData *Fog::_create_fog_shader_func() {
|
||||
RendererRD::MaterialStorage::ShaderData *Fog::_create_fog_shader_func() {
|
||||
FogShaderData *shader_data = memnew(FogShaderData);
|
||||
return shader_data;
|
||||
}
|
||||
|
||||
RendererRD::ShaderData *Fog::_create_fog_shader_funcs() {
|
||||
RendererRD::MaterialStorage::ShaderData *Fog::_create_fog_shader_funcs() {
|
||||
return Fog::get_singleton()->_create_fog_shader_func();
|
||||
};
|
||||
|
||||
RendererRD::MaterialData *Fog::_create_fog_material_func(FogShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *Fog::_create_fog_material_func(FogShaderData *p_shader) {
|
||||
FogMaterialData *material_data = memnew(FogMaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
||||
RendererRD::MaterialData *Fog::_create_fog_material_funcs(RendererRD::ShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *Fog::_create_fog_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) {
|
||||
return Fog::get_singleton()->_create_fog_material_func(static_cast<FogShaderData *>(p_shader));
|
||||
};
|
||||
|
||||
|
@ -190,8 +190,8 @@ void Fog::init_fog_shader(uint32_t p_max_directional_lights, int p_roughness_lay
|
|||
volumetric_fog_modes.push_back("");
|
||||
volumetric_fog.shader.initialize(volumetric_fog_modes);
|
||||
|
||||
material_storage->shader_set_data_request_function(RendererRD::SHADER_TYPE_FOG, _create_fog_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::SHADER_TYPE_FOG, _create_fog_material_funcs);
|
||||
material_storage->shader_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_FOG, _create_fog_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_FOG, _create_fog_material_funcs);
|
||||
volumetric_fog.volume_ubo = RD::get_singleton()->uniform_buffer_create(sizeof(VolumetricFogShader::VolumeUBO));
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ ALBEDO = vec3(1.0);
|
|||
material_storage->material_initialize(volumetric_fog.default_material);
|
||||
material_storage->material_set_shader(volumetric_fog.default_material, volumetric_fog.default_shader);
|
||||
|
||||
FogMaterialData *md = static_cast<FogMaterialData *>(material_storage->material_get_data(volumetric_fog.default_material, RendererRD::SHADER_TYPE_FOG));
|
||||
FogMaterialData *md = static_cast<FogMaterialData *>(material_storage->material_get_data(volumetric_fog.default_material, RendererRD::MaterialStorage::SHADER_TYPE_FOG));
|
||||
volumetric_fog.default_shader_rd = volumetric_fog.shader.version_get_shader(md->shader_data->version, 0);
|
||||
|
||||
Vector<RD::Uniform> uniforms;
|
||||
|
@ -701,7 +701,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
|
|||
FogMaterialData *material = nullptr;
|
||||
|
||||
if (fog_material.is_valid()) {
|
||||
material = static_cast<FogMaterialData *>(material_storage->material_get_data(fog_material, RendererRD::SHADER_TYPE_FOG));
|
||||
material = static_cast<FogMaterialData *>(material_storage->material_get_data(fog_material, RendererRD::MaterialStorage::SHADER_TYPE_FOG));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
|
|||
|
||||
if (!material) {
|
||||
fog_material = volumetric_fog.default_material;
|
||||
material = static_cast<FogMaterialData *>(material_storage->material_get_data(fog_material, RendererRD::SHADER_TYPE_FOG));
|
||||
material = static_cast<FogMaterialData *>(material_storage->material_get_data(fog_material, RendererRD::MaterialStorage::SHADER_TYPE_FOG));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
|
@ -805,7 +805,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
|
|||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.binding = 1;
|
||||
if (p_settings.shadow_atlas_depth.is_null()) {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK));
|
||||
} else {
|
||||
u.append_id(p_settings.shadow_atlas_depth);
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
|
|||
if (p_settings.directional_shadow_depth.is_valid()) {
|
||||
u.append_id(p_settings.directional_shadow_depth);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
copy_uniforms.push_back(u);
|
||||
|
@ -986,7 +986,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P
|
|||
RD::Uniform u;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.binding = 19;
|
||||
RID radiance_texture = texture_storage->texture_rd_get_default(p_settings.is_using_radiance_cubemap_array ? RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
RID radiance_texture = texture_storage->texture_rd_get_default(p_settings.is_using_radiance_cubemap_array ? RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
RID sky_texture = RendererSceneRenderRD::get_singleton()->environment_get_sky(p_settings.env).is_valid() ? p_settings.sky->sky_get_radiance_texture_rd(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_settings.env)) : RID();
|
||||
u.append_id(sky_texture.is_valid() ? sky_texture : radiance_texture);
|
||||
uniforms.push_back(u);
|
||||
|
|
|
@ -180,7 +180,7 @@ private:
|
|||
|
||||
Vector3i _point_get_position_in_froxel_volume(const Vector3 &p_point, float fog_end, const Vector2 &fog_near_size, const Vector2 &fog_far_size, float volumetric_fog_detail_spread, const Vector3 &fog_size, const Transform3D &p_cam_transform);
|
||||
|
||||
struct FogShaderData : public RendererRD::ShaderData {
|
||||
struct FogShaderData : public RendererRD::MaterialStorage::ShaderData {
|
||||
bool valid = false;
|
||||
RID version;
|
||||
|
||||
|
@ -212,7 +212,7 @@ private:
|
|||
virtual ~FogShaderData();
|
||||
};
|
||||
|
||||
struct FogMaterialData : public RendererRD::MaterialData {
|
||||
struct FogMaterialData : public RendererRD::MaterialStorage::MaterialData {
|
||||
FogShaderData *shader_data = nullptr;
|
||||
RID uniform_set;
|
||||
bool uniform_set_updated;
|
||||
|
@ -223,11 +223,11 @@ private:
|
|||
virtual ~FogMaterialData();
|
||||
};
|
||||
|
||||
RendererRD::ShaderData *_create_fog_shader_func();
|
||||
static RendererRD::ShaderData *_create_fog_shader_funcs();
|
||||
RendererRD::MaterialStorage::ShaderData *_create_fog_shader_func();
|
||||
static RendererRD::MaterialStorage::ShaderData *_create_fog_shader_funcs();
|
||||
|
||||
RendererRD::MaterialData *_create_fog_material_func(FogShaderData *p_shader);
|
||||
static RendererRD::MaterialData *_create_fog_material_funcs(RendererRD::ShaderData *p_shader);
|
||||
RendererRD::MaterialStorage::MaterialData *_create_fog_material_func(FogShaderData *p_shader);
|
||||
static RendererRD::MaterialStorage::MaterialData *_create_fog_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader);
|
||||
|
||||
public:
|
||||
static Fog *get_singleton() { return singleton; }
|
||||
|
|
|
@ -734,7 +734,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re
|
|||
if (j < cascades.size()) {
|
||||
u.append_id(cascades[j].sdf_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -978,7 +978,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re
|
|||
if (j < cascades.size()) {
|
||||
u.append_id(cascades[j].sdf_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -991,7 +991,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re
|
|||
if (j < cascades.size()) {
|
||||
u.append_id(cascades[j].light_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -1004,7 +1004,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re
|
|||
if (j < cascades.size()) {
|
||||
u.append_id(cascades[j].light_aniso_0_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -1017,7 +1017,7 @@ void GI::SDFGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_re
|
|||
if (j < cascades.size()) {
|
||||
u.append_id(cascades[j].light_aniso_1_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -1498,7 +1498,7 @@ void GI::SDFGI::debug_draw(uint32_t p_view_count, const Projection *p_projection
|
|||
if (i < cascades.size()) {
|
||||
u.append_id(cascades[i].sdf_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -1511,7 +1511,7 @@ void GI::SDFGI::debug_draw(uint32_t p_view_count, const Projection *p_projection
|
|||
if (i < cascades.size()) {
|
||||
u.append_id(cascades[i].light_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -1524,7 +1524,7 @@ void GI::SDFGI::debug_draw(uint32_t p_view_count, const Projection *p_projection
|
|||
if (i < cascades.size()) {
|
||||
u.append_id(cascades[i].light_aniso_0_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -1537,7 +1537,7 @@ void GI::SDFGI::debug_draw(uint32_t p_view_count, const Projection *p_projection
|
|||
if (i < cascades.size()) {
|
||||
u.append_id(cascades[i].light_aniso_1_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -3353,9 +3353,9 @@ void GI::init(SkyRD *p_sky) {
|
|||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.binding = 0;
|
||||
if (p_sky->sky_use_cubemap_array) {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_WHITE));
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_WHITE));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -3550,7 +3550,7 @@ void GI::setup_voxel_gi_instances(RID p_render_buffers, const Transform3D &p_tra
|
|||
}
|
||||
|
||||
if (texture == RID()) {
|
||||
texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
}
|
||||
|
||||
if (texture != rb->rbgi.voxel_gi_textures[i]) {
|
||||
|
@ -3761,7 +3761,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
if (rb->sdfgi && j < rb->sdfgi->cascades.size()) {
|
||||
u.append_id(rb->sdfgi->cascades[j].sdf_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -3774,7 +3774,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
if (rb->sdfgi && j < rb->sdfgi->cascades.size()) {
|
||||
u.append_id(rb->sdfgi->cascades[j].light_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -3787,7 +3787,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
if (rb->sdfgi && j < rb->sdfgi->cascades.size()) {
|
||||
u.append_id(rb->sdfgi->cascades[j].light_aniso_0_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -3800,7 +3800,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
if (rb->sdfgi && j < rb->sdfgi->cascades.size()) {
|
||||
u.append_id(rb->sdfgi->cascades[j].light_aniso_1_tex);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -3812,7 +3812,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
if (rb->sdfgi) {
|
||||
u.append_id(rb->sdfgi->occlusion_texture);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -3854,7 +3854,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
if (rb->sdfgi) {
|
||||
u.append_id(rb->sdfgi->lightprobe_texture);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -3876,7 +3876,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
RD::Uniform u;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.binding = 14;
|
||||
RID buffer = p_voxel_gi_buffer.is_valid() ? p_voxel_gi_buffer : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
RID buffer = p_voxel_gi_buffer.is_valid() ? p_voxel_gi_buffer : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
u.append_id(buffer);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -3914,7 +3914,7 @@ void GI::process_gi(RID p_render_buffers, const RID *p_normal_roughness_slices,
|
|||
RD::Uniform u;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_IMAGE;
|
||||
u.binding = 19;
|
||||
RID buffer = p_vrs_slices[v].is_valid() ? p_vrs_slices[v] : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_VRS);
|
||||
RID buffer = p_vrs_slices[v].is_valid() ? p_vrs_slices[v] : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_VRS);
|
||||
u.append_id(buffer);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
|
|
@ -655,7 +655,7 @@ RID SkyRD::Sky::get_textures(SkyTextureSetVersion p_version, RID p_default_shade
|
|||
if (radiance.is_valid() && p_version <= SKY_TEXTURE_SET_QUARTER_RES) {
|
||||
u.append_id(radiance);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -671,9 +671,9 @@ RID SkyRD::Sky::get_textures(SkyTextureSetVersion p_version, RID p_default_shade
|
|||
}
|
||||
} else {
|
||||
if (p_version < SKY_TEXTURE_SET_CUBEMAP) {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE));
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -690,9 +690,9 @@ RID SkyRD::Sky::get_textures(SkyTextureSetVersion p_version, RID p_default_shade
|
|||
}
|
||||
} else {
|
||||
if (p_version < SKY_TEXTURE_SET_CUBEMAP) {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE));
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
}
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
|
@ -789,24 +789,24 @@ Ref<Image> SkyRD::Sky::bake_panorama(float p_energy, int p_roughness_layers, con
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SkyRD
|
||||
|
||||
RendererRD::ShaderData *SkyRD::_create_sky_shader_func() {
|
||||
RendererRD::MaterialStorage::ShaderData *SkyRD::_create_sky_shader_func() {
|
||||
SkyShaderData *shader_data = memnew(SkyShaderData);
|
||||
return shader_data;
|
||||
}
|
||||
|
||||
RendererRD::ShaderData *SkyRD::_create_sky_shader_funcs() {
|
||||
RendererRD::MaterialStorage::ShaderData *SkyRD::_create_sky_shader_funcs() {
|
||||
// !BAS! Why isn't _create_sky_shader_func not just static too?
|
||||
return static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton)->sky._create_sky_shader_func();
|
||||
};
|
||||
|
||||
RendererRD::MaterialData *SkyRD::_create_sky_material_func(SkyShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *SkyRD::_create_sky_material_func(SkyShaderData *p_shader) {
|
||||
SkyMaterialData *material_data = memnew(SkyMaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
//update will happen later anyway so do nothing.
|
||||
return material_data;
|
||||
}
|
||||
|
||||
RendererRD::MaterialData *SkyRD::_create_sky_material_funcs(RendererRD::ShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *SkyRD::_create_sky_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) {
|
||||
// !BAS! same here, we could just make _create_sky_material_func static?
|
||||
return static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton)->sky._create_sky_material_func(static_cast<SkyShaderData *>(p_shader));
|
||||
};
|
||||
|
@ -855,8 +855,8 @@ void SkyRD::init() {
|
|||
}
|
||||
|
||||
// register our shader funds
|
||||
material_storage->shader_set_data_request_function(RendererRD::SHADER_TYPE_SKY, _create_sky_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::SHADER_TYPE_SKY, _create_sky_material_funcs);
|
||||
material_storage->shader_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_SKY, _create_sky_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_SKY, _create_sky_material_funcs);
|
||||
|
||||
{
|
||||
ShaderCompiler::DefaultIdentifierActions actions;
|
||||
|
@ -937,7 +937,7 @@ void sky() {
|
|||
|
||||
material_storage->material_set_shader(sky_shader.default_material, sky_shader.default_shader);
|
||||
|
||||
SkyMaterialData *md = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_shader.default_material, RendererRD::SHADER_TYPE_SKY));
|
||||
SkyMaterialData *md = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_shader.default_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
sky_shader.default_shader_rd = sky_shader.shader.version_get_shader(md->shader_data->version, SKY_VERSION_BACKGROUND);
|
||||
|
||||
sky_scene_state.uniform_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(SkySceneState::UBO));
|
||||
|
@ -999,7 +999,7 @@ void sky() {
|
|||
RD::Uniform u;
|
||||
u.binding = 0;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID vfog = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
RID vfog = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
u.append_id(vfog);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -1033,21 +1033,21 @@ void sky() {
|
|||
RD::Uniform u;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.binding = 0;
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
{
|
||||
RD::Uniform u;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.binding = 1;
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE));
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
{
|
||||
RD::Uniform u;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.binding = 2;
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE));
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
||||
|
@ -1080,7 +1080,7 @@ SkyRD::~SkyRD() {
|
|||
// cleanup anything created in init...
|
||||
RendererRD::MaterialStorage *material_storage = RendererRD::MaterialStorage::get_singleton();
|
||||
|
||||
SkyMaterialData *md = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_shader.default_material, RendererRD::SHADER_TYPE_SKY));
|
||||
SkyMaterialData *md = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_shader.default_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
sky_shader.shader.version_free(md->shader_data->version);
|
||||
RD::get_singleton()->free(sky_scene_state.directional_light_buffer);
|
||||
RD::get_singleton()->free(sky_scene_state.uniform_buffer);
|
||||
|
@ -1122,7 +1122,7 @@ void SkyRD::setup(RID p_env, RID p_render_buffers, const PagedArray<RID> &p_ligh
|
|||
sky_material = sky_get_material(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
|
||||
if (sky_material.is_valid()) {
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -1130,7 +1130,7 @@ void SkyRD::setup(RID p_env, RID p_render_buffers, const PagedArray<RID> &p_ligh
|
|||
|
||||
if (!material) {
|
||||
sky_material = sky_shader.default_material;
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
|
@ -1330,7 +1330,7 @@ void SkyRD::update(RID p_env, const Projection &p_projection, const Transform3D
|
|||
SkyMaterialData *material = nullptr;
|
||||
|
||||
if (sky_material.is_valid()) {
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -1338,7 +1338,7 @@ void SkyRD::update(RID p_env, const Projection &p_projection, const Transform3D
|
|||
|
||||
if (!material) {
|
||||
sky_material = sky_shader.default_material;
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
|
@ -1506,7 +1506,7 @@ void SkyRD::draw(RID p_env, bool p_can_continue_color, bool p_can_continue_depth
|
|||
sky_material = sky_get_material(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
|
||||
if (sky_material.is_valid()) {
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -1514,13 +1514,13 @@ void SkyRD::draw(RID p_env, bool p_can_continue_color, bool p_can_continue_depth
|
|||
|
||||
if (!material) {
|
||||
sky_material = sky_shader.default_material;
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
}
|
||||
|
||||
if (background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) {
|
||||
sky_material = sky_scene_state.fog_material;
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
|
@ -1610,7 +1610,7 @@ void SkyRD::update_res_buffers(RID p_env, uint32_t p_view_count, const Projectio
|
|||
sky_material = sky_get_material(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
|
||||
if (sky_material.is_valid()) {
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -1618,7 +1618,7 @@ void SkyRD::update_res_buffers(RID p_env, uint32_t p_view_count, const Projectio
|
|||
|
||||
if (!material) {
|
||||
sky_material = sky_shader.default_material;
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
|
@ -1698,7 +1698,7 @@ void SkyRD::draw(RD::DrawListID p_draw_list, RID p_env, RID p_fb, uint32_t p_vie
|
|||
sky_material = sky_get_material(RendererSceneRenderRD::get_singleton()->environment_get_sky(p_env));
|
||||
|
||||
if (sky_material.is_valid()) {
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -1706,13 +1706,13 @@ void SkyRD::draw(RD::DrawListID p_draw_list, RID p_env, RID p_fb, uint32_t p_vie
|
|||
|
||||
if (!material) {
|
||||
sky_material = sky_shader.default_material;
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
}
|
||||
|
||||
if (background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) {
|
||||
sky_material = sky_scene_state.fog_material;
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::SHADER_TYPE_SKY));
|
||||
material = static_cast<SkyMaterialData *>(material_storage->material_get_data(sky_material, RendererRD::MaterialStorage::SHADER_TYPE_SKY));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!material);
|
||||
|
|
|
@ -107,7 +107,7 @@ private:
|
|||
// 128 is the max size of a push constant. We can replace "pad" but we can't add any more.
|
||||
};
|
||||
|
||||
struct SkyShaderData : public RendererRD::ShaderData {
|
||||
struct SkyShaderData : public RendererRD::MaterialStorage::ShaderData {
|
||||
bool valid = false;
|
||||
RID version;
|
||||
|
||||
|
@ -231,7 +231,7 @@ public:
|
|||
RID default_shader_rd;
|
||||
} sky_shader;
|
||||
|
||||
struct SkyMaterialData : public RendererRD::MaterialData {
|
||||
struct SkyMaterialData : public RendererRD::MaterialStorage::MaterialData {
|
||||
SkyShaderData *shader_data = nullptr;
|
||||
RID uniform_set;
|
||||
bool uniform_set_updated;
|
||||
|
@ -285,11 +285,11 @@ public:
|
|||
mutable RID_Owner<Sky, true> sky_owner;
|
||||
int roughness_layers;
|
||||
|
||||
RendererRD::ShaderData *_create_sky_shader_func();
|
||||
static RendererRD::ShaderData *_create_sky_shader_funcs();
|
||||
RendererRD::MaterialStorage::ShaderData *_create_sky_shader_func();
|
||||
static RendererRD::MaterialStorage::ShaderData *_create_sky_shader_funcs();
|
||||
|
||||
RendererRD::MaterialData *_create_sky_material_func(SkyShaderData *p_shader);
|
||||
static RendererRD::MaterialData *_create_sky_material_funcs(RendererRD::ShaderData *p_shader);
|
||||
RendererRD::MaterialStorage::MaterialData *_create_sky_material_func(SkyShaderData *p_shader);
|
||||
static RendererRD::MaterialStorage::MaterialData *_create_sky_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader);
|
||||
|
||||
SkyRD();
|
||||
void init();
|
||||
|
|
|
@ -2433,7 +2433,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
if (p_radiance_texture.is_valid()) {
|
||||
radiance_texture = p_radiance_texture;
|
||||
} else {
|
||||
radiance_texture = texture_storage->texture_rd_get_default(is_using_radiance_cubemap_array() ? RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
radiance_texture = texture_storage->texture_rd_get_default(is_using_radiance_cubemap_array() ? RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
}
|
||||
RD::Uniform u;
|
||||
u.binding = 2;
|
||||
|
@ -2450,7 +2450,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
if (ref_texture.is_valid()) {
|
||||
u.append_id(ref_texture);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2464,7 +2464,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
texture = shadow_atlas_get_texture(p_render_data->shadow_atlas);
|
||||
}
|
||||
if (!texture.is_valid()) {
|
||||
texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
}
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
|
@ -2476,7 +2476,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
if (p_use_directional_shadow_atlas && directional_shadow_get_texture().is_valid()) {
|
||||
u.append_id(directional_shadow_get_texture());
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2485,7 +2485,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
u.binding = 6;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
for (uint32_t i = 0; i < scene_state.max_lightmaps; i++) {
|
||||
if (p_render_data && i < p_render_data->lightmaps->size()) {
|
||||
RID base = lightmap_instance_get_lightmap((*p_render_data->lightmaps)[i]);
|
||||
|
@ -2503,7 +2503,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
RD::Uniform u;
|
||||
u.binding = 7;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
for (int i = 0; i < MAX_VOXEL_GI_INSTANCESS; i++) {
|
||||
if (p_render_data && i < (int)p_render_data->voxel_gi_instances->size()) {
|
||||
RID tex = gi.voxel_gi_instance_get_texture((*p_render_data->voxel_gi_instances)[i]);
|
||||
|
@ -2533,7 +2533,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
u.binding = 9;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID dbt = rb ? render_buffers_get_back_depth_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = (dbt.is_valid()) ? dbt : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
RID texture = (dbt.is_valid()) ? dbt : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2542,7 +2542,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
u.binding = 10;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID bbt = rb ? render_buffers_get_back_buffer_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = bbt.is_valid() ? bbt : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
RID texture = bbt.is_valid() ? bbt : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2552,7 +2552,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
RD::Uniform u;
|
||||
u.binding = 11;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID texture = rb && rb->normal_roughness_buffer.is_valid() ? rb->normal_roughness_buffer : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_NORMAL);
|
||||
RID texture = rb && rb->normal_roughness_buffer.is_valid() ? rb->normal_roughness_buffer : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_NORMAL);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2562,7 +2562,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
u.binding = 12;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID aot = rb ? render_buffers_get_ao_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = aot.is_valid() ? aot : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
RID texture = aot.is_valid() ? aot : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2572,7 +2572,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
u.binding = 13;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID ambient_buffer = rb ? render_buffers_get_gi_ambient_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = ambient_buffer.is_valid() ? ambient_buffer : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
RID texture = ambient_buffer.is_valid() ? ambient_buffer : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2582,7 +2582,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
u.binding = 14;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID reflection_buffer = rb ? render_buffers_get_gi_reflection_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = reflection_buffer.is_valid() ? reflection_buffer : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
RID texture = reflection_buffer.is_valid() ? reflection_buffer : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2594,7 +2594,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
if (rb && render_buffers_is_sdfgi_enabled(p_render_data->render_buffers)) {
|
||||
t = render_buffers_get_sdfgi_irradiance_probes(p_render_data->render_buffers);
|
||||
} else {
|
||||
t = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
t = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
}
|
||||
u.append_id(t);
|
||||
uniforms.push_back(u);
|
||||
|
@ -2606,7 +2606,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
if (rb && render_buffers_is_sdfgi_enabled(p_render_data->render_buffers)) {
|
||||
u.append_id(render_buffers_get_sdfgi_occlusion_texture(p_render_data->render_buffers));
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2625,10 +2625,10 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
if (rb && render_buffers_has_volumetric_fog(p_render_data->render_buffers)) {
|
||||
vfog = render_buffers_get_volumetric_fog_texture(p_render_data->render_buffers);
|
||||
if (vfog.is_null()) {
|
||||
vfog = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
vfog = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
}
|
||||
} else {
|
||||
vfog = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
vfog = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
}
|
||||
u.append_id(vfog);
|
||||
uniforms.push_back(u);
|
||||
|
@ -2638,7 +2638,7 @@ RID RenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_rend
|
|||
u.binding = 19;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID ssil = rb ? render_buffers_get_ssil_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = ssil.is_valid() ? ssil : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
RID texture = ssil.is_valid() ? ssil : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2667,7 +2667,7 @@ RID RenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_te
|
|||
}
|
||||
{
|
||||
// No radiance texture.
|
||||
RID radiance_texture = texture_storage->texture_rd_get_default(is_using_radiance_cubemap_array() ? RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
RID radiance_texture = texture_storage->texture_rd_get_default(is_using_radiance_cubemap_array() ? RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
RD::Uniform u;
|
||||
u.binding = 2;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
|
@ -2677,7 +2677,7 @@ RID RenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_te
|
|||
|
||||
{
|
||||
// No reflection atlas.
|
||||
RID ref_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK);
|
||||
RID ref_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK);
|
||||
RD::Uniform u;
|
||||
u.binding = 3;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
|
@ -2690,7 +2690,7 @@ RID RenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_te
|
|||
RD::Uniform u;
|
||||
u.binding = 4;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
RID texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2700,7 +2700,7 @@ RID RenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_te
|
|||
RD::Uniform u;
|
||||
u.binding = 5;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
RID texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2711,7 +2711,7 @@ RID RenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_te
|
|||
u.binding = 6;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
for (uint32_t i = 0; i < scene_state.max_lightmaps; i++) {
|
||||
u.append_id(default_tex);
|
||||
}
|
||||
|
@ -2725,7 +2725,7 @@ RID RenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_te
|
|||
u.binding = 7;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
for (int i = 0; i < MAX_VOXEL_GI_INSTANCESS; i++) {
|
||||
u.append_id(default_tex);
|
||||
}
|
||||
|
@ -2860,7 +2860,7 @@ void RenderForwardClustered::_geometry_instance_add_surface_with_material(Geomet
|
|||
void *surface_shadow = nullptr;
|
||||
if (!p_material->shader_data->uses_particle_trails && !p_material->shader_data->writes_modelview_or_projection && !p_material->shader_data->uses_vertex && !p_material->shader_data->uses_position && !p_material->shader_data->uses_discard && !p_material->shader_data->uses_depth_pre_pass && !p_material->shader_data->uses_alpha_clip && p_material->shader_data->cull_mode == SceneShaderForwardClustered::ShaderData::CULL_BACK) {
|
||||
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_SHARED_SHADOW_MATERIAL;
|
||||
material_shadow = static_cast<SceneShaderForwardClustered::MaterialData *>(RendererRD::MaterialStorage::get_singleton()->material_get_data(scene_shader.default_material, RendererRD::SHADER_TYPE_3D));
|
||||
material_shadow = static_cast<SceneShaderForwardClustered::MaterialData *>(RendererRD::MaterialStorage::get_singleton()->material_get_data(scene_shader.default_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
|
||||
RID shadow_mesh = mesh_storage->mesh_get_shadow_mesh(p_mesh);
|
||||
|
||||
|
@ -2921,7 +2921,7 @@ void RenderForwardClustered::_geometry_instance_add_surface_with_material_chain(
|
|||
|
||||
while (material->next_pass.is_valid()) {
|
||||
RID next_pass = material->next_pass;
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(next_pass, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(next_pass, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
break;
|
||||
}
|
||||
|
@ -2941,7 +2941,7 @@ void RenderForwardClustered::_geometry_instance_add_surface(GeometryInstanceForw
|
|||
SceneShaderForwardClustered::MaterialData *material = nullptr;
|
||||
|
||||
if (m_src.is_valid()) {
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -2952,7 +2952,7 @@ void RenderForwardClustered::_geometry_instance_add_surface(GeometryInstanceForw
|
|||
material_storage->material_update_dependency(m_src, &ginstance->data->dependency_tracker);
|
||||
}
|
||||
} else {
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(scene_shader.default_material, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(scene_shader.default_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
m_src = scene_shader.default_material;
|
||||
}
|
||||
|
||||
|
@ -2963,7 +2963,7 @@ void RenderForwardClustered::_geometry_instance_add_surface(GeometryInstanceForw
|
|||
if (ginstance->data->material_overlay.is_valid()) {
|
||||
m_src = ginstance->data->material_overlay;
|
||||
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardClustered::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (material && material->shader_data->valid) {
|
||||
if (ginstance->data->dirty_dependencies) {
|
||||
material_storage->material_update_dependency(m_src, &ginstance->data->dependency_tracker);
|
||||
|
|
|
@ -488,7 +488,7 @@ SceneShaderForwardClustered::ShaderData::~ShaderData() {
|
|||
}
|
||||
}
|
||||
|
||||
RendererRD::ShaderData *SceneShaderForwardClustered::_create_shader_func() {
|
||||
RendererRD::MaterialStorage::ShaderData *SceneShaderForwardClustered::_create_shader_func() {
|
||||
ShaderData *shader_data = memnew(ShaderData);
|
||||
singleton->shader_list.add(&shader_data->shader_list_element);
|
||||
return shader_data;
|
||||
|
@ -512,7 +512,7 @@ SceneShaderForwardClustered::MaterialData::~MaterialData() {
|
|||
free_parameters_uniform_set(uniform_set);
|
||||
}
|
||||
|
||||
RendererRD::MaterialData *SceneShaderForwardClustered::_create_material_func(ShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *SceneShaderForwardClustered::_create_material_func(ShaderData *p_shader) {
|
||||
MaterialData *material_data = memnew(MaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
//update will happen later anyway so do nothing.
|
||||
|
@ -610,8 +610,8 @@ void SceneShaderForwardClustered::init(const String p_defines) {
|
|||
|
||||
valid_color_pass_pipelines.insert(PIPELINE_COLOR_PASS_FLAG_MOTION_VECTORS);
|
||||
|
||||
material_storage->shader_set_data_request_function(RendererRD::SHADER_TYPE_3D, _create_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::SHADER_TYPE_3D, _create_material_funcs);
|
||||
material_storage->shader_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_3D, _create_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_3D, _create_material_funcs);
|
||||
|
||||
{
|
||||
//shader compiler
|
||||
|
@ -817,7 +817,7 @@ void fragment() {
|
|||
material_storage->material_initialize(default_material);
|
||||
material_storage->material_set_shader(default_material, default_shader);
|
||||
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(default_material, RendererRD::SHADER_TYPE_3D));
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(default_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
default_shader_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_COLOR_PASS);
|
||||
default_shader_sdfgi_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_DEPTH_PASS_WITH_SDF);
|
||||
|
||||
|
@ -845,7 +845,7 @@ void fragment() {
|
|||
material_storage->material_initialize(overdraw_material);
|
||||
material_storage->material_set_shader(overdraw_material, overdraw_material_shader);
|
||||
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(overdraw_material, RendererRD::SHADER_TYPE_3D));
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(overdraw_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
overdraw_material_shader_ptr = md->shader_data;
|
||||
overdraw_material_uniform_set = md->uniform_set;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
SHADER_SPECIALIZATION_DIRECTIONAL_SOFT_SHADOWS = 1 << 3,
|
||||
};
|
||||
|
||||
struct ShaderData : public RendererRD::ShaderData {
|
||||
struct ShaderData : public RendererRD::MaterialStorage::ShaderData {
|
||||
enum BlendMode { //used internally
|
||||
BLEND_MODE_MIX,
|
||||
BLEND_MODE_ADD,
|
||||
|
@ -198,12 +198,12 @@ public:
|
|||
|
||||
SelfList<ShaderData>::List shader_list;
|
||||
|
||||
RendererRD::ShaderData *_create_shader_func();
|
||||
static RendererRD::ShaderData *_create_shader_funcs() {
|
||||
RendererRD::MaterialStorage::ShaderData *_create_shader_func();
|
||||
static RendererRD::MaterialStorage::ShaderData *_create_shader_funcs() {
|
||||
return static_cast<SceneShaderForwardClustered *>(singleton)->_create_shader_func();
|
||||
}
|
||||
|
||||
struct MaterialData : public RendererRD::MaterialData {
|
||||
struct MaterialData : public RendererRD::MaterialStorage::MaterialData {
|
||||
ShaderData *shader_data = nullptr;
|
||||
RID uniform_set;
|
||||
uint64_t last_pass = 0;
|
||||
|
@ -216,8 +216,8 @@ public:
|
|||
virtual ~MaterialData();
|
||||
};
|
||||
|
||||
RendererRD::MaterialData *_create_material_func(ShaderData *p_shader);
|
||||
static RendererRD::MaterialData *_create_material_funcs(RendererRD::ShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *_create_material_func(ShaderData *p_shader);
|
||||
static RendererRD::MaterialStorage::MaterialData *_create_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) {
|
||||
return static_cast<SceneShaderForwardClustered *>(singleton)->_create_material_func(static_cast<ShaderData *>(p_shader));
|
||||
}
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
if (p_radiance_texture.is_valid()) {
|
||||
radiance_texture = p_radiance_texture;
|
||||
} else {
|
||||
radiance_texture = texture_storage->texture_rd_get_default(is_using_radiance_cubemap_array() ? RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
radiance_texture = texture_storage->texture_rd_get_default(is_using_radiance_cubemap_array() ? RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK : RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
}
|
||||
RD::Uniform u;
|
||||
u.binding = 2;
|
||||
|
@ -354,7 +354,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
if (ref_texture.is_valid()) {
|
||||
u.append_id(ref_texture);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
texture = shadow_atlas_get_texture(p_render_data->shadow_atlas);
|
||||
}
|
||||
if (!texture.is_valid()) {
|
||||
texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
}
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
|
@ -380,7 +380,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
if (p_use_directional_shadow_atlas && directional_shadow_get_texture().is_valid()) {
|
||||
u.append_id(directional_shadow_get_texture());
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH));
|
||||
u.append_id(texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
u.binding = 6;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
for (uint32_t i = 0; i < scene_state.max_lightmaps; i++) {
|
||||
if (p_render_data && i < p_render_data->lightmaps->size()) {
|
||||
RID base = lightmap_instance_get_lightmap((*p_render_data->lightmaps)[i]);
|
||||
|
@ -412,7 +412,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
u.binding = 7;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
u.ids.resize(MAX_VOXEL_GI_INSTANCESS);
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
RID default_tex = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
for (int i = 0; i < MAX_VOXEL_GI_INSTANCESS; i++) {
|
||||
if (i < (int)p_voxel_gi_instances.size()) {
|
||||
RID tex = gi.voxel_gi_instance_get_texture(p_voxel_gi_instances[i]);
|
||||
|
@ -443,7 +443,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
u.binding = 9;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID dbt = rb ? render_buffers_get_back_depth_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = (dbt.is_valid()) ? dbt : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
RID texture = (dbt.is_valid()) ? dbt : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_DEPTH);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_
|
|||
u.binding = 10;
|
||||
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
|
||||
RID bbt = rb ? render_buffers_get_back_buffer_texture(p_render_data->render_buffers) : RID();
|
||||
RID texture = bbt.is_valid() ? bbt : texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
RID texture = bbt.is_valid() ? bbt : texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
u.append_id(texture);
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -2227,7 +2227,7 @@ void RenderForwardMobile::_geometry_instance_add_surface_with_material(GeometryI
|
|||
void *surface_shadow = nullptr;
|
||||
if (!p_material->shader_data->uses_particle_trails && !p_material->shader_data->writes_modelview_or_projection && !p_material->shader_data->uses_vertex && !p_material->shader_data->uses_discard && !p_material->shader_data->uses_depth_pre_pass && !p_material->shader_data->uses_alpha_clip) {
|
||||
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_SHARED_SHADOW_MATERIAL;
|
||||
material_shadow = static_cast<SceneShaderForwardMobile::MaterialData *>(RendererRD::MaterialStorage::get_singleton()->material_get_data(scene_shader.default_material, RendererRD::SHADER_TYPE_3D));
|
||||
material_shadow = static_cast<SceneShaderForwardMobile::MaterialData *>(RendererRD::MaterialStorage::get_singleton()->material_get_data(scene_shader.default_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
|
||||
RID shadow_mesh = mesh_storage->mesh_get_shadow_mesh(p_mesh);
|
||||
|
||||
|
@ -2286,7 +2286,7 @@ void RenderForwardMobile::_geometry_instance_add_surface_with_material_chain(Geo
|
|||
|
||||
while (material->next_pass.is_valid()) {
|
||||
RID next_pass = material->next_pass;
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(next_pass, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(next_pass, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
break;
|
||||
}
|
||||
|
@ -2306,7 +2306,7 @@ void RenderForwardMobile::_geometry_instance_add_surface(GeometryInstanceForward
|
|||
SceneShaderForwardMobile::MaterialData *material = nullptr;
|
||||
|
||||
if (m_src.is_valid()) {
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (!material || !material->shader_data->valid) {
|
||||
material = nullptr;
|
||||
}
|
||||
|
@ -2317,7 +2317,7 @@ void RenderForwardMobile::_geometry_instance_add_surface(GeometryInstanceForward
|
|||
material_storage->material_update_dependency(m_src, &ginstance->data->dependency_tracker);
|
||||
}
|
||||
} else {
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(scene_shader.default_material, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(scene_shader.default_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
m_src = scene_shader.default_material;
|
||||
}
|
||||
|
||||
|
@ -2328,7 +2328,7 @@ void RenderForwardMobile::_geometry_instance_add_surface(GeometryInstanceForward
|
|||
if (ginstance->data->material_overlay.is_valid()) {
|
||||
m_src = ginstance->data->material_overlay;
|
||||
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::SHADER_TYPE_3D));
|
||||
material = static_cast<SceneShaderForwardMobile::MaterialData *>(material_storage->material_get_data(m_src, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
if (material && material->shader_data->valid) {
|
||||
if (ginstance->data->dirty_dependencies) {
|
||||
material_storage->material_update_dependency(m_src, &ginstance->data->dependency_tracker);
|
||||
|
|
|
@ -445,7 +445,7 @@ SceneShaderForwardMobile::ShaderData::~ShaderData() {
|
|||
}
|
||||
}
|
||||
|
||||
RendererRD::ShaderData *SceneShaderForwardMobile::_create_shader_func() {
|
||||
RendererRD::MaterialStorage::ShaderData *SceneShaderForwardMobile::_create_shader_func() {
|
||||
ShaderData *shader_data = memnew(ShaderData);
|
||||
singleton->shader_list.add(&shader_data->shader_list_element);
|
||||
return shader_data;
|
||||
|
@ -469,7 +469,7 @@ SceneShaderForwardMobile::MaterialData::~MaterialData() {
|
|||
free_parameters_uniform_set(uniform_set);
|
||||
}
|
||||
|
||||
RendererRD::MaterialData *SceneShaderForwardMobile::_create_material_func(ShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *SceneShaderForwardMobile::_create_material_func(ShaderData *p_shader) {
|
||||
MaterialData *material_data = memnew(MaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
//update will happen later anyway so do nothing.
|
||||
|
@ -512,8 +512,8 @@ void SceneShaderForwardMobile::init(const String p_defines) {
|
|||
}
|
||||
}
|
||||
|
||||
material_storage->shader_set_data_request_function(RendererRD::SHADER_TYPE_3D, _create_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::SHADER_TYPE_3D, _create_material_funcs);
|
||||
material_storage->shader_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_3D, _create_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_3D, _create_material_funcs);
|
||||
|
||||
{
|
||||
//shader compiler
|
||||
|
@ -716,7 +716,7 @@ void fragment() {
|
|||
material_storage->material_initialize(default_material);
|
||||
material_storage->material_set_shader(default_material, default_shader);
|
||||
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(default_material, RendererRD::SHADER_TYPE_3D));
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(default_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
default_shader_rd = shader.version_get_shader(md->shader_data->version, SHADER_VERSION_COLOR_PASS);
|
||||
|
||||
default_material_shader_ptr = md->shader_data;
|
||||
|
@ -743,7 +743,7 @@ void fragment() {
|
|||
material_storage->material_initialize(overdraw_material);
|
||||
material_storage->material_set_shader(overdraw_material, overdraw_material_shader);
|
||||
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(overdraw_material, RendererRD::SHADER_TYPE_3D));
|
||||
MaterialData *md = static_cast<MaterialData *>(material_storage->material_get_data(overdraw_material, RendererRD::MaterialStorage::SHADER_TYPE_3D));
|
||||
overdraw_material_shader_ptr = md->shader_data;
|
||||
overdraw_material_uniform_set = md->uniform_set;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
SHADER_VERSION_MAX
|
||||
};
|
||||
|
||||
struct ShaderData : public RendererRD::ShaderData {
|
||||
struct ShaderData : public RendererRD::MaterialStorage::ShaderData {
|
||||
enum BlendMode { //used internally
|
||||
BLEND_MODE_MIX,
|
||||
BLEND_MODE_ADD,
|
||||
|
@ -157,12 +157,12 @@ public:
|
|||
virtual ~ShaderData();
|
||||
};
|
||||
|
||||
RendererRD::ShaderData *_create_shader_func();
|
||||
static RendererRD::ShaderData *_create_shader_funcs() {
|
||||
RendererRD::MaterialStorage::ShaderData *_create_shader_func();
|
||||
static RendererRD::MaterialStorage::ShaderData *_create_shader_funcs() {
|
||||
return static_cast<SceneShaderForwardMobile *>(singleton)->_create_shader_func();
|
||||
}
|
||||
|
||||
struct MaterialData : public RendererRD::MaterialData {
|
||||
struct MaterialData : public RendererRD::MaterialStorage::MaterialData {
|
||||
ShaderData *shader_data = nullptr;
|
||||
RID uniform_set;
|
||||
uint64_t last_pass = 0;
|
||||
|
@ -177,8 +177,8 @@ public:
|
|||
|
||||
SelfList<ShaderData>::List shader_list;
|
||||
|
||||
RendererRD::MaterialData *_create_material_func(ShaderData *p_shader);
|
||||
static RendererRD::MaterialData *_create_material_funcs(RendererRD::ShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *_create_material_func(ShaderData *p_shader);
|
||||
static RendererRD::MaterialStorage::MaterialData *_create_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) {
|
||||
return static_cast<SceneShaderForwardMobile *>(singleton)->_create_material_func(static_cast<ShaderData *>(p_shader));
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve
|
|||
vd.stride = 0;
|
||||
|
||||
descriptions.write[1] = vd;
|
||||
buffers.write[1] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::DEFAULT_RD_BUFFER_COLOR);
|
||||
buffers.write[1] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::MeshStorage::DEFAULT_RD_BUFFER_COLOR);
|
||||
}
|
||||
|
||||
//uvs
|
||||
|
@ -220,7 +220,7 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve
|
|||
vd.stride = 0;
|
||||
|
||||
descriptions.write[2] = vd;
|
||||
buffers.write[2] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::DEFAULT_RD_BUFFER_TEX_UV);
|
||||
buffers.write[2] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::MeshStorage::DEFAULT_RD_BUFFER_TEX_UV);
|
||||
}
|
||||
|
||||
//bones
|
||||
|
@ -253,7 +253,7 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve
|
|||
vd.stride = 0;
|
||||
|
||||
descriptions.write[3] = vd;
|
||||
buffers.write[3] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::DEFAULT_RD_BUFFER_BONES);
|
||||
buffers.write[3] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::MeshStorage::DEFAULT_RD_BUFFER_BONES);
|
||||
}
|
||||
|
||||
//weights
|
||||
|
@ -286,7 +286,7 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve
|
|||
vd.stride = 0;
|
||||
|
||||
descriptions.write[4] = vd;
|
||||
buffers.write[4] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::DEFAULT_RD_BUFFER_WEIGHTS);
|
||||
buffers.write[4] = mesh_storage->mesh_get_default_rd_buffer(RendererRD::MeshStorage::DEFAULT_RD_BUFFER_WEIGHTS);
|
||||
}
|
||||
|
||||
//check that everything is as it should be
|
||||
|
@ -988,7 +988,7 @@ RID RendererCanvasRenderRD::_create_base_uniform_set(RID p_to_render_target, boo
|
|||
} else {
|
||||
screen = texture_storage->render_target_get_rd_backbuffer(p_to_render_target);
|
||||
if (screen.is_null()) { //unallocated backbuffer
|
||||
screen = RendererRD::TextureStorage::get_singleton()->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE);
|
||||
screen = RendererRD::TextureStorage::get_singleton()->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
}
|
||||
}
|
||||
u.append_id(screen);
|
||||
|
@ -1115,7 +1115,7 @@ void RendererCanvasRenderRD::_render_items(RID p_to_render_target, int p_item_co
|
|||
if (material != prev_material) {
|
||||
CanvasMaterialData *material_data = nullptr;
|
||||
if (material.is_valid()) {
|
||||
material_data = static_cast<CanvasMaterialData *>(material_storage->material_get_data(material, RendererRD::SHADER_TYPE_2D));
|
||||
material_data = static_cast<CanvasMaterialData *>(material_storage->material_get_data(material, RendererRD::MaterialStorage::SHADER_TYPE_2D));
|
||||
}
|
||||
|
||||
if (material_data) {
|
||||
|
@ -1383,7 +1383,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
|
|||
RID material = ci->material_owner == nullptr ? ci->material : ci->material_owner->material;
|
||||
|
||||
if (material.is_valid()) {
|
||||
CanvasMaterialData *md = static_cast<CanvasMaterialData *>(material_storage->material_get_data(material, RendererRD::SHADER_TYPE_2D));
|
||||
CanvasMaterialData *md = static_cast<CanvasMaterialData *>(material_storage->material_get_data(material, RendererRD::MaterialStorage::SHADER_TYPE_2D));
|
||||
if (md && md->shader_data->valid) {
|
||||
if (md->shader_data->uses_screen_texture && canvas_group_owner == nullptr) {
|
||||
if (!material_screen_texture_found) {
|
||||
|
@ -2261,7 +2261,7 @@ RendererCanvasRenderRD::CanvasShaderData::~CanvasShaderData() {
|
|||
}
|
||||
}
|
||||
|
||||
RendererRD::ShaderData *RendererCanvasRenderRD::_create_shader_func() {
|
||||
RendererRD::MaterialStorage::ShaderData *RendererCanvasRenderRD::_create_shader_func() {
|
||||
CanvasShaderData *shader_data = memnew(CanvasShaderData);
|
||||
return shader_data;
|
||||
}
|
||||
|
@ -2276,7 +2276,7 @@ RendererCanvasRenderRD::CanvasMaterialData::~CanvasMaterialData() {
|
|||
free_parameters_uniform_set(uniform_set);
|
||||
}
|
||||
|
||||
RendererRD::MaterialData *RendererCanvasRenderRD::_create_material_func(CanvasShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *RendererCanvasRenderRD::_create_material_func(CanvasShaderData *p_shader) {
|
||||
CanvasMaterialData *material_data = memnew(CanvasMaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
//update will happen later anyway so do nothing.
|
||||
|
@ -2629,8 +2629,8 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
|
|||
state.shadow_texture_size = GLOBAL_GET("rendering/2d/shadow_atlas/size");
|
||||
|
||||
//create functions for shader and material
|
||||
material_storage->shader_set_data_request_function(RendererRD::SHADER_TYPE_2D, _create_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::SHADER_TYPE_2D, _create_material_funcs);
|
||||
material_storage->shader_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_2D, _create_shader_funcs);
|
||||
material_storage->material_set_data_request_function(RendererRD::MaterialStorage::SHADER_TYPE_2D, _create_material_funcs);
|
||||
|
||||
state.time = 0;
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
|
|||
ShaderCompiler compiler;
|
||||
} shader;
|
||||
|
||||
struct CanvasShaderData : public RendererRD::ShaderData {
|
||||
struct CanvasShaderData : public RendererRD::MaterialStorage::ShaderData {
|
||||
enum BlendMode { //used internally
|
||||
BLEND_MODE_MIX,
|
||||
BLEND_MODE_ADD,
|
||||
|
@ -193,12 +193,12 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
|
|||
virtual ~CanvasShaderData();
|
||||
};
|
||||
|
||||
RendererRD::ShaderData *_create_shader_func();
|
||||
static RendererRD::ShaderData *_create_shader_funcs() {
|
||||
RendererRD::MaterialStorage::ShaderData *_create_shader_func();
|
||||
static RendererRD::MaterialStorage::ShaderData *_create_shader_funcs() {
|
||||
return static_cast<RendererCanvasRenderRD *>(singleton)->_create_shader_func();
|
||||
}
|
||||
|
||||
struct CanvasMaterialData : public RendererRD::MaterialData {
|
||||
struct CanvasMaterialData : public RendererRD::MaterialStorage::MaterialData {
|
||||
CanvasShaderData *shader_data = nullptr;
|
||||
RID uniform_set;
|
||||
|
||||
|
@ -208,8 +208,8 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
|
|||
virtual ~CanvasMaterialData();
|
||||
};
|
||||
|
||||
RendererRD::MaterialData *_create_material_func(CanvasShaderData *p_shader);
|
||||
static RendererRD::MaterialData *_create_material_funcs(RendererRD::ShaderData *p_shader) {
|
||||
RendererRD::MaterialStorage::MaterialData *_create_material_func(CanvasShaderData *p_shader);
|
||||
static RendererRD::MaterialStorage::MaterialData *_create_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) {
|
||||
return static_cast<RendererCanvasRenderRD *>(singleton)->_create_material_func(static_cast<CanvasShaderData *>(p_shader));
|
||||
}
|
||||
|
||||
|
|
|
@ -2007,7 +2007,7 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
|
|||
tonemap.exposure_texture = rb->luminance.current;
|
||||
tonemap.auto_exposure_grey = environment_get_auto_exp_scale(p_render_data->environment);
|
||||
} else {
|
||||
tonemap.exposure_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE);
|
||||
tonemap.exposure_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
}
|
||||
|
||||
if (can_use_effects && p_render_data->environment.is_valid() && environment_get_glow_enabled(p_render_data->environment)) {
|
||||
|
@ -2026,12 +2026,12 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
|
|||
tonemap.glow_map = texture_storage->texture_get_rd_texture(environment_get_glow_map(p_render_data->environment));
|
||||
} else {
|
||||
tonemap.glow_map_strength = 0.0f;
|
||||
tonemap.glow_map = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE);
|
||||
tonemap.glow_map = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
}
|
||||
|
||||
} else {
|
||||
tonemap.glow_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
tonemap.glow_map = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE);
|
||||
tonemap.glow_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
tonemap.glow_map = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
}
|
||||
|
||||
if (rb->screen_space_aa == RS::VIEWPORT_SCREEN_SPACE_AA_FXAA) {
|
||||
|
@ -2053,7 +2053,7 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
|
|||
|
||||
tonemap.use_color_correction = false;
|
||||
tonemap.use_1d_color_correction = false;
|
||||
tonemap.color_correction_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
tonemap.color_correction_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
|
||||
if (can_use_effects && p_render_data->environment.is_valid()) {
|
||||
tonemap.use_bcs = environment_get_adjustments_enabled(p_render_data->environment);
|
||||
|
@ -2123,14 +2123,14 @@ void RendererSceneRenderRD::_post_process_subpass(RID p_source_texture, RID p_fr
|
|||
}
|
||||
|
||||
tonemap.use_glow = false;
|
||||
tonemap.glow_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
tonemap.glow_map = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE);
|
||||
tonemap.glow_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
tonemap.glow_map = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
tonemap.use_auto_exposure = false;
|
||||
tonemap.exposure_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_WHITE);
|
||||
tonemap.exposure_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
|
||||
tonemap.use_color_correction = false;
|
||||
tonemap.use_1d_color_correction = false;
|
||||
tonemap.color_correction_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
tonemap.color_correction_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
|
||||
if (can_use_effects && p_render_data->environment.is_valid()) {
|
||||
tonemap.use_bcs = environment_get_adjustments_enabled(p_render_data->environment);
|
||||
|
@ -2174,7 +2174,7 @@ void RendererSceneRenderRD::_render_buffers_debug_draw(RID p_render_buffers, RID
|
|||
RID shadow_atlas_texture = shadow_atlas_get_texture(p_shadow_atlas);
|
||||
|
||||
if (shadow_atlas_texture.is_null()) {
|
||||
shadow_atlas_texture = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_BLACK);
|
||||
shadow_atlas_texture = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
}
|
||||
|
||||
Size2 rtsize = texture_storage->render_target_get_size(rb->render_target);
|
||||
|
|
|
@ -56,7 +56,7 @@ LightStorage::LightStorage() {
|
|||
}
|
||||
|
||||
for (int i = 0; i < lightmap_textures.size(); i++) {
|
||||
lightmap_textures.write[i] = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
lightmap_textures.write[i] = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,6 +366,13 @@ AABB LightStorage::light_get_aabb(RID p_light) const {
|
|||
ERR_FAIL_V(AABB());
|
||||
}
|
||||
|
||||
Dependency *LightStorage::light_get_dependency(RID p_light) const {
|
||||
Light *light = light_owner.get_or_null(p_light);
|
||||
ERR_FAIL_NULL_V(light, nullptr);
|
||||
|
||||
return &light->dependency;
|
||||
}
|
||||
|
||||
/* REFLECTION PROBE */
|
||||
|
||||
RID LightStorage::reflection_probe_allocate() {
|
||||
|
@ -601,6 +608,13 @@ float LightStorage::reflection_probe_get_ambient_color_energy(RID p_probe) const
|
|||
return reflection_probe->ambient_color_energy;
|
||||
}
|
||||
|
||||
Dependency *LightStorage::reflection_probe_get_dependency(RID p_probe) const {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
||||
ERR_FAIL_NULL_V(reflection_probe, nullptr);
|
||||
|
||||
return &reflection_probe->dependency;
|
||||
}
|
||||
|
||||
/* LIGHTMAP API */
|
||||
|
||||
RID LightStorage::lightmap_allocate() {
|
||||
|
@ -628,17 +642,17 @@ void LightStorage::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_use
|
|||
|
||||
//erase lightmap users
|
||||
if (lm->light_texture.is_valid()) {
|
||||
RendererRD::Texture *t = RendererRD::TextureStorage::get_singleton()->get_texture(lm->light_texture);
|
||||
RendererRD::TextureStorage::Texture *t = RendererRD::TextureStorage::get_singleton()->get_texture(lm->light_texture);
|
||||
if (t) {
|
||||
t->lightmap_users.erase(p_lightmap);
|
||||
}
|
||||
}
|
||||
|
||||
RendererRD::Texture *t = RendererRD::TextureStorage::get_singleton()->get_texture(p_light);
|
||||
RendererRD::TextureStorage::Texture *t = RendererRD::TextureStorage::get_singleton()->get_texture(p_light);
|
||||
lm->light_texture = p_light;
|
||||
lm->uses_spherical_harmonics = p_uses_spherical_haromics;
|
||||
|
||||
RID default_2d_array = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
RID default_2d_array = texture_storage->texture_rd_get_default(RendererRD::TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
if (!t) {
|
||||
if (using_lightmap_array) {
|
||||
if (lm->array_index >= 0) {
|
||||
|
@ -725,6 +739,13 @@ void LightStorage::lightmap_set_probe_capture_update_speed(float p_speed) {
|
|||
lightmap_probe_capture_update_speed = p_speed;
|
||||
}
|
||||
|
||||
Dependency *LightStorage::lightmap_get_dependency(RID p_lightmap) const {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_NULL_V(lm, nullptr);
|
||||
|
||||
return &lm->dependency;
|
||||
}
|
||||
|
||||
void LightStorage::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) {
|
||||
Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
||||
ERR_FAIL_COND(!lm);
|
||||
|
|
|
@ -39,8 +39,11 @@
|
|||
|
||||
namespace RendererRD {
|
||||
|
||||
/* LIGHT */
|
||||
class LightStorage : public RendererLightStorage {
|
||||
private:
|
||||
static LightStorage *singleton;
|
||||
|
||||
/* LIGHT */
|
||||
struct Light {
|
||||
RS::LightType type;
|
||||
float param[RS::LIGHT_PARAM_MAX];
|
||||
|
@ -65,6 +68,8 @@ struct Light {
|
|||
Dependency dependency;
|
||||
};
|
||||
|
||||
mutable RID_Owner<Light, true> light_owner;
|
||||
|
||||
/* REFLECTION PROBE */
|
||||
|
||||
struct ReflectionProbe {
|
||||
|
@ -85,6 +90,7 @@ struct ReflectionProbe {
|
|||
|
||||
Dependency dependency;
|
||||
};
|
||||
mutable RID_Owner<ReflectionProbe, true> reflection_probe_owner;
|
||||
|
||||
/* LIGHTMAP */
|
||||
|
||||
|
@ -108,18 +114,6 @@ struct Lightmap {
|
|||
Dependency dependency;
|
||||
};
|
||||
|
||||
class LightStorage : public RendererLightStorage {
|
||||
private:
|
||||
static LightStorage *singleton;
|
||||
|
||||
/* LIGHT */
|
||||
mutable RID_Owner<Light, true> light_owner;
|
||||
|
||||
/* REFLECTION PROBE */
|
||||
mutable RID_Owner<ReflectionProbe, true> reflection_probe_owner;
|
||||
|
||||
/* LIGHTMAP */
|
||||
|
||||
bool using_lightmap_array;
|
||||
Vector<RID> lightmap_textures;
|
||||
uint64_t lightmap_array_version = 0;
|
||||
|
@ -135,7 +129,6 @@ public:
|
|||
|
||||
/* LIGHT */
|
||||
|
||||
Light *get_light(RID p_rid) { return light_owner.get_or_null(p_rid); };
|
||||
bool owns_light(RID p_rid) { return light_owner.owns(p_rid); };
|
||||
|
||||
void _light_initialize(RID p_rid, RS::LightType p_type);
|
||||
|
@ -268,9 +261,10 @@ public:
|
|||
virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) override;
|
||||
virtual uint64_t light_get_version(RID p_light) const override;
|
||||
|
||||
Dependency *light_get_dependency(RID p_light) const;
|
||||
|
||||
/* REFLECTION PROBE */
|
||||
|
||||
ReflectionProbe *get_reflection_probe(RID p_rid) { return reflection_probe_owner.get_or_null(p_rid); };
|
||||
bool owns_reflection_probe(RID p_rid) { return reflection_probe_owner.owns(p_rid); };
|
||||
|
||||
virtual RID reflection_probe_allocate() override;
|
||||
|
@ -310,9 +304,10 @@ public:
|
|||
Color reflection_probe_get_ambient_color(RID p_probe) const;
|
||||
float reflection_probe_get_ambient_color_energy(RID p_probe) const;
|
||||
|
||||
Dependency *reflection_probe_get_dependency(RID p_probe) const;
|
||||
|
||||
/* LIGHTMAP */
|
||||
|
||||
Lightmap *get_lightmap(RID p_rid) { return lightmap_owner.get_or_null(p_rid); };
|
||||
bool owns_lightmap(RID p_rid) { return lightmap_owner.owns(p_rid); };
|
||||
|
||||
virtual RID lightmap_allocate() override;
|
||||
|
@ -332,6 +327,8 @@ public:
|
|||
virtual void lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) override;
|
||||
virtual void lightmap_set_probe_capture_update_speed(float p_speed) override;
|
||||
|
||||
Dependency *lightmap_get_dependency(RID p_lightmap) const;
|
||||
|
||||
virtual float lightmap_get_probe_capture_update_speed() const override {
|
||||
return lightmap_probe_capture_update_speed;
|
||||
}
|
||||
|
|
|
@ -926,9 +926,9 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type,
|
|||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// MaterialData
|
||||
// MaterialStorage::MaterialData
|
||||
|
||||
void MaterialData::update_uniform_buffer(const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const HashMap<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color) {
|
||||
void MaterialStorage::MaterialData::update_uniform_buffer(const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const HashMap<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color) {
|
||||
MaterialStorage *material_storage = MaterialStorage::get_singleton();
|
||||
bool uses_global_buffer = false;
|
||||
|
||||
|
@ -1007,7 +1007,7 @@ void MaterialData::update_uniform_buffer(const HashMap<StringName, ShaderLanguag
|
|||
}
|
||||
}
|
||||
|
||||
MaterialData::~MaterialData() {
|
||||
MaterialStorage::MaterialData::~MaterialData() {
|
||||
MaterialStorage *material_storage = MaterialStorage::get_singleton();
|
||||
|
||||
if (global_buffer_E) {
|
||||
|
@ -1033,14 +1033,14 @@ MaterialData::~MaterialData() {
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialData::update_textures(const HashMap<StringName, Variant> &p_parameters, const HashMap<StringName, HashMap<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color) {
|
||||
void MaterialStorage::MaterialData::update_textures(const HashMap<StringName, Variant> &p_parameters, const HashMap<StringName, HashMap<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color) {
|
||||
TextureStorage *texture_storage = TextureStorage::get_singleton();
|
||||
MaterialStorage *material_storage = MaterialStorage::get_singleton();
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Texture *roughness_detect_texture = nullptr;
|
||||
TextureStorage::Texture *roughness_detect_texture = nullptr;
|
||||
RS::TextureDetectRoughnessChannel roughness_channel = RS::TEXTURE_DETECT_ROUGHNESS_R;
|
||||
Texture *normal_detect_texture = nullptr;
|
||||
TextureStorage::Texture *normal_detect_texture = nullptr;
|
||||
#endif
|
||||
|
||||
bool uses_global_textures = false;
|
||||
|
@ -1123,19 +1123,19 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
|
|||
case ShaderLanguage::TYPE_SAMPLER2D: {
|
||||
switch (p_texture_uniforms[i].hint) {
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_DEFAULT_BLACK: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_BLACK);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_BLACK);
|
||||
} break;
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_ANISOTROPY: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_ANISO);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_ANISO);
|
||||
} break;
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_NORMAL: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_NORMAL);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_NORMAL);
|
||||
} break;
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_NORMAL: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_NORMAL);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_NORMAL);
|
||||
} break;
|
||||
default: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_WHITE);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
|
@ -1143,27 +1143,27 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
|
|||
case ShaderLanguage::TYPE_SAMPLERCUBE: {
|
||||
switch (p_texture_uniforms[i].hint) {
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_DEFAULT_BLACK: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK);
|
||||
} break;
|
||||
default: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_CUBEMAP_WHITE);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_WHITE);
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
case ShaderLanguage::TYPE_SAMPLERCUBEARRAY: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK);
|
||||
} break;
|
||||
|
||||
case ShaderLanguage::TYPE_ISAMPLER3D:
|
||||
case ShaderLanguage::TYPE_USAMPLER3D:
|
||||
case ShaderLanguage::TYPE_SAMPLER3D: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
} break;
|
||||
|
||||
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
|
||||
case ShaderLanguage::TYPE_USAMPLER2DARRAY:
|
||||
case ShaderLanguage::TYPE_SAMPLER2DARRAY: {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
||||
} break;
|
||||
|
||||
default: {
|
||||
|
@ -1185,7 +1185,7 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
|
|||
bool srgb = p_use_linear_color && p_texture_uniforms[i].use_color;
|
||||
|
||||
for (int j = 0; j < textures.size(); j++) {
|
||||
Texture *tex = TextureStorage::get_singleton()->get_texture(textures[j]);
|
||||
TextureStorage::Texture *tex = TextureStorage::get_singleton()->get_texture(textures[j]);
|
||||
|
||||
if (tex) {
|
||||
rd_texture = (srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture;
|
||||
|
@ -1207,7 +1207,7 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
|
|||
#endif
|
||||
}
|
||||
if (rd_texture.is_null()) {
|
||||
rd_texture = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_WHITE);
|
||||
rd_texture = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_WHITE);
|
||||
}
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (roughness_detect_texture && normal_detect_texture && !normal_detect_texture->path.is_empty()) {
|
||||
|
@ -1248,14 +1248,14 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialData::free_parameters_uniform_set(RID p_uniform_set) {
|
||||
void MaterialStorage::MaterialData::free_parameters_uniform_set(RID p_uniform_set) {
|
||||
if (p_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(p_uniform_set)) {
|
||||
RD::get_singleton()->uniform_set_set_invalidation_callback(p_uniform_set, nullptr, nullptr);
|
||||
RD::get_singleton()->free(p_uniform_set);
|
||||
}
|
||||
}
|
||||
|
||||
bool MaterialData::update_parameters_uniform_set(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty, const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, const HashMap<StringName, HashMap<int, RID>> &p_default_texture_params, uint32_t p_ubo_size, RID &uniform_set, RID p_shader, uint32_t p_shader_uniform_set, uint32_t p_barrier) {
|
||||
bool MaterialStorage::MaterialData::update_parameters_uniform_set(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty, const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, const HashMap<StringName, HashMap<int, RID>> &p_default_texture_params, uint32_t p_ubo_size, RID &uniform_set, RID p_shader, uint32_t p_shader_uniform_set, uint32_t p_barrier) {
|
||||
if ((uint32_t)ubo_data.size() != p_ubo_size) {
|
||||
p_uniform_dirty = true;
|
||||
if (uniform_buffer.is_valid()) {
|
||||
|
@ -2577,6 +2577,15 @@ void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
|
|||
_material_queue_update(material, true, true);
|
||||
}
|
||||
|
||||
MaterialStorage::ShaderData *MaterialStorage::material_get_shader_data(RID p_material) {
|
||||
const MaterialStorage::Material *material = MaterialStorage::get_singleton()->get_material(p_material);
|
||||
if (material && material->shader && material->shader->data) {
|
||||
return material->shader->data;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MaterialStorage::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
|
@ -2678,12 +2687,12 @@ void MaterialStorage::material_update_dependency(RID p_material, DependencyTrack
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::material_set_data_request_function(ShaderType p_shader_type, MaterialDataRequestFunction p_function) {
|
||||
void MaterialStorage::material_set_data_request_function(ShaderType p_shader_type, MaterialStorage::MaterialDataRequestFunction p_function) {
|
||||
ERR_FAIL_INDEX(p_shader_type, SHADER_TYPE_MAX);
|
||||
material_data_request_func[p_shader_type] = p_function;
|
||||
}
|
||||
|
||||
MaterialDataRequestFunction MaterialStorage::material_get_data_request_function(ShaderType p_shader_type) {
|
||||
MaterialStorage::MaterialDataRequestFunction MaterialStorage::material_get_data_request_function(ShaderType p_shader_type) {
|
||||
ERR_FAIL_INDEX_V(p_shader_type, SHADER_TYPE_MAX, nullptr);
|
||||
return material_data_request_func[p_shader_type];
|
||||
}
|
||||
|
|
|
@ -42,10 +42,8 @@
|
|||
|
||||
namespace RendererRD {
|
||||
|
||||
class MaterialStorage;
|
||||
|
||||
/* SHADER Structs */
|
||||
|
||||
class MaterialStorage : public RendererMaterialStorage {
|
||||
public:
|
||||
enum ShaderType {
|
||||
SHADER_TYPE_2D,
|
||||
SHADER_TYPE_3D,
|
||||
|
@ -71,21 +69,6 @@ struct ShaderData {
|
|||
virtual ~ShaderData() {}
|
||||
};
|
||||
|
||||
typedef ShaderData *(*ShaderDataRequestFunction)();
|
||||
|
||||
struct Material;
|
||||
|
||||
struct Shader {
|
||||
ShaderData *data = nullptr;
|
||||
String code;
|
||||
String path_hint;
|
||||
ShaderType type;
|
||||
HashMap<StringName, HashMap<int, RID>> default_texture_parameter;
|
||||
HashSet<Material *> owners;
|
||||
};
|
||||
|
||||
/* Material structs */
|
||||
|
||||
struct MaterialData {
|
||||
void update_uniform_buffer(const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const HashMap<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color);
|
||||
void update_textures(const HashMap<StringName, Variant> &p_parameters, const HashMap<StringName, HashMap<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color);
|
||||
|
@ -101,6 +84,7 @@ struct MaterialData {
|
|||
|
||||
private:
|
||||
friend class MaterialStorage;
|
||||
|
||||
RID self;
|
||||
List<RID>::Element *global_buffer_E = nullptr;
|
||||
List<RID>::Element *global_texture_E = nullptr;
|
||||
|
@ -113,29 +97,21 @@ private:
|
|||
Vector<RID> texture_cache;
|
||||
};
|
||||
|
||||
typedef MaterialData *(*MaterialDataRequestFunction)(ShaderData *);
|
||||
private:
|
||||
static MaterialStorage *singleton;
|
||||
|
||||
struct Material {
|
||||
RID self;
|
||||
MaterialData *data = nullptr;
|
||||
Shader *shader = nullptr;
|
||||
//shortcut to shader data and type
|
||||
ShaderType shader_type = SHADER_TYPE_MAX;
|
||||
uint32_t shader_id = 0;
|
||||
bool uniform_dirty = false;
|
||||
bool texture_dirty = false;
|
||||
HashMap<StringName, Variant> params;
|
||||
int32_t priority = 0;
|
||||
RID next_pass;
|
||||
SelfList<Material> update_element;
|
||||
/* Samplers */
|
||||
|
||||
Dependency dependency;
|
||||
RID default_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
|
||||
RID custom_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
|
||||
|
||||
Material() :
|
||||
update_element(this) {}
|
||||
};
|
||||
/* Buffers */
|
||||
|
||||
RID quad_index_buffer;
|
||||
RID quad_index_array;
|
||||
|
||||
/* GLOBAL SHADER UNIFORM API */
|
||||
|
||||
/* Global shader uniform structs */
|
||||
struct GlobalShaderUniforms {
|
||||
enum {
|
||||
BUFFER_DIRTY_REGION_SIZE = 1024
|
||||
|
@ -192,26 +168,7 @@ struct GlobalShaderUniforms {
|
|||
bool must_update_buffer_materials = false;
|
||||
|
||||
HashMap<RID, int32_t> instance_buffer_pos;
|
||||
};
|
||||
|
||||
class MaterialStorage : public RendererMaterialStorage {
|
||||
private:
|
||||
friend struct MaterialData;
|
||||
static MaterialStorage *singleton;
|
||||
|
||||
/* Samplers */
|
||||
|
||||
RID default_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
|
||||
RID custom_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
|
||||
|
||||
/* Buffers */
|
||||
|
||||
RID quad_index_buffer;
|
||||
RID quad_index_array;
|
||||
|
||||
/* GLOBAL SHADER UNIFORM API */
|
||||
|
||||
GlobalShaderUniforms global_shader_uniforms;
|
||||
} global_shader_uniforms;
|
||||
|
||||
int32_t _global_shader_uniform_allocate(uint32_t p_elements);
|
||||
void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderUniformType p_type, const Variant &p_value);
|
||||
|
@ -219,12 +176,50 @@ private:
|
|||
|
||||
/* SHADER API */
|
||||
|
||||
struct Material;
|
||||
|
||||
struct Shader {
|
||||
ShaderData *data = nullptr;
|
||||
String code;
|
||||
String path_hint;
|
||||
ShaderType type;
|
||||
HashMap<StringName, HashMap<int, RID>> default_texture_parameter;
|
||||
HashSet<Material *> owners;
|
||||
};
|
||||
|
||||
typedef ShaderData *(*ShaderDataRequestFunction)();
|
||||
ShaderDataRequestFunction shader_data_request_func[SHADER_TYPE_MAX];
|
||||
|
||||
mutable RID_Owner<Shader, true> shader_owner;
|
||||
Shader *get_shader(RID p_rid) { return shader_owner.get_or_null(p_rid); }
|
||||
|
||||
/* MATERIAL API */
|
||||
|
||||
typedef MaterialData *(*MaterialDataRequestFunction)(ShaderData *);
|
||||
|
||||
struct Material {
|
||||
RID self;
|
||||
MaterialData *data = nullptr;
|
||||
Shader *shader = nullptr;
|
||||
//shortcut to shader data and type
|
||||
ShaderType shader_type = SHADER_TYPE_MAX;
|
||||
uint32_t shader_id = 0;
|
||||
bool uniform_dirty = false;
|
||||
bool texture_dirty = false;
|
||||
HashMap<StringName, Variant> params;
|
||||
int32_t priority = 0;
|
||||
RID next_pass;
|
||||
SelfList<Material> update_element;
|
||||
|
||||
Dependency dependency;
|
||||
|
||||
Material() :
|
||||
update_element(this) {}
|
||||
};
|
||||
|
||||
MaterialDataRequestFunction material_data_request_func[SHADER_TYPE_MAX];
|
||||
mutable RID_Owner<Material, true> material_owner;
|
||||
Material *get_material(RID p_rid) { return material_owner.get_or_null(p_rid); };
|
||||
|
||||
SelfList<Material>::List material_update_list;
|
||||
|
||||
|
@ -358,7 +353,6 @@ public:
|
|||
|
||||
/* SHADER API */
|
||||
|
||||
Shader *get_shader(RID p_rid) { return shader_owner.get_or_null(p_rid); };
|
||||
bool owns_shader(RID p_rid) { return shader_owner.owns(p_rid); };
|
||||
|
||||
virtual RID shader_allocate() override;
|
||||
|
@ -379,7 +373,6 @@ public:
|
|||
|
||||
/* MATERIAL API */
|
||||
|
||||
Material *get_material(RID p_rid) { return material_owner.get_or_null(p_rid); };
|
||||
bool owns_material(RID p_rid) { return material_owner.owns(p_rid); };
|
||||
|
||||
void _material_queue_update(Material *material, bool p_uniform, bool p_texture);
|
||||
|
@ -390,6 +383,7 @@ public:
|
|||
virtual void material_free(RID p_rid) override;
|
||||
|
||||
virtual void material_set_shader(RID p_material, RID p_shader) override;
|
||||
ShaderData *material_get_shader_data(RID p_material);
|
||||
|
||||
virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) override;
|
||||
virtual Variant material_get_param(RID p_material, const StringName &p_param) const override;
|
||||
|
|
|
@ -758,6 +758,13 @@ bool MeshStorage::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
|
|||
return mesh->blend_shape_count > 0 || (mesh->has_bone_weights && p_has_skeleton);
|
||||
}
|
||||
|
||||
Dependency *MeshStorage::mesh_get_dependency(RID p_mesh) const {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, nullptr);
|
||||
|
||||
return &mesh->dependency;
|
||||
}
|
||||
|
||||
/* MESH INSTANCE */
|
||||
|
||||
RID MeshStorage::mesh_instance_create(RID p_base) {
|
||||
|
@ -1473,6 +1480,13 @@ RID MeshStorage::multimesh_get_mesh(RID p_multimesh) const {
|
|||
return multimesh->mesh;
|
||||
}
|
||||
|
||||
Dependency *MeshStorage::multimesh_get_dependency(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, nullptr);
|
||||
|
||||
return &multimesh->dependency;
|
||||
}
|
||||
|
||||
Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_COND_V(!multimesh, Transform3D());
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
|
||||
namespace RendererRD {
|
||||
|
||||
/* Mesh */
|
||||
|
||||
class MeshStorage : public RendererMeshStorage {
|
||||
public:
|
||||
enum DefaultRDBuffer {
|
||||
DEFAULT_RD_BUFFER_VERTEX,
|
||||
DEFAULT_RD_BUFFER_NORMAL,
|
||||
|
@ -58,6 +58,15 @@ enum DefaultRDBuffer {
|
|||
DEFAULT_RD_BUFFER_MAX,
|
||||
};
|
||||
|
||||
private:
|
||||
static MeshStorage *singleton;
|
||||
|
||||
RID default_rd_storage_buffer;
|
||||
|
||||
/* Mesh */
|
||||
|
||||
RID mesh_default_rd_buffers[DEFAULT_RD_BUFFER_MAX];
|
||||
|
||||
struct MeshInstance;
|
||||
|
||||
struct Mesh {
|
||||
|
@ -146,7 +155,9 @@ struct Mesh {
|
|||
Dependency dependency;
|
||||
};
|
||||
|
||||
/* Mesh Instance */
|
||||
mutable RID_Owner<Mesh, true> mesh_owner;
|
||||
|
||||
/* Mesh Instance API */
|
||||
|
||||
struct MeshInstance {
|
||||
Mesh *mesh = nullptr;
|
||||
|
@ -172,6 +183,16 @@ struct MeshInstance {
|
|||
weight_update_list(this), array_update_list(this) {}
|
||||
};
|
||||
|
||||
void _mesh_surface_generate_version_for_input_mask(Mesh::Surface::Version &v, Mesh::Surface *s, uint32_t p_input_mask, MeshInstance::Surface *mis = nullptr);
|
||||
|
||||
void _mesh_instance_clear(MeshInstance *mi);
|
||||
void _mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh, uint32_t p_surface);
|
||||
|
||||
mutable RID_Owner<MeshInstance> mesh_instance_owner;
|
||||
|
||||
SelfList<MeshInstance>::List dirty_mesh_instance_weights;
|
||||
SelfList<MeshInstance>::List dirty_mesh_instance_arrays;
|
||||
|
||||
/* MultiMesh */
|
||||
|
||||
struct MultiMesh {
|
||||
|
@ -202,6 +223,15 @@ struct MultiMesh {
|
|||
Dependency dependency;
|
||||
};
|
||||
|
||||
mutable RID_Owner<MultiMesh, true> multimesh_owner;
|
||||
|
||||
MultiMesh *multimesh_dirty_list = nullptr;
|
||||
|
||||
_FORCE_INLINE_ void _multimesh_make_local(MultiMesh *multimesh) const;
|
||||
_FORCE_INLINE_ void _multimesh_mark_dirty(MultiMesh *multimesh, int p_index, bool p_aabb);
|
||||
_FORCE_INLINE_ void _multimesh_mark_all_dirty(MultiMesh *multimesh, bool p_data, bool p_aabb);
|
||||
_FORCE_INLINE_ void _multimesh_re_create_aabb(MultiMesh *multimesh, const float *p_data, int p_instances);
|
||||
|
||||
/* Skeleton */
|
||||
|
||||
struct SkeletonShader {
|
||||
|
@ -239,7 +269,7 @@ struct SkeletonShader {
|
|||
RID pipeline[SHADER_MODE_MAX];
|
||||
|
||||
RID default_skeleton_uniform_set;
|
||||
};
|
||||
} skeleton_shader;
|
||||
|
||||
struct Skeleton {
|
||||
bool use_2d = false;
|
||||
|
@ -259,44 +289,6 @@ struct Skeleton {
|
|||
Dependency dependency;
|
||||
};
|
||||
|
||||
class MeshStorage : public RendererMeshStorage {
|
||||
private:
|
||||
static MeshStorage *singleton;
|
||||
|
||||
RID mesh_default_rd_buffers[DEFAULT_RD_BUFFER_MAX];
|
||||
RID default_rd_storage_buffer;
|
||||
|
||||
/* Mesh */
|
||||
|
||||
mutable RID_Owner<Mesh, true> mesh_owner;
|
||||
|
||||
void _mesh_surface_generate_version_for_input_mask(Mesh::Surface::Version &v, Mesh::Surface *s, uint32_t p_input_mask, MeshInstance::Surface *mis = nullptr);
|
||||
|
||||
/* Mesh Instance API */
|
||||
|
||||
void _mesh_instance_clear(MeshInstance *mi);
|
||||
void _mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh, uint32_t p_surface);
|
||||
|
||||
mutable RID_Owner<MeshInstance> mesh_instance_owner;
|
||||
|
||||
SelfList<MeshInstance>::List dirty_mesh_instance_weights;
|
||||
SelfList<MeshInstance>::List dirty_mesh_instance_arrays;
|
||||
|
||||
/* MultiMesh */
|
||||
|
||||
mutable RID_Owner<MultiMesh, true> multimesh_owner;
|
||||
|
||||
MultiMesh *multimesh_dirty_list = nullptr;
|
||||
|
||||
_FORCE_INLINE_ void _multimesh_make_local(MultiMesh *multimesh) const;
|
||||
_FORCE_INLINE_ void _multimesh_mark_dirty(MultiMesh *multimesh, int p_index, bool p_aabb);
|
||||
_FORCE_INLINE_ void _multimesh_mark_all_dirty(MultiMesh *multimesh, bool p_data, bool p_aabb);
|
||||
_FORCE_INLINE_ void _multimesh_re_create_aabb(MultiMesh *multimesh, const float *p_data, int p_instances);
|
||||
|
||||
/* Skeleton */
|
||||
|
||||
SkeletonShader skeleton_shader;
|
||||
|
||||
mutable RID_Owner<Skeleton, true> skeleton_owner;
|
||||
|
||||
_FORCE_INLINE_ void _skeleton_make_dirty(Skeleton *skeleton);
|
||||
|
@ -309,11 +301,10 @@ public:
|
|||
MeshStorage();
|
||||
virtual ~MeshStorage();
|
||||
|
||||
RID get_default_rd_storage_buffer() { return default_rd_storage_buffer; }
|
||||
RID get_default_rd_storage_buffer() const { return default_rd_storage_buffer; }
|
||||
|
||||
/* MESH API */
|
||||
|
||||
Mesh *get_mesh(RID p_rid) { return mesh_owner.get_or_null(p_rid); };
|
||||
bool owns_mesh(RID p_rid) { return mesh_owner.owns(p_rid); };
|
||||
|
||||
virtual RID mesh_allocate() override;
|
||||
|
@ -542,10 +533,11 @@ public:
|
|||
return s->particles_render_index;
|
||||
}
|
||||
|
||||
Dependency *mesh_get_dependency(RID p_mesh) const;
|
||||
|
||||
/* MESH INSTANCE API */
|
||||
|
||||
MeshInstance *get_mesh_instance(RID p_rid) { return mesh_instance_owner.get_or_null(p_rid); };
|
||||
bool owns_mesh_instance(RID p_rid) { return mesh_instance_owner.owns(p_rid); };
|
||||
bool owns_mesh_instance(RID p_rid) const { return mesh_instance_owner.owns(p_rid); };
|
||||
|
||||
virtual RID mesh_instance_create(RID p_base) override;
|
||||
virtual void mesh_instance_free(RID p_rid) override;
|
||||
|
@ -556,7 +548,6 @@ public:
|
|||
|
||||
/* MULTIMESH API */
|
||||
|
||||
MultiMesh *get_multimesh(RID p_rid) { return multimesh_owner.get_or_null(p_rid); };
|
||||
bool owns_multimesh(RID p_rid) { return multimesh_owner.owns(p_rid); };
|
||||
|
||||
virtual RID multimesh_allocate() override;
|
||||
|
@ -654,10 +645,11 @@ public:
|
|||
return multimesh->uniform_set_2d;
|
||||
}
|
||||
|
||||
Dependency *multimesh_get_dependency(RID p_multimesh) const;
|
||||
|
||||
/* SKELETON API */
|
||||
|
||||
Skeleton *get_skeleton(RID p_rid) { return skeleton_owner.get_or_null(p_rid); };
|
||||
bool owns_skeleton(RID p_rid) { return skeleton_owner.owns(p_rid); };
|
||||
bool owns_skeleton(RID p_rid) const { return skeleton_owner.owns(p_rid); };
|
||||
|
||||
virtual RID skeleton_allocate() override;
|
||||
virtual void skeleton_initialize(RID p_skeleton) override;
|
||||
|
|
|
@ -54,8 +54,8 @@ ParticlesStorage::ParticlesStorage() {
|
|||
particles_modes.push_back("");
|
||||
particles_shader.shader.initialize(particles_modes, String());
|
||||
}
|
||||
MaterialStorage::get_singleton()->shader_set_data_request_function(SHADER_TYPE_PARTICLES, _create_particles_shader_funcs);
|
||||
MaterialStorage::get_singleton()->material_set_data_request_function(SHADER_TYPE_PARTICLES, _create_particles_material_funcs);
|
||||
MaterialStorage::get_singleton()->shader_set_data_request_function(MaterialStorage::SHADER_TYPE_PARTICLES, _create_particles_shader_funcs);
|
||||
MaterialStorage::get_singleton()->material_set_data_request_function(MaterialStorage::SHADER_TYPE_PARTICLES, _create_particles_material_funcs);
|
||||
|
||||
{
|
||||
ShaderCompiler::DefaultIdentifierActions actions;
|
||||
|
@ -134,7 +134,7 @@ void process() {
|
|||
material_storage->material_initialize(particles_shader.default_material);
|
||||
material_storage->material_set_shader(particles_shader.default_material, particles_shader.default_shader);
|
||||
|
||||
ParticlesMaterialData *md = static_cast<ParticlesMaterialData *>(material_storage->material_get_data(particles_shader.default_material, SHADER_TYPE_PARTICLES));
|
||||
ParticlesMaterialData *md = static_cast<ParticlesMaterialData *>(material_storage->material_get_data(particles_shader.default_material, MaterialStorage::SHADER_TYPE_PARTICLES));
|
||||
particles_shader.default_shader_rd = particles_shader.shader.version_get_shader(md->shader_data->version, 0);
|
||||
|
||||
Vector<RD::Uniform> uniforms;
|
||||
|
@ -987,14 +987,13 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
for (uint32_t i = 0; i < ParticlesFrameParams::MAX_3D_TEXTURES; i++) {
|
||||
RID rd_tex;
|
||||
if (i < collision_3d_textures_used) {
|
||||
Texture *t = TextureStorage::get_singleton()->get_texture(collision_3d_textures[i]);
|
||||
if (t && t->type == Texture::TYPE_3D) {
|
||||
rd_tex = t->rd_texture;
|
||||
if (TextureStorage::get_singleton()->texture_get_type(collision_3d_textures[i]) == TextureStorage::TYPE_3D) {
|
||||
rd_tex = TextureStorage::get_singleton()->texture_get_rd_texture(collision_3d_textures[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (rd_tex == RID()) {
|
||||
rd_tex = texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
rd_tex = texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_3D_WHITE);
|
||||
}
|
||||
u.append_id(rd_tex);
|
||||
}
|
||||
|
@ -1007,7 +1006,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
if (collision_heightmap_texture.is_valid()) {
|
||||
u.append_id(collision_heightmap_texture);
|
||||
} else {
|
||||
u.append_id(texture_storage->texture_rd_get_default(DEFAULT_RD_TEXTURE_BLACK));
|
||||
u.append_id(texture_storage->texture_rd_get_default(TextureStorage::DEFAULT_RD_TEXTURE_BLACK));
|
||||
}
|
||||
uniforms.push_back(u);
|
||||
}
|
||||
|
@ -1073,9 +1072,9 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
|
|||
|
||||
RD::get_singleton()->buffer_update(p_particles->frame_params_buffer, 0, sizeof(ParticlesFrameParams) * p_particles->trail_params.size(), p_particles->trail_params.ptr());
|
||||
|
||||
ParticlesMaterialData *m = static_cast<ParticlesMaterialData *>(material_storage->material_get_data(p_particles->process_material, SHADER_TYPE_PARTICLES));
|
||||
ParticlesMaterialData *m = static_cast<ParticlesMaterialData *>(material_storage->material_get_data(p_particles->process_material, MaterialStorage::SHADER_TYPE_PARTICLES));
|
||||
if (!m) {
|
||||
m = static_cast<ParticlesMaterialData *>(material_storage->material_get_data(particles_shader.default_material, SHADER_TYPE_PARTICLES));
|
||||
m = static_cast<ParticlesMaterialData *>(material_storage->material_get_data(particles_shader.default_material, MaterialStorage::SHADER_TYPE_PARTICLES));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!m);
|
||||
|
@ -1228,10 +1227,10 @@ void ParticlesStorage::particles_set_view_axis(RID p_particles, const Vector3 &p
|
|||
void ParticlesStorage::_particles_update_buffers(Particles *particles) {
|
||||
uint32_t userdata_count = 0;
|
||||
|
||||
const Material *material = MaterialStorage::get_singleton()->get_material(particles->process_material);
|
||||
if (material && material->shader && material->shader->data) {
|
||||
const ParticlesShaderData *shader_data = static_cast<const ParticlesShaderData *>(material->shader->data);
|
||||
userdata_count = shader_data->userdata_count;
|
||||
MaterialStorage::ShaderData *shader_data = MaterialStorage::get_singleton()->material_get_shader_data(particles->process_material);
|
||||
if (shader_data) {
|
||||
const ParticlesShaderData *particle_shader_data = static_cast<const ParticlesShaderData *>(shader_data);
|
||||
userdata_count = particle_shader_data->userdata_count;
|
||||
}
|
||||
|
||||
if (userdata_count != particles->userdata_count) {
|
||||
|
@ -1503,6 +1502,13 @@ void ParticlesStorage::update_particles() {
|
|||
}
|
||||
}
|
||||
|
||||
Dependency *ParticlesStorage::particles_get_dependency(RID p_particles) const {
|
||||
Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
ERR_FAIL_NULL_V(particles, nullptr);
|
||||
|
||||
return &particles->dependency;
|
||||
}
|
||||
|
||||
bool ParticlesStorage::particles_is_inactive(RID p_particles) const {
|
||||
ERR_FAIL_COND_V_MSG(RSG::threaded, false, "This function should never be used with threaded rendering, as it stalls the renderer.");
|
||||
const Particles *particles = particles_owner.get_or_null(p_particles);
|
||||
|
@ -1685,7 +1691,7 @@ ParticlesStorage::ParticlesShaderData::~ParticlesShaderData() {
|
|||
}
|
||||
}
|
||||
|
||||
ShaderData *ParticlesStorage::_create_particles_shader_func() {
|
||||
MaterialStorage::ShaderData *ParticlesStorage::_create_particles_shader_func() {
|
||||
ParticlesShaderData *shader_data = memnew(ParticlesShaderData);
|
||||
return shader_data;
|
||||
}
|
||||
|
@ -1698,7 +1704,7 @@ ParticlesStorage::ParticlesMaterialData::~ParticlesMaterialData() {
|
|||
free_parameters_uniform_set(uniform_set);
|
||||
}
|
||||
|
||||
MaterialData *ParticlesStorage::_create_particles_material_func(ParticlesShaderData *p_shader) {
|
||||
MaterialStorage::MaterialData *ParticlesStorage::_create_particles_material_func(ParticlesShaderData *p_shader) {
|
||||
ParticlesMaterialData *material_data = memnew(ParticlesMaterialData);
|
||||
material_data->shader_data = p_shader;
|
||||
//update will happen later anyway so do nothing.
|
||||
|
@ -1884,6 +1890,15 @@ bool ParticlesStorage::particles_collision_is_heightfield(RID p_particles_collis
|
|||
return particles_collision->type == RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE;
|
||||
}
|
||||
|
||||
Dependency *ParticlesStorage::particles_collision_get_dependency(RID p_particles_collision) const {
|
||||
ParticlesCollision *pc = particles_collision_owner.get_or_null(p_particles_collision);
|
||||
ERR_FAIL_NULL_V(pc, nullptr);
|
||||
|
||||
return &pc->dependency;
|
||||
}
|
||||
|
||||
/* Particles collision instance */
|
||||
|
||||
RID ParticlesStorage::particles_collision_instance_create(RID p_collision) {
|
||||
ParticlesCollisionInstance pci;
|
||||
pci.collision = p_collision;
|
||||
|
|
|
@ -43,6 +43,10 @@
|
|||
|
||||
namespace RendererRD {
|
||||
|
||||
class ParticlesStorage : public RendererParticlesStorage {
|
||||
private:
|
||||
static ParticlesStorage *singleton;
|
||||
|
||||
/* PARTICLES */
|
||||
|
||||
struct ParticleData {
|
||||
|
@ -237,38 +241,6 @@ struct Particles {
|
|||
}
|
||||
};
|
||||
|
||||
/* Particles Collision */
|
||||
|
||||
struct ParticlesCollision {
|
||||
RS::ParticlesCollisionType type = RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT;
|
||||
uint32_t cull_mask = 0xFFFFFFFF;
|
||||
float radius = 1.0;
|
||||
Vector3 extents = Vector3(1, 1, 1);
|
||||
float attractor_strength = 1.0;
|
||||
float attractor_attenuation = 1.0;
|
||||
float attractor_directionality = 0.0;
|
||||
RID field_texture;
|
||||
RID heightfield_texture;
|
||||
RID heightfield_fb;
|
||||
Size2i heightfield_fb_size;
|
||||
|
||||
RS::ParticlesCollisionHeightfieldResolution heightfield_resolution = RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024;
|
||||
|
||||
Dependency dependency;
|
||||
};
|
||||
|
||||
struct ParticlesCollisionInstance {
|
||||
RID collision;
|
||||
Transform3D transform;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
class ParticlesStorage : public RendererParticlesStorage {
|
||||
private:
|
||||
static ParticlesStorage *singleton;
|
||||
|
||||
/* PARTICLES */
|
||||
|
||||
void _particles_process(Particles *p_particles, double p_delta);
|
||||
void _particles_allocate_emission_buffer(Particles *particles);
|
||||
void _particles_free_data(Particles *particles);
|
||||
|
@ -340,7 +312,7 @@ private:
|
|||
|
||||
/* Particle Shader */
|
||||
|
||||
struct ParticlesShaderData : public ShaderData {
|
||||
struct ParticlesShaderData : public MaterialStorage::ShaderData {
|
||||
bool valid = false;
|
||||
RID version;
|
||||
bool uses_collision = false;
|
||||
|
@ -377,12 +349,12 @@ private:
|
|||
virtual ~ParticlesShaderData();
|
||||
};
|
||||
|
||||
ShaderData *_create_particles_shader_func();
|
||||
static ShaderData *_create_particles_shader_funcs() {
|
||||
MaterialStorage::ShaderData *_create_particles_shader_func();
|
||||
static MaterialStorage::ShaderData *_create_particles_shader_funcs() {
|
||||
return ParticlesStorage::get_singleton()->_create_particles_shader_func();
|
||||
}
|
||||
|
||||
struct ParticlesMaterialData : public MaterialData {
|
||||
struct ParticlesMaterialData : public MaterialStorage::MaterialData {
|
||||
ParticlesShaderData *shader_data = nullptr;
|
||||
RID uniform_set;
|
||||
|
||||
|
@ -392,13 +364,37 @@ private:
|
|||
virtual ~ParticlesMaterialData();
|
||||
};
|
||||
|
||||
MaterialData *_create_particles_material_func(ParticlesShaderData *p_shader);
|
||||
static MaterialData *_create_particles_material_funcs(ShaderData *p_shader) {
|
||||
MaterialStorage::MaterialData *_create_particles_material_func(ParticlesShaderData *p_shader);
|
||||
static MaterialStorage::MaterialData *_create_particles_material_funcs(MaterialStorage::ShaderData *p_shader) {
|
||||
return ParticlesStorage::get_singleton()->_create_particles_material_func(static_cast<ParticlesShaderData *>(p_shader));
|
||||
}
|
||||
|
||||
/* Particles Collision */
|
||||
|
||||
struct ParticlesCollision {
|
||||
RS::ParticlesCollisionType type = RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT;
|
||||
uint32_t cull_mask = 0xFFFFFFFF;
|
||||
float radius = 1.0;
|
||||
Vector3 extents = Vector3(1, 1, 1);
|
||||
float attractor_strength = 1.0;
|
||||
float attractor_attenuation = 1.0;
|
||||
float attractor_directionality = 0.0;
|
||||
RID field_texture;
|
||||
RID heightfield_texture;
|
||||
RID heightfield_fb;
|
||||
Size2i heightfield_fb_size;
|
||||
|
||||
RS::ParticlesCollisionHeightfieldResolution heightfield_resolution = RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024;
|
||||
|
||||
Dependency dependency;
|
||||
};
|
||||
|
||||
struct ParticlesCollisionInstance {
|
||||
RID collision;
|
||||
Transform3D transform;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
mutable RID_Owner<ParticlesCollision, true> particles_collision_owner;
|
||||
|
||||
mutable RID_Owner<ParticlesCollisionInstance> particles_collision_instance_owner;
|
||||
|
@ -411,7 +407,6 @@ public:
|
|||
|
||||
/* PARTICLES */
|
||||
|
||||
Particles *get_particles(RID p_rid) { return particles_owner.get_or_null(p_rid); }
|
||||
bool owns_particles(RID p_rid) { return particles_owner.owns(p_rid); }
|
||||
|
||||
virtual RID particles_allocate() override;
|
||||
|
@ -526,9 +521,10 @@ public:
|
|||
|
||||
virtual void update_particles() override;
|
||||
|
||||
Dependency *particles_get_dependency(RID p_particles) const;
|
||||
|
||||
/* Particles Collision */
|
||||
|
||||
ParticlesCollision *get_particles_collision(RID p_rid) { return particles_collision_owner.get_or_null(p_rid); }
|
||||
bool owns_particles_collision(RID p_rid) { return particles_collision_owner.owns(p_rid); }
|
||||
|
||||
virtual RID particles_collision_allocate() override;
|
||||
|
@ -550,8 +546,9 @@ public:
|
|||
virtual bool particles_collision_is_heightfield(RID p_particles_collision) const override;
|
||||
virtual RID particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const override;
|
||||
|
||||
Dependency *particles_collision_get_dependency(RID p_particles) const;
|
||||
|
||||
//used from 2D and 3D
|
||||
ParticlesCollisionInstance *get_particles_collision_instance(RID p_rid) { return particles_collision_instance_owner.get_or_null(p_rid); }
|
||||
bool owns_particles_collision_instance(RID p_rid) { return particles_collision_instance_owner.owns(p_rid); }
|
||||
|
||||
virtual RID particles_collision_instance_create(RID p_collision) override;
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
using namespace RendererRD;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CanvasTexture
|
||||
// TextureStorage::CanvasTexture
|
||||
|
||||
void CanvasTexture::clear_sets() {
|
||||
void TextureStorage::CanvasTexture::clear_sets() {
|
||||
if (cleared_cache) {
|
||||
return;
|
||||
}
|
||||
|
@ -52,14 +52,14 @@ void CanvasTexture::clear_sets() {
|
|||
cleared_cache = true;
|
||||
}
|
||||
|
||||
CanvasTexture::~CanvasTexture() {
|
||||
TextureStorage::CanvasTexture::~CanvasTexture() {
|
||||
clear_sets();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Texture
|
||||
// TextureStorage::Texture
|
||||
|
||||
void Texture::cleanup() {
|
||||
void TextureStorage::Texture::cleanup() {
|
||||
if (RD::get_singleton()->texture_is_valid(rd_texture_srgb)) {
|
||||
//erase this first, as it's a dependency of the one below
|
||||
RD::get_singleton()->free(rd_texture_srgb);
|
||||
|
@ -534,7 +534,7 @@ bool TextureStorage::canvas_texture_get_uniform_set(RID p_texture, RS::CanvasIte
|
|||
|
||||
ct = t->canvas_texture;
|
||||
} else {
|
||||
ct = get_canvas_texture(p_texture);
|
||||
ct = canvas_texture_owner.get_or_null(p_texture);
|
||||
}
|
||||
|
||||
if (!ct) {
|
||||
|
@ -657,7 +657,7 @@ void TextureStorage::texture_2d_initialize(RID p_texture, const Ref<Image> &p_im
|
|||
|
||||
Texture texture;
|
||||
|
||||
texture.type = Texture::TYPE_2D;
|
||||
texture.type = TextureStorage::TYPE_2D;
|
||||
|
||||
texture.width = p_image->get_width();
|
||||
texture.height = p_image->get_height();
|
||||
|
@ -753,7 +753,7 @@ void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vector<R
|
|||
|
||||
Texture texture;
|
||||
|
||||
texture.type = Texture::TYPE_LAYERED;
|
||||
texture.type = TextureStorage::TYPE_LAYERED;
|
||||
texture.layered_type = p_layered_type;
|
||||
|
||||
texture.width = p_layers[0]->get_width();
|
||||
|
@ -883,7 +883,7 @@ void TextureStorage::texture_3d_initialize(RID p_texture, Image::Format p_format
|
|||
|
||||
Texture texture;
|
||||
|
||||
texture.type = Texture::TYPE_3D;
|
||||
texture.type = TextureStorage::TYPE_3D;
|
||||
texture.width = p_width;
|
||||
texture.height = p_height;
|
||||
texture.depth = p_depth;
|
||||
|
@ -975,7 +975,7 @@ void TextureStorage::_texture_2d_update(RID p_texture, const Ref<Image> &p_image
|
|||
ERR_FAIL_COND(p_image->get_width() != tex->width || p_image->get_height() != tex->height);
|
||||
ERR_FAIL_COND(p_image->get_format() != tex->format);
|
||||
|
||||
if (tex->type == Texture::TYPE_LAYERED) {
|
||||
if (tex->type == TextureStorage::TYPE_LAYERED) {
|
||||
ERR_FAIL_INDEX(p_layer, tex->layers);
|
||||
}
|
||||
|
||||
|
@ -995,7 +995,7 @@ void TextureStorage::texture_2d_update(RID p_texture, const Ref<Image> &p_image,
|
|||
void TextureStorage::texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_COND(tex->type != Texture::TYPE_3D);
|
||||
ERR_FAIL_COND(tex->type != TextureStorage::TYPE_3D);
|
||||
|
||||
Image::Image3DValidateError verr = Image::validate_3d_image(tex->format, tex->width, tex->height, tex->depth, tex->mipmaps > 1, p_data);
|
||||
if (verr != Image::VALIDATE_3D_OK) {
|
||||
|
@ -1167,7 +1167,7 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons
|
|||
Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, Vector<Ref<Image>>());
|
||||
ERR_FAIL_COND_V(tex->type != Texture::TYPE_3D, Vector<Ref<Image>>());
|
||||
ERR_FAIL_COND_V(tex->type != TextureStorage::TYPE_3D, Vector<Ref<Image>>());
|
||||
|
||||
Vector<uint8_t> all_data = RD::get_singleton()->texture_get_data(tex->rd_texture, 0);
|
||||
|
||||
|
@ -1243,7 +1243,7 @@ void TextureStorage::texture_replace(RID p_texture, RID p_by_texture) {
|
|||
void TextureStorage::texture_set_size_override(RID p_texture, int p_width, int p_height) {
|
||||
Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_COND(tex->type != Texture::TYPE_2D);
|
||||
ERR_FAIL_COND(tex->type != TextureStorage::TYPE_2D);
|
||||
|
||||
tex->width_2d = p_width;
|
||||
tex->height_2d = p_height;
|
||||
|
@ -1855,6 +1855,13 @@ AABB TextureStorage::decal_get_aabb(RID p_decal) const {
|
|||
return AABB(-decal->extents, decal->extents * 2.0);
|
||||
}
|
||||
|
||||
Dependency *TextureStorage::decal_get_dependency(RID p_decal) {
|
||||
Decal *decal = decal_owner.get_or_null(p_decal);
|
||||
ERR_FAIL_COND_V(!decal, nullptr);
|
||||
|
||||
return &decal->dependency;
|
||||
}
|
||||
|
||||
void TextureStorage::update_decal_atlas() {
|
||||
RendererRD::CopyEffects *copy_effects = RendererRD::CopyEffects::get_singleton();
|
||||
ERR_FAIL_NULL(copy_effects);
|
||||
|
|
|
@ -38,6 +38,11 @@
|
|||
|
||||
namespace RendererRD {
|
||||
|
||||
class LightStorage;
|
||||
class MaterialStorage;
|
||||
|
||||
class TextureStorage : public RendererTextureStorage {
|
||||
public:
|
||||
enum DefaultRDTexture {
|
||||
DEFAULT_RD_TEXTURE_WHITE,
|
||||
DEFAULT_RD_TEXTURE_BLACK,
|
||||
|
@ -57,6 +62,22 @@ enum DefaultRDTexture {
|
|||
DEFAULT_RD_TEXTURE_MAX
|
||||
};
|
||||
|
||||
enum TextureType {
|
||||
TYPE_2D,
|
||||
TYPE_LAYERED,
|
||||
TYPE_3D
|
||||
};
|
||||
|
||||
private:
|
||||
friend class LightStorage;
|
||||
friend class MaterialStorage;
|
||||
|
||||
static TextureStorage *singleton;
|
||||
|
||||
RID default_rd_textures[DEFAULT_RD_TEXTURE_MAX];
|
||||
|
||||
/* Canvas Texture API */
|
||||
|
||||
class CanvasTexture {
|
||||
public:
|
||||
RID diffuse;
|
||||
|
@ -78,15 +99,13 @@ public:
|
|||
~CanvasTexture();
|
||||
};
|
||||
|
||||
RID_Owner<CanvasTexture, true> canvas_texture_owner;
|
||||
|
||||
/* Texture API */
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
enum Type {
|
||||
TYPE_2D,
|
||||
TYPE_LAYERED,
|
||||
TYPE_3D
|
||||
};
|
||||
|
||||
Type type;
|
||||
TextureType type;
|
||||
RS::TextureLayeredType layered_type = RS::TEXTURE_LAYERED_2D_ARRAY;
|
||||
|
||||
RenderingDevice::TextureType rd_type;
|
||||
|
@ -142,6 +161,32 @@ public:
|
|||
void cleanup();
|
||||
};
|
||||
|
||||
//textures can be created from threads, so this RID_Owner is thread safe
|
||||
mutable RID_Owner<Texture, true> texture_owner;
|
||||
Texture *get_texture(RID p_rid) { return texture_owner.get_or_null(p_rid); };
|
||||
|
||||
struct TextureToRDFormat {
|
||||
RD::DataFormat format;
|
||||
RD::DataFormat format_srgb;
|
||||
RD::TextureSwizzle swizzle_r;
|
||||
RD::TextureSwizzle swizzle_g;
|
||||
RD::TextureSwizzle swizzle_b;
|
||||
RD::TextureSwizzle swizzle_a;
|
||||
TextureToRDFormat() {
|
||||
format = RD::DATA_FORMAT_MAX;
|
||||
format_srgb = RD::DATA_FORMAT_MAX;
|
||||
swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
}
|
||||
};
|
||||
|
||||
Ref<Image> _validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format);
|
||||
void _texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0, bool p_immediate = false);
|
||||
|
||||
/* DECAL API */
|
||||
|
||||
struct DecalAtlas {
|
||||
struct Texture {
|
||||
int panorama_to_dp_users;
|
||||
|
@ -179,7 +224,7 @@ struct DecalAtlas {
|
|||
Vector<MipMap> texture_mipmaps;
|
||||
|
||||
Size2i size;
|
||||
};
|
||||
} decal_atlas;
|
||||
|
||||
struct Decal {
|
||||
Vector3 extents = Vector3(1, 1, 1);
|
||||
|
@ -198,6 +243,11 @@ struct Decal {
|
|||
Dependency dependency;
|
||||
};
|
||||
|
||||
mutable RID_Owner<Decal, true> decal_owner;
|
||||
Decal *get_decal(RID p_rid) const { return decal_owner.get_or_null(p_rid); };
|
||||
|
||||
/* RENDER TARGET API */
|
||||
|
||||
struct RenderTarget {
|
||||
Size2i size;
|
||||
uint32_t view_count;
|
||||
|
@ -244,6 +294,16 @@ struct RenderTarget {
|
|||
Color clear_color;
|
||||
};
|
||||
|
||||
mutable RID_Owner<RenderTarget> render_target_owner;
|
||||
RenderTarget *get_render_target(RID p_rid) const { return render_target_owner.get_or_null(p_rid); };
|
||||
|
||||
void _clear_render_target(RenderTarget *rt);
|
||||
void _update_render_target(RenderTarget *rt);
|
||||
void _create_render_target_backbuffer(RenderTarget *rt);
|
||||
void _render_target_allocate_sdf(RenderTarget *rt);
|
||||
void _render_target_clear_sdf(RenderTarget *rt);
|
||||
Rect2i _render_target_get_sdf_rect(const RenderTarget *rt) const;
|
||||
|
||||
struct RenderTargetSDF {
|
||||
enum {
|
||||
SHADER_LOAD,
|
||||
|
@ -266,65 +326,11 @@ struct RenderTargetSDF {
|
|||
CanvasSdfShaderRD shader;
|
||||
RID shader_version;
|
||||
RID pipelines[SHADER_MAX];
|
||||
};
|
||||
|
||||
class TextureStorage : public RendererTextureStorage {
|
||||
private:
|
||||
static TextureStorage *singleton;
|
||||
|
||||
/* Canvas Texture API */
|
||||
|
||||
RID_Owner<RendererRD::CanvasTexture, true> canvas_texture_owner;
|
||||
|
||||
/* Texture API */
|
||||
|
||||
//textures can be created from threads, so this RID_Owner is thread safe
|
||||
mutable RID_Owner<Texture, true> texture_owner;
|
||||
|
||||
struct TextureToRDFormat {
|
||||
RD::DataFormat format;
|
||||
RD::DataFormat format_srgb;
|
||||
RD::TextureSwizzle swizzle_r;
|
||||
RD::TextureSwizzle swizzle_g;
|
||||
RD::TextureSwizzle swizzle_b;
|
||||
RD::TextureSwizzle swizzle_a;
|
||||
TextureToRDFormat() {
|
||||
format = RD::DATA_FORMAT_MAX;
|
||||
format_srgb = RD::DATA_FORMAT_MAX;
|
||||
swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
}
|
||||
};
|
||||
|
||||
Ref<Image> _validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format);
|
||||
void _texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0, bool p_immediate = false);
|
||||
|
||||
/* DECAL API */
|
||||
|
||||
DecalAtlas decal_atlas;
|
||||
|
||||
mutable RID_Owner<Decal, true> decal_owner;
|
||||
|
||||
/* RENDER TARGET API */
|
||||
|
||||
mutable RID_Owner<RenderTarget> render_target_owner;
|
||||
|
||||
void _clear_render_target(RenderTarget *rt);
|
||||
void _update_render_target(RenderTarget *rt);
|
||||
void _create_render_target_backbuffer(RenderTarget *rt);
|
||||
void _render_target_allocate_sdf(RenderTarget *rt);
|
||||
void _render_target_clear_sdf(RenderTarget *rt);
|
||||
Rect2i _render_target_get_sdf_rect(const RenderTarget *rt) const;
|
||||
|
||||
RenderTargetSDF rt_sdf;
|
||||
} rt_sdf;
|
||||
|
||||
public:
|
||||
static TextureStorage *get_singleton();
|
||||
|
||||
RID default_rd_textures[DEFAULT_RD_TEXTURE_MAX];
|
||||
|
||||
_FORCE_INLINE_ RID texture_rd_get_default(DefaultRDTexture p_texture) {
|
||||
return default_rd_textures[p_texture];
|
||||
}
|
||||
|
@ -334,7 +340,6 @@ public:
|
|||
|
||||
/* Canvas Texture API */
|
||||
|
||||
CanvasTexture *get_canvas_texture(RID p_rid) { return canvas_texture_owner.get_or_null(p_rid); };
|
||||
bool owns_canvas_texture(RID p_rid) { return canvas_texture_owner.owns(p_rid); };
|
||||
|
||||
virtual RID canvas_texture_allocate() override;
|
||||
|
@ -351,8 +356,7 @@ public:
|
|||
|
||||
/* Texture API */
|
||||
|
||||
Texture *get_texture(RID p_rid) { return texture_owner.get_or_null(p_rid); };
|
||||
bool owns_texture(RID p_rid) { return texture_owner.owns(p_rid); };
|
||||
bool owns_texture(RID p_rid) const { return texture_owner.owns(p_rid); };
|
||||
|
||||
virtual bool can_create_resources_async() const override;
|
||||
|
||||
|
@ -394,12 +398,29 @@ public:
|
|||
virtual Size2 texture_size_with_proxy(RID p_proxy) override;
|
||||
|
||||
//internal usage
|
||||
_FORCE_INLINE_ TextureType texture_get_type(RID p_texture) {
|
||||
RendererRD::TextureStorage::Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
if (tex == nullptr) {
|
||||
return TYPE_2D;
|
||||
}
|
||||
|
||||
return tex->type;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int texture_get_layers(RID p_texture) {
|
||||
RendererRD::TextureStorage::Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
if (tex == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return tex->layers;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) {
|
||||
if (p_texture.is_null()) {
|
||||
return RID();
|
||||
}
|
||||
RendererRD::Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
RendererRD::TextureStorage::Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
|
||||
if (!tex) {
|
||||
return RID();
|
||||
|
@ -411,7 +432,7 @@ public:
|
|||
if (p_texture.is_null()) {
|
||||
return Size2i();
|
||||
}
|
||||
RendererRD::Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
RendererRD::TextureStorage::Texture *tex = texture_owner.get_or_null(p_texture);
|
||||
|
||||
if (!tex) {
|
||||
return Size2i();
|
||||
|
@ -423,8 +444,7 @@ public:
|
|||
|
||||
void update_decal_atlas();
|
||||
|
||||
Decal *get_decal(RID p_rid) { return decal_owner.get_or_null(p_rid); };
|
||||
bool owns_decal(RID p_rid) { return decal_owner.owns(p_rid); };
|
||||
bool owns_decal(RID p_rid) const { return decal_owner.owns(p_rid); };
|
||||
|
||||
RID decal_atlas_get_texture() const;
|
||||
RID decal_atlas_get_texture_srgb() const;
|
||||
|
@ -518,11 +538,11 @@ public:
|
|||
}
|
||||
|
||||
virtual AABB decal_get_aabb(RID p_decal) const override;
|
||||
Dependency *decal_get_dependency(RID p_decal);
|
||||
|
||||
/* RENDER TARGET API */
|
||||
|
||||
RenderTarget *get_render_target(RID p_rid) { return render_target_owner.get_or_null(p_rid); };
|
||||
bool owns_render_target(RID p_rid) { return render_target_owner.owns(p_rid); };
|
||||
bool owns_render_target(RID p_rid) const { return render_target_owner.owns(p_rid); };
|
||||
|
||||
virtual RID render_target_create() override;
|
||||
virtual void render_target_free(RID p_rid) override;
|
||||
|
|
|
@ -138,35 +138,37 @@ bool Utilities::free(RID p_rid) {
|
|||
|
||||
void Utilities::base_update_dependency(RID p_base, DependencyTracker *p_instance) {
|
||||
if (MeshStorage::get_singleton()->owns_mesh(p_base)) {
|
||||
Mesh *mesh = MeshStorage::get_singleton()->get_mesh(p_base);
|
||||
p_instance->update_dependency(&mesh->dependency);
|
||||
Dependency *dependency = MeshStorage::get_singleton()->mesh_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
} else if (MeshStorage::get_singleton()->owns_multimesh(p_base)) {
|
||||
MultiMesh *multimesh = MeshStorage::get_singleton()->get_multimesh(p_base);
|
||||
p_instance->update_dependency(&multimesh->dependency);
|
||||
if (multimesh->mesh.is_valid()) {
|
||||
base_update_dependency(multimesh->mesh, p_instance);
|
||||
Dependency *dependency = MeshStorage::get_singleton()->multimesh_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
|
||||
RID mesh = MeshStorage::get_singleton()->multimesh_get_mesh(p_base);
|
||||
if (mesh.is_valid()) {
|
||||
base_update_dependency(mesh, p_instance);
|
||||
}
|
||||
} else if (LightStorage::get_singleton()->owns_reflection_probe(p_base)) {
|
||||
ReflectionProbe *rp = LightStorage::get_singleton()->get_reflection_probe(p_base);
|
||||
p_instance->update_dependency(&rp->dependency);
|
||||
Dependency *dependency = LightStorage::get_singleton()->reflection_probe_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
} else if (TextureStorage::get_singleton()->owns_decal(p_base)) {
|
||||
Decal *decal = TextureStorage::get_singleton()->get_decal(p_base);
|
||||
p_instance->update_dependency(&decal->dependency);
|
||||
Dependency *dependency = TextureStorage::get_singleton()->decal_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
} else if (GI::get_singleton()->owns_voxel_gi(p_base)) {
|
||||
GI::VoxelGI *gip = GI::get_singleton()->get_voxel_gi(p_base);
|
||||
p_instance->update_dependency(&gip->dependency);
|
||||
} else if (LightStorage::get_singleton()->owns_lightmap(p_base)) {
|
||||
Lightmap *lm = LightStorage::get_singleton()->get_lightmap(p_base);
|
||||
p_instance->update_dependency(&lm->dependency);
|
||||
Dependency *dependency = LightStorage::get_singleton()->lightmap_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
} else if (LightStorage::get_singleton()->owns_light(p_base)) {
|
||||
Light *l = LightStorage::get_singleton()->get_light(p_base);
|
||||
p_instance->update_dependency(&l->dependency);
|
||||
Dependency *dependency = LightStorage::get_singleton()->light_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
} else if (ParticlesStorage::get_singleton()->owns_particles(p_base)) {
|
||||
Particles *p = ParticlesStorage::get_singleton()->get_particles(p_base);
|
||||
p_instance->update_dependency(&p->dependency);
|
||||
Dependency *dependency = ParticlesStorage::get_singleton()->particles_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
} else if (ParticlesStorage::get_singleton()->owns_particles_collision(p_base)) {
|
||||
ParticlesCollision *pc = ParticlesStorage::get_singleton()->get_particles_collision(p_base);
|
||||
p_instance->update_dependency(&pc->dependency);
|
||||
Dependency *dependency = ParticlesStorage::get_singleton()->particles_collision_get_dependency(p_base);
|
||||
p_instance->update_dependency(dependency);
|
||||
} else if (Fog::get_singleton()->owns_fog_volume(p_base)) {
|
||||
Fog::FogVolume *fv = Fog::get_singleton()->get_fog_volume(p_base);
|
||||
p_instance->update_dependency(&fv->dependency);
|
||||
|
|
Loading…
Reference in New Issue