summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp2
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp28
-rw-r--r--drivers/gles3/shaders/copy.glsl4
-rw-r--r--drivers/unix/file_access_unix.cpp5
-rw-r--r--drivers/unix/file_access_unix.h1
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp2
-rw-r--r--drivers/unix/stream_peer_tcp_posix.h2
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp88
-rw-r--r--drivers/windows/file_access_windows.cpp8
-rw-r--r--drivers/windows/file_access_windows.h1
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.cpp2
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.h2
12 files changed, 134 insertions, 11 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index da6df7198d..d1892eb1e8 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -4916,7 +4916,6 @@ void RasterizerSceneGLES3::initialize() {
const int ubo_light_size = 160;
state.ubo_light_size = ubo_light_size;
state.max_ubo_lights = MIN(RenderList::MAX_LIGHTS, max_ubo_size / ubo_light_size);
- print_line("GLES3: max ubo light: " + itos(state.max_ubo_lights));
state.spot_array_tmp = (uint8_t *)memalloc(ubo_light_size * state.max_ubo_lights);
state.omni_array_tmp = (uint8_t *)memalloc(ubo_light_size * state.max_ubo_lights);
@@ -4942,7 +4941,6 @@ void RasterizerSceneGLES3::initialize() {
state.scene_shader.add_custom_define("#define MAX_FORWARD_LIGHTS " + itos(state.max_forward_lights_per_object) + "\n");
state.max_ubo_reflections = MIN(RenderList::MAX_REFLECTIONS, max_ubo_size / sizeof(ReflectionProbeDataUBO));
- print_line("GLES3: max ubo reflections: " + itos(state.max_ubo_reflections) + ", ubo size: " + itos(sizeof(ReflectionProbeDataUBO)));
state.reflection_array_tmp = (uint8_t *)memalloc(sizeof(ReflectionProbeDataUBO) * state.max_ubo_reflections);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 7dc4f71b8e..0fc095a868 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -876,11 +876,34 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, VS::CubeMapSi
}
}
+ Image::Format img_format;
+
+ //convert special case RGB10_A2 to RGBA8 because it's not a supported image format
+ if (texture->gl_internal_format_cache == GL_RGB10_A2) {
+
+ img_format = Image::FORMAT_RGBA8;
+
+ uint32_t *ptr = (uint32_t *)wb.ptr();
+ uint32_t num_pixels = data_size / 4;
+
+ for (int ofs = 0; ofs < num_pixels; ofs++) {
+ uint32_t px = ptr[ofs];
+ uint32_t a = px >> 30 & 0xFF;
+
+ ptr[ofs] = (px >> 2 & 0xFF) |
+ (px >> 12 & 0xFF) << 8 |
+ (px >> 22 & 0xFF) << 16 |
+ (a | a << 2 | a << 4 | a << 6) << 24;
+ }
+ } else {
+ img_format = texture->format;
+ }
+
wb = PoolVector<uint8_t>::Write();
data.resize(data_size);
- Image *img = memnew(Image(texture->alloc_width, texture->alloc_height, texture->mipmaps > 1 ? true : false, texture->format, data));
+ Image *img = memnew(Image(texture->alloc_width, texture->alloc_height, texture->mipmaps > 1 ? true : false, img_format, data));
return Ref<Image>(img);
#else
@@ -5346,7 +5369,7 @@ void RasterizerStorageGLES3::particles_set_emitting(RID p_particles, bool p_emit
Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND(!particles);
if (p_emitting != particles->emitting) {
- // Restart is overriden by set_emitting
+ // Restart is overridden by set_emitting
particles->restart_request = false;
}
particles->emitting = p_emitting;
@@ -5694,6 +5717,7 @@ void RasterizerStorageGLES3::_particles_process(Particles *p_particles, float p_
SWAP(p_particles->particle_buffers[0], p_particles->particle_buffers[1]);
SWAP(p_particles->particle_vaos[0], p_particles->particle_vaos[1]);
+ glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
glBindVertexArray(0);
/* //debug particles :D
glBindBuffer(GL_ARRAY_BUFFER, p_particles->particle_buffers[0]);
diff --git a/drivers/gles3/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl
index 743fe122d1..1b7c626d3c 100644
--- a/drivers/gles3/shaders/copy.glsl
+++ b/drivers/gles3/shaders/copy.glsl
@@ -131,7 +131,7 @@ void main() {
#elif defined(USE_ASYM_PANO)
- // When an assymetrical projection matrix is used (applicable for stereoscopic rendering i.e. VR) we need to do this calculation per fragment to get a perspective correct result.
+ // When an asymmetrical projection matrix is used (applicable for stereoscopic rendering i.e. VR) we need to do this calculation per fragment to get a perspective correct result.
// Note that we're ignoring the x-offset for IPD, with Z sufficiently in the distance it becomes neglectible, as a result we could probably just set cube_normal.z to -1.
// The Matrix[2][0] (= asym_proj.x) and Matrix[2][1] (= asym_proj.z) values are what provide the right shift in the image.
@@ -161,7 +161,7 @@ void main() {
#ifdef SRGB_TO_LINEAR
- color.rgb = mix(pow((color.rgb + vec3(0.055)) * (1.0 / (1 + 0.055)),vec3(2.4)),color.rgb * (1.0 / 12.92),lessThan(color.rgb,vec3(0.04045)));
+ color.rgb = mix(pow((color.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),color.rgb * (1.0 / 12.92),lessThan(color.rgb,vec3(0.04045)));
#endif
#ifdef DEBUG_GRADIENT
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index 1ed3999e1e..5b093a5885 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -236,6 +236,11 @@ void FileAccessUnix::store_8(uint8_t p_dest) {
ERR_FAIL_COND(fwrite(&p_dest, 1, 1, f) != 1);
}
+void FileAccessUnix::store_buffer(const uint8_t *p_src, int p_length) {
+ ERR_FAIL_COND(!f);
+ ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != p_length);
+}
+
bool FileAccessUnix::file_exists(const String &p_path) {
int err;
diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h
index 6f792076b8..dbb1c9f3b5 100644
--- a/drivers/unix/file_access_unix.h
+++ b/drivers/unix/file_access_unix.h
@@ -75,6 +75,7 @@ public:
virtual void flush();
virtual void store_8(uint8_t p_dest); ///< store a byte
+ virtual void store_buffer(const uint8_t *p_src, int p_length); ///< store an array of bytes
virtual bool file_exists(const String &p_path); ///< return true if a file exists
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index ba9481d36b..17112e5ab5 100644
--- a/drivers/unix/stream_peer_tcp_posix.cpp
+++ b/drivers/unix/stream_peer_tcp_posix.cpp
@@ -304,7 +304,7 @@ Error StreamPeerTCPPosix::read(uint8_t *p_buffer, int p_bytes, int &r_received,
return OK;
};
-void StreamPeerTCPPosix::set_nodelay(bool p_enabled) {
+void StreamPeerTCPPosix::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!is_connected_to_host());
int flag = p_enabled ? 1 : 0;
diff --git a/drivers/unix/stream_peer_tcp_posix.h b/drivers/unix/stream_peer_tcp_posix.h
index 5770ae48f4..bcebe57771 100644
--- a/drivers/unix/stream_peer_tcp_posix.h
+++ b/drivers/unix/stream_peer_tcp_posix.h
@@ -77,7 +77,7 @@ public:
virtual Status get_status() const;
virtual void disconnect_from_host();
- virtual void set_nodelay(bool p_enabled);
+ virtual void set_no_delay(bool p_enabled);
static void make_default();
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index 4c80e70a95..36acfb10d1 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -40,6 +40,76 @@ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
const IID IID_IAudioClient = __uuidof(IAudioClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
+static bool default_device_changed = false;
+
+class CMMNotificationClient : public IMMNotificationClient {
+ LONG _cRef;
+ IMMDeviceEnumerator *_pEnumerator;
+
+public:
+ CMMNotificationClient() :
+ _cRef(1),
+ _pEnumerator(NULL) {}
+ ~CMMNotificationClient() {
+ if ((_pEnumerator) != NULL) {
+ (_pEnumerator)->Release();
+ (_pEnumerator) = NULL;
+ }
+ }
+
+ ULONG STDMETHODCALLTYPE AddRef() {
+ return InterlockedIncrement(&_cRef);
+ }
+
+ ULONG STDMETHODCALLTYPE Release() {
+ ULONG ulRef = InterlockedDecrement(&_cRef);
+ if (0 == ulRef) {
+ delete this;
+ }
+ return ulRef;
+ }
+
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID **ppvInterface) {
+ if (IID_IUnknown == riid) {
+ AddRef();
+ *ppvInterface = (IUnknown *)this;
+ } else if (__uuidof(IMMNotificationClient) == riid) {
+ AddRef();
+ *ppvInterface = (IMMNotificationClient *)this;
+ } else {
+ *ppvInterface = NULL;
+ return E_NOINTERFACE;
+ }
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId) {
+ return S_OK;
+ };
+
+ HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId) {
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState) {
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) {
+ if (flow == eRender && role == eConsole) {
+ default_device_changed = true;
+ }
+
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) {
+ return S_OK;
+ }
+};
+
+static CMMNotificationClient notif_client;
+
Error AudioDriverWASAPI::init_device(bool reinit) {
WAVEFORMATEX *pwfex;
@@ -54,7 +124,7 @@ Error AudioDriverWASAPI::init_device(bool reinit) {
hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
if (reinit) {
// In case we're trying to re-initialize the device prevent throwing this error on the console,
- // otherwise if there is currently no devie available this will spam the console.
+ // otherwise if there is currently no device available this will spam the console.
if (hr != S_OK) {
return ERR_CANT_OPEN;
}
@@ -62,6 +132,11 @@ Error AudioDriverWASAPI::init_device(bool reinit) {
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
}
+ hr = enumerator->RegisterEndpointNotificationCallback(&notif_client);
+ if (hr != S_OK) {
+ ERR_PRINT("WASAPI: RegisterEndpointNotificationCallback error");
+ }
+
hr = device->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&audio_client);
if (reinit) {
if (hr != S_OK) {
@@ -148,6 +223,8 @@ Error AudioDriverWASAPI::finish_device() {
if (audio_client) {
if (active) {
audio_client->Stop();
+ audio_client->Release();
+ audio_client = NULL;
active = false;
}
}
@@ -323,6 +400,15 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
}
}
+ if (default_device_changed) {
+ Error err = ad->finish_device();
+ if (err != OK) {
+ ERR_PRINT("WASAPI: finish_device error");
+ }
+
+ default_device_changed = false;
+ }
+
if (!ad->audio_client) {
Error err = ad->init_device(true);
if (err == OK) {
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 832d75b17d..072790876f 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -148,6 +148,9 @@ void FileAccessWindows::close() {
}
save_path = "";
+ if (rename_error) {
+ ERR_EXPLAIN("Safe save failed. This may be a permissions problem, but also may happen because you are running a paranoid antivirus. If this is the case, please switch to Windows Defender or disable the 'safe save' option in editor settings. This makes it work, but increases the risk of file corruption in a crash.");
+ }
ERR_FAIL_COND(rename_error);
}
}
@@ -232,6 +235,11 @@ void FileAccessWindows::store_8(uint8_t p_dest) {
fwrite(&p_dest, 1, 1, f);
}
+void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) {
+ ERR_FAIL_COND(!f);
+ ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != p_length);
+}
+
bool FileAccessWindows::file_exists(const String &p_name) {
FILE *g;
diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h
index bbdf830c96..26bd08b7af 100644
--- a/drivers/windows/file_access_windows.h
+++ b/drivers/windows/file_access_windows.h
@@ -67,6 +67,7 @@ public:
virtual void flush();
virtual void store_8(uint8_t p_dest); ///< store a byte
+ virtual void store_buffer(const uint8_t *p_src, int p_length); ///< store an array of bytes
virtual bool file_exists(const String &p_name); ///< return true if a file exists
diff --git a/drivers/windows/stream_peer_tcp_winsock.cpp b/drivers/windows/stream_peer_tcp_winsock.cpp
index d6a320fb5e..55775fc231 100644
--- a/drivers/windows/stream_peer_tcp_winsock.cpp
+++ b/drivers/windows/stream_peer_tcp_winsock.cpp
@@ -332,7 +332,7 @@ Error StreamPeerTCPWinsock::connect_to_host(const IP_Address &p_host, uint16_t p
return OK;
};
-void StreamPeerTCPWinsock::set_nodelay(bool p_enabled) {
+void StreamPeerTCPWinsock::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!is_connected_to_host());
int flag = p_enabled ? 1 : 0;
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
diff --git a/drivers/windows/stream_peer_tcp_winsock.h b/drivers/windows/stream_peer_tcp_winsock.h
index 9be8414878..a0177d374e 100644
--- a/drivers/windows/stream_peer_tcp_winsock.h
+++ b/drivers/windows/stream_peer_tcp_winsock.h
@@ -81,7 +81,7 @@ public:
static void make_default();
static void cleanup();
- virtual void set_nodelay(bool p_enabled);
+ virtual void set_no_delay(bool p_enabled);
StreamPeerTCPWinsock();
~StreamPeerTCPWinsock();