diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 18 | ||||
-rw-r--r-- | drivers/unix/file_access_unix_pipe.cpp | 16 | ||||
-rw-r--r-- | drivers/unix/file_access_unix_pipe.h | 2 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 6 | ||||
-rw-r--r-- | drivers/unix/os_unix.h | 2 | ||||
-rw-r--r-- | drivers/windows/file_access_windows_pipe.cpp | 12 | ||||
-rw-r--r-- | drivers/windows/file_access_windows_pipe.h | 2 |
7 files changed, 36 insertions, 22 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 6143ce2167..393ba014c6 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1803,22 +1803,22 @@ void main() { #ifdef LIGHTMAP_BICUBIC_FILTER vec3 lm_light_l0 = textureArray_bicubic(lightmap_textures, uvw + vec3(0.0, 0.0, 0.0), lightmap_texture_size).rgb; - vec3 lm_light_l1n1 = textureArray_bicubic(lightmap_textures, uvw + vec3(0.0, 0.0, 1.0), lightmap_texture_size).rgb; - vec3 lm_light_l1_0 = textureArray_bicubic(lightmap_textures, uvw + vec3(0.0, 0.0, 2.0), lightmap_texture_size).rgb; - vec3 lm_light_l1p1 = textureArray_bicubic(lightmap_textures, uvw + vec3(0.0, 0.0, 3.0), lightmap_texture_size).rgb; + vec3 lm_light_l1n1 = (textureArray_bicubic(lightmap_textures, uvw + vec3(0.0, 0.0, 1.0), lightmap_texture_size).rgb - vec3(0.5)) * 2.0; + vec3 lm_light_l1_0 = (textureArray_bicubic(lightmap_textures, uvw + vec3(0.0, 0.0, 2.0), lightmap_texture_size).rgb - vec3(0.5)) * 2.0; + vec3 lm_light_l1p1 = (textureArray_bicubic(lightmap_textures, uvw + vec3(0.0, 0.0, 3.0), lightmap_texture_size).rgb - vec3(0.5)) * 2.0; #else vec3 lm_light_l0 = textureLod(lightmap_textures, uvw + vec3(0.0, 0.0, 0.0), 0.0).rgb; - vec3 lm_light_l1n1 = textureLod(lightmap_textures, uvw + vec3(0.0, 0.0, 1.0), 0.0).rgb; - vec3 lm_light_l1_0 = textureLod(lightmap_textures, uvw + vec3(0.0, 0.0, 2.0), 0.0).rgb; - vec3 lm_light_l1p1 = textureLod(lightmap_textures, uvw + vec3(0.0, 0.0, 3.0), 0.0).rgb; + vec3 lm_light_l1n1 = (textureLod(lightmap_textures, uvw + vec3(0.0, 0.0, 1.0), 0.0).rgb - vec3(0.5)) * 2.0; + vec3 lm_light_l1_0 = (textureLod(lightmap_textures, uvw + vec3(0.0, 0.0, 2.0), 0.0).rgb - vec3(0.5)) * 2.0; + vec3 lm_light_l1p1 = (textureLod(lightmap_textures, uvw + vec3(0.0, 0.0, 3.0), 0.0).rgb - vec3(0.5)) * 2.0; #endif vec3 n = normalize(lightmap_normal_xform * normal); ambient_light += lm_light_l0 * lightmap_exposure_normalization; - ambient_light += lm_light_l1n1 * n.y * lightmap_exposure_normalization; - ambient_light += lm_light_l1_0 * n.z * lightmap_exposure_normalization; - ambient_light += lm_light_l1p1 * n.x * lightmap_exposure_normalization; + ambient_light += lm_light_l1n1 * n.y * (lm_light_l0 * lightmap_exposure_normalization * 4.0); + ambient_light += lm_light_l1_0 * n.z * (lm_light_l0 * lightmap_exposure_normalization * 4.0); + ambient_light += lm_light_l1p1 * n.x * (lm_light_l0 * lightmap_exposure_normalization * 4.0); #else #ifdef LIGHTMAP_BICUBIC_FILTER ambient_light += textureArray_bicubic(lightmap_textures, uvw, lightmap_texture_size).rgb * lightmap_exposure_normalization; diff --git a/drivers/unix/file_access_unix_pipe.cpp b/drivers/unix/file_access_unix_pipe.cpp index 34758e8c7d..0a78429dec 100644 --- a/drivers/unix/file_access_unix_pipe.cpp +++ b/drivers/unix/file_access_unix_pipe.cpp @@ -41,7 +41,7 @@ #include <sys/types.h> #include <unistd.h> -Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd) { +Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd, bool p_blocking) { // Open pipe using handles created by pipe(fd) call in the OS.execute_with_pipe. _close(); @@ -51,6 +51,11 @@ Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd) { fd[0] = p_rfd; fd[1] = p_wfd; + if (!p_blocking) { + fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL) | O_NONBLOCK); + fcntl(fd[1], F_SETFL, fcntl(fd[1], F_GETFL) | O_NONBLOCK); + } + last_error = OK; return OK; } @@ -74,7 +79,7 @@ Error FileAccessUnixPipe::open_internal(const String &p_path, int p_mode_flags) ERR_FAIL_COND_V_MSG(!S_ISFIFO(st.st_mode), ERR_ALREADY_IN_USE, "Pipe name is already used by file."); } - int f = ::open(path.utf8().get_data(), O_RDWR | O_CLOEXEC); + int f = ::open(path.utf8().get_data(), O_RDWR | O_CLOEXEC | O_NONBLOCK); if (f < 0) { switch (errno) { case ENOENT: { @@ -129,8 +134,11 @@ uint64_t FileAccessUnixPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const ERR_FAIL_COND_V_MSG(fd[0] < 0, -1, "Pipe must be opened before use."); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); - uint64_t read = ::read(fd[0], p_dst, p_length); - if (read == p_length) { + ssize_t read = ::read(fd[0], p_dst, p_length); + if (read == -1) { + last_error = ERR_FILE_CANT_READ; + read = 0; + } else if (read != (ssize_t)p_length) { last_error = ERR_FILE_CANT_READ; } else { last_error = OK; diff --git a/drivers/unix/file_access_unix_pipe.h b/drivers/unix/file_access_unix_pipe.h index 19acdb5a37..1a4199f239 100644 --- a/drivers/unix/file_access_unix_pipe.h +++ b/drivers/unix/file_access_unix_pipe.h @@ -50,7 +50,7 @@ class FileAccessUnixPipe : public FileAccess { void _close(); public: - Error open_existing(int p_rfd, int p_wfd); + Error open_existing(int p_rfd, int p_wfd, bool p_blocking); virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file virtual bool is_open() const override; ///< true when file is open diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index ce2553456d..8a9b130068 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -493,7 +493,7 @@ Dictionary OS_Unix::get_memory_info() const { return meminfo; } -Dictionary OS_Unix::execute_with_pipe(const String &p_path, const List<String> &p_arguments) { +Dictionary OS_Unix::execute_with_pipe(const String &p_path, const List<String> &p_arguments, bool p_blocking) { #define CLEAN_PIPES \ if (pipe_in[0] >= 0) { \ ::close(pipe_in[0]); \ @@ -578,11 +578,11 @@ Dictionary OS_Unix::execute_with_pipe(const String &p_path, const List<String> & Ref<FileAccessUnixPipe> main_pipe; main_pipe.instantiate(); - main_pipe->open_existing(pipe_out[0], pipe_in[1]); + main_pipe->open_existing(pipe_out[0], pipe_in[1], p_blocking); Ref<FileAccessUnixPipe> err_pipe; err_pipe.instantiate(); - err_pipe->open_existing(pipe_err[0], 0); + err_pipe->open_existing(pipe_err[0], 0, p_blocking); ProcessInfo pi; process_map_mutex.lock(); diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index df269a59d3..3add5df055 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -83,7 +83,7 @@ public: virtual Dictionary get_memory_info() const override; virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) override; - virtual Dictionary execute_with_pipe(const String &p_path, const List<String> &p_arguments) override; + virtual Dictionary execute_with_pipe(const String &p_path, const List<String> &p_arguments, bool p_blocking = true) override; virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override; virtual Error kill(const ProcessID &p_pid) override; virtual int get_process_id() const override; diff --git a/drivers/windows/file_access_windows_pipe.cpp b/drivers/windows/file_access_windows_pipe.cpp index 0c953b14aa..9bf0f4d852 100644 --- a/drivers/windows/file_access_windows_pipe.cpp +++ b/drivers/windows/file_access_windows_pipe.cpp @@ -35,7 +35,7 @@ #include "core/os/os.h" #include "core/string/print_string.h" -Error FileAccessWindowsPipe::open_existing(HANDLE p_rfd, HANDLE p_wfd) { +Error FileAccessWindowsPipe::open_existing(HANDLE p_rfd, HANDLE p_wfd, bool p_blocking) { // Open pipe using handles created by CreatePipe(rfd, wfd, NULL, 4096) call in the OS.execute_with_pipe. _close(); @@ -44,6 +44,12 @@ Error FileAccessWindowsPipe::open_existing(HANDLE p_rfd, HANDLE p_wfd) { fd[0] = p_rfd; fd[1] = p_wfd; + if (!p_blocking) { + DWORD mode = PIPE_READMODE_BYTE | PIPE_NOWAIT; + SetNamedPipeHandleState(fd[0], &mode, nullptr, nullptr); + SetNamedPipeHandleState(fd[1], &mode, nullptr, nullptr); + } + last_error = OK; return OK; } @@ -58,7 +64,7 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE) { - h = CreateNamedPipeW((LPCWSTR)path.utf16().get_data(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 4096, 4096, 0, nullptr); + h = CreateNamedPipeW((LPCWSTR)path.utf16().get_data(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 4096, 4096, 0, nullptr); if (h == INVALID_HANDLE_VALUE) { last_error = ERR_FILE_CANT_OPEN; return last_error; @@ -100,7 +106,7 @@ uint64_t FileAccessWindowsPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) co ERR_FAIL_COND_V_MSG(fd[0] == 0, -1, "Pipe must be opened before use."); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); - DWORD read = -1; + DWORD read = 0; if (!ReadFile(fd[0], p_dst, p_length, &read, nullptr) || read != p_length) { last_error = ERR_FILE_CANT_READ; } else { diff --git a/drivers/windows/file_access_windows_pipe.h b/drivers/windows/file_access_windows_pipe.h index 4e9bd036ae..1eb3c6ef2f 100644 --- a/drivers/windows/file_access_windows_pipe.h +++ b/drivers/windows/file_access_windows_pipe.h @@ -49,7 +49,7 @@ class FileAccessWindowsPipe : public FileAccess { void _close(); public: - Error open_existing(HANDLE p_rfd, HANDLE p_wfd); + Error open_existing(HANDLE p_rfd, HANDLE p_wfd, bool p_blocking); virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file virtual bool is_open() const override; ///< true when file is open |