diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/shaders/scene.glsl | 109 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 8 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.h | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 6 | ||||
-rw-r--r-- | drivers/gles3/shader_gles3.h | 12 | ||||
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 4 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 6 | ||||
-rw-r--r-- | drivers/unix/net_socket_posix.cpp | 4 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 6 | ||||
-rw-r--r-- | drivers/wasapi/audio_driver_wasapi.cpp | 13 |
10 files changed, 84 insertions, 86 deletions
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index fae010b003..7b57f5d497 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -75,12 +75,12 @@ attribute highp vec4 instance_custom_data; // attrib:12 // uniforms // -uniform mat4 camera_matrix; -uniform mat4 camera_inverse_matrix; -uniform mat4 projection_matrix; -uniform mat4 projection_inverse_matrix; +uniform highp mat4 camera_matrix; +uniform highp mat4 camera_inverse_matrix; +uniform highp mat4 projection_matrix; +uniform highp mat4 projection_inverse_matrix; -uniform mat4 world_transform; +uniform highp mat4 world_transform; uniform highp float time; @@ -156,22 +156,22 @@ varying highp vec3 diffuse_interp; varying highp vec3 specular_interp; // general for all lights -uniform vec4 light_color; -uniform float light_specular; +uniform highp vec4 light_color; +uniform highp float light_specular; // directional -uniform vec3 light_direction; +uniform highp vec3 light_direction; // omni -uniform vec3 light_position; +uniform highp vec3 light_position; -uniform float light_range; -uniform float light_attenuation; +uniform highp float light_range; +uniform highp float light_attenuation; // spot -uniform float light_spot_attenuation; -uniform float light_spot_range; -uniform float light_spot_angle; +uniform highp float light_spot_attenuation; +uniform highp float light_spot_range; +uniform highp float light_spot_angle; void light_compute( vec3 N, @@ -262,9 +262,9 @@ void light_compute( #ifdef USE_REFLECTION_PROBE1 -uniform mat4 refprobe1_local_matrix; +uniform highp mat4 refprobe1_local_matrix; varying mediump vec4 refprobe1_reflection_normal_blend; -uniform vec3 refprobe1_box_extents; +uniform highp vec3 refprobe1_box_extents; #ifndef USE_LIGHTMAP varying mediump vec3 refprobe1_ambient_normal; @@ -274,9 +274,9 @@ varying mediump vec3 refprobe1_ambient_normal; #ifdef USE_REFLECTION_PROBE2 -uniform mat4 refprobe2_local_matrix; +uniform highp mat4 refprobe2_local_matrix; varying mediump vec4 refprobe2_reflection_normal_blend; -uniform vec3 refprobe2_box_extents; +uniform highp vec3 refprobe2_box_extents; #ifndef USE_LIGHTMAP varying mediump vec3 refprobe2_ambient_normal; @@ -310,7 +310,6 @@ uniform highp float fog_height_max; uniform mediump float fog_height_curve; #endif - #endif //fog void main() { @@ -625,19 +624,19 @@ VERTEX_SHADER_CODE { - float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); + float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); - fog_amount = pow(fog_z, fog_depth_curve); + fog_amount = pow(fog_z, fog_depth_curve); } #endif #ifdef FOG_HEIGHT_ENABLED { - float y = (camera_matrix * vec4(vertex_interp, 1.0)).y; - fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve)); + float y = (camera_matrix * vec4(vertex_interp, 1.0)).y; + fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve)); } #endif - fog_interp = vec4(fog_color,fog_amount); + fog_interp = vec4(fog_color, fog_amount); #endif //fog @@ -671,13 +670,13 @@ precision highp int; // uniforms // -uniform mat4 camera_matrix; +uniform highp mat4 camera_matrix; /* clang-format on */ -uniform mat4 camera_inverse_matrix; -uniform mat4 projection_matrix; -uniform mat4 projection_inverse_matrix; +uniform highp mat4 camera_inverse_matrix; +uniform highp mat4 projection_matrix; +uniform highp mat4 projection_inverse_matrix; -uniform mat4 world_transform; +uniform highp mat4 world_transform; uniform highp float time; @@ -704,9 +703,9 @@ varying mediump vec3 refprobe1_ambient_normal; #else uniform bool refprobe1_use_box_project; -uniform vec3 refprobe1_box_extents; +uniform highp vec3 refprobe1_box_extents; uniform vec3 refprobe1_box_offset; -uniform mat4 refprobe1_local_matrix; +uniform highp mat4 refprobe1_local_matrix; #endif //use vertex lighting @@ -731,9 +730,9 @@ varying mediump vec3 refprobe2_ambient_normal; #else uniform bool refprobe2_use_box_project; -uniform vec3 refprobe2_box_extents; +uniform highp vec3 refprobe2_box_extents; uniform vec3 refprobe2_box_offset; -uniform mat4 refprobe2_local_matrix; +uniform highp mat4 refprobe2_local_matrix; #endif //use vertex lighting @@ -874,29 +873,29 @@ uniform float ambient_energy; varying highp vec3 diffuse_interp; varying highp vec3 specular_interp; -uniform vec3 light_direction; //may be used by fog, so leave here +uniform highp vec3 light_direction; //may be used by fog, so leave here #else //done in fragment // general for all lights -uniform vec4 light_color; -uniform float light_specular; +uniform highp vec4 light_color; +uniform highp float light_specular; // directional -uniform vec3 light_direction; +uniform highp vec3 light_direction; // omni -uniform vec3 light_position; +uniform highp vec3 light_position; -uniform float light_attenuation; +uniform highp float light_attenuation; // spot -uniform float light_spot_attenuation; -uniform float light_spot_range; -uniform float light_spot_angle; +uniform highp float light_spot_attenuation; +uniform highp float light_spot_range; +uniform highp float light_spot_angle; #endif //this is needed outside above if because dual paraboloid wants it -uniform float light_range; +uniform highp float light_range; #ifdef USE_SHADOW @@ -2021,8 +2020,8 @@ FRAGMENT_SHADER_CODE #if defined(USE_VERTEX_LIGHTING) - gl_FragColor.rgb = mix(gl_FragColor.rgb,fog_interp.rgb,fog_interp.a); -#else //pixel based fog + gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_interp.rgb, fog_interp.a); +#else //pixel based fog float fog_amount = 0.0; #ifdef LIGHT_MODE_DIRECTIONAL @@ -2036,26 +2035,26 @@ FRAGMENT_SHADER_CODE { - float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); + float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); - fog_amount = pow(fog_z, fog_depth_curve); + fog_amount = pow(fog_z, fog_depth_curve); - if (fog_transmit_enabled) { - vec3 total_light = gl_FragColor.rgb; - float transmit = pow(fog_z, fog_transmit_curve); - fog_color = mix(max(total_light, fog_color), fog_color, transmit); - } + if (fog_transmit_enabled) { + vec3 total_light = gl_FragColor.rgb; + float transmit = pow(fog_z, fog_transmit_curve); + fog_color = mix(max(total_light, fog_color), fog_color, transmit); + } } #endif #ifdef FOG_HEIGHT_ENABLED { - float y = (camera_matrix * vec4(vertex, 1.0)).y; - fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve)); + float y = (camera_matrix * vec4(vertex, 1.0)).y; + fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve)); } #endif - gl_FragColor.rgb = mix(gl_FragColor.rgb,fog_color,fog_amount); + gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_color, fog_amount); #endif //use vertex lit diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 14c436fd00..ed2b39a17d 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -653,7 +653,7 @@ bool RasterizerSceneGLES3::reflection_probe_instance_begin_render(RID p_instance int best_free = -1; int best_used = -1; - uint64_t best_used_frame; + uint64_t best_used_frame = 0; for (int i = 0; i < reflection_atlas->reflections.size(); i++) { if (reflection_atlas->reflections[i].owner == RID()) { @@ -2519,7 +2519,7 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, false); } -void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform) { +void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_no_fog) { //store camera into ubo store_camera(p_cam_projection, state.ubo_data.projection_matrix); @@ -2570,7 +2570,7 @@ void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatr state.ubo_data.fog_color_enabled[0] = linear_fog.r; state.ubo_data.fog_color_enabled[1] = linear_fog.g; state.ubo_data.fog_color_enabled[2] = linear_fog.b; - state.ubo_data.fog_color_enabled[3] = env->fog_enabled ? 1.0 : 0.0; + state.ubo_data.fog_color_enabled[3] = (!p_no_fog && env->fog_enabled) ? 1.0 : 0.0; Color linear_sun = env->fog_sun_color.to_linear(); state.ubo_data.fog_sun_color_amount[0] = linear_sun.r; @@ -4083,7 +4083,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height; } - _setup_environment(env, p_cam_projection, p_cam_transform); + _setup_environment(env, p_cam_projection, p_cam_transform, p_reflection_probe.is_valid()); bool fb_cleared = false; diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index b4c4a0558f..4b4a0b9303 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -831,7 +831,7 @@ public: void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy); - void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform); + void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_no_fog = false); void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transform, bool p_use_shadows); void _setup_lights(RID *p_light_cull_result, int p_light_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_shadow_atlas); void _setup_reflections(RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_reflection_atlas, Environment *p_env); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 58c0a104c1..9faf07c2f9 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -730,7 +730,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p } }; - GLenum blit_target; + GLenum blit_target = GL_TEXTURE_2D; switch (texture->type) { case VS::TEXTURE_TYPE_2D: { @@ -948,7 +948,7 @@ void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<I Image::Format real_format; Ref<Image> img = _get_gl_image_and_format(p_sub_img, p_sub_img->get_format(), texture->flags, real_format, format, internal_format, type, compressed, srgb); - GLenum blit_target; + GLenum blit_target = GL_TEXTURE_2D; switch (texture->type) { case VS::TEXTURE_TYPE_2D: { @@ -6841,7 +6841,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level); glDisable(GL_SCISSOR_TEST); glColorMask(1, 1, 1, 1); - if (rt->buffers.active == false) { + if (!rt->buffers.active) { glDepthMask(GL_TRUE); } diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h index 9db4942163..0d360e8453 100644 --- a/drivers/gles3/shader_gles3.h +++ b/drivers/gles3/shader_gles3.h @@ -128,11 +128,13 @@ private: Vector<GLint> texture_uniform_locations; uint32_t code_version; bool ok; - Version() { - code_version = 0; - ok = false; - uniform_location = NULL; - } + Version() : + id(0), + vert_id(0), + frag_id(0), + uniform_location(NULL), + code_version(0), + ok(false) {} }; Version *version; diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 598bd3465e..8388b15edb 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1340,7 +1340,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal, vec3 binormal, vec3 t reflection_accum += reflection; } -#ifndef USE_LIGHTMAP +#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE) if (reflections[idx].ambient.a > 0.0) { //compute ambient using skybox vec3 local_amb_vec = (reflections[idx].local_matrix * vec4(normal, 0.0)).xyz; @@ -1957,7 +1957,7 @@ FRAGMENT_SHADER_CODE } else { specular_light += env_reflection_light; } -#ifndef USE_LIGHTMAP +#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE) if (ambient_accum.a > 0.0) { ambient_light = ambient_accum.rgb / ambient_accum.a; } diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 48b4369b7e..929e67faa9 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -309,7 +309,7 @@ Error DirAccessUnix::change_dir(String p_dir) { // prev_dir is the directory we are changing out of String prev_dir; char real_current_dir_name[2048]; - getcwd(real_current_dir_name, 2048); + ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG); if (prev_dir.parse_utf8(real_current_dir_name)) prev_dir = real_current_dir_name; //no utf8, maybe latin? @@ -330,7 +330,7 @@ Error DirAccessUnix::change_dir(String p_dir) { // the directory exists, so set current_dir to try_dir current_dir = try_dir; - chdir(prev_dir.utf8().get_data()); + ERR_FAIL_COND_V(chdir(prev_dir.utf8().get_data()) != 0, ERR_BUG); return OK; } @@ -405,7 +405,7 @@ DirAccessUnix::DirAccessUnix() { // set current directory to an absolute path of the current directory char real_current_dir_name[2048]; - getcwd(real_current_dir_name, 2048); + ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == NULL); if (current_dir.parse_utf8(real_current_dir_name)) current_dir = real_current_dir_name; diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index 3f03175403..2cc2032cbb 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -42,12 +42,8 @@ #include <sys/types.h> #include <unistd.h> #ifndef NO_FCNTL -#ifdef __HAIKU__ #include <fcntl.h> #else -#include <sys/fcntl.h> -#endif -#else #include <sys/ioctl.h> #endif #include <netinet/in.h> diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 6c70934bc6..7ff27be501 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -487,9 +487,11 @@ String OS_Unix::get_executable_path() const { //fix for running from a symlink char buf[256]; memset(buf, 0, 256); - readlink("/proc/self/exe", buf, sizeof(buf)); + ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf)); String b; - b.parse_utf8(buf); + if (len > 0) { + b.parse_utf8(buf, len); + } if (b == "") { WARN_PRINT("Couldn't get executable path from /proc/self/exe, using argv[0]"); return OS::get_executable_path(); diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 3d4979175b..a91e41b008 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -796,19 +796,18 @@ Error AudioDriverWASAPI::capture_start() { return err; } - if (audio_input.active == false) { - audio_input.audio_client->Start(); - audio_input.active = true; - - return OK; + if (audio_input.active) { + return FAILED; } - return FAILED; + audio_input.audio_client->Start(); + audio_input.active = true; + return OK; } Error AudioDriverWASAPI::capture_stop() { - if (audio_input.active == true) { + if (audio_input.active) { audio_input.audio_client->Stop(); audio_input.active = false; |