summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp6
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h3
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp2
-rw-r--r--drivers/gles3/shaders/scene.glsl3
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp53
-rw-r--r--drivers/wasapi/audio_driver_wasapi.h2
6 files changed, 50 insertions, 19 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index ddcb04fa7d..8ec988bec1 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1134,9 +1134,9 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
state.current_depth_draw = p_material->shader->spatial.depth_draw_mode;
}
-//glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
+ //glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
-/*
+ /*
if (p_material->flags[VS::MATERIAL_FLAG_WIREFRAME])
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
else
@@ -4023,6 +4023,8 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
state.ubo_data.shadow_dual_paraboloid_render_side = 0;
state.ubo_data.shadow_dual_paraboloid_render_zfar = 0;
+ p_cam_projection.get_viewport_size(state.ubo_data.viewport_size[0], state.ubo_data.viewport_size[1]);
+
if (storage->frame.current_rt) {
state.ubo_data.screen_pixel_size[0] = 1.0 / storage->frame.current_rt->width;
state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height;
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index ff691ddcec..69b43c7813 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -124,6 +124,7 @@ public:
float z_slope_scale;
float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side;
+ float viewport_size[2];
float screen_pixel_size[2];
float shadow_atlas_pixel_size[2];
float shadow_directional_pixel_size[2];
@@ -143,7 +144,7 @@ public:
float fog_height_min;
float fog_height_max;
float fog_height_curve;
- uint8_t padding[8];
+ // make sure this struct is padded to be a multiple of 16 bytes for webgl
} ubo_data;
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index f39342b680..ad08c59de8 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -766,7 +766,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
//builtins
actions[VS::SHADER_SPATIAL].renames["TIME"] = "time";
- //actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"]=ShaderLanguage::TYPE_VEC2;
+ actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index e4d76753cb..9880663143 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -80,6 +80,7 @@ layout(std140) uniform SceneData { //ubo:0
highp float shadow_dual_paraboloid_render_zfar;
highp float shadow_dual_paraboloid_render_side;
+ highp vec2 viewport_size;
highp vec2 screen_pixel_size;
highp vec2 shadow_atlas_pixel_size;
highp vec2 directional_shadow_pixel_size;
@@ -566,6 +567,7 @@ in vec3 normal_interp;
uniform bool no_ambient_light;
+
#ifdef USE_RADIANCE_MAP
@@ -663,6 +665,7 @@ layout(std140) uniform SceneData {
highp float shadow_dual_paraboloid_render_zfar;
highp float shadow_dual_paraboloid_render_side;
+ highp vec2 viewport_size;
highp vec2 screen_pixel_size;
highp vec2 shadow_atlas_pixel_size;
highp vec2 directional_shadow_pixel_size;
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index eb86491dec..0671ee408e 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -39,7 +39,7 @@ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
const IID IID_IAudioClient = __uuidof(IAudioClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
-Error AudioDriverWASAPI::init_device() {
+Error AudioDriverWASAPI::init_device(bool reinit) {
WAVEFORMATEX *pwfex;
IMMDeviceEnumerator *enumerator = NULL;
@@ -51,10 +51,24 @@ Error AudioDriverWASAPI::init_device() {
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
- ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ 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.
+ if (hr != S_OK) {
+ return ERR_CANT_OPEN;
+ }
+ } else {
+ ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ }
hr = device->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&audio_client);
- ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ if (reinit) {
+ if (hr != S_OK) {
+ return ERR_CANT_OPEN;
+ }
+ } else {
+ ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ }
hr = audio_client->GetMixFormat(&pwfex);
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
@@ -152,7 +166,9 @@ Error AudioDriverWASAPI::finish_device() {
Error AudioDriverWASAPI::init() {
Error err = init_device();
- ERR_FAIL_COND_V(err != OK, err);
+ if (err != OK) {
+ ERR_PRINT("WASAPI: init_device error");
+ }
active = false;
exit_thread = false;
@@ -209,7 +225,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
unsigned int left_frames = ad->buffer_frames;
unsigned int buffer_idx = 0;
- while (left_frames > 0) {
+ while (left_frames > 0 && ad->audio_client) {
WaitForSingleObject(ad->event, 1000);
UINT32 cur_frames;
@@ -271,9 +287,9 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
} else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Device is not valid anymore, reopen it
- Error err = ad->reopen();
+ Error err = ad->finish_device();
if (err != OK) {
- ad->exit_thread = true;
+ ERR_PRINT("WASAPI: finish_device error");
} else {
// We reopened the device and samples_in may have resized, so invalidate the current left_frames
left_frames = 0;
@@ -285,9 +301,9 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
} else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Device is not valid anymore, reopen it
- Error err = ad->reopen();
+ Error err = ad->finish_device();
if (err != OK) {
- ad->exit_thread = true;
+ ERR_PRINT("WASAPI: finish_device error");
} else {
// We reopened the device and samples_in may have resized, so invalidate the current left_frames
left_frames = 0;
@@ -296,6 +312,13 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
ERR_PRINT("WASAPI: GetCurrentPadding error");
}
}
+
+ if (!ad->audio_client) {
+ Error err = ad->init_device(true);
+ if (err == OK) {
+ ad->start();
+ }
+ }
}
ad->thread_exited = true;
@@ -303,11 +326,13 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
void AudioDriverWASAPI::start() {
- HRESULT hr = audio_client->Start();
- if (hr != S_OK) {
- ERR_PRINT("WASAPI: Start failed");
- } else {
- active = true;
+ if (audio_client) {
+ HRESULT hr = audio_client->Start();
+ if (hr != S_OK) {
+ ERR_PRINT("WASAPI: Start failed");
+ } else {
+ active = true;
+ }
}
}
diff --git a/drivers/wasapi/audio_driver_wasapi.h b/drivers/wasapi/audio_driver_wasapi.h
index fab8ab3250..87a2db724c 100644
--- a/drivers/wasapi/audio_driver_wasapi.h
+++ b/drivers/wasapi/audio_driver_wasapi.h
@@ -64,7 +64,7 @@ class AudioDriverWASAPI : public AudioDriver {
static void thread_func(void *p_udata);
- Error init_device();
+ Error init_device(bool reinit = false);
Error finish_device();
Error reopen();