summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/SCsub2
-rw-r--r--drivers/dummy/rasterizer_dummy.h261
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp8
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h10
-rw-r--r--drivers/gles2/shader_compiler_gles2.h2
-rw-r--r--drivers/gles2/shader_gles2.h2
-rw-r--r--drivers/unix/os_unix.cpp10
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp100
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h8
-rw-r--r--drivers/vulkan/vulkan_context.cpp36
10 files changed, 234 insertions, 205 deletions
diff --git a/drivers/SCsub b/drivers/SCsub
index 932014b540..41c20d81ad 100644
--- a/drivers/SCsub
+++ b/drivers/SCsub
@@ -23,7 +23,7 @@ SConscript('coremidi/SCsub')
SConscript('winmidi/SCsub')
# Graphics drivers
-if (env["platform"] != "server"):
+if (env["platform"] != "server" and env["platform"] != "javascript"):
# SConscript('gles2/SCsub')
SConscript('vulkan/SCsub')
SConscript('gl_context/SCsub')
diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h
index fb23370863..4dc634aefa 100644
--- a/drivers/dummy/rasterizer_dummy.h
+++ b/drivers/dummy/rasterizer_dummy.h
@@ -47,9 +47,18 @@ public:
void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {}
bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { return false; }
+ void directional_shadow_atlas_set_size(int p_size) {}
int get_directional_light_shadow_size(RID p_light_intance) { return 0; }
void set_directional_shadow_count(int p_count) {}
+ /* SKY API */
+
+ RID sky_create() { return RID(); }
+ void sky_set_radiance_size(RID p_sky, int p_radiance_size) {}
+ void sky_set_mode(RID p_sky, VS::SkyMode p_samples) {}
+ void sky_set_texture(RID p_sky, RID p_panorama) {}
+ void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {}
+
/* ENVIRONMENT API */
RID environment_create() { return RID(); }
@@ -61,17 +70,19 @@ public:
void environment_set_bg_color(RID p_env, const Color &p_color) {}
void environment_set_bg_energy(RID p_env, float p_energy) {}
void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {}
- void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) {}
- void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id){};
+ void environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient = VS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, VS::EnvironmentReflectionSource p_reflection_source = VS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) {}
+// FIXME: Disabled during Vulkan refactoring, should be ported.
+#if 0
+ void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {}
+#endif
- void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) {}
- void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) {}
- void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {}
+ void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {}
void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {}
void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {}
- void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {}
+ virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {}
+ virtual void environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size) {}
void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {}
@@ -81,9 +92,17 @@ public:
void environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) {}
void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {}
- bool is_environment(RID p_env) { return false; }
- VS::EnvironmentBG environment_get_background(RID p_env) { return VS::ENV_BG_KEEP; }
- int environment_get_canvas_max_layer(RID p_env) { return 0; }
+ bool is_environment(RID p_env) const { return false; }
+ VS::EnvironmentBG environment_get_background(RID p_env) const { return VS::ENV_BG_KEEP; }
+ int environment_get_canvas_max_layer(RID p_env) const { return 0; }
+
+ virtual RID camera_effects_create() { return RID(); }
+
+ virtual void camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter) {}
+ virtual void camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape) {}
+
+ virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {}
+ virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {}
RID light_instance_create(RID p_light) { return RID(); }
void light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {}
@@ -91,8 +110,7 @@ public:
void light_instance_mark_visible(RID p_light_instance) {}
RID reflection_atlas_create() { return RID(); }
- void reflection_atlas_set_size(RID p_ref_atlas, int p_size) {}
- void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv) {}
+ virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {}
RID reflection_probe_instance_create(RID p_probe) { return RID(); }
void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {}
@@ -102,18 +120,28 @@ public:
bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { return false; }
bool reflection_probe_instance_postprocess_step(RID p_instance) { return true; }
- RID gi_probe_instance_create() { return RID(); }
+ virtual RID gi_probe_instance_create(RID p_gi_probe) { return RID(); }
void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data) {}
void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {}
- void gi_probe_instance_set_bounds(RID p_probe, const Vector3 &p_bounds) {}
+ virtual bool gi_probe_needs_update(RID p_probe) const { return false; }
+ virtual void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, int p_dynamic_object_count, InstanceBase **p_dynamic_objects) {}
- void render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {}
+ virtual void render_scene(RID p_render_buffers, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID *p_gi_probe_cull_result, int p_gi_probe_cull_count, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {}
void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {}
+ virtual void render_material(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID p_framebuffer, const Rect2i &p_region) {}
void set_scene_pass(uint64_t p_pass) {}
+ virtual void set_time(double p_time, double p_step) {}
void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) {}
+ virtual RID render_buffers_create() { return RID(); }
+ virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa) {}
+
+ virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_curve) {}
+ virtual bool screen_space_roughness_limiter_is_active() const { return false; }
+
bool free(RID p_rid) { return true; }
+ virtual void update() {}
RasterizerSceneDummy() {}
~RasterizerSceneDummy() {}
@@ -139,7 +167,7 @@ public:
Vector<uint8_t> index_array;
int index_count;
AABB aabb;
- Vector<Vector<uint8_t> > blend_shapes;
+ Vector<Vector<uint8_t>> blend_shapes;
Vector<AABB> bone_aabbs;
};
@@ -152,6 +180,43 @@ public:
mutable RID_PtrOwner<DummyTexture> texture_owner;
mutable RID_PtrOwner<DummyMesh> mesh_owner;
+ virtual RID texture_2d_create(const Ref<Image> &p_image) { return RID(); }
+ virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type) { return RID(); }
+ virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return RID(); }
+ virtual RID texture_proxy_create(RID p_base) { return RID(); }
+
+ virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) {}
+ virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) {}
+ virtual void texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap) {}
+ virtual void texture_proxy_update(RID p_proxy, RID p_base) {}
+
+ virtual RID texture_2d_placeholder_create() { return RID(); }
+ virtual RID texture_2d_layered_placeholder_create() { return RID(); }
+ virtual RID texture_3d_placeholder_create() { return RID(); }
+
+ virtual Ref<Image> texture_2d_get(RID p_texture) const { return Ref<Image>(); }
+ virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const { return Ref<Image>(); }
+ virtual Ref<Image> texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const { return Ref<Image>(); }
+
+ virtual void texture_replace(RID p_texture, RID p_by_texture) {}
+ virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) {}
+// FIXME: Disabled during Vulkan refactoring, should be ported.
+#if 0
+ virtual void texture_bind(RID p_texture, uint32_t p_texture_no) = 0;
+#endif
+
+ virtual void texture_set_path(RID p_texture, const String &p_path) {}
+ virtual String texture_get_path(RID p_texture) const { return String(); }
+
+ virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {}
+ virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {}
+ virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {}
+
+ virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) {}
+ virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
+ virtual Size2 texture_size_with_proxy(RID p_proxy) { return Size2(); }
+
+#if 0
RID texture_create() {
DummyTexture *texture = memnew(DummyTexture);
@@ -246,11 +311,7 @@ public:
void texture_set_proxy(RID p_proxy, RID p_base) {}
virtual Size2 texture_size_with_proxy(RID p_texture) const { return Size2(); }
void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
-
- /* SKY API */
-
- RID sky_create() { return RID(); }
- void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {}
+#endif
/* SHADER API */
@@ -262,6 +323,7 @@ public:
void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {}
RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const { return RID(); }
+ virtual Variant shader_get_param_default(RID p_material, const StringName &p_param) const { return Variant(); }
/* COMMON MATERIAL API */
@@ -269,21 +331,15 @@ public:
void material_set_render_priority(RID p_material, int priority) {}
void material_set_shader(RID p_shader_material, RID p_shader) {}
- RID material_get_shader(RID p_shader_material) const { return RID(); }
void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {}
Variant material_get_param(RID p_material, const StringName &p_param) const { return Variant(); }
- Variant material_get_param_default(RID p_material, const StringName &p_param) const { return Variant(); }
-
- void material_set_line_width(RID p_material, float p_width) {}
void material_set_next_pass(RID p_material, RID p_next_material) {}
bool material_is_animated(RID p_material) { return false; }
bool material_casts_shadows(RID p_material) { return false; }
-
- void material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {}
- void material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {}
+ void material_update_dependency(RID p_material, RasterizerScene::InstanceBase *p_instance) {}
/* MESH API */
@@ -295,6 +351,9 @@ public:
return mesh_owner.make_rid(mesh);
}
+ void mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface) {}
+
+#if 0
void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!m);
@@ -317,6 +376,8 @@ public:
ERR_FAIL_COND(!m);
m->blend_shape_count = p_amount;
}
+#endif
+
int mesh_get_blend_shape_count(RID p_mesh) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!m, 0);
@@ -339,6 +400,7 @@ public:
void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {}
RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); }
+#if 0
int mesh_surface_get_array_len(RID p_mesh, int p_surface) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!m, 0);
@@ -404,6 +466,9 @@ public:
m->surfaces.remove(p_index);
}
+#endif
+
+ VS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const { return VS::SurfaceData(); }
int mesh_get_surface_count(RID p_mesh) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!m, 0);
@@ -413,14 +478,14 @@ public:
void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {}
AABB mesh_get_custom_aabb(RID p_mesh) const { return AABB(); }
- AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const { return AABB(); }
+ AABB mesh_get_aabb(RID p_mesh, RID p_skeleton = RID()) { return AABB(); }
void mesh_clear(RID p_mesh) {}
/* MULTIMESH API */
virtual RID multimesh_create() { return RID(); }
- void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format, VS::MultimeshCustomDataFormat p_data = VS::MULTIMESH_CUSTOM_DATA_NONE) {}
+ virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) {}
int multimesh_get_instance_count(RID p_multimesh) const { return 0; }
void multimesh_set_mesh(RID p_multimesh, RID p_mesh) {}
@@ -430,19 +495,18 @@ public:
void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {}
RID multimesh_get_mesh(RID p_multimesh) const { return RID(); }
+ AABB multimesh_get_aabb(RID p_multimesh) const { return AABB(); }
Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const { return Transform(); }
Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const { return Transform2D(); }
Color multimesh_instance_get_color(RID p_multimesh, int p_index) const { return Color(); }
Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { return Color(); }
-
- void multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array) {}
+ virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {}
+ virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const { return Vector<float>(); }
void multimesh_set_visible_instances(RID p_multimesh, int p_visible) {}
int multimesh_get_visible_instances(RID p_multimesh) const { return 0; }
- AABB multimesh_get_aabb(RID p_multimesh) const { return AABB(); }
-
/* IMMEDIATE API */
RID immediate_create() { return RID(); }
@@ -490,7 +554,6 @@ public:
void light_set_use_gi(RID p_light, bool p_enabled) {}
void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {}
- void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) {}
void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {}
void light_directional_set_blend_splits(RID p_light, bool p_enable) {}
@@ -536,57 +599,55 @@ public:
float reflection_probe_get_origin_max_distance(RID p_probe) const { return 0.0; }
bool reflection_probe_renders_shadows(RID p_probe) const { return false; }
- void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {}
- void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {}
-
- void instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
- void instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
+ virtual void base_update_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
+ virtual void skeleton_update_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
/* GI PROBE API */
RID gi_probe_create() { return RID(); }
- void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) {}
- AABB gi_probe_get_bounds(RID p_probe) const { return AABB(); }
+ virtual void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {}
- void gi_probe_set_cell_size(RID p_probe, float p_range) {}
- float gi_probe_get_cell_size(RID p_probe) const { return 0.0; }
+ virtual AABB gi_probe_get_bounds(RID p_gi_probe) const { return AABB(); }
+ virtual Vector3i gi_probe_get_octree_size(RID p_gi_probe) const { return Vector3i(); }
+ virtual Vector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const { return Vector<uint8_t>(); }
+ virtual Vector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const { return Vector<uint8_t>(); }
+ virtual Vector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const { return Vector<uint8_t>(); }
- void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform) {}
- Transform gi_probe_get_to_cell_xform(RID p_probe) const { return Transform(); }
+ virtual Vector<int> gi_probe_get_level_counts(RID p_gi_probe) const { return Vector<int>(); }
+ virtual Transform gi_probe_get_to_cell_xform(RID p_gi_probe) const { return Transform(); }
- void gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data) {}
- Vector<int> gi_probe_get_dynamic_data(RID p_probe) const {
- Vector<int> p;
- return p;
- }
+ virtual void gi_probe_set_dynamic_range(RID p_gi_probe, float p_range) {}
+ virtual float gi_probe_get_dynamic_range(RID p_gi_probe) const { return 0; }
+
+ virtual void gi_probe_set_propagation(RID p_gi_probe, float p_range) {}
+ virtual float gi_probe_get_propagation(RID p_gi_probe) const { return 0; }
- void gi_probe_set_dynamic_range(RID p_probe, int p_range) {}
- int gi_probe_get_dynamic_range(RID p_probe) const { return 0; }
+ void gi_probe_set_energy(RID p_gi_probe, float p_range) {}
+ float gi_probe_get_energy(RID p_gi_probe) const { return 0.0; }
- void gi_probe_set_energy(RID p_probe, float p_range) {}
- float gi_probe_get_energy(RID p_probe) const { return 0.0; }
+ virtual void gi_probe_set_ao(RID p_gi_probe, float p_ao) {}
+ virtual float gi_probe_get_ao(RID p_gi_probe) const { return 0; }
- void gi_probe_set_bias(RID p_probe, float p_range) {}
- float gi_probe_get_bias(RID p_probe) const { return 0.0; }
+ virtual void gi_probe_set_ao_size(RID p_gi_probe, float p_strength) {}
+ virtual float gi_probe_get_ao_size(RID p_gi_probe) const { return 0; }
- void gi_probe_set_normal_bias(RID p_probe, float p_range) {}
- float gi_probe_get_normal_bias(RID p_probe) const { return 0.0; }
+ void gi_probe_set_bias(RID p_gi_probe, float p_range) {}
+ float gi_probe_get_bias(RID p_gi_probe) const { return 0.0; }
- void gi_probe_set_propagation(RID p_probe, float p_range) {}
- float gi_probe_get_propagation(RID p_probe) const { return 0.0; }
+ void gi_probe_set_normal_bias(RID p_gi_probe, float p_range) {}
+ float gi_probe_get_normal_bias(RID p_gi_probe) const { return 0.0; }
- void gi_probe_set_interior(RID p_probe, bool p_enable) {}
- bool gi_probe_is_interior(RID p_probe) const { return false; }
+ void gi_probe_set_interior(RID p_gi_probe, bool p_enable) {}
+ bool gi_probe_is_interior(RID p_gi_probe) const { return false; }
- void gi_probe_set_compress(RID p_probe, bool p_enable) {}
- bool gi_probe_is_compressed(RID p_probe) const { return false; }
+ virtual void gi_probe_set_use_two_bounces(RID p_gi_probe, bool p_enable) {}
+ virtual bool gi_probe_is_using_two_bounces(RID p_gi_probe) const { return false; }
- uint32_t gi_probe_get_version(RID p_probe) { return 0; }
+ virtual void gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength) {}
+ virtual float gi_probe_get_anisotropy_strength(RID p_gi_probe) const { return 0; }
- GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const { return GI_PROBE_UNCOMPRESSED; }
- RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression) { return RID(); }
- void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data) {}
+ uint32_t gi_probe_get_version(RID p_gi_probe) { return 0; }
/* LIGHTMAP CAPTURE */
struct Instantiable {
@@ -598,7 +659,7 @@ public:
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
- instances->self()->base_changed(p_aabb, p_materials);
+ //instances->self()->base_changed(p_aabb, p_materials);
instances = instances->next();
}
}
@@ -608,7 +669,7 @@ public:
while (instances) {
SelfList<RasterizerScene::InstanceBase> *next = instances->next();
- instances->self()->base_removed();
+ //instances->self()->base_removed();
instances = next;
}
}
@@ -697,21 +758,17 @@ public:
RID render_target_create() { return RID(); }
void render_target_set_position(RID p_render_target, int p_x, int p_y) {}
void render_target_set_size(RID p_render_target, int p_width, int p_height) {}
- RID render_target_get_texture(RID p_render_target) const { return RID(); }
+ RID render_target_get_texture(RID p_render_target) { return RID(); }
void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) {}
void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {}
bool render_target_was_used(RID p_render_target) { return false; }
void render_target_set_as_unused(RID p_render_target) {}
- void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {}
-
- /* CANVAS SHADOW */
-
- RID canvas_light_shadow_buffer_create(int p_width) { return RID(); }
- /* LIGHT SHADOW MAPPING */
-
- RID canvas_light_occluder_create() { return RID(); }
- void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) {}
+ virtual void render_target_request_clear(RID p_render_target, const Color &p_clear_color) {}
+ virtual bool render_target_is_clear_requested(RID p_render_target) { return false; }
+ virtual Color render_target_get_clear_request_color(RID p_render_target) { return Color(); }
+ virtual void render_target_disable_clear_request(RID p_render_target) {}
+ virtual void render_target_do_clear_request(RID p_render_target) {}
VS::InstanceType get_base_type(RID p_rid) const {
if (mesh_owner.owns(p_rid)) {
@@ -748,28 +805,43 @@ public:
static RasterizerStorage *base_singleton;
- RasterizerStorageDummy(){};
+ virtual void capture_timestamps_begin() {}
+ virtual void capture_timestamp(const String &p_name) {}
+ virtual uint32_t get_captured_timestamps_count() const { return 0; }
+ virtual uint64_t get_captured_timestamps_frame() const { return 0; }
+ virtual uint64_t get_captured_timestamp_gpu_time(uint32_t p_index) const { return 0; }
+ virtual uint64_t get_captured_timestamp_cpu_time(uint32_t p_index) const { return 0; }
+ virtual String get_captured_timestamp_name(uint32_t p_index) const { return String(); }
+
+ RasterizerStorageDummy() {}
~RasterizerStorageDummy() {}
};
class RasterizerCanvasDummy : public RasterizerCanvas {
public:
- RID light_internal_create() { return RID(); }
- void light_internal_update(RID p_rid, Light *p_light) {}
- void light_internal_free(RID p_rid) {}
+ virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { return 0; }
+ virtual void free_texture_binding(TextureBindingID p_binding) {}
- void canvas_begin(){};
- void canvas_end(){};
+ virtual PolygonID request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>()) { return 0; }
+ virtual void free_polygon(PolygonID p_polygon) {}
- void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_transform){};
- void canvas_debug_viewport_shadows(Light *p_lights_with_shadow){};
+ virtual void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform) {}
+ virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) {}
- void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {}
+ virtual RID light_create() { return RID(); }
+ virtual void light_set_texture(RID p_rid, RID p_texture) {}
+ virtual void light_set_use_shadow(RID p_rid, bool p_enable, int p_resolution) {}
+ virtual void light_update_shadow(RID p_rid, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {}
- void reset_canvas() {}
+ virtual RID occluder_polygon_create() { return RID(); }
+ virtual void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines) {}
+ virtual void occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode) {}
void draw_window_margins(int *p_margins, RID *p_margin_textures) {}
+ virtual bool free(RID p_rid) { return true; }
+ virtual void update() {}
+
RasterizerCanvasDummy() {}
~RasterizerCanvasDummy() {}
};
@@ -789,11 +861,10 @@ public:
void initialize() {}
void begin_frame(double frame_step) {}
- void set_current_render_target(RID p_render_target) {}
- void restore_render_target(bool p_3d_was_drawn) {}
- void clear_render_target(const Color &p_color) {}
- void blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0) {}
- void output_lens_distorted_to_screen(RID p_render_target, const Rect2 &p_screen_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {}
+
+ virtual void prepare_for_blitting_render_targets() {}
+ virtual void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) {}
+
void end_frame(bool p_swap_buffers) { OS::get_singleton()->swap_buffers(); }
void finalize() {}
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 55b1c7e560..0f5452effc 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -2270,7 +2270,7 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
return ret;
}
-void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
+void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -2737,10 +2737,10 @@ AABB RasterizerStorageGLES2::mesh_surface_get_aabb(RID p_mesh, int p_surface) co
return mesh->surfaces[p_surface]->aabb;
}
-Vector<Vector<uint8_t> > RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
+Vector<Vector<uint8_t>> RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, Vector<Vector<uint8_t> >());
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Vector<uint8_t> >());
+ ERR_FAIL_COND_V(!mesh, Vector<Vector<uint8_t>>());
+ ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Vector<uint8_t>>());
#ifndef TOOLS_ENABLED
ERR_PRINT("OpenGL ES 2.0 does not allow retrieving mesh array data");
#endif
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index 6fbfe57778..86965730e0 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -275,7 +275,7 @@ public:
RenderTarget *render_target;
- Vector<Ref<Image> > images;
+ Vector<Ref<Image>> images;
bool redraw_if_visible;
@@ -541,7 +541,7 @@ public:
Map<StringName, Variant> params;
SelfList<Material> list;
SelfList<Material> dirty_list;
- Vector<Pair<StringName, RID> > textures;
+ Vector<Pair<StringName, RID>> textures;
float line_width;
int render_priority;
@@ -650,7 +650,7 @@ public:
Vector<uint8_t> data;
Vector<uint8_t> index_data;
- Vector<Vector<uint8_t> > blend_shape_data;
+ Vector<Vector<uint8_t>> blend_shape_data;
int total_data_size;
@@ -702,7 +702,7 @@ public:
virtual RID mesh_create();
- virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
+ virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount);
virtual int mesh_get_blend_shape_count(RID p_mesh) const;
@@ -725,7 +725,7 @@ public:
virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const;
- virtual Vector<Vector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const;
+ virtual Vector<Vector<uint8_t>> mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const;
virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const;
virtual void mesh_remove_surface(RID p_mesh, int p_surface);
diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h
index e39ef5e7bd..dd10a27c0d 100644
--- a/drivers/gles2/shader_compiler_gles2.h
+++ b/drivers/gles2/shader_compiler_gles2.h
@@ -41,7 +41,7 @@ class ShaderCompilerGLES2 {
public:
struct IdentifierActions {
- Map<StringName, Pair<int *, int> > render_mode_values;
+ Map<StringName, Pair<int *, int>> render_mode_values;
Map<StringName, bool *> render_mode_flags;
Map<StringName, bool *> usage_flag_pointers;
Map<StringName, bool *> write_flag_pointers;
diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h
index f2953c9ae8..d5e8159479 100644
--- a/drivers/gles2/shader_gles2.h
+++ b/drivers/gles2/shader_gles2.h
@@ -179,7 +179,7 @@ private:
int max_image_units;
- Map<StringName, Pair<ShaderLanguage::DataType, Vector<ShaderLanguage::ConstantNode::Value> > > uniform_values;
+ Map<StringName, Pair<ShaderLanguage::DataType, Vector<ShaderLanguage::ConstantNode::Value>>> uniform_values;
protected:
_FORCE_INLINE_ int _get_uniform(int p_which) const;
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index d21b095037..458488f3e9 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -32,6 +32,8 @@
#ifdef UNIX_ENABLED
+#include "core/debugger/engine_debugger.h"
+#include "core/debugger/script_debugger.h"
#include "core/os/thread_dummy.h"
#include "core/project_settings.h"
#include "drivers/unix/dir_access_unix.h"
@@ -94,16 +96,16 @@ void OS_Unix::debug_break() {
};
static void handle_interrupt(int sig) {
- if (ScriptDebugger::get_singleton() == NULL)
+ if (!EngineDebugger::is_active())
return;
- ScriptDebugger::get_singleton()->set_depth(-1);
- ScriptDebugger::get_singleton()->set_lines_left(1);
+ EngineDebugger::get_script_debugger()->set_depth(-1);
+ EngineDebugger::get_script_debugger()->set_lines_left(1);
}
void OS_Unix::initialize_debugging() {
- if (ScriptDebugger::get_singleton() != NULL) {
+ if (EngineDebugger::is_active()) {
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = handle_interrupt;
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 3b0d1f6ac3..76541c3cd5 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -57,7 +57,7 @@ void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
//direct dependencies must be freed
- Map<RID, Set<RID> >::Element *E = dependency_map.find(p_id);
+ Map<RID, Set<RID>>::Element *E = dependency_map.find(p_id);
if (E) {
while (E->get().size()) {
@@ -72,7 +72,7 @@ void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
if (E) {
for (Set<RID>::Element *F = E->get().front(); F; F = F->next()) {
- Map<RID, Set<RID> >::Element *G = dependency_map.find(F->get());
+ Map<RID, Set<RID>>::Element *G = dependency_map.find(F->get());
ERR_CONTINUE(!G);
ERR_CONTINUE(!G->get().has(p_id));
G->get().erase(p_id);
@@ -1252,7 +1252,7 @@ Error RenderingDeviceVulkan::_buffer_allocate(Buffer *p_buffer, uint32_t p_size,
allocInfo.pUserData = NULL;
VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &p_buffer->buffer, &p_buffer->allocation, NULL);
- ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Can't create buffer of size: " + itos(p_size));
+ ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
p_buffer->size = p_size;
p_buffer->buffer_info.buffer = p_buffer->buffer;
p_buffer->buffer_info.offset = 0;
@@ -1296,7 +1296,7 @@ Error RenderingDeviceVulkan::_insert_staging_block() {
StagingBufferBlock block;
VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &block.buffer, &block.allocation, NULL);
- ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vmaCreateBuffer failed with error " + itos(err) + ".");
block.frame_used = 0;
block.fill_amount = 0;
@@ -1462,9 +1462,7 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c
void *data_ptr = NULL;
{
VkResult vkerr = vmaMapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation, &data_ptr);
- if (vkerr) {
- ERR_FAIL_V(ERR_CANT_CREATE);
- }
+ ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + ".");
}
//copy to staging buffer
@@ -1557,7 +1555,7 @@ void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_f
/**** TEXTURE ****/
/*****************/
-RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t> > &p_data) {
+RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t>> &p_data) {
_THREAD_SAFE_METHOD_
@@ -1752,7 +1750,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
Texture texture;
VkResult err = vmaCreateImage(allocator, &image_create_info, &allocInfo, &texture.image, &texture.allocation, &texture.allocation_info);
- ERR_FAIL_COND_V(err, RID());
+ ERR_FAIL_COND_V_MSG(err, RID(), "vmaCreateImage failed with error " + itos(err) + ".");
texture.type = p_format.type;
texture.format = p_format.format;
@@ -1858,7 +1856,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
if (err) {
vmaDestroyImage(allocator, texture.image, texture.allocation);
- ERR_FAIL_V(RID());
+ ERR_FAIL_V_MSG(RID(), "vkCreateImageView failed with error " + itos(err) + ".");
}
//barrier to set layout
@@ -1964,10 +1962,7 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID
}
VkResult err = vkCreateImageView(device, &image_view_create_info, NULL, &texture.view);
-
- if (err) {
- ERR_FAIL_V(RID());
- }
+ ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateImageView failed with error " + itos(err) + ".");
texture.owner = p_with_texture;
RID id = texture_owner.make_rid(texture);
@@ -2065,10 +2060,7 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p
}
VkResult err = vkCreateImageView(device, &image_view_create_info, NULL, &texture.view);
-
- if (err) {
- ERR_FAIL_V(RID());
- }
+ ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateImageView failed with error " + itos(err) + ".");
texture.owner = p_with_texture;
RID id = texture_owner.make_rid(texture);
@@ -2179,9 +2171,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
{ //map
void *data_ptr = NULL;
VkResult vkerr = vmaMapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation, &data_ptr);
- if (vkerr) {
- ERR_FAIL_V(ERR_CANT_CREATE);
- }
+ ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + ".");
write_ptr = (uint8_t *)data_ptr;
write_ptr += alloc_offset;
}
@@ -2468,9 +2458,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
void *buffer_mem;
VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem);
- if (vkerr) {
- ERR_FAIL_V(Vector<uint8_t>());
- }
+ ERR_FAIL_COND_V_MSG(vkerr, Vector<uint8_t>(), "vmaMapMemory failed with error " + itos(vkerr) + ".");
Vector<uint8_t> buffer_data;
{
@@ -2977,7 +2965,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
VkRenderPass render_pass;
VkResult res = vkCreateRenderPass(device, &render_pass_create_info, NULL, &render_pass);
- ERR_FAIL_COND_V(res, VK_NULL_HANDLE);
+ ERR_FAIL_COND_V_MSG(res, VK_NULL_HANDLE, "vkCreateRenderPass failed with error " + itos(res) + ".");
if (r_color_attachment_count) {
*r_color_attachment_count = color_references.size();
@@ -3126,7 +3114,7 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
VkSampler sampler;
VkResult res = vkCreateSampler(device, &sampler_create_info, NULL, &sampler);
- ERR_FAIL_COND_V(res, RID());
+ ERR_FAIL_COND_V_MSG(res, RID(), "vkCreateSampler failed with error " + itos(res) + ".");
return sampler_owner.make_rid(sampler);
}
@@ -3580,8 +3568,8 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages) {
//descriptor layouts
- Vector<Vector<VkDescriptorSetLayoutBinding> > set_bindings;
- Vector<Vector<UniformInfo> > uniform_info;
+ Vector<Vector<VkDescriptorSetLayoutBinding>> set_bindings;
+ Vector<Vector<UniformInfo>> uniform_info;
Shader::PushConstant push_constant;
push_constant.push_constant_size = 0;
push_constant.push_constants_vk_stage = 0;
@@ -3880,7 +3868,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
VkResult res = vkCreateShaderModule(device, &shader_module_create_info, NULL, &module);
if (res) {
success = false;
- error_text = "Error creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]);
+ error_text = "Error (" + itos(res) + ") creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]);
break;
}
@@ -3920,7 +3908,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
VkDescriptorSetLayout layout;
VkResult res = vkCreateDescriptorSetLayout(device, &layout_create_info, NULL, &layout);
if (res) {
- error_text = "Error creating descriptor set layout for set " + itos(i);
+ error_text = "Error (" + itos(res) + ") creating descriptor set layout for set " + itos(i);
success = false;
break;
}
@@ -3983,7 +3971,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
VkResult err = vkCreatePipelineLayout(device, &pipeline_layout_create_info, NULL, &shader.pipeline_layout);
if (err) {
- error_text = "Error creating pipeline layout.";
+ error_text = "Error (" + itos(err) + ") creating pipeline layout.";
success = false;
}
}
@@ -4088,7 +4076,7 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF
VkResult res = vkCreateBufferView(device, &view_create_info, NULL, &texture_buffer.view);
if (res) {
_buffer_free(&texture_buffer.buffer);
- ERR_FAIL_V_MSG(RID(), "Unable to create buffer view");
+ ERR_FAIL_V_MSG(RID(), "Unable to create buffer view, error " + itos(res) + ".");
}
//allocate the view
@@ -4184,7 +4172,7 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a
VkResult res = vkCreateDescriptorPool(device, &descriptor_pool_create_info, NULL, &pool->pool);
if (res) {
memdelete(pool);
- ERR_FAIL_COND_V(res, NULL);
+ ERR_FAIL_COND_V_MSG(res, NULL, "vkCreateDescriptorPool failed with error " + itos(res) + ".");
}
descriptor_pools[p_key].insert(pool);
}
@@ -4235,9 +4223,9 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
DescriptorPoolKey pool_key;
//to keep them alive until update call
- List<Vector<VkDescriptorBufferInfo> > buffer_infos;
- List<Vector<VkBufferView> > buffer_views;
- List<Vector<VkDescriptorImageInfo> > image_infos;
+ List<Vector<VkDescriptorBufferInfo>> buffer_infos;
+ List<Vector<VkBufferView>> buffer_views;
+ List<Vector<VkDescriptorImageInfo>> image_infos;
//used for verification to make sure a uniform set does not use a framebuffer bound texture
Vector<RID> attachable_textures;
Vector<Texture *> mutable_sampled_textures;
@@ -4600,7 +4588,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
VkResult res = vkAllocateDescriptorSets(device, &descriptor_set_allocate_info, &descriptor_set);
if (res) {
_descriptor_pool_free(pool_key, pool); // meh
- ERR_FAIL_V_MSG(RID(), "Cannot allocate descriptor sets.");
+ ERR_FAIL_V_MSG(RID(), "Cannot allocate descriptor sets, error " + itos(res) + ".");
}
UniformSet uniform_set;
@@ -4722,9 +4710,7 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
void *buffer_mem;
VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem);
- if (vkerr) {
- ERR_FAIL_V(Vector<uint8_t>());
- }
+ ERR_FAIL_COND_V_MSG(vkerr, Vector<uint8_t>(), "vmaMapMemory failed with error " + itos(vkerr) + ".");
Vector<uint8_t> buffer_data;
{
@@ -5067,7 +5053,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
RenderPipeline pipeline;
VkResult err = vkCreateGraphicsPipelines(device, NULL, 1, &graphics_pipeline_create_info, NULL, &pipeline.pipeline);
- ERR_FAIL_COND_V(err, RID());
+ ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateGraphicsPipelines failed with error " + itos(err) + ".");
pipeline.set_formats = shader->set_formats;
pipeline.push_constant_stages = shader->push_constant.push_constants_vk_stage;
@@ -5140,7 +5126,7 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader) {
ComputePipeline pipeline;
VkResult err = vkCreateComputePipelines(device, NULL, 1, &compute_pipeline_create_info, NULL, &pipeline.pipeline);
- ERR_FAIL_COND_V(err, RID());
+ ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateComputePipelines failed with error " + itos(err) + ".");
pipeline.set_formats = shader->set_formats;
pipeline.push_constant_stages = shader->push_constant.push_constants_vk_stage;
@@ -5300,7 +5286,7 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu
framebuffer_create_info.layers = 1;
VkResult err = vkCreateFramebuffer(device, &framebuffer_create_info, NULL, &version.framebuffer);
- ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkCreateFramebuffer failed with error " + itos(err) + ".");
p_framebuffer->framebuffers.insert(vk, version);
}
@@ -5561,7 +5547,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
VkResult res = vkCreateCommandPool(device, &cmd_pool_info, NULL, &split_draw_list_allocators.write[i].command_pool);
- ERR_FAIL_COND_V(res, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(res, ERR_CANT_CREATE, "vkCreateCommandPool failed with error " + itos(res) + ".");
for (int j = 0; j < frame_count; j++) {
@@ -5576,7 +5562,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
cmdbuf.commandBufferCount = 1;
VkResult err = vkAllocateCommandBuffers(device, &cmdbuf, &command_buffer);
- ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkAllocateCommandBuffers failed with error " + itos(err) + ".");
split_draw_list_allocators.write[i].command_buffers.push_back(command_buffer);
}
@@ -5625,14 +5611,14 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
if (res) {
memdelete_arr(draw_list);
draw_list = NULL;
- ERR_FAIL_V(ERR_CANT_CREATE);
+ ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkResetCommandBuffer failed with error " + itos(res) + ".");
}
res = vkBeginCommandBuffer(command_buffer, &cmdbuf_begin);
if (res) {
memdelete_arr(draw_list);
draw_list = NULL;
- ERR_FAIL_V(ERR_CANT_CREATE);
+ ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkBeginCommandBuffer failed with error " + itos(res) + ".");
}
draw_list[i].command_buffer = command_buffer;
@@ -6566,13 +6552,13 @@ void RenderingDeviceVulkan::swap_buffers() {
cmdbuf_begin.pInheritanceInfo = NULL;
VkResult err = vkResetCommandBuffer(frames[frame].setup_command_buffer, 0);
- ERR_FAIL_COND(err);
+ ERR_FAIL_COND_MSG(err, "vkResetCommandBuffer failed with error " + itos(err) + ".");
err = vkBeginCommandBuffer(frames[frame].setup_command_buffer, &cmdbuf_begin);
- ERR_FAIL_COND(err);
+ ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + ".");
context->set_setup_buffer(frames[frame].setup_command_buffer); //append now so it's added before everything else
err = vkBeginCommandBuffer(frames[frame].draw_command_buffer, &cmdbuf_begin);
- ERR_FAIL_COND(err);
+ ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + ".");
context->append_command_buffer(frames[frame].draw_command_buffer);
}
@@ -6727,7 +6713,7 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) {
cmdbuf_begin.pInheritanceInfo = NULL;
VkResult err = vkBeginCommandBuffer(frames[frame].setup_command_buffer, &cmdbuf_begin);
- ERR_FAIL_COND(err);
+ ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + ".");
context->set_setup_buffer(frames[frame].setup_command_buffer); //append now so it's added before everything else
}
@@ -6739,7 +6725,7 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) {
cmdbuf_begin.pInheritanceInfo = NULL;
VkResult err = vkBeginCommandBuffer(frames[frame].draw_command_buffer, &cmdbuf_begin);
- ERR_FAIL_COND(err);
+ ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + ".");
context->append_command_buffer(frames[frame].draw_command_buffer);
}
}
@@ -6776,7 +6762,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) {
cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
VkResult res = vkCreateCommandPool(device, &cmd_pool_info, NULL, &frames[i].command_pool);
- ERR_FAIL_COND(res);
+ ERR_FAIL_COND_MSG(res, "vkCreateCommandPool failed with error " + itos(res) + ".");
}
{ //create command buffers
@@ -6790,10 +6776,10 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) {
cmdbuf.commandBufferCount = 1;
VkResult err = vkAllocateCommandBuffers(device, &cmdbuf, &frames[i].setup_command_buffer);
- ERR_CONTINUE(err);
+ ERR_CONTINUE_MSG(err, "vkAllocateCommandBuffers failed with error " + itos(err) + ".");
err = vkAllocateCommandBuffers(device, &cmdbuf, &frames[i].draw_command_buffer);
- ERR_CONTINUE(err);
+ ERR_CONTINUE_MSG(err, "vkAllocateCommandBuffers failed with error " + itos(err) + ".");
}
{
@@ -6828,11 +6814,11 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) {
cmdbuf_begin.pInheritanceInfo = NULL;
VkResult err = vkBeginCommandBuffer(frames[0].setup_command_buffer, &cmdbuf_begin);
- ERR_FAIL_COND(err);
+ ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + ".");
context->set_setup_buffer(frames[0].setup_command_buffer); //append now so it's added before everything else
err = vkBeginCommandBuffer(frames[0].draw_command_buffer, &cmdbuf_begin);
- ERR_FAIL_COND(err);
+ ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + ".");
context->append_command_buffer(frames[0].draw_command_buffer);
}
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 30c10e922e..4a224f0ceb 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -98,8 +98,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
VkDevice device;
- Map<RID, Set<RID> > dependency_map; //IDs to IDs that depend on it
- Map<RID, Set<RID> > reverse_dependency_map; //same as above, but in reverse
+ Map<RID, Set<RID>> dependency_map; //IDs to IDs that depend on it
+ Map<RID, Set<RID>> reverse_dependency_map; //same as above, but in reverse
void _add_dependency(RID p_id, RID p_depends_on);
void _free_dependencies(RID p_id);
@@ -602,7 +602,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
uint32_t usage;
};
- Map<DescriptorPoolKey, Set<DescriptorPool *> > descriptor_pools;
+ Map<DescriptorPoolKey, Set<DescriptorPool *>> descriptor_pools;
uint32_t max_descriptors_per_pool;
DescriptorPool *_descriptor_pool_allocate(const DescriptorPoolKey &p_key);
@@ -968,7 +968,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
void _free_rids(T &p_owner, const char *p_type);
public:
- virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t> > &p_data = Vector<Vector<uint8_t> >());
+ virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t>> &p_data = Vector<Vector<uint8_t>>());
virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture);
virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index 038cae7f96..c8ff342713 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -356,39 +356,8 @@ Error VulkanContext::_create_physical_device() {
free(physical_devices);
ERR_FAIL_V(ERR_CANT_CREATE);
}
-
- /*Find the first discrete GPU with the most VRAM.*/
- {
- print_line("Selecting primary GPU.");
- VkPhysicalDeviceProperties device_properties;
- VkPhysicalDeviceMemoryProperties memory_properties;
- gpu = physical_devices[0];
- uint32_t largest_vram_size = 0;
- VkPhysicalDeviceType gpu_type = VK_PHYSICAL_DEVICE_TYPE_OTHER;
- for (uint32_t i = 0; i < gpu_count; i++) {
- vkGetPhysicalDeviceProperties(physical_devices[i], &device_properties);
-
- /*Skip virtual and CPU devices for now.*/
- if (device_properties.deviceType > VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) {
- continue;
- }
-
- vkGetPhysicalDeviceMemoryProperties(physical_devices[i], &memory_properties);
-
- /*Total all heaps in case of 3GB+1GB configurations and similar.*/
- uint32_t memory_size = 0;
- for (uint32_t j = 0; j < memory_properties.memoryHeapCount; j++) {
- memory_size += memory_properties.memoryHeaps[j].size;
- }
-
- if ((device_properties.deviceType >= gpu_type) || (device_properties.deviceType == gpu_type && memory_size > largest_vram_size)) {
- gpu = physical_devices[i];
- gpu_type = device_properties.deviceType;
- largest_vram_size = memory_size;
- print_line(device_properties.deviceName);
- }
- }
- }
+ /* for now, just grab the first physical device */
+ gpu = physical_devices[0];
free(physical_devices);
/* Look for device extensions */
@@ -1514,6 +1483,7 @@ VkPhysicalDeviceLimits VulkanContext::get_device_limits() const {
}
VulkanContext::VulkanContext() {
+ queue_props = NULL;
command_buffer_count = 0;
instance_validation_layers = NULL;
use_validation_layers = true;