summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp3
-rw-r--r--drivers/gles3/shaders/canvas.glsl59
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp57
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h2
-rw-r--r--drivers/windows/file_access_windows.cpp18
5 files changed, 83 insertions, 56 deletions
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 070c661c8a..1f3b76f5cd 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -795,7 +795,6 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height";
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color";
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv";
- //actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_SHADOW_COLOR"]="light_shadow_color";
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light";
actions[VS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color";
@@ -805,9 +804,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
-
actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
/** SPATIAL SHADER **/
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index f436ef06f7..3bbeb1149d 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -285,7 +285,19 @@ MATERIAL_UNIFORMS
FRAGMENT_SHADER_GLOBALS
-void light_compute(inout vec4 light,vec2 light_vec,float light_height,vec4 light_color,vec2 light_uv,vec4 shadow,vec3 normal,vec2 uv,vec2 screen_uv,vec4 color) {
+void light_compute(
+ inout vec4 light,
+ inout vec2 light_vec,
+ inout float light_height,
+ inout vec4 light_color,
+ vec2 light_uv,
+ inout vec4 shadow_color,
+ vec3 normal,
+ vec2 uv,
+#if defined(SCREEN_UV_USED)
+ vec2 screen_uv,
+#endif
+ vec4 color) {
#if defined(USE_LIGHT_SHADER_CODE)
@@ -462,39 +474,41 @@ FRAGMENT_SHADER_CODE
float att=1.0;
vec2 light_uv = light_uv_interp.xy;
- vec4 light = texture(light_texture,light_uv) * light_color;
-#if defined(SHADOW_COLOR_USED)
- vec4 shadow_color=vec4(0.0,0.0,0.0,0.0);
-#endif
+ vec4 light = texture(light_texture,light_uv);
if (any(lessThan(light_uv_interp.xy,vec2(0.0,0.0))) || any(greaterThanEqual(light_uv_interp.xy,vec2(1.0,1.0)))) {
color.a*=light_outside_alpha; //invisible
} else {
+ float real_light_height = light_height;
+ vec4 real_light_color = light_color;
+ vec4 real_light_shadow_color = light_shadow_color;
#if defined(USE_LIGHT_SHADER_CODE)
//light is written by the light shader
- light_compute(light,light_vec,light_height,light_color,light_uv,shadow,normal,uv,screen_uv,color);
+ light_compute(
+ light,
+ light_vec,
+ real_light_height,
+ real_light_color,
+ light_uv,
+ real_light_shadow_color,
+ normal,
+ uv,
+#if defined(SCREEN_UV_USED)
+ screen_uv,
+#endif
+ color);
+#endif
-#else
+ light *= real_light_color;
if (normal_used) {
-
- vec3 light_normal = normalize(vec3(light_vec,-light_height));
+ vec3 light_normal = normalize(vec3(light_vec,-real_light_height));
light*=max(dot(-light_normal,normal),0.0);
}
color*=light;
-/*
-#ifdef USE_NORMAL
- color.xy=local_rot.xy;//normal.xy;
- color.zw=vec2(0.0,1.0);
-#endif
-*/
-
-//light shader code
-#endif
-
#ifdef USE_SHADOWS
@@ -634,13 +648,8 @@ FRAGMENT_SHADER_CODE
#endif
-
-#if defined(SHADOW_COLOR_USED)
- color=mix(shadow_color,color,shadow_attenuation);
-#else
//color*=shadow_attenuation;
- color=mix(light_shadow_color,color,shadow_attenuation);
-#endif
+ color=mix(real_light_shadow_color,color,shadow_attenuation);
//use shadows
#endif
}
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index fac73da44d..733c7cc80c 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -60,7 +60,7 @@ void AudioDriverPulseAudio::pa_sink_info_cb(pa_context *c, const pa_sink_info *l
return;
}
- ad->pa_channels = l->channel_map.channels;
+ ad->pa_map = l->channel_map;
ad->pa_status++;
}
@@ -73,7 +73,7 @@ void AudioDriverPulseAudio::pa_server_info_cb(pa_context *c, const pa_server_inf
void AudioDriverPulseAudio::detect_channels() {
- pa_channels = 2;
+ pa_channel_map_init_stereo(&pa_map);
if (device_name == "Default") {
// Get the default output device name
@@ -129,60 +129,64 @@ Error AudioDriverPulseAudio::init_device() {
}
// Detect the amount of channels PulseAudio is using
- // Note: If using an even amount of channels (2, 4, etc) channels and pa_channels will be equal,
- // if not then pa_channels will have the real amount of channels PulseAudio is using and channels
- // will have the amount of channels Godot is using (in this case it's pa_channels + 1)
+ // Note: If using an even amount of channels (2, 4, etc) channels and pa_map.channels will be equal,
+ // if not then pa_map.channels will have the real amount of channels PulseAudio is using and channels
+ // will have the amount of channels Godot is using (in this case it's pa_map.channels + 1)
detect_channels();
- switch (pa_channels) {
+ switch (pa_map.channels) {
case 1: // Mono
case 3: // Surround 2.1
case 5: // Surround 5.0
case 7: // Surround 7.0
- channels = pa_channels + 1;
+ channels = pa_map.channels + 1;
break;
case 2: // Stereo
case 4: // Surround 4.0
case 6: // Surround 5.1
case 8: // Surround 7.1
- channels = pa_channels;
+ channels = pa_map.channels;
break;
default:
- WARN_PRINTS("PulseAudio: Unsupported number of channels: " + itos(pa_channels));
- pa_channels = 2;
+ WARN_PRINTS("PulseAudio: Unsupported number of channels: " + itos(pa_map.channels));
+ pa_channel_map_init_stereo(&pa_map);
channels = 2;
break;
}
- pa_sample_spec spec;
- spec.format = PA_SAMPLE_S16LE;
- spec.channels = pa_channels;
- spec.rate = mix_rate;
-
int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
- pa_buffer_size = buffer_frames * pa_channels;
+ pa_buffer_size = buffer_frames * pa_map.channels;
if (OS::get_singleton()->is_stdout_verbose()) {
- print_line("PulseAudio: detected " + itos(pa_channels) + " channels");
+ print_line("PulseAudio: detected " + itos(pa_map.channels) + " channels");
print_line("PulseAudio: audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms");
}
+ pa_sample_spec spec;
+ spec.format = PA_SAMPLE_S16LE;
+ spec.channels = pa_map.channels;
+ spec.rate = mix_rate;
+
+ pa_str = pa_stream_new(pa_ctx, "Sound", &spec, &pa_map);
+ if (pa_str == NULL) {
+ ERR_PRINTS("PulseAudio: pa_stream_new error: " + String(pa_strerror(pa_context_errno(pa_ctx))));
+ ERR_FAIL_V(ERR_CANT_OPEN);
+ }
+
pa_buffer_attr attr;
// set to appropriate buffer length (in bytes) from global settings
- attr.tlength = pa_buffer_size * sizeof(int16_t);
+ // Note: PulseAudio defaults to 4 fragments, which means that the actual
+ // latency is tlength / fragments. It seems that the PulseAudio has no way
+ // to get the fragments number so we're hardcoding this to the default of 4
+ const int fragments = 4;
+ attr.tlength = pa_buffer_size * sizeof(int16_t) * fragments;
// set them to be automatically chosen
attr.prebuf = (uint32_t)-1;
attr.maxlength = (uint32_t)-1;
attr.minreq = (uint32_t)-1;
- pa_str = pa_stream_new(pa_ctx, "Sound", &spec, NULL);
- if (pa_str == NULL) {
- ERR_PRINTS("PulseAudio: pa_stream_new error: " + String(pa_strerror(pa_context_errno(pa_ctx))));
- ERR_FAIL_V(ERR_CANT_OPEN);
- }
-
const char *dev = device_name == "Default" ? NULL : device_name.utf8().get_data();
pa_stream_flags flags = pa_stream_flags(PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE);
int error_code = pa_stream_connect_playback(pa_str, dev, &attr, flags, NULL, NULL);
@@ -297,7 +301,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
ad->unlock();
- if (ad->channels == ad->pa_channels) {
+ if (ad->channels == ad->pa_map.channels) {
for (unsigned int i = 0; i < ad->pa_buffer_size; i++) {
ad->samples_out[i] = ad->samples_in[i] >> 16;
}
@@ -307,7 +311,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
unsigned int out_idx = 0;
for (unsigned int i = 0; i < ad->buffer_frames; i++) {
- for (unsigned int j = 0; j < ad->pa_channels - 1; j++) {
+ for (unsigned int j = 0; j < ad->pa_map.channels - 1; j++) {
ad->samples_out[out_idx++] = ad->samples_in[in_idx++] >> 16;
}
uint32_t l = ad->samples_in[in_idx++];
@@ -516,7 +520,6 @@ AudioDriverPulseAudio::AudioDriverPulseAudio() {
buffer_frames = 0;
pa_buffer_size = 0;
channels = 0;
- pa_channels = 0;
pa_ready = 0;
pa_status = 0;
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h
index 934031e2a5..b471f5f9d5 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.h
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.h
@@ -47,6 +47,7 @@ class AudioDriverPulseAudio : public AudioDriver {
pa_mainloop *pa_ml;
pa_context *pa_ctx;
pa_stream *pa_str;
+ pa_channel_map pa_map;
String device_name;
String new_device;
@@ -59,7 +60,6 @@ class AudioDriverPulseAudio : public AudioDriver {
unsigned int buffer_frames;
unsigned int pa_buffer_size;
int channels;
- int pa_channels;
int pa_ready;
int pa_status;
Array pa_devices;
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 23c8ea2ec7..d4b8a8c361 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -78,6 +78,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
/* pretty much every implementation that uses fopen as primary
backend supports utf8 encoding */
+
struct _stat st;
if (_wstat(path.c_str(), &st) == 0) {
@@ -85,6 +86,23 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
return ERR_FILE_CANT_OPEN;
};
+#ifdef TOOLS_ENABLED
+ if (p_mode_flags==READ) {
+ WIN32_FIND_DATAW d = {0};
+ HANDLE f = FindFirstFileW(filename.c_str(),&d);
+ if (f) {
+ String fname = d.cFileName;
+ if (fname!=String()) {
+
+ String base_file = filename.get_file();
+ if (base_file!=fname && base_file.findn(fname)==0) {
+ WARN_PRINTS("Case mismatch opening file '"+base_file+"', stored as '"+fname+"' in the filesystem. This file will not open when exported to other platforms.");
+ }
+ }
+ FindClose(f);
+ }
+ }
+#endif
if (is_backup_save_enabled() && p_mode_flags & WRITE && !(p_mode_flags & READ)) {
save_path = path;
path = path + ".tmp";