summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 14:29:06 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit07bc4e2f96f8f47991339654ff4ab16acc19d44f (patch)
tree43cdc7cfe8239c23065616a931de3769d2db1e86 /drivers
parent0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (diff)
Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp2
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp4
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp13
-rw-r--r--drivers/gles2/shaders/blend_shape.glsl1
-rw-r--r--drivers/gles2/shaders/particles.glsl1
-rw-r--r--drivers/gles2/shaders/scene.glsl2
-rw-r--r--drivers/unix/os_unix.cpp1
-rw-r--r--drivers/unix/thread_posix.cpp2
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp10
-rw-r--r--drivers/vulkan/vulkan_context.cpp2
-rw-r--r--drivers/windows/dir_access_windows.cpp4
-rw-r--r--drivers/windows/file_access_windows.cpp4
-rw-r--r--drivers/windows/thread_windows.cpp2
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp1
14 files changed, 49 insertions, 0 deletions
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index b6e36d87a5..c92eb4cd11 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -1887,6 +1887,7 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
+
void RasterizerCanvasGLES2::reset_canvas() {
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
@@ -1918,6 +1919,7 @@ void RasterizerCanvasGLES2::_bind_quad_buffer() {
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
}
+
void RasterizerCanvasGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
state.canvas_shader.set_uniform(CanvasShaderGLES2::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES2::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y));
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index 02e9d7d504..c66506f182 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -460,6 +460,7 @@ int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance)
return shadow_size;
}
+
//////////////////////////////////////////////////////
RID RasterizerSceneGLES2::reflection_atlas_create() {
@@ -840,6 +841,7 @@ void RasterizerSceneGLES2::environment_set_fog_height(RID p_env, bool p_enable,
env->fog_height_max = p_max_height;
env->fog_height_curve = p_height_curve;
}
+
bool RasterizerSceneGLES2::is_environment(RID p_env) {
return environment_owner.owns(p_env);
}
@@ -917,6 +919,7 @@ RID RasterizerSceneGLES2::gi_probe_instance_create() {
void RasterizerSceneGLES2::gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data) {
}
+
void RasterizerSceneGLES2::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {
}
@@ -965,6 +968,7 @@ void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geo
_add_geometry_with_material(p_geometry, p_instance, p_owner, material, p_depth_pass, p_shadow_pass);
}
}
+
void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass, bool p_shadow_pass) {
bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture || p_material->shader->spatial.uses_depth_texture;
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_MIX;
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 0636676ffa..6eef04b87f 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -2617,6 +2617,7 @@ Vector<Vector<uint8_t>> RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RI
return mesh->surfaces[p_surface]->blend_shape_data;
}
+
Vector<AABB> RasterizerStorageGLES2::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, Vector<AABB>());
@@ -2782,6 +2783,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
return aabb;
}
+
void RasterizerStorageGLES2::mesh_clear(RID p_mesh) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -3560,6 +3562,7 @@ Transform RasterizerStorageGLES2::skeleton_bone_get_transform(RID p_skeleton, in
return ret;
}
+
void RasterizerStorageGLES2::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -3987,6 +3990,7 @@ void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, floa
reflection_probe->max_distance = p_distance;
reflection_probe->instance_change_notify(true, false);
}
+
void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3994,6 +3998,7 @@ void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vec
reflection_probe->extents = p_extents;
reflection_probe->instance_change_notify(true, false);
}
+
void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4009,6 +4014,7 @@ void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool
reflection_probe->interior = p_enable;
reflection_probe->instance_change_notify(true, false);
}
+
void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4023,6 +4029,7 @@ void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bo
reflection_probe->enable_shadows = p_enable;
reflection_probe->instance_change_notify(true, false);
}
+
void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4048,6 +4055,7 @@ AABB RasterizerStorageGLES2::reflection_probe_get_aabb(RID p_probe) const {
return aabb;
}
+
RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
@@ -4068,6 +4076,7 @@ Vector3 RasterizerStorageGLES2::reflection_probe_get_extents(RID p_probe) const
return reflection_probe->extents;
}
+
Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
@@ -4160,6 +4169,7 @@ void RasterizerStorageGLES2::gi_probe_set_compress(RID p_probe, bool p_enable) {
bool RasterizerStorageGLES2::gi_probe_is_compressed(RID p_probe) const {
return false;
}
+
float RasterizerStorageGLES2::gi_probe_get_energy(RID p_probe) const {
return 0;
}
@@ -4204,11 +4214,13 @@ void RasterizerStorageGLES2::lightmap_capture_set_bounds(RID p_capture, const AA
capture->bounds = p_bounds;
capture->instance_change_notify(true, false);
}
+
AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, AABB());
return capture->bounds;
}
+
void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
@@ -4223,6 +4235,7 @@ void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Ve
}
capture->instance_change_notify(true, false);
}
+
Vector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, Vector<uint8_t>());
diff --git a/drivers/gles2/shaders/blend_shape.glsl b/drivers/gles2/shaders/blend_shape.glsl
index 7a0a7ebe99..e229da6f18 100644
--- a/drivers/gles2/shaders/blend_shape.glsl
+++ b/drivers/gles2/shaders/blend_shape.glsl
@@ -190,4 +190,5 @@ void main() {
void main() {
}
+
/* clang-format on */
diff --git a/drivers/gles2/shaders/particles.glsl b/drivers/gles2/shaders/particles.glsl
index 1575db701f..d762dade2f 100644
--- a/drivers/gles2/shaders/particles.glsl
+++ b/drivers/gles2/shaders/particles.glsl
@@ -257,4 +257,5 @@ FRAGMENT_SHADER_CODE
}
}
+
/* clang-format on */
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index d658ccd5cd..0311dc4742 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -1065,6 +1065,7 @@ float G_GGX_2cos(float cos_theta_m, float alpha) {
// float sin2 = (1.0 - cos2);
// return 1.0 / (cos_theta_m + sqrt(cos2 + alpha * alpha * sin2));
}
+
*/
// This approximates G_GGX_2cos(cos_theta_l, alpha) * G_GGX_2cos(cos_theta_v, alpha)
@@ -1087,6 +1088,7 @@ float G_GGX_anisotropic_2cos(float cos_theta_m, float alpha_x, float alpha_y, fl
float s_y = alpha_y * sin_phi;
return 1.0 / max(cos_theta_m + sqrt(cos2 + (s_x * s_x + s_y * s_y) * sin2), 0.001);
}
+
*/
// This approximates G_GGX_anisotropic_2cos(cos_theta_l, ...) * G_GGX_anisotropic_2cos(cos_theta_v, ...)
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 920d594ea1..3ba667b2f7 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -244,6 +244,7 @@ void OS_Unix::delay_usec(uint32_t p_usec) const {
while (nanosleep(&rem, &rem) == EINTR) {
}
}
+
uint64_t OS_Unix::get_ticks_usec() const {
#if defined(__APPLE__)
uint64_t longtime = mach_absolute_time() * _clock_scale;
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index dda1edc3c3..16897883e8 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -87,6 +87,7 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_
return tr;
}
+
Thread::ID ThreadPosix::get_thread_id_func_posix() {
void *value = pthread_getspecific(thread_id_key);
@@ -97,6 +98,7 @@ Thread::ID ThreadPosix::get_thread_id_func_posix() {
pthread_setspecific(thread_id_key, (void *)memnew(ID(new_id)));
return new_id;
}
+
void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
ThreadPosix *tp = static_cast<ThreadPosix *>(p_thread);
ERR_FAIL_COND(!tp);
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index f8b0eafcd0..ea99594810 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -2699,6 +2699,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
return OK;
}
+
Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID p_to_texture, bool p_sync_with_draw) {
_THREAD_SAFE_METHOD_
@@ -5323,12 +5324,14 @@ int RenderingDeviceVulkan::screen_get_width(DisplayServer::WindowID p_screen) co
ERR_FAIL_COND_V_MSG(local_device.is_valid(), -1, "Local devices have no screen");
return context->window_get_width(p_screen);
}
+
int RenderingDeviceVulkan::screen_get_height(DisplayServer::WindowID p_screen) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(local_device.is_valid(), -1, "Local devices have no screen");
return context->window_get_height(p_screen);
}
+
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuffer_format() const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(local_device.is_valid(), INVALID_ID, "Local devices have no screen");
@@ -5978,6 +5981,7 @@ void RenderingDeviceVulkan::draw_list_bind_vertex_array(DrawListID p_list, RID p
dl->validation.vertex_array_size = vertex_array->vertex_count;
vkCmdBindVertexBuffers(dl->command_buffer, 0, vertex_array->buffers.size(), vertex_array->buffers.ptr(), vertex_array->offsets.ptr());
}
+
void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_index_array) {
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
@@ -6164,6 +6168,7 @@ void RenderingDeviceVulkan::draw_list_enable_scissor(DrawListID p_list, const Re
vkCmdSetScissor(dl->command_buffer, 0, 1, &scissor);
}
+
void RenderingDeviceVulkan::draw_list_disable_scissor(DrawListID p_list) {
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
@@ -6302,6 +6307,7 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l
cl->validation.pipeline_push_constant_size = pipeline->push_constant_size;
#endif
}
+
void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, RID p_uniform_set, uint32_t p_index) {
ERR_FAIL_COND(p_list != ID_TYPE_COMPUTE_LIST);
ERR_FAIL_COND(!compute_list);
@@ -6424,6 +6430,7 @@ void RenderingDeviceVulkan::compute_list_set_push_constant(ComputeListID p_list,
cl->validation.pipeline_push_constant_suppplied = true;
#endif
}
+
void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t p_x_groups, uint32_t p_y_groups, uint32_t p_z_groups) {
ERR_FAIL_COND(p_list != ID_TYPE_COMPUTE_LIST);
ERR_FAIL_COND(!compute_list);
@@ -6646,6 +6653,7 @@ void RenderingDeviceVulkan::_free_internal(RID p_id) {
ERR_PRINT("Attempted to free invalid ID: " + itos(p_id.get_id()));
}
}
+
void RenderingDeviceVulkan::free(RID p_id) {
_THREAD_SAFE_METHOD_
@@ -7163,10 +7171,12 @@ uint64_t RenderingDeviceVulkan::get_captured_timestamp_gpu_time(uint32_t p_index
return l;
}
+
uint64_t RenderingDeviceVulkan::get_captured_timestamp_cpu_time(uint32_t p_index) const {
ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, 0);
return frames[frame].timestamp_cpu_result_values[p_index];
}
+
String RenderingDeviceVulkan::get_captured_timestamp_name(uint32_t p_index) const {
ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, String());
return frames[frame].timestamp_result_names[p_index];
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index 875ace32a5..a8a29aaeea 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -1459,9 +1459,11 @@ VkDevice VulkanContext::get_device() {
VkPhysicalDevice VulkanContext::get_physical_device() {
return gpu;
}
+
int VulkanContext::get_swapchain_image_count() const {
return swapchainImageCount;
}
+
uint32_t VulkanContext::get_graphics_queue() const {
return graphics_queue_family_index;
}
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index 52ba8527ab..d0f06ae4c4 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -101,9 +101,11 @@ void DirAccessWindows::list_dir_end() {
p->h = INVALID_HANDLE_VALUE;
}
}
+
int DirAccessWindows::get_drive_count() {
return drive_count;
}
+
String DirAccessWindows::get_drive(int p_drive) {
if (p_drive < 0 || p_drive >= drive_count)
return "";
@@ -298,6 +300,7 @@ Error DirAccessWindows::remove(String p_path) {
else
return ::_wunlink(p_path.c_str()) == 0 ? OK : FAILED;
}
+
/*
FileType DirAccessWindows::get_file_type(const String& p_file) const {
@@ -325,6 +328,7 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const {
return (attr&FILE_ATTRIBUTE_DIRECTORY)?FILE_TYPE_
}
+
*/
size_t DirAccessWindows::get_space_left() {
uint64_t bytes = 0;
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index b74e89e2dc..50366d0b2d 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -188,6 +188,7 @@ String FileAccessWindows::get_path_absolute() const {
bool FileAccessWindows::is_open() const {
return (f != nullptr);
}
+
void FileAccessWindows::seek(size_t p_position) {
ERR_FAIL_COND(!f);
last_error = OK;
@@ -195,12 +196,14 @@ void FileAccessWindows::seek(size_t p_position) {
check_errors();
prev_op = 0;
}
+
void FileAccessWindows::seek_end(int64_t p_position) {
ERR_FAIL_COND(!f);
if (fseek(f, p_position, SEEK_END))
check_errors();
prev_op = 0;
}
+
size_t FileAccessWindows::get_position() const {
size_t aux_position = 0;
aux_position = ftell(f);
@@ -209,6 +212,7 @@ size_t FileAccessWindows::get_position() const {
};
return aux_position;
}
+
size_t FileAccessWindows::get_len() const {
ERR_FAIL_COND_V(!f, 0);
diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp
index adc3a9a019..ca7d936fac 100644
--- a/drivers/windows/thread_windows.cpp
+++ b/drivers/windows/thread_windows.cpp
@@ -66,9 +66,11 @@ Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void
return tr;
}
+
Thread::ID ThreadWindows::get_thread_id_func_windows() {
return (ID)GetCurrentThreadId(); //must implement
}
+
void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
ThreadWindows *tp = static_cast<ThreadWindows *>(p_thread);
ERR_FAIL_COND(!tp);
diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index 9ff1030165..df7d2488fd 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -150,6 +150,7 @@ void AudioDriverXAudio2::lock() {
return;
mutex.lock();
}
+
void AudioDriverXAudio2::unlock() {
if (!thread)
return;