summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp13
-rw-r--r--drivers/alsa/audio_driver_alsa.h1
-rw-r--r--drivers/alsamidi/midi_driver_alsamidi.cpp7
-rw-r--r--drivers/alsamidi/midi_driver_alsamidi.h1
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp15
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.h1
-rw-r--r--drivers/coremidi/midi_driver_coremidi.cpp4
-rw-r--r--drivers/coremidi/midi_driver_coremidi.h1
-rw-r--r--drivers/dummy/rasterizer_dummy.h1
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp69
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.h1
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp16
-rw-r--r--drivers/gles2/rasterizer_gles2.h1
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp115
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h6
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp247
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h26
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp38
-rw-r--r--drivers/gles2/shader_compiler_gles2.h3
-rw-r--r--drivers/gles2/shader_gles2.cpp24
-rw-r--r--drivers/gles2/shader_gles2.h10
-rw-r--r--drivers/gles2/shaders/blend_shape.glsl1
-rw-r--r--drivers/gles2/shaders/canvas.glsl5
-rw-r--r--drivers/gles2/shaders/canvas_shadow.glsl2
-rw-r--r--drivers/gles2/shaders/copy.glsl3
-rw-r--r--drivers/gles2/shaders/cube_to_dp.glsl2
-rw-r--r--drivers/gles2/shaders/cubemap_filter.glsl4
-rw-r--r--drivers/gles2/shaders/effect_blur.glsl4
-rw-r--r--drivers/gles2/shaders/exposure.glsl2
-rw-r--r--drivers/gles2/shaders/lens_distorted.glsl1
-rw-r--r--drivers/gles2/shaders/particles.glsl6
-rw-r--r--drivers/gles2/shaders/resolve.glsl2
-rw-r--r--drivers/gles2/shaders/scene.glsl21
-rw-r--r--drivers/gles2/shaders/screen_space_reflection.glsl5
-rw-r--r--drivers/gles2/shaders/ssao.glsl2
-rw-r--r--drivers/gles2/shaders/ssao_blur.glsl3
-rw-r--r--drivers/gles2/shaders/ssao_minify.glsl2
-rw-r--r--drivers/gles2/shaders/subsurf_scattering.glsl3
-rw-r--r--drivers/png/image_loader_png.cpp6
-rw-r--r--drivers/png/png_driver_common.cpp3
-rw-r--r--drivers/png/resource_saver_png.cpp6
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp24
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h1
-rw-r--r--drivers/register_driver_types.cpp2
-rw-r--r--drivers/unix/dir_access_unix.cpp24
-rw-r--r--drivers/unix/dir_access_unix.h1
-rw-r--r--drivers/unix/file_access_unix.cpp23
-rw-r--r--drivers/unix/file_access_unix.h1
-rw-r--r--drivers/unix/ip_unix.cpp10
-rw-r--r--drivers/unix/net_socket_posix.cpp13
-rw-r--r--drivers/unix/net_socket_posix.h1
-rw-r--r--drivers/unix/os_unix.cpp29
-rw-r--r--drivers/unix/os_unix.h1
-rw-r--r--drivers/unix/rw_lock_posix.cpp9
-rw-r--r--drivers/unix/rw_lock_posix.h1
-rw-r--r--drivers/unix/thread_posix.cpp9
-rw-r--r--drivers/unix/thread_posix.h1
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp121
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h9
-rw-r--r--drivers/vulkan/vulkan_context.cpp19
-rw-r--r--drivers/vulkan/vulkan_context.h2
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp27
-rw-r--r--drivers/wasapi/audio_driver_wasapi.h1
-rw-r--r--drivers/windows/dir_access_windows.cpp25
-rw-r--r--drivers/windows/dir_access_windows.h1
-rw-r--r--drivers/windows/file_access_windows.cpp25
-rw-r--r--drivers/windows/file_access_windows.h1
-rw-r--r--drivers/windows/rw_lock_windows.cpp8
-rw-r--r--drivers/windows/rw_lock_windows.h1
-rw-r--r--drivers/windows/thread_windows.cpp7
-rw-r--r--drivers/windows/thread_windows.h1
-rw-r--r--drivers/winmidi/midi_driver_winmidi.cpp5
-rw-r--r--drivers/winmidi/midi_driver_winmidi.h1
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp13
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.h2
75 files changed, 0 insertions, 1102 deletions
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index e394222d3a..895a746b20 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -147,7 +147,6 @@ Error AudioDriverALSA::init_device() {
}
Error AudioDriverALSA::init() {
-
active = false;
thread_exited = false;
exit_thread = false;
@@ -161,11 +160,9 @@ Error AudioDriverALSA::init() {
}
void AudioDriverALSA::thread_func(void *p_udata) {
-
AudioDriverALSA *ad = (AudioDriverALSA *)p_udata;
while (!ad->exit_thread) {
-
ad->lock();
ad->start_counting_ticks();
@@ -237,22 +234,18 @@ void AudioDriverALSA::thread_func(void *p_udata) {
}
void AudioDriverALSA::start() {
-
active = true;
}
int AudioDriverALSA::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverALSA::get_speaker_mode() const {
-
return speaker_mode;
}
Array AudioDriverALSA::get_device_list() {
-
Array list;
list.push_back("Default");
@@ -285,33 +278,28 @@ Array AudioDriverALSA::get_device_list() {
}
String AudioDriverALSA::get_device() {
-
return device_name;
}
void AudioDriverALSA::set_device(String device) {
-
lock();
new_device = device;
unlock();
}
void AudioDriverALSA::lock() {
-
if (!thread)
return;
mutex.lock();
}
void AudioDriverALSA::unlock() {
-
if (!thread)
return;
mutex.unlock();
}
void AudioDriverALSA::finish_device() {
-
if (pcm_handle) {
snd_pcm_close(pcm_handle);
pcm_handle = nullptr;
@@ -319,7 +307,6 @@ void AudioDriverALSA::finish_device() {
}
void AudioDriverALSA::finish() {
-
if (thread) {
exit_thread = true;
Thread::wait_to_finish(thread);
diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h
index d437993901..7aec0c4071 100644
--- a/drivers/alsa/audio_driver_alsa.h
+++ b/drivers/alsa/audio_driver_alsa.h
@@ -40,7 +40,6 @@
#include <alsa/asoundlib.h>
class AudioDriverALSA : public AudioDriver {
-
Thread *thread = nullptr;
Mutex mutex;
diff --git a/drivers/alsamidi/midi_driver_alsamidi.cpp b/drivers/alsamidi/midi_driver_alsamidi.cpp
index e3e54ea267..a4c9fbece8 100644
--- a/drivers/alsamidi/midi_driver_alsamidi.cpp
+++ b/drivers/alsamidi/midi_driver_alsamidi.cpp
@@ -125,7 +125,6 @@ void MIDIDriverALSAMidi::thread_func(void *p_udata) {
}
Error MIDIDriverALSAMidi::open() {
-
void **hints;
if (snd_device_name_hint(-1, "rawmidi", &hints) < 0)
@@ -155,7 +154,6 @@ Error MIDIDriverALSAMidi::open() {
}
void MIDIDriverALSAMidi::close() {
-
if (thread) {
exit_thread = true;
Thread::wait_to_finish(thread);
@@ -172,17 +170,14 @@ void MIDIDriverALSAMidi::close() {
}
void MIDIDriverALSAMidi::lock() const {
-
mutex.lock();
}
void MIDIDriverALSAMidi::unlock() const {
-
mutex.unlock();
}
PackedStringArray MIDIDriverALSAMidi::get_connected_inputs() {
-
PackedStringArray list;
lock();
@@ -201,14 +196,12 @@ PackedStringArray MIDIDriverALSAMidi::get_connected_inputs() {
}
MIDIDriverALSAMidi::MIDIDriverALSAMidi() {
-
thread = nullptr;
exit_thread = false;
}
MIDIDriverALSAMidi::~MIDIDriverALSAMidi() {
-
close();
}
diff --git a/drivers/alsamidi/midi_driver_alsamidi.h b/drivers/alsamidi/midi_driver_alsamidi.h
index 6797c7c138..e8ed6df5b0 100644
--- a/drivers/alsamidi/midi_driver_alsamidi.h
+++ b/drivers/alsamidi/midi_driver_alsamidi.h
@@ -42,7 +42,6 @@
#include <stdio.h>
class MIDIDriverALSAMidi : public MIDIDriver {
-
Thread *thread;
Mutex mutex;
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 76d2d13dfe..d71d8cdaba 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -168,7 +168,6 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData) {
-
AudioDriverCoreAudio *ad = (AudioDriverCoreAudio *)inRefCon;
if (!ad->active || !ad->try_lock()) {
@@ -182,18 +181,15 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
ad->start_counting_ticks();
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
-
AudioBuffer *abuf = &ioData->mBuffers[i];
unsigned int frames_left = inNumberFrames;
int16_t *out = (int16_t *)abuf->mData;
while (frames_left) {
-
unsigned int frames = MIN(frames_left, ad->buffer_frames);
ad->audio_server_process(frames, ad->samples_in.ptrw());
for (unsigned int j = 0; j < frames * ad->channels; j++) {
-
out[j] = ad->samples_in[j] >> 16;
}
@@ -213,7 +209,6 @@ OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData) {
-
AudioDriverCoreAudio *ad = (AudioDriverCoreAudio *)inRefCon;
if (!ad->active) {
return 0;
@@ -475,7 +470,6 @@ void AudioDriverCoreAudio::capture_finish() {
}
Error AudioDriverCoreAudio::capture_start() {
-
input_buffer_init(buffer_frames);
OSStatus result = AudioOutputUnitStart(input_unit);
@@ -487,7 +481,6 @@ Error AudioDriverCoreAudio::capture_start() {
}
Error AudioDriverCoreAudio::capture_stop() {
-
if (input_unit) {
OSStatus result = AudioOutputUnitStop(input_unit);
if (result != noErr) {
@@ -501,7 +494,6 @@ Error AudioDriverCoreAudio::capture_stop() {
#ifdef OSX_ENABLED
Array AudioDriverCoreAudio::_get_device_list(bool capture) {
-
Array list;
list.push_back("Default");
@@ -558,7 +550,6 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
}
void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
-
AudioDeviceID deviceId;
bool found = false;
if (device != "Default") {
@@ -639,17 +630,14 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
Array AudioDriverCoreAudio::get_device_list() {
-
return _get_device_list();
}
String AudioDriverCoreAudio::get_device() {
-
return device_name;
}
void AudioDriverCoreAudio::set_device(String device) {
-
device_name = device;
if (active) {
_set_device(device_name);
@@ -657,7 +645,6 @@ void AudioDriverCoreAudio::set_device(String device) {
}
void AudioDriverCoreAudio::capture_set_device(const String &p_name) {
-
capture_device_name = p_name;
if (active) {
_set_device(capture_device_name, true);
@@ -665,12 +652,10 @@ void AudioDriverCoreAudio::capture_set_device(const String &p_name) {
}
Array AudioDriverCoreAudio::capture_get_device_list() {
-
return _get_device_list(true);
}
String AudioDriverCoreAudio::capture_get_device() {
-
return capture_device_name;
}
diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h
index 89dd52181f..6b7a35588f 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.h
+++ b/drivers/coreaudio/audio_driver_coreaudio.h
@@ -41,7 +41,6 @@
#endif
class AudioDriverCoreAudio : public AudioDriver {
-
AudioComponentInstance audio_unit = nullptr;
AudioComponentInstance input_unit = nullptr;
diff --git a/drivers/coremidi/midi_driver_coremidi.cpp b/drivers/coremidi/midi_driver_coremidi.cpp
index f155b4accc..004c594e17 100644
--- a/drivers/coremidi/midi_driver_coremidi.cpp
+++ b/drivers/coremidi/midi_driver_coremidi.cpp
@@ -46,7 +46,6 @@ void MIDIDriverCoreMidi::read(const MIDIPacketList *packet_list, void *read_proc
}
Error MIDIDriverCoreMidi::open() {
-
CFStringRef name = CFStringCreateWithCString(nullptr, "Godot", kCFStringEncodingASCII);
OSStatus result = MIDIClientCreate(name, nullptr, nullptr, &client);
CFRelease(name);
@@ -63,7 +62,6 @@ Error MIDIDriverCoreMidi::open() {
int sources = MIDIGetNumberOfSources();
for (int i = 0; i < sources; i++) {
-
MIDIEndpointRef source = MIDIGetSource(i);
if (source) {
MIDIPortConnectSource(port_in, source, (void *)this);
@@ -75,7 +73,6 @@ Error MIDIDriverCoreMidi::open() {
}
void MIDIDriverCoreMidi::close() {
-
for (int i = 0; i < connected_sources.size(); i++) {
MIDIEndpointRef source = connected_sources[i];
MIDIPortDisconnectSource(port_in, source);
@@ -94,7 +91,6 @@ void MIDIDriverCoreMidi::close() {
}
PackedStringArray MIDIDriverCoreMidi::get_connected_inputs() {
-
PackedStringArray list;
for (int i = 0; i < connected_sources.size(); i++) {
diff --git a/drivers/coremidi/midi_driver_coremidi.h b/drivers/coremidi/midi_driver_coremidi.h
index 68de7a11fb..0459544f75 100644
--- a/drivers/coremidi/midi_driver_coremidi.h
+++ b/drivers/coremidi/midi_driver_coremidi.h
@@ -40,7 +40,6 @@
#include <stdio.h>
class MIDIDriverCoreMidi : public MIDIDriver {
-
MIDIClientRef client = 0;
MIDIPortRef port_in;
diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h
index 05a45315b2..d619a20745 100644
--- a/drivers/dummy/rasterizer_dummy.h
+++ b/drivers/dummy/rasterizer_dummy.h
@@ -855,7 +855,6 @@ public:
}
bool free(RID p_rid) {
-
if (texture_owner.owns(p_rid)) {
// delete the texture
DummyTexture *texture = texture_owner.getornull(p_rid);
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index 069eeaba6c..b6e36d87a5 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -40,7 +40,6 @@
#endif
RID RasterizerCanvasGLES2::light_internal_create() {
-
return RID();
}
@@ -51,7 +50,6 @@ void RasterizerCanvasGLES2::light_internal_free(RID p_rid) {
}
void RasterizerCanvasGLES2::_set_uniforms() {
-
state.canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX, state.uniforms.projection_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, state.uniforms.extra_matrix);
@@ -75,7 +73,6 @@ void RasterizerCanvasGLES2::_set_uniforms() {
}
if (state.using_light) {
-
Light *light = state.using_light;
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_MATRIX, light->light_shader_xform);
Transform2D basis_inverse = light->light_shader_xform.affine_inverse().orthonormalized();
@@ -110,7 +107,6 @@ void RasterizerCanvasGLES2::_set_uniforms() {
}
void RasterizerCanvasGLES2::canvas_begin() {
-
state.canvas_shader.bind();
state.using_transparent_rt = false;
int viewport_x, viewport_y, viewport_width, viewport_height;
@@ -160,7 +156,6 @@ void RasterizerCanvasGLES2::canvas_begin() {
Transform canvas_transform;
if (storage->frame.current_rt) {
-
float csy = 1.0;
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP]) {
csy = -1.0;
@@ -185,7 +180,6 @@ void RasterizerCanvasGLES2::canvas_begin() {
}
void RasterizerCanvasGLES2::canvas_end() {
-
glBindBuffer(GL_ARRAY_BUFFER, 0);
for (int i = 0; i < RS::ARRAY_MAX; i++) {
@@ -207,11 +201,9 @@ void RasterizerCanvasGLES2::canvas_end() {
}
RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
-
RasterizerStorageGLES2::Texture *tex_return = nullptr;
if (p_texture.is_valid()) {
-
RasterizerStorageGLES2::Texture *texture = storage->texture_owner.getornull(p_texture);
if (!texture) {
@@ -222,7 +214,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
} else {
-
if (texture->redraw_if_visible) {
RenderingServerRaster::redraw_request();
}
@@ -254,7 +245,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, state.current_normal.is_valid());
} else if (p_normal_map.is_valid()) {
-
RasterizerStorageGLES2::Texture *normal_map = storage->texture_owner.getornull(p_normal_map);
if (!normal_map) {
@@ -264,7 +254,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, false);
} else {
-
if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies
RenderingServerRaster::redraw_request();
}
@@ -278,7 +267,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
}
} else {
-
state.current_normal = RID();
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
@@ -289,7 +277,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
}
void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
-
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
@@ -365,7 +352,6 @@ void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_coun
}
void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
-
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
@@ -407,7 +393,6 @@ void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count
}
void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
-
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
@@ -467,7 +452,6 @@ void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int
}
void RasterizerCanvasGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
-
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
int color_offset = 0;
@@ -542,18 +526,14 @@ static const GLenum gl_primitive[] = {
};
void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip, RasterizerStorageGLES2::Material *p_material) {
-
int command_count = p_item->commands.size();
Item::Command **commands = p_item->commands.ptrw();
for (int i = 0; i < command_count; i++) {
-
Item::Command *command = commands[i];
switch (command->type) {
-
case Item::Command::TYPE_LINE: {
-
Item::CommandLine *line = static_cast<Item::CommandLine *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -613,7 +593,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_RECT: {
-
Item::CommandRect *r = static_cast<Item::CommandRect *>(command);
glDisableVertexAttribArray(RS::ARRAY_COLOR);
@@ -626,7 +605,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
RasterizerStorageGLES2::Texture *texture = storage->texture_owner.getornull(r->texture);
if (texture) {
-
texture = texture->get_ptr();
if (next_power_of_2(texture->alloc_width) != (unsigned int)texture->alloc_width && next_power_of_2(texture->alloc_height) != (unsigned int)texture->alloc_height) {
@@ -750,7 +728,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} else {
-
bool untile = false;
if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RS::TEXTURE_FLAG_REPEAT)) {
@@ -807,7 +784,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_NINEPATCH: {
-
Item::CommandNinePatch *np = static_cast<Item::CommandNinePatch *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -845,7 +821,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
float screen_scale = 1.0;
if (source.size.x != 0 && source.size.y != 0) {
-
screen_scale = MIN(np->rect.size.x / source.size.x, np->rect.size.y / source.size.y);
screen_scale = MIN(1.0, screen_scale);
}
@@ -857,7 +832,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
float buffer[16 * 2 + 16 * 2];
{
-
// first row
buffer[(0 * 4 * 4) + 0] = np->rect.position.x;
@@ -982,7 +956,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_CIRCLE: {
-
Item::CommandCircle *circle = static_cast<Item::CommandCircle *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1012,7 +985,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_POLYGON: {
-
Item::CommandPolygon *polygon = static_cast<Item::CommandPolygon *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1043,7 +1015,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
#endif
} break;
case Item::Command::TYPE_MESH: {
-
Item::CommandMesh *mesh = static_cast<Item::CommandMesh *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1061,7 +1032,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
RasterizerStorageGLES2::Mesh *mesh_data = storage->mesh_owner.getornull(mesh->mesh);
if (mesh_data) {
-
for (int j = 0; j < mesh_data->surfaces.size(); j++) {
RasterizerStorageGLES2::Surface *s = mesh_data->surfaces[j];
// materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing
@@ -1186,7 +1156,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
const float *buffer = base_buffer + k * stride;
{
-
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]);
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]);
if (multi_mesh->transform_format == RS::MULTIMESH_TRANSFORM_3D) {
@@ -1252,7 +1221,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glDisable(GL_LINE_SMOOTH);
#endif
} else {
-
#ifdef GLES_OVER_GL
if (pline->antialiased)
glEnable(GL_LINE_SMOOTH);
@@ -1281,7 +1249,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_PRIMITIVE: {
-
Item::CommandPrimitive *primitive = static_cast<Item::CommandPrimitive *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1316,11 +1283,9 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_PARTICLES: {
-
} break;
case Item::Command::TYPE_CLIP_IGNORE: {
-
Item::CommandClipIgnore *ci = static_cast<Item::CommandClipIgnore *>(command);
if (current_clip) {
if (ci->ignore != reclip) {
@@ -1356,7 +1321,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
}
void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
-
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen.");
return;
@@ -1412,7 +1376,6 @@ void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
}
void RasterizerCanvasGLES2::_copy_texscreen(const Rect2 &p_rect) {
-
state.canvas_texscreen_used = true;
_copy_screen(p_rect);
@@ -1425,7 +1388,6 @@ void RasterizerCanvasGLES2::_copy_texscreen(const Rect2 &p_rect) {
}
void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
-
Item *current_clip = nullptr;
RasterizerStorageGLES2::Shader *shader_cache = nullptr;
@@ -1447,11 +1409,9 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
RID canvas_last_material = RID();
while (p_item_list) {
-
Item *ci = p_item_list;
if (current_clip != ci->final_clip_owner) {
-
current_clip = ci->final_clip_owner;
if (current_clip) {
@@ -1512,7 +1472,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
RasterizerStorageGLES2::Material *material_ptr = storage->material_owner.getornull(material);
if (material != canvas_last_material || rebind_shader) {
-
RasterizerStorageGLES2::Shader *shader_ptr = nullptr;
if (material_ptr) {
@@ -1540,7 +1499,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (shader_ptr != shader_cache) {
-
if (shader_ptr->canvas_item.uses_time) {
RenderingServerRaster::redraw_request();
}
@@ -1555,13 +1513,11 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = shader_ptr->texture_hints.ptrw();
for (int i = 0; i < tc; i++) {
-
glActiveTexture(GL_TEXTURE0 + i);
RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(textures[i].second);
if (!t) {
-
switch (texture_hints[i]) {
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO:
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: {
@@ -1616,9 +1572,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
bool reclip = false;
if (last_blend_mode != blend_mode) {
-
switch (blend_mode) {
-
case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_MIX: {
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
@@ -1629,7 +1583,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
} break;
case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_ADD: {
-
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
@@ -1639,7 +1592,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
} break;
case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_SUB: {
-
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
@@ -1679,24 +1631,19 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
rebind_shader = true; // hacked in for now.
if ((blend_mode == RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode == RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_PMALPHA) && p_light && !unshaded) {
-
Light *light = p_light;
bool light_used = false;
RS::CanvasLightMode mode = RS::CANVAS_LIGHT_MODE_ADD;
state.uniforms.final_modulate = ci->final_modulate; // remove the canvas modulate
while (light) {
-
if (ci->light_mask & light->item_mask && p_z >= light->z_min && p_z <= light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) {
-
//intersects this light
if (!light_used || mode != light->mode) {
-
mode = light->mode;
switch (mode) {
-
case RS::CANVAS_LIGHT_MODE_ADD: {
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
@@ -1716,7 +1663,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (!light_used) {
-
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, true);
light_used = true;
}
@@ -1762,7 +1708,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (light_used) {
-
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, false);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS, false);
state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_NEAREST, false);
@@ -1824,7 +1769,6 @@ void RasterizerCanvasGLES2::canvas_debug_viewport_shadows(Light *p_lights_with_s
}
void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
-
RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(p_buffer);
ERR_FAIL_COND(!cls);
@@ -1849,7 +1793,6 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
RS::CanvasOccluderPolygonCullMode cull = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
for (int i = 0; i < 4; i++) {
-
//make sure it remains orthogonal, makes easy to read angle later
Transform light;
@@ -1893,10 +1836,8 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
LightOccluderInstance *instance = p_occluders;
while (instance) {
-
RasterizerStorageGLES2::CanvasOccluder *cc = storage->canvas_occluder_owner.getornull(instance->polygon_buffer);
if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) {
-
instance = instance->next;
continue;
}
@@ -1914,21 +1855,17 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
}
if (cull != transformed_cull_cache) {
-
cull = transformed_cull_cache;
switch (cull) {
case RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
-
glDisable(GL_CULL_FACE);
} break;
case RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: {
-
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
} break;
case RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: {
-
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -1951,7 +1888,6 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void RasterizerCanvasGLES2::reset_canvas() {
-
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
@@ -1983,7 +1919,6 @@ void RasterizerCanvasGLES2::_bind_quad_buffer() {
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
}
void RasterizerCanvasGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
-
state.canvas_shader.set_uniform(CanvasShaderGLES2::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES2::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y));
@@ -2028,7 +1963,6 @@ void RasterizerCanvasGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float
}
void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_image) {
-
Vector2 window_size = DisplayServer::get_singleton()->window_get_size();
int window_h = window_size.height;
int window_w = window_size.width;
@@ -2073,14 +2007,12 @@ void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_im
}
if (black_image[MARGIN_BOTTOM].is_valid()) {
-
_bind_canvas_texture(black_image[MARGIN_BOTTOM], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM]));
draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y));
} else if (black_margin[MARGIN_BOTTOM]) {
-
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
@@ -2091,7 +2023,6 @@ void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_im
}
void RasterizerCanvasGLES2::initialize() {
-
// quad buffer
{
glGenBuffers(1, &data.canvas_quad_vertices);
diff --git a/drivers/gles2/rasterizer_canvas_gles2.h b/drivers/gles2/rasterizer_canvas_gles2.h
index 2d6355e948..84452fe220 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.h
+++ b/drivers/gles2/rasterizer_canvas_gles2.h
@@ -59,7 +59,6 @@ public:
};
struct Data {
-
GLuint canvas_quad_vertices;
GLuint polygon_buffer;
GLuint polygon_index_buffer;
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 28f06f939c..fc9f3c67e6 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -86,7 +86,6 @@
#ifdef CAN_DEBUG
static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam) {
-
if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
return;
@@ -145,22 +144,18 @@ typedef void (*DEBUGPROCARB)(GLenum source,
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
RasterizerStorage *RasterizerGLES2::get_storage() {
-
return storage;
}
RasterizerCanvas *RasterizerGLES2::get_canvas() {
-
return canvas;
}
RasterizerScene *RasterizerGLES2::get_scene() {
-
return scene;
}
Error RasterizerGLES2::is_viable() {
-
#ifdef GLAD_ENABLED
if (!gladLoadGL()) {
ERR_PRINT("Error initializing GLAD");
@@ -214,7 +209,6 @@ Error RasterizerGLES2::is_viable() {
}
void RasterizerGLES2::initialize() {
-
print_verbose("Using GLES2 video driver");
#ifdef GLAD_ENABLED
@@ -253,7 +247,6 @@ void RasterizerGLES2::initialize() {
}
if (callback) {
-
print_line("godot: ENABLING GL DEBUG");
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
callback(_gl_debug_print, nullptr);
@@ -296,7 +289,6 @@ void RasterizerGLES2::begin_frame(double frame_step) {
}
void RasterizerGLES2::set_current_render_target(RID p_render_target) {
-
if (!p_render_target.is_valid() && storage->frame.current_rt && storage->frame.clear_request) {
// pending clear request. Do that first.
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo);
@@ -337,7 +329,6 @@ void RasterizerGLES2::clear_render_target(const Color &p_color) {
}
void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
-
if (p_image.is_null() || p_image->empty())
return;
@@ -364,7 +355,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height());
Rect2 screenrect;
if (p_scale) {
-
if (window_w > window_h) {
//scale horizontally
screenrect.size.y = window_h;
@@ -378,7 +368,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
screenrect.position.y = (window_h - screenrect.size.y) / 2;
}
} else {
-
screenrect = imgrect;
screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
}
@@ -396,7 +385,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
}
void RasterizerGLES2::blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen) {
-
ERR_FAIL_COND(storage->frame.current_rt);
RasterizerStorageGLES2::RenderTarget *rt = storage->render_target_owner.getornull(p_render_target);
@@ -446,7 +434,6 @@ void RasterizerGLES2::output_lens_distorted_to_screen(RID p_render_target, const
}
void RasterizerGLES2::end_frame(bool p_swap_buffers) {
-
if (OS::get_singleton()->is_layered_allowed()) {
if (OS::get_singleton()->get_window_per_pixel_transparency_enabled()) {
#if (defined WINDOWS_ENABLED) && !(defined UWP_ENABLED)
@@ -478,7 +465,6 @@ void RasterizerGLES2::finalize() {
}
Rasterizer *RasterizerGLES2::_create_current() {
-
return memnew(RasterizerGLES2);
}
@@ -490,7 +476,6 @@ void RasterizerGLES2::register_config() {
}
RasterizerGLES2::RasterizerGLES2() {
-
storage = memnew(RasterizerStorageGLES2);
canvas = memnew(RasterizerCanvasGLES2);
scene = memnew(RasterizerSceneGLES2);
@@ -504,7 +489,6 @@ RasterizerGLES2::RasterizerGLES2() {
}
RasterizerGLES2::~RasterizerGLES2() {
-
memdelete(storage);
memdelete(canvas);
}
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 027a634ae8..e9bef31d1e 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -37,7 +37,6 @@
#include "servers/rendering/rasterizer.h"
class RasterizerGLES2 : public Rasterizer {
-
static Rasterizer *_create_current();
RasterizerStorageGLES2 *storage;
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index bdf0559f58..02e9d7d504 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -72,7 +72,6 @@ static const GLenum _cube_side_enum[6] = {
/* SHADOW ATLAS API */
RID RasterizerSceneGLES2::shadow_atlas_create() {
-
ShadowAtlas *shadow_atlas = memnew(ShadowAtlas);
shadow_atlas->fbo = 0;
shadow_atlas->depth = 0;
@@ -133,7 +132,6 @@ void RasterizerSceneGLES2::shadow_atlas_set_size(RID p_atlas, int p_size) {
glActiveTexture(GL_TEXTURE0);
if (storage->config.use_rgba_3d_shadows) {
-
//maximum compatibility, renderbuffer and RGBA shadow
glGenRenderbuffers(1, &shadow_atlas->depth);
glBindRenderbuffer(GL_RENDERBUFFER, shadow_atlas->depth);
@@ -234,7 +232,6 @@ void RasterizerSceneGLES2::shadow_atlas_set_quadrant_subdivision(RID p_atlas, in
}
bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_in_quadrants, int p_quadrant_count, int p_current_subdiv, uint64_t p_tick, int &r_quadrant, int &r_shadow) {
-
for (int i = p_quadrant_count - 1; i >= 0; i--) {
int qidx = p_in_quadrants[i];
@@ -262,7 +259,6 @@ bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
ERR_CONTINUE(!sli);
if (sli->last_scene_pass != scene_pass) {
-
// was just allocated, don't kill it so soon, wait a bit...
if (p_tick - sarr[j].alloc_tick < shadow_atlas_realloc_tolerance_msec) {
@@ -294,7 +290,6 @@ bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
}
bool RasterizerSceneGLES2::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
ERR_FAIL_COND_V(!shadow_atlas, false);
@@ -441,7 +436,6 @@ void RasterizerSceneGLES2::set_directional_shadow_count(int p_count) {
}
int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance) {
-
ERR_FAIL_COND_V(directional_shadow.light_count == 0, 0);
int shadow_size;
@@ -481,7 +475,6 @@ void RasterizerSceneGLES2::reflection_atlas_set_subdivision(RID p_ref_atlas, int
////////////////////////////////////////////////////
RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
-
RasterizerStorageGLES2::ReflectionProbe *probe = storage->reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!probe, RID());
@@ -512,7 +505,6 @@ RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
}
void RasterizerSceneGLES2::reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND(!rpi);
rpi->transform = p_transform;
@@ -535,14 +527,12 @@ bool RasterizerSceneGLES2::reflection_probe_instance_has_reflection(RID p_instan
}
bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
rpi->render_step = 0;
if (rpi->probe_ptr->resolution != rpi->current_resolution) {
-
//update cubemap if resolution changed
int size = rpi->probe_ptr->resolution;
rpi->current_resolution = size;
@@ -594,7 +584,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance
}
bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_instance) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
ERR_FAIL_COND_V(rpi->current_resolution == 0, false);
@@ -643,7 +632,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst
//blur
while (size >= 1) {
-
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, storage->resources.mipmap_blur_color);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
@@ -652,7 +640,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst
glActiveTexture(GL_TEXTURE0);
for (int i = 0; i < 6; i++) {
-
storage->bind_quad_array();
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i);
float roughness = CLAMP(lod / (float)(mipmaps - 1), 0, 1);
@@ -684,14 +671,12 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst
/* ENVIRONMENT API */
RID RasterizerSceneGLES2::environment_create() {
-
Environment *env = memnew(Environment);
return environment_owner.make_rid(env);
}
void RasterizerSceneGLES2::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->bg_mode = p_bg;
@@ -756,7 +741,6 @@ void RasterizerSceneGLES2::environment_set_camera_feed_id(RID p_env, int p_camer
}
void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -768,7 +752,6 @@ void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable
}
void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -780,7 +763,6 @@ void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enabl
}
void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -817,7 +799,6 @@ void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, RS::EnvironmentTon
}
void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -829,7 +810,6 @@ void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable,
}
void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -840,7 +820,6 @@ void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const C
}
void RasterizerSceneGLES2::environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -853,7 +832,6 @@ void RasterizerSceneGLES2::environment_set_fog_depth(RID p_env, bool p_enable, f
}
void RasterizerSceneGLES2::environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -881,7 +859,6 @@ int RasterizerSceneGLES2::environment_get_canvas_max_layer(RID p_env) {
}
RID RasterizerSceneGLES2::light_instance_create(RID p_light) {
-
LightInstance *light_instance = memnew(LightInstance);
light_instance->last_scene_pass = 0;
@@ -902,7 +879,6 @@ RID RasterizerSceneGLES2::light_instance_create(RID p_light) {
}
void RasterizerSceneGLES2::light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -910,7 +886,6 @@ void RasterizerSceneGLES2::light_instance_set_transform(RID p_light_instance, co
}
void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -928,7 +903,6 @@ void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_insta
}
void RasterizerSceneGLES2::light_instance_mark_visible(RID p_light_instance) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -938,7 +912,6 @@ void RasterizerSceneGLES2::light_instance_mark_visible(RID p_light_instance) {
//////////////////////
RID RasterizerSceneGLES2::gi_probe_instance_create() {
-
return RID();
}
@@ -955,7 +928,6 @@ void RasterizerSceneGLES2::gi_probe_instance_set_bounds(RID p_probe, const Vecto
////////////////////////////
void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass) {
-
RasterizerStorageGLES2::Material *material = nullptr;
RID material_src;
@@ -994,7 +966,6 @@ void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geo
}
}
void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass, bool p_shadow_pass) {
-
bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture || p_material->shader->spatial.uses_depth_texture;
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_MIX;
bool has_alpha = has_base_alpha || has_blend_alpha;
@@ -1016,7 +987,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
}
if (p_depth_pass) {
-
if (has_blend_alpha || p_material->shader->spatial.uses_depth_texture || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
return; //bye
@@ -1077,7 +1047,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
e->refprobe_1_index = RenderList::MAX_REFLECTION_PROBES; //refprobe disabled by default
if (!p_depth_pass) {
-
e->depth_layer = e->instance->depth_layer;
e->priority = p_material->render_priority;
@@ -1119,11 +1088,9 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
if (p_material->shader->spatial.unshaded) {
e->light_mode = LIGHTMODE_UNSHADED;
} else {
-
bool copy = false;
for (int i = 0; i < render_directional_lights; i++) {
-
if (copy) {
RenderList::Element *e2 = has_alpha ? render_list.add_alpha_element() : render_list.add_element();
if (!e2) {
@@ -1144,7 +1111,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
//add omni / spots
for (int i = 0; i < e->instance->light_instances.size(); i++) {
-
LightInstance *li = light_instance_owner.getornull(e->instance->light_instances[i]);
if (!li || li->light_index >= render_light_instance_count || render_light_instances[li->light_index] != li) {
@@ -1186,7 +1152,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
}
void RasterizerSceneGLES2::_copy_texture_to_buffer(GLuint p_texture, GLuint p_buffer) {
-
//copy to front buffer
glBindFramebuffer(GL_FRAMEBUFFER, p_buffer);
@@ -1210,7 +1175,6 @@ void RasterizerSceneGLES2::_copy_texture_to_buffer(GLuint p_texture, GLuint p_bu
}
void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass) {
-
render_pass++;
current_material_index = 0;
current_geometry_index = 0;
@@ -1219,13 +1183,10 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p
current_shader_index = 0;
for (int i = 0; i < p_cull_count; i++) {
-
InstanceBase *instance = p_cull_result[i];
switch (instance->base_type) {
-
case RS::INSTANCE_MESH: {
-
RasterizerStorageGLES2::Mesh *mesh = storage->mesh_owner.getornull(instance->base);
ERR_CONTINUE(!mesh);
@@ -1285,7 +1246,6 @@ static const GLenum gl_primitive[] = {
};
void RasterizerSceneGLES2::_set_cull(bool p_front, bool p_disabled, bool p_reverse_cull) {
-
bool front = p_front;
if (p_reverse_cull)
front = !front;
@@ -1300,14 +1260,12 @@ void RasterizerSceneGLES2::_set_cull(bool p_front, bool p_disabled, bool p_rever
}
if (front != state.cull_front) {
-
glCullFace(front ? GL_FRONT : GL_BACK);
state.cull_front = front;
}
}
bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_material, bool p_alpha_pass, Size2i p_skeleton_tex_size) {
-
// material parameters
state.scene_shader.set_custom_shader(p_material->shader->custom_code_id);
@@ -1333,7 +1291,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
switch (p_material->shader->spatial.depth_draw_mode) {
case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS:
case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_OPAQUE: {
-
glDepthMask(!p_alpha_pass && !p_material->shader->spatial.uses_depth_texture);
} break;
case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALWAYS: {
@@ -1355,20 +1312,17 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
state.current_main_tex = 0;
for (int i = 0; i < tc; i++) {
-
glActiveTexture(GL_TEXTURE0 + i);
RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(textures[i].second);
if (!t) {
-
GLenum target = GL_TEXTURE_2D;
GLuint tex = 0;
switch (texture_types[i]) {
case ShaderLanguage::TYPE_ISAMPLER2D:
case ShaderLanguage::TYPE_USAMPLER2D:
case ShaderLanguage::TYPE_SAMPLER2D: {
-
switch (texture_hints[i]) {
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO:
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: {
@@ -1394,7 +1348,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
case ShaderLanguage::TYPE_ISAMPLER3D:
case ShaderLanguage::TYPE_USAMPLER3D:
case ShaderLanguage::TYPE_SAMPLER3D: {
-
target = GL_TEXTURE_3D;
tex = storage->resources.white_tex_3d;
@@ -1407,7 +1360,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
case ShaderLanguage::TYPE_USAMPLER2DARRAY:
case ShaderLanguage::TYPE_SAMPLER2DARRAY: {
-
target = GL_TEXTURE_2D_ARRAY;
tex = storage->resources.white_tex_array;
@@ -1456,9 +1408,7 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
}
void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, RasterizerStorageGLES2::Skeleton *p_skeleton) {
-
switch (p_element->instance->base_type) {
-
case RS::INSTANCE_MESH: {
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
@@ -1491,7 +1441,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
bool clear_skeleton_buffer = storage->config.use_skeleton_software;
if (p_skeleton) {
-
if (!storage->config.use_skeleton_software) {
//use float texture workflow
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1);
@@ -1524,7 +1473,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
const uint8_t *vertex_data = vertex_array_read.ptr();
for (int i = 0; i < s->array_len; i++) {
-
// do magic
size_t bones[4];
@@ -1613,7 +1561,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
}
if (clear_skeleton_buffer) {
-
glDisableVertexAttribArray(INSTANCE_BONE_BASE + 0);
glDisableVertexAttribArray(INSTANCE_BONE_BASE + 1);
glDisableVertexAttribArray(INSTANCE_BONE_BASE + 2);
@@ -1671,11 +1618,8 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
}
void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
-
switch (p_element->instance->base_type) {
-
case RS::INSTANCE_MESH: {
-
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
// drawing
@@ -1704,7 +1648,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
} break;
case RS::INSTANCE_MULTIMESH: {
-
RasterizerStorageGLES2::MultiMesh *multi_mesh = static_cast<RasterizerStorageGLES2::MultiMesh *>(p_element->owner);
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
@@ -1727,7 +1670,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
const float *buffer = base_buffer + i * stride;
{
-
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]);
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]);
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 2, &buffer[8]);
@@ -1809,7 +1751,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
glBindTexture(t->target, t->tex_id);
restore_tex = true;
} else if (restore_tex) {
-
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, state.current_main_tex);
restore_tex = false;
@@ -1880,7 +1821,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
}
void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas *shadow_atlas) {
-
//turn off all by default
state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTING, false);
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, false);
@@ -1902,7 +1842,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
switch (p_light->light_ptr->type) {
case RS::LIGHT_DIRECTIONAL: {
-
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_DIRECTIONAL, true);
switch (p_light->light_ptr->directional_shadow_mode) {
case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: {
@@ -1932,7 +1871,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
} break;
case RS::LIGHT_OMNI: {
-
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_OMNI, true);
if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) {
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, true);
@@ -1947,7 +1885,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
}
} break;
case RS::LIGHT_SPOT: {
-
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_SPOT, true);
if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) {
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, true);
@@ -1965,7 +1902,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
}
void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform, bool accum_pass) {
-
RasterizerStorageGLES2::Light *light_ptr = light->light_ptr;
//common parameters
@@ -1990,7 +1926,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
CameraMatrix matrices[4];
if (!state.render_no_shadows && light_ptr->shadow && directional_shadow.depth) {
-
int shadow_count = 0;
Color split_offsets;
@@ -2009,14 +1944,12 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
for (int k = 0; k < shadow_count; k++) {
-
uint32_t x = light->directional_rect.position.x;
uint32_t y = light->directional_rect.position.y;
uint32_t width = light->directional_rect.size.x;
uint32_t height = light->directional_rect.size.y;
if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
-
width /= 2;
height /= 2;
@@ -2030,7 +1963,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
} else if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
-
height /= 2;
if (k != 0) {
@@ -2068,7 +2000,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
} break;
case RS::LIGHT_OMNI: {
-
Vector3 position = p_view_transform.xform_inv(light->transform.origin);
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position);
@@ -2080,7 +2011,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_ATTENUATION, attenuation);
if (!state.render_no_shadows && light_ptr->shadow && shadow_atlas && shadow_atlas->shadow_owners.has(light->self)) {
-
uint32_t key = shadow_atlas->shadow_owners[light->self];
uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x03;
@@ -2122,7 +2052,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
} break;
case RS::LIGHT_SPOT: {
-
Vector3 position = p_view_transform.xform_inv(light->transform.origin);
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position);
@@ -2191,7 +2120,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
void RasterizerSceneGLES2::_setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform &p_view_transform, Environment *p_env) {
-
if (p_refprobe1) {
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_USE_BOX_PROJECT, p_refprobe1->probe_ptr->box_projection);
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_BOX_EXTENTS, p_refprobe1->probe_ptr->extents);
@@ -2240,7 +2168,6 @@ void RasterizerSceneGLES2::_setup_refprobes(ReflectionProbeInstance *p_refprobe1
}
void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const CameraMatrix &p_projection, RID p_shadow_atlas, Environment *p_env, GLuint p_base_env, float p_shadow_bias, float p_shadow_normal_bias, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
Vector2 viewport_size = state.viewport_size;
@@ -2323,7 +2250,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
bool rebind_lightmap = false;
if (!p_shadow && material->shader) {
-
bool unshaded = material->shader->spatial.unshaded;
if (unshaded != prev_unshaded) {
@@ -2353,7 +2279,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
}
if (light != prev_light) {
-
_setup_light_type(light, shadow_atlas);
rebind = true;
rebind_light = true;
@@ -2369,7 +2294,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
}
if (prev_blend_mode != blend_mode) {
-
if (prev_blend_mode == -1 && blend_mode != -1) {
//does blend
glEnable(GL_BLEND);
@@ -2390,13 +2314,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
} break;
case RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_ADD: {
-
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(p_alpha_pass ? GL_SRC_ALPHA : GL_ONE, GL_ONE);
} break;
case RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_SUB: {
-
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
} break;
@@ -2449,13 +2371,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
use_lightmap_capture = !unshaded && !accum_pass && !e->instance->lightmap_capture_data.empty();
if (use_lightmap_capture != prev_use_lightmap_capture) {
-
state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP_CAPTURE, use_lightmap_capture);
rebind = true;
}
if (!unshaded && !accum_pass && e->instance->lightmap.is_valid()) {
-
lightmap = storage->texture_owner.getornull(e->instance->lightmap);
lightmap_energy = 1.0;
if (lightmap) {
@@ -2484,7 +2404,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
}
if (depth_prepass != prev_depth_prepass) {
-
state.scene_shader.set_conditional(SceneShaderGLES2::USE_DEPTH_PREPASS, depth_prepass);
prev_depth_prepass = depth_prepass;
rebind = true;
@@ -2493,7 +2412,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
bool instancing = e->instance->base_type == RS::INSTANCE_MULTIMESH;
if (instancing != prev_instancing) {
-
state.scene_shader.set_conditional(SceneShaderGLES2::USE_INSTANCING, instancing);
rebind = true;
}
@@ -2520,7 +2438,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
bool shader_rebind = false;
if (rebind || material != prev_material) {
-
storage->info.render.material_switch_count++;
shader_rebind = _setup_material(material, p_alpha_pass, Size2i(skeleton ? skeleton->size * 3 : 0, 0));
if (shader_rebind) {
@@ -2572,7 +2489,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
rebind_lightmap = true;
if (using_fog) {
-
state.scene_shader.set_uniform(SceneShaderGLES2::FOG_COLOR_BASE, p_env->fog_color);
Color sun_color_amount = p_env->fog_sun_color;
sun_color_amount.a = p_env->fog_sun_amount;
@@ -2679,7 +2595,6 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
CameraMatrix camera;
if (p_custom_fov) {
-
float near_plane = p_projection.get_z_near();
float far_plane = p_projection.get_z_far();
float aspect = p_projection.get_aspect();
@@ -2763,7 +2678,6 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
}
void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p_cam_projection) {
-
//copy to front buffer
glDepthMask(GL_FALSE);
@@ -2839,7 +2753,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
// DOF Blur
if (env->dof_blur_far_enabled) {
-
int vp_h = storage->frame.current_rt->height;
int vp_w = storage->frame.current_rt->width;
@@ -2896,7 +2809,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
if (env->dof_blur_near_enabled) {
-
//convert texture to RGBA format if not already
if (!storage->frame.current_rt->used_dof_blur_near) {
glActiveTexture(GL_TEXTURE0);
@@ -3002,10 +2914,8 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
int glow_mask = 0;
if (env->glow_enabled) {
-
for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) {
if (env->glow_levels & (1 << i)) {
-
if (i >= storage->frame.current_rt->mip_maps[1].sizes.size()) {
max_glow_level = storage->frame.current_rt->mip_maps[1].sizes.size() - 1;
glow_mask |= 1 << max_glow_level;
@@ -3018,7 +2928,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
for (int i = 0; i < (max_glow_level + 1); i++) {
-
int vp_w = storage->frame.current_rt->mip_maps[1].sizes[i].width;
int vp_h = storage->frame.current_rt->mip_maps[1].sizes[i].height;
glViewport(0, 0, vp_w, vp_h);
@@ -3043,7 +2952,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
if (i == 0) {
-
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_BLOOM, env->glow_bloom);
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_THRESHOLD, env->glow_hdr_bleed_threshold);
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_SCALE, env->glow_hdr_bleed_scale);
@@ -3094,7 +3002,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
if (max_glow_level >= 0) {
if (storage->frame.current_rt->mip_maps[0].color) {
for (int i = 0; i < (max_glow_level + 1); i++) {
-
if (glow_mask & (1 << i)) {
if (i == 0) {
state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL1, true);
@@ -3122,11 +3029,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
} else {
-
state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_MULTI_TEXTURE_GLOW, true);
int active_glow_level = 0;
for (int i = 0; i < (max_glow_level + 1); i++) {
-
if (glow_mask & (1 << i)) {
active_glow_level++;
glActiveTexture(GL_TEXTURE0 + active_glow_level);
@@ -3163,7 +3068,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
//Adjustments
if (env->adjustments_enabled) {
-
state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_BCS, true);
RasterizerStorageGLES2::Texture *tex = storage->texture_owner.getornull(env->color_correction);
if (tex) {
@@ -3176,7 +3080,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
state.tonemap_shader.bind();
if (max_glow_level >= 0) {
-
state.tonemap_shader.set_uniform(TonemapShaderGLES2::GLOW_INTENSITY, env->glow_intensity);
int ss[2] = {
storage->frame.current_rt->width,
@@ -3186,7 +3089,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
if (env->adjustments_enabled) {
-
state.tonemap_shader.set_uniform(TonemapShaderGLES2::BCS, Vector3(env->adjustments_brightness, env->adjustments_contrast, env->adjustments_saturation));
}
@@ -3210,7 +3112,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
-
Transform cam_transform = p_cam_transform;
storage->info.render.object_count += p_cull_count;
@@ -3306,7 +3207,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
}
if (p_reflection_probe_cull_count) {
-
reflection_probe_instances = (ReflectionProbeInstance **)alloca(sizeof(ReflectionProbeInstance *) * p_reflection_probe_cull_count);
reflection_probe_count = p_reflection_probe_cull_count;
for (int i = 0; i < p_reflection_probe_cull_count; i++) {
@@ -3339,7 +3239,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
-
glScissor(viewport_x, viewport_y, viewport_width, viewport_height);
glEnable(GL_SCISSOR_TEST);
}
@@ -3395,7 +3294,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
GLuint env_radiance_tex = 0;
if (env) {
switch (env->bg_mode) {
-
case RS::ENV_BG_COLOR_SKY:
case RS::ENV_BG_SKY: {
sky = storage->sky_owner.getornull(env->sky);
@@ -3485,7 +3383,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
// then draw the sky after
if (env && env->bg_mode == RS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) {
-
if (sky && sky->panorama.is_valid()) {
_draw_sky(sky, p_cam_projection, cam_transform, false, env->sky_custom_fov, env->bg_energy, env->sky_orientation);
}
@@ -3586,7 +3483,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
}
void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {
-
state.render_no_shadows = false;
LightInstance *light_instance = light_instance_owner.getornull(p_light);
@@ -3652,7 +3548,6 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
height = light_instance->directional_rect.size.height;
if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
-
width /= 2;
height /= 2;
@@ -3666,11 +3561,9 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
}
} else if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
-
height /= 2;
if (p_pass == 0) {
-
} else {
y += height;
}
@@ -3737,7 +3630,6 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
light_transform = light_instance->shadow_transform[0].transform;
if (light->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
-
height /= 2;
y += p_pass * height;
} else {
@@ -3871,9 +3763,7 @@ void RasterizerSceneGLES2::set_scene_pass(uint64_t p_pass) {
}
bool RasterizerSceneGLES2::free(RID p_rid) {
-
if (light_instance_owner.owns(p_rid)) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_rid);
//remove from shadow atlases..
@@ -3892,13 +3782,11 @@ bool RasterizerSceneGLES2::free(RID p_rid) {
memdelete(light_instance);
} else if (shadow_atlas_owner.owns(p_rid)) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_rid);
shadow_atlas_set_size(p_rid, 0);
shadow_atlas_owner.free(p_rid);
memdelete(shadow_atlas);
} else if (reflection_probe_instance_owner.owns(p_rid)) {
-
ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.getornull(p_rid);
for (int i = 0; i < 6; i++) {
@@ -4000,7 +3888,6 @@ void RasterizerSceneGLES2::initialize() {
glActiveTexture(GL_TEXTURE0);
while (cube_size >= 32) {
-
ShadowCubeMap cube;
cube.size = cube_size;
@@ -4009,7 +3896,6 @@ void RasterizerSceneGLES2::initialize() {
glBindTexture(GL_TEXTURE_CUBE_MAP, cube.cubemap);
for (int i = 0; i < 6; i++) {
-
glTexImage2D(_cube_side_enum[i], 0, storage->config.depth_internalformat, cube_size, cube_size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, nullptr);
}
@@ -4021,7 +3907,6 @@ void RasterizerSceneGLES2::initialize() {
glGenFramebuffers(6, cube.fbo);
for (int i = 0; i < 6; i++) {
-
glBindFramebuffer(GL_FRAMEBUFFER, cube.fbo[i]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _cube_side_enum[i], cube.cubemap, 0);
}
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index 56c0e632c2..d017fc49a2 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -77,7 +77,6 @@ public:
RasterizerStorageGLES2 *storage;
struct State {
-
bool texscreen_copied;
int current_blend_mode;
float current_line_width;
@@ -195,7 +194,6 @@ public:
/* REFLECTION PROBE INSTANCE */
struct ReflectionProbeInstance {
-
RasterizerStorageGLES2::ReflectionProbe *probe_ptr;
RID probe;
RID self;
@@ -387,7 +385,6 @@ public:
/* LIGHT INSTANCE */
struct LightInstance {
-
struct ShadowTransform {
CameraMatrix camera;
Transform transform;
@@ -449,7 +446,6 @@ public:
};
struct RenderList {
-
enum {
MAX_LIGHTS = 255,
MAX_REFLECTION_PROBES = 255,
@@ -534,7 +530,6 @@ public:
}
struct SortByDepth {
-
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
return A->instance->depth < B->instance->depth;
}
@@ -551,7 +546,6 @@ public:
}
struct SortByReverseDepthAndPriority {
-
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
if (A->priority == B->priority) {
return A->instance->depth > B->instance->depth;
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index b8c7815f6a..0636676ffa 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -135,7 +135,6 @@ void RasterizerStorageGLES2::bind_quad_array() const {
}
Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const {
-
r_gl_format = 0;
Ref<Image> image = p_image;
r_compressed = false;
@@ -144,9 +143,7 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
bool need_decompress = false;
switch (p_format) {
-
case Image::FORMAT_L8: {
-
r_gl_internal_format = GL_LUMINANCE;
r_gl_format = GL_LUMINANCE;
r_gl_type = GL_UNSIGNED_BYTE;
@@ -157,7 +154,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
r_gl_type = GL_UNSIGNED_BYTE;
} break;
case Image::FORMAT_R8: {
-
r_gl_internal_format = GL_ALPHA;
r_gl_format = GL_ALPHA;
r_gl_type = GL_UNSIGNED_BYTE;
@@ -174,28 +170,24 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_RGB8: {
-
r_gl_internal_format = GL_RGB;
r_gl_format = GL_RGB;
r_gl_type = GL_UNSIGNED_BYTE;
} break;
case Image::FORMAT_RGBA8: {
-
r_gl_format = GL_RGBA;
r_gl_internal_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
} break;
case Image::FORMAT_RGBA4444: {
-
r_gl_internal_format = GL_RGBA;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_SHORT_4_4_4_4;
} break;
case Image::FORMAT_RGB565: {
-
r_gl_internal_format = GL_RGB5_A1;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_SHORT_5_5_5_1;
@@ -280,7 +272,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_DXT1: {
-
if (config.s3tc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
r_gl_format = GL_RGBA;
@@ -292,7 +283,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_DXT3: {
-
if (config.s3tc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT;
r_gl_format = GL_RGBA;
@@ -304,7 +294,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_DXT5: {
-
if (config.s3tc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT;
r_gl_format = GL_RGBA;
@@ -316,134 +305,107 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_RGTC_R: {
-
if (config.rgtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RED_RGTC1_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_RGTC_RG: {
-
if (config.rgtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RED_GREEN_RGTC2_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_BPTC_RGBA: {
-
if (config.bptc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGBA_BPTC_UNORM;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_BPTC_RGBF: {
-
if (config.bptc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT;
r_gl_format = GL_RGB;
r_gl_type = GL_FLOAT;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_BPTC_RGBFU: {
if (config.bptc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT;
r_gl_format = GL_RGB;
r_gl_type = GL_FLOAT;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC2: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC2A: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC4: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC4A: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_ETC: {
-
if (config.etc1_supported) {
r_gl_internal_format = _EXT_ETC1_RGB8_OES;
r_gl_format = GL_RGBA;
@@ -454,43 +416,33 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
}
} break;
case Image::FORMAT_ETC2_R11: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_R11S: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RG11: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RG11S: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RGB8: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RGBA8: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RGB8A1: {
-
need_decompress = true;
} break;
default: {
-
ERR_FAIL_V(Ref<Image>());
}
}
if (need_decompress || p_force_decompress) {
-
if (!image.is_null()) {
-
image = image->duplicate();
image->decompress();
ERR_FAIL_COND_V(image->is_compressed(), image);
@@ -539,7 +491,6 @@ static const GLenum _cube_side_enum[6] = {
};
RID RasterizerStorageGLES2::texture_create() {
-
Texture *texture = memnew(Texture);
ERR_FAIL_COND_V(!texture, RID());
glGenTextures(1, &texture->tex_id);
@@ -612,7 +563,6 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
bool is_po2 = p_width == po2_width && p_height == po2_height;
if (!is_po2 && (p_flags & RS::TEXTURE_FLAG_REPEAT || p_flags & RS::TEXTURE_FLAG_MIPMAPS)) {
-
if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
//not supported
ERR_PRINT("Streaming texture for non power of 2 or has mipmaps on this hardware: " + texture->path + "'. Mipmaps and repeat disabled.");
@@ -641,7 +591,6 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
#if defined(GLES_OVER_GL) || defined(ANDROID_ENABLED)
if ((p_type == RS::TEXTURE_TYPE_3D && config.texture_3d_supported) || (p_type == RS::TEXTURE_TYPE_2D_ARRAY && config.texture_array_supported)) {
-
int width = p_width;
int height = p_height;
int depth = p_depth_3d;
@@ -718,15 +667,12 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
}
if (config.shrink_textures_x2 && (p_image->has_mipmaps() || !p_image->is_compressed()) && !(texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING)) {
-
texture->alloc_height = MAX(1, texture->alloc_height / 2);
texture->alloc_width = MAX(1, texture->alloc_width / 2);
if (texture->alloc_width == img->get_width() / 2 && texture->alloc_height == img->get_height() / 2) {
-
img->shrink_x2();
} else if (img->get_format() <= Image::FORMAT_RGBA8) {
-
img->resize(texture->alloc_width, texture->alloc_height, Image::INTERPOLATE_BILINEAR);
}
}
@@ -769,16 +715,13 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
}
if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
} else {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
}
if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
-
if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
@@ -787,7 +730,6 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
} else {
-
//glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@@ -801,11 +743,9 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
int tsize = 0;
for (int i = 0; i < mipmaps; i++) {
-
int size, ofs;
img->get_mipmap_offset_and_size(i, ofs, size);
if (texture->type == RS::TEXTURE_TYPE_2D || texture->type == RS::TEXTURE_TYPE_CUBEMAP) {
-
if (compressed) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
@@ -814,7 +754,6 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
glCompressedTexImage2D(blit_target, i, internal_format, bw, bh, 0, size, &read[ofs]);
} else {
-
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
glTexSubImage2D(blit_target, i, 0, 0, w, h, format, type, &read[ofs]);
@@ -868,7 +807,6 @@ void RasterizerStorageGLES2::texture_set_data_partial(RID p_texture, const Ref<I
}
Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) const {
-
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Ref<Image>());
@@ -902,7 +840,6 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
for (int i = 0; i < texture->mipmaps; i++) {
-
int ofs = Image::get_image_mipmap_offset(texture->alloc_width, texture->alloc_height, real_format, i);
if (texture->compressed) {
@@ -993,7 +930,6 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
}
void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) {
-
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -1005,7 +941,6 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
glBindTexture(texture->target, texture->tex_id);
if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
-
if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
@@ -1034,11 +969,9 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
}
if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
} else {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
}
}
@@ -1140,7 +1073,6 @@ void RasterizerStorageGLES2::texture_debug_usage(List<RS::TextureInfo> *r_info)
texture_owner.get_owned_list(&textures);
for (List<RID>::Element *E = textures.front(); E; E = E->next()) {
-
Texture *t = texture_owner.getornull(E->get());
if (!t)
continue;
@@ -1164,7 +1096,6 @@ void RasterizerStorageGLES2::textures_keep_original(bool p_enable) {
}
Size2 RasterizerStorageGLES2::texture_size_with_proxy(RID p_texture) const {
-
const Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Size2());
if (texture->proxy) {
@@ -1193,7 +1124,6 @@ void RasterizerStorageGLES2::texture_set_proxy(RID p_texture, RID p_proxy) {
}
void RasterizerStorageGLES2::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {
-
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -1225,7 +1155,6 @@ void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, R
}
RID RasterizerStorageGLES2::texture_create_radiance_cubemap(RID p_source, int p_resolution) const {
-
return RID();
}
@@ -1326,7 +1255,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
// third, render to the framebuffer using separate textures, then copy to mipmaps
while (size >= 1) {
-
//make framebuffer size the texture size, need to use a separate texture for compatibility
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, resources.mipmap_blur_color);
@@ -1348,7 +1276,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE2); //back to panorama
for (int i = 0; i < 6; i++) {
-
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i);
float roughness = mm_level >= 0 ? lod / (float)(mipmaps - 1) : 1;
@@ -1395,7 +1322,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
/* SHADER API */
RID RasterizerStorageGLES2::shader_create() {
-
Shader *shader = memnew(Shader);
shader->mode = RS::SHADER_SPATIAL;
shader->shader = &scene->state.scene_shader;
@@ -1414,7 +1340,6 @@ void RasterizerStorageGLES2::_shader_make_dirty(Shader *p_shader) {
}
void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code) {
-
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
@@ -1457,7 +1382,6 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code)
}
String RasterizerStorageGLES2::shader_get_code(RID p_shader) const {
-
const Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND_V(!shader, "");
@@ -1465,7 +1389,6 @@ String RasterizerStorageGLES2::shader_get_code(RID p_shader) const {
}
void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const {
-
_shader_dirty_list.remove(&p_shader->dirty_list);
p_shader->valid = false;
@@ -1480,9 +1403,7 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const {
ShaderCompilerGLES2::IdentifierActions *actions = nullptr;
switch (p_shader->mode) {
-
case RS::SHADER_CANVAS_ITEM: {
-
p_shader->canvas_item.light_mode = Shader::CanvasItem::LIGHT_MODE_NORMAL;
p_shader->canvas_item.blend_mode = Shader::CanvasItem::BLEND_MODE_MIX;
@@ -1611,7 +1532,6 @@ void RasterizerStorageGLES2::update_dirty_shaders() {
}
void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
-
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
@@ -1622,7 +1542,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
Map<int, StringName> order;
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) {
-
if (E->get().texture_order >= 0) {
order[E->get().texture_order + 100000] = E->key();
} else {
@@ -1631,7 +1550,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
}
for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
-
PropertyInfo pi;
ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[E->get()];
@@ -1738,7 +1656,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
case ShaderLanguage::TYPE_USAMPLER2DARRAY: {
-
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "TextureArray";
@@ -1758,7 +1675,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
}
void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
-
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
@@ -1773,7 +1689,6 @@ void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, cons
}
RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
-
const Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND_V(!shader, RID());
@@ -1789,7 +1704,6 @@ RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const
/* COMMON MATERIAL API */
void RasterizerStorageGLES2::_material_make_dirty(Material *p_material) const {
-
if (p_material->dirty_list.in_list())
return;
@@ -1797,14 +1711,12 @@ void RasterizerStorageGLES2::_material_make_dirty(Material *p_material) const {
}
RID RasterizerStorageGLES2::material_create() {
-
Material *material = memnew(Material);
return material_owner.make_rid(material);
}
void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1825,7 +1737,6 @@ void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) {
}
RID RasterizerStorageGLES2::material_get_shader(RID p_material) const {
-
const Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, RID());
@@ -1837,7 +1748,6 @@ RID RasterizerStorageGLES2::material_get_shader(RID p_material) const {
}
void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1851,7 +1761,6 @@ void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName
}
Variant RasterizerStorageGLES2::material_get_param(RID p_material, const StringName &p_param) const {
-
const Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, RID());
@@ -1921,7 +1830,6 @@ bool RasterizerStorageGLES2::material_casts_shadows(RID p_material) {
}
void RasterizerStorageGLES2::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1934,7 +1842,6 @@ void RasterizerStorageGLES2::material_add_instance_owner(RID p_material, Rasteri
}
void RasterizerStorageGLES2::material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1976,7 +1883,6 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) {
bool is_animated = false;
if (p_material->shader && p_material->shader->mode == RS::SHADER_SPATIAL) {
-
if (p_material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX &&
(!p_material->shader->spatial.uses_alpha || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) {
can_cast_shadow = true;
@@ -2008,7 +1914,6 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) {
// uniforms and other things will be set in the use_material method in ShaderGLES2
if (p_material->shader && p_material->shader->texture_count > 0) {
-
p_material->textures.resize(p_material->shader->texture_count);
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = p_material->shader->uniforms.front(); E; E = E->next()) {
@@ -2052,7 +1957,6 @@ void RasterizerStorageGLES2::_material_add_geometry(RID p_material, Geometry *p_
}
void RasterizerStorageGLES2::_material_remove_geometry(RID p_material, Geometry *p_geometry) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -2068,7 +1972,6 @@ void RasterizerStorageGLES2::_material_remove_geometry(RID p_material, Geometry
void RasterizerStorageGLES2::update_dirty_materials() {
while (_material_dirty_list.first()) {
-
Material *material = _material_dirty_list.first()->self();
_update_material(material);
}
@@ -2077,14 +1980,12 @@ void RasterizerStorageGLES2::update_dirty_materials() {
/* MESH API */
RID RasterizerStorageGLES2::mesh_create() {
-
Mesh *mesh = memnew(Mesh);
return mesh_owner.make_rid(mesh);
}
static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_t &format, int p_vertices) {
-
uint32_t p_format = format;
static int src_size[RS::ARRAY_MAX];
@@ -2095,7 +1996,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
int dst_stride = 0;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
to_convert[i] = 0;
if (!(p_format & (1 << i))) {
src_size[i] = 0;
@@ -2104,11 +2004,8 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & RS::ARRAY_COMPRESS_VERTEX) {
-
if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
src_size[i] = 4;
dst_size[i] = 8;
@@ -2121,7 +2018,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
format &= ~RS::ARRAY_COMPRESS_VERTEX;
} else {
-
if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
src_size[i] = 8;
dst_size[i] = 8;
@@ -2133,7 +2029,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_NORMAL: {
-
if (p_format & RS::ARRAY_COMPRESS_NORMAL) {
src_size[i] = 4;
dst_size[i] = 4;
@@ -2144,7 +2039,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_TANGENT: {
-
if (p_format & RS::ARRAY_COMPRESS_TANGENT) {
src_size[i] = 4;
dst_size[i] = 4;
@@ -2155,7 +2049,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_COLOR: {
-
if (p_format & RS::ARRAY_COMPRESS_COLOR) {
src_size[i] = 4;
dst_size[i] = 4;
@@ -2166,7 +2059,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_TEX_UV: {
-
if (p_format & RS::ARRAY_COMPRESS_TEX_UV) {
src_size[i] = 4;
to_convert[i] = 2;
@@ -2179,7 +2071,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_TEX_UV2: {
-
if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) {
src_size[i] = 4;
to_convert[i] = 2;
@@ -2192,7 +2083,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_BONES: {
-
if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) {
src_size[i] = 8;
dst_size[i] = 8;
@@ -2203,7 +2093,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_WEIGHTS: {
-
if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) {
src_size[i] = 8;
dst_size[i] = 8;
@@ -2214,7 +2103,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_INDEX: {
-
src_size[i] = 0;
dst_size[i] = 0;
@@ -2235,7 +2123,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
int dst_offset = 0;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
if (src_size[i] == 0) {
continue; //no go
}
@@ -2248,7 +2135,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
float *dst = (float *)&wptr[dst_stride * j + dst_offset];
for (int k = 0; k < to_convert[i]; k++) {
-
dst[k] = Math::half_to_float(src[k]);
}
}
@@ -2273,7 +2159,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
-
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -2293,7 +2178,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
bool uses_half_float = false;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
attribs[i].index = i;
if (!(p_format & (1 << i))) {
@@ -2307,9 +2191,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
attribs[i].integer = false;
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
attribs[i].size = 2;
} else {
@@ -2329,7 +2211,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_NORMAL: {
-
attribs[i].size = 3;
if (p_format & RS::ARRAY_COMPRESS_NORMAL) {
@@ -2344,7 +2225,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_TANGENT: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_COMPRESS_TANGENT) {
@@ -2359,7 +2239,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_COLOR: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_COMPRESS_COLOR) {
@@ -2374,7 +2253,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_TEX_UV: {
-
attribs[i].size = 2;
if (p_format & RS::ARRAY_COMPRESS_TEX_UV) {
@@ -2390,7 +2268,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_TEX_UV2: {
-
attribs[i].size = 2;
if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) {
@@ -2405,7 +2282,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_BONES: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) {
@@ -2421,11 +2297,9 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_WEIGHTS: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) {
-
attribs[i].type = GL_UNSIGNED_SHORT;
stride += 8;
attribs[i].normalized = GL_TRUE;
@@ -2437,7 +2311,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_INDEX: {
-
attribs[i].size = 1;
if (p_vertex_count >= (1 << 16)) {
@@ -2478,7 +2351,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
uint16_t one = Math::make_half_float(1);
for (int i = 0; i < p_vertex_count; i++) {
-
*w16++ = *r16++;
*w16++ = *r16++;
*w16++ = *r16++;
@@ -2492,7 +2364,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
ERR_FAIL_COND(array.size() != array_size);
if (!config.support_half_float_vertices && uses_half_float) {
-
uint32_t new_format = p_format;
Vector<uint8_t> unpacked_array = _unpack_half_floats(array, new_format, p_vertex_count);
@@ -2501,7 +2372,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
}
if (p_format & RS::ARRAY_FORMAT_INDEX) {
-
index_array_size = attribs[RS::ARRAY_INDEX].stride * p_index_count;
}
@@ -2577,7 +2447,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
// blend shapes
for (int i = 0; i < p_blend_shapes.size(); i++) {
-
Surface::BlendShape mt;
const uint8_t *vr = p_blend_shapes[i].ptr();
@@ -2692,7 +2561,6 @@ int RasterizerStorageGLES2::mesh_surface_get_array_index_len(RID p_mesh, int p_s
}
Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p_surface) const {
-
const Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, Vector<uint8_t>());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>());
@@ -2758,7 +2626,6 @@ Vector<AABB> RasterizerStorageGLES2::mesh_surface_get_skeleton_aabb(RID p_mesh,
}
void RasterizerStorageGLES2::mesh_remove_surface(RID p_mesh, int p_surface) {
-
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX(p_surface, mesh->surfaces.size());
@@ -2823,12 +2690,9 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
AABB aabb;
if (sk && sk->size != 0) {
-
for (int i = 0; i < mesh->surfaces.size(); i++) {
-
AABB laabb;
if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
-
int bs = mesh->surfaces[i]->skeleton_bone_aabb.size();
const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr();
const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr();
@@ -2840,7 +2704,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
bool first = true;
if (sk->use_2d) {
for (int j = 0; j < bs; j++) {
-
if (!skused[j])
continue;
@@ -2867,7 +2730,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
}
} else {
for (int j = 0; j < bs; j++) {
-
if (!skused[j])
continue;
@@ -2901,7 +2763,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
}
} else {
-
laabb = mesh->surfaces[i]->aabb;
}
@@ -2911,9 +2772,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
aabb.merge_with(laabb);
}
} else {
-
for (int i = 0; i < mesh->surfaces.size(); i++) {
-
if (i == 0)
aabb = mesh->surfaces[i]->aabb;
else
@@ -3158,7 +3017,6 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
-
uint8_t *data8 = (uint8_t *)dataptr;
data8[0] = CLAMP(p_color.r * 255.0, 0, 255);
data8[1] = CLAMP(p_color.g * 255.0, 0, 255);
@@ -3191,7 +3049,6 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh,
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
-
uint8_t *data8 = (uint8_t *)dataptr;
data8[0] = CLAMP(p_custom_data.r * 255.0, 0, 255);
data8[1] = CLAMP(p_custom_data.g * 255.0, 0, 255);
@@ -3379,13 +3236,10 @@ AABB RasterizerStorageGLES2::multimesh_get_aabb(RID p_multimesh) const {
}
void RasterizerStorageGLES2::update_dirty_multimeshes() {
-
while (multimesh_update_list.first()) {
-
MultiMesh *multimesh = multimesh_update_list.first()->self();
if (multimesh->size && multimesh->dirty_aabb) {
-
AABB mesh_aabb;
if (multimesh->mesh.is_valid()) {
@@ -3401,9 +3255,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() {
AABB aabb;
if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) {
-
for (int i = 0; i < count; i += stride) {
-
float *dataptr = &data[i];
Transform xform;
@@ -3424,9 +3276,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() {
}
} else {
-
for (int i = 0; i < count; i += stride) {
-
float *dataptr = &data[i];
Transform xform;
@@ -3599,7 +3449,6 @@ RID RasterizerStorageGLES2::immediate_get_material(RID p_immediate) const {
/* SKELETON API */
RID RasterizerStorageGLES2::skeleton_create() {
-
Skeleton *skeleton = memnew(Skeleton);
glGenTextures(1, &skeleton->tex_id);
@@ -3608,7 +3457,6 @@ RID RasterizerStorageGLES2::skeleton_create() {
}
void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_COND(p_bones < 0);
@@ -3621,7 +3469,6 @@ void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool
skeleton->use_2d = p_2d_skeleton;
if (!config.use_skeleton_software) {
-
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, skeleton->tex_id);
@@ -3762,7 +3609,6 @@ Transform2D RasterizerStorageGLES2::skeleton_bone_get_transform_2d(RID p_skeleto
}
void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -3770,7 +3616,6 @@ void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, cons
}
void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size) {
-
glBindBuffer(GL_ARRAY_BUFFER, resources.skeleton_transform_buffer);
if (p_size > resources.skeleton_transform_buffer_size) {
@@ -3787,7 +3632,6 @@ void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<floa
}
void RasterizerStorageGLES2::update_dirty_skeletons() {
-
if (config.use_skeleton_software)
return;
@@ -3813,7 +3657,6 @@ void RasterizerStorageGLES2::update_dirty_skeletons() {
/* Light API */
RID RasterizerStorageGLES2::light_create(RS::LightType p_type) {
-
Light *light = memnew(Light);
light->type = p_type;
@@ -4060,7 +3903,6 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const {
ERR_FAIL_COND_V(!light, AABB());
switch (light->type) {
-
case RS::LIGHT_SPOT: {
float len = light->param[RS::LIGHT_PARAM_RANGE];
float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
@@ -4083,7 +3925,6 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const {
/* PROBE API */
RID RasterizerStorageGLES2::reflection_probe_create() {
-
ReflectionProbe *reflection_probe = memnew(ReflectionProbe);
reflection_probe->intensity = 1.0;
@@ -4104,7 +3945,6 @@ RID RasterizerStorageGLES2::reflection_probe_create() {
}
void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4113,7 +3953,6 @@ void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::R
}
void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4121,7 +3960,6 @@ void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p
}
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4129,7 +3967,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient(RID p_probe,
}
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4137,7 +3974,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_energy(RID p_
}
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4145,7 +3981,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_probe_contrib
}
void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4153,7 +3988,6 @@ void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, floa
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4161,7 +3995,6 @@ void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vec
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4170,7 +4003,6 @@ void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, con
}
void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4178,7 +4010,6 @@ void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4186,7 +4017,6 @@ void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_pr
}
void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4194,7 +4024,6 @@ void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bo
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4203,7 +4032,6 @@ void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_
}
void RasterizerStorageGLES2::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4221,7 +4049,6 @@ AABB RasterizerStorageGLES2::reflection_probe_get_aabb(RID p_probe) const {
return aabb;
}
RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
@@ -4229,7 +4056,6 @@ RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_updat
}
uint32_t RasterizerStorageGLES2::reflection_probe_get_cull_mask(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -4237,14 +4063,12 @@ uint32_t RasterizerStorageGLES2::reflection_probe_get_cull_mask(RID p_probe) con
}
Vector3 RasterizerStorageGLES2::reflection_probe_get_extents(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
return reflection_probe->extents;
}
Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
@@ -4252,7 +4076,6 @@ Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe)
}
bool RasterizerStorageGLES2::reflection_probe_renders_shadows(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
@@ -4260,7 +4083,6 @@ bool RasterizerStorageGLES2::reflection_probe_renders_shadows(RID p_probe) const
}
float RasterizerStorageGLES2::reflection_probe_get_origin_max_distance(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -4268,7 +4090,6 @@ float RasterizerStorageGLES2::reflection_probe_get_origin_max_distance(RID p_pro
}
int RasterizerStorageGLES2::reflection_probe_get_resolution(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -4373,26 +4194,22 @@ void RasterizerStorageGLES2::gi_probe_dynamic_data_update(RID p_gi_probe_data, i
///////
RID RasterizerStorageGLES2::lightmap_capture_create() {
-
LightmapCapture *capture = memnew(LightmapCapture);
return lightmap_capture_data_owner.make_rid(capture);
}
void RasterizerStorageGLES2::lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {
-
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
capture->bounds = p_bounds;
capture->instance_change_notify(true, false);
}
AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const {
-
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, AABB());
return capture->bounds;
}
void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {
-
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
@@ -4407,7 +4224,6 @@ void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Ve
capture->instance_change_notify(true, false);
}
Vector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const {
-
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, Vector<uint8_t>());
@@ -4450,14 +4266,12 @@ int RasterizerStorageGLES2::lightmap_capture_get_octree_cell_subdiv(RID p_captur
}
void RasterizerStorageGLES2::lightmap_capture_set_energy(RID p_capture, float p_energy) {
-
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
capture->energy = p_energy;
}
float RasterizerStorageGLES2::lightmap_capture_get_energy(RID p_capture) const {
-
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, 0);
return capture->energy;
@@ -4562,7 +4376,6 @@ bool RasterizerStorageGLES2::particles_is_inactive(RID p_particles) const {
////////
void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -4570,7 +4383,6 @@ void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerSce
}
void RasterizerStorageGLES2::instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -4578,7 +4390,6 @@ void RasterizerStorageGLES2::instance_remove_skeleton(RID p_skeleton, Rasterizer
}
void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {
-
Instantiable *inst = nullptr;
switch (p_instance->base_type) {
case RS::INSTANCE_MESH: {
@@ -4622,7 +4433,6 @@ void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene
}
void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {
-
Instantiable *inst = nullptr;
switch (p_instance->base_type) {
@@ -4669,7 +4479,6 @@ void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerSc
/* RENDER TARGET */
void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
-
// do not allocate a render target with no size
if (rt->width <= 0 || rt->height <= 0)
return;
@@ -4707,7 +4516,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
rt->mip_maps_allocated = false;
{
-
/* Front FBO */
Texture *texture = texture_owner.getornull(rt->texture);
@@ -4724,11 +4532,9 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, nullptr);
if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
@@ -4741,7 +4547,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
// depth
if (config.support_depth_texture) {
-
glGenTextures(1, &rt->depth);
glBindTexture(GL_TEXTURE_2D, rt->depth);
glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, rt->width, rt->height, 0, GL_DEPTH_COMPONENT, config.depth_type, nullptr);
@@ -4753,7 +4558,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
} else {
-
glGenRenderbuffers(1, &rt->depth);
glBindRenderbuffer(GL_RENDERBUFFER, rt->depth);
@@ -4765,13 +4569,10 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
-
glDeleteFramebuffers(1, &rt->fbo);
if (config.support_depth_texture) {
-
glDeleteTextures(1, &rt->depth);
} else {
-
glDeleteRenderbuffers(1, &rt->depth);
}
@@ -4806,7 +4607,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
#ifndef JAVASCRIPT_ENABLED
if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_16X && config.multisample_supported) {
-
rt->multisample_active = true;
static const int msaa_value[] = { 0, 2, 4, 8, 16 };
@@ -4889,7 +4689,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
// copy texscreen buffers
if (!(rt->flags[RasterizerStorage::RENDER_TARGET_NO_SAMPLING])) {
-
glGenTextures(1, &rt->copy_screen_effect.color);
glBindTexture(GL_TEXTURE_2D, rt->copy_screen_effect.color);
@@ -4920,9 +4719,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
// Allocate mipmap chains for post_process effects
if (!rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D] && rt->width >= 2 && rt->height >= 2) {
-
for (int i = 0; i < 2; i++) {
-
ERR_FAIL_COND(rt->mip_maps[i].sizes.size());
int w = rt->width;
int h = rt->height;
@@ -4937,7 +4734,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
int fb_h = h;
while (true) {
-
RenderTarget::MipMaps::Size mm;
mm.width = w;
mm.height = h;
@@ -4956,7 +4752,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
GLsizei height = fb_h;
if (config.render_to_mipmap_supported) {
-
glGenTextures(1, &rt->mip_maps[i].color);
glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].color);
@@ -4970,7 +4765,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);
#endif
} else {
-
// Can't render to specific levels of a mipmap in ES 2.0 or Webgl so create a texture for each level
for (int l = 0; l < level + 1; l++) {
glGenTextures(1, &rt->mip_maps[i].sizes.write[l].color);
@@ -4990,17 +4784,14 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glDepthMask(GL_TRUE);
for (int j = 0; j < rt->mip_maps[i].sizes.size(); j++) {
-
RenderTarget::MipMaps::Size &mm = rt->mip_maps[i].sizes.write[j];
glGenFramebuffers(1, &mm.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, mm.fbo);
if (config.render_to_mipmap_supported) {
-
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].color, j);
} else {
-
glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color, 0);
}
@@ -5046,7 +4837,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
}
void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) {
-
// there is nothing to clear when DIRECT_TO_SCREEN is used
if (rt->flags[RENDER_TARGET_DIRECT_TO_SCREEN])
return;
@@ -5129,7 +4919,6 @@ void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) {
}
RID RasterizerStorageGLES2::render_target_create() {
-
RenderTarget *rt = memnew(RenderTarget);
Texture *t = memnew(Texture);
@@ -5160,7 +4949,6 @@ RID RasterizerStorageGLES2::render_target_create() {
}
void RasterizerStorageGLES2::render_target_set_position(RID p_render_target, int p_x, int p_y) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
@@ -5169,7 +4957,6 @@ void RasterizerStorageGLES2::render_target_set_position(RID p_render_target, int
}
void RasterizerStorageGLES2::render_target_set_size(RID p_render_target, int p_width, int p_height) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
@@ -5185,7 +4972,6 @@ void RasterizerStorageGLES2::render_target_set_size(RID p_render_target, int p_w
}
RID RasterizerStorageGLES2::render_target_get_texture(RID p_render_target) const {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
@@ -5390,7 +5176,6 @@ void RasterizerStorageGLES2::render_target_set_msaa(RID p_render_target, RS::Vie
/* CANVAS SHADOW */
RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) {
-
CanvasLightShadow *cls = memnew(CanvasLightShadow);
if (p_width > config.max_texture_size)
@@ -5442,7 +5227,6 @@ RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) {
/* LIGHT SHADOW MAPPING */
RID RasterizerStorageGLES2::canvas_light_occluder_create() {
-
CanvasOccluder *co = memnew(CanvasOccluder);
co->index_id = 0;
co->vertex_id = 0;
@@ -5452,14 +5236,12 @@ RID RasterizerStorageGLES2::canvas_light_occluder_create() {
}
void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) {
-
CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!co);
co->lines = p_lines;
if (p_lines.size() != co->len) {
-
if (co->index_id)
glDeleteBuffers(1, &co->index_id);
if (co->vertex_id)
@@ -5471,7 +5253,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
}
if (p_lines.size()) {
-
Vector<float> geometry;
Vector<uint16_t> indices;
int lc = p_lines.size();
@@ -5487,7 +5268,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
const int POLY_HEIGHT = 16384;
for (int i = 0; i < lc / 2; i++) {
-
vw[i * 12 + 0] = lr[i * 2 + 0].x;
vw[i * 12 + 1] = lr[i * 2 + 0].y;
vw[i * 12 + 2] = POLY_HEIGHT;
@@ -5520,7 +5300,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id);
glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_STATIC_DRAW);
} else {
-
glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id);
glBufferSubData(GL_ARRAY_BUFFER, 0, lc * 6 * sizeof(real_t), vw.ptr());
}
@@ -5528,12 +5307,10 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
if (!co->index_id) {
-
glGenBuffers(1, &co->index_id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, lc * 3 * sizeof(uint16_t), iw.ptr(), GL_DYNAMIC_DRAW);
} else {
-
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, lc * 3 * sizeof(uint16_t), iw.ptr());
}
@@ -5545,7 +5322,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
}
RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const {
-
if (mesh_owner.owns(p_rid)) {
return RS::INSTANCE_MESH;
} else if (light_owner.owns(p_rid)) {
@@ -5564,9 +5340,7 @@ RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const {
}
bool RasterizerStorageGLES2::free(RID p_rid) {
-
if (render_target_owner.owns(p_rid)) {
-
RenderTarget *rt = render_target_owner.getornull(p_rid);
_render_target_clear(rt);
@@ -5578,7 +5352,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (texture_owner.owns(p_rid)) {
-
Texture *t = texture_owner.getornull(p_rid);
// can't free a render target texture
ERR_FAIL_COND_V(t->render_target, true);
@@ -5589,7 +5362,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (sky_owner.owns(p_rid)) {
-
Sky *sky = sky_owner.getornull(p_rid);
sky_set_texture(p_rid, RID(), 256);
sky_owner.free(p_rid);
@@ -5597,7 +5369,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (shader_owner.owns(p_rid)) {
-
Shader *shader = shader_owner.getornull(p_rid);
if (shader->shader && shader->custom_code_id) {
@@ -5622,7 +5393,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (material_owner.owns(p_rid)) {
-
Material *m = material_owner.getornull(p_rid);
if (m->shader) {
@@ -5635,7 +5405,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
}
for (Map<RasterizerScene::InstanceBase *, int>::Element *E = m->instance_owners.front(); E; E = E->next()) {
-
RasterizerScene::InstanceBase *ins = E->key();
if (ins->material_override == p_rid) {
@@ -5654,7 +5423,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (skeleton_owner.owns(p_rid)) {
-
Skeleton *s = skeleton_owner.getornull(p_rid);
if (s->update_list.in_list()) {
@@ -5676,7 +5444,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (mesh_owner.owns(p_rid)) {
-
Mesh *mesh = mesh_owner.getornull(p_rid);
mesh->instance_remove_deps();
@@ -5699,7 +5466,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (multimesh_owner.owns(p_rid)) {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
multimesh->instance_remove_deps();
@@ -5727,7 +5493,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (light_owner.owns(p_rid)) {
-
Light *light = light_owner.getornull(p_rid);
light->instance_remove_deps();
@@ -5736,7 +5501,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (reflection_probe_owner.owns(p_rid)) {
-
// delete the texture
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid);
reflection_probe->instance_remove_deps();
@@ -5746,7 +5510,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (lightmap_capture_data_owner.owns(p_rid)) {
-
// delete the texture
LightmapCapture *lightmap_capture = lightmap_capture_data_owner.getornull(p_rid);
lightmap_capture->instance_remove_deps();
@@ -5756,7 +5519,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (canvas_occluder_owner.owns(p_rid)) {
-
CanvasOccluder *co = canvas_occluder_owner.getornull(p_rid);
if (co->index_id)
glDeleteBuffers(1, &co->index_id);
@@ -5769,7 +5531,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (canvas_light_shadow_owner.owns(p_rid)) {
-
CanvasLightShadow *cls = canvas_light_shadow_owner.getornull(p_rid);
glDeleteFramebuffers(1, &cls->fbo);
glDeleteRenderbuffers(1, &cls->depth);
@@ -5784,7 +5545,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
}
bool RasterizerStorageGLES2::has_os_feature(const String &p_feature) const {
-
if (p_feature == "pvrtc")
return config.pvrtc_supported;
@@ -5803,12 +5563,10 @@ void RasterizerStorageGLES2::set_debug_generate_wireframes(bool p_generate) {
}
void RasterizerStorageGLES2::render_info_begin_capture() {
-
info.snap = info.render;
}
void RasterizerStorageGLES2::render_info_end_capture() {
-
info.snap.object_count = info.render.object_count - info.snap.object_count;
info.snap.draw_call_count = info.render.draw_call_count - info.snap.draw_call_count;
info.snap.material_switch_count = info.render.material_switch_count - info.snap.material_switch_count;
@@ -5818,7 +5576,6 @@ void RasterizerStorageGLES2::render_info_end_capture() {
}
int RasterizerStorageGLES2::get_captured_render_info(RS::RenderInfo p_info) {
-
switch (p_info) {
case RS::INFO_OBJECTS_IN_FRAME: {
return info.snap.object_count;
@@ -5872,12 +5629,10 @@ int RasterizerStorageGLES2::get_render_info(RS::RenderInfo p_info) {
}
String RasterizerStorageGLES2::get_video_adapter_name() const {
-
return (const char *)glGetString(GL_RENDERER);
}
String RasterizerStorageGLES2::get_video_adapter_vendor() const {
-
return (const char *)glGetString(GL_VENDOR);
}
@@ -5885,7 +5640,6 @@ void RasterizerStorageGLES2::initialize() {
RasterizerStorageGLES2::system_fbo = 0;
{
-
const GLubyte *extension_string = glGetString(GL_EXTENSIONS);
Vector<String> extensions = String((const char *)extension_string).split(" ");
@@ -6236,7 +5990,6 @@ void RasterizerStorageGLES2::initialize() {
}
{
-
glGenFramebuffers(1, &resources.mipmap_blur_fbo);
glGenTextures(1, &resources.mipmap_blur_color);
}
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index 29651936fb..15761e4efd 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -57,7 +57,6 @@ public:
static GLuint system_fbo;
struct Config {
-
bool shrink_textures_x2;
bool use_fast_texture_filter;
bool use_skeleton_software;
@@ -106,7 +105,6 @@ public:
} config;
struct Resources {
-
GLuint white_tex;
GLuint black_tex;
GLuint normal_tex;
@@ -129,7 +127,6 @@ public:
} resources;
mutable struct Shaders {
-
ShaderCompilerGLES2 compiler;
CopyShaderGLES2 copy;
@@ -142,7 +139,6 @@ public:
} shaders;
struct Info {
-
uint64_t texture_mem;
uint64_t vertex_mem;
@@ -183,10 +179,8 @@ public:
SelfList<RasterizerScene::InstanceBase>::List instance_list;
_FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) {
-
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
-
instances->self()->base_changed(p_aabb, p_materials);
instances = instances->next();
}
@@ -210,7 +204,6 @@ public:
};
struct Geometry : public Instantiable {
-
enum Type {
GEOMETRY_INVALID,
GEOMETRY_SURFACE,
@@ -240,7 +233,6 @@ public:
struct RenderTarget;
struct Texture {
-
Texture *proxy;
Set<Texture *> proxy_owners;
@@ -383,7 +375,6 @@ public:
/* SKY API */
struct Sky {
-
RID panorama;
GLuint radiance;
int radiance_size;
@@ -399,7 +390,6 @@ public:
struct Material;
struct Shader {
-
RID self;
RS::ShaderMode mode;
@@ -429,7 +419,6 @@ public:
uint64_t last_pass;
struct CanvasItem {
-
enum BlendMode {
BLEND_MODE_MIX,
BLEND_MODE_ADD,
@@ -455,7 +444,6 @@ public:
} canvas_item;
struct Spatial {
-
enum BlendMode {
BLEND_MODE_MIX,
BLEND_MODE_ADD,
@@ -499,7 +487,6 @@ public:
} spatial;
struct Particles {
-
} particles;
bool uses_vertex_time;
@@ -507,7 +494,6 @@ public:
Shader() :
dirty_list(this) {
-
shader = nullptr;
valid = false;
custom_code_id = 0;
@@ -536,7 +522,6 @@ public:
/* COMMON MATERIAL API */
struct Material {
-
Shader *shader;
Map<StringName, Variant> params;
SelfList<Material> list;
@@ -605,7 +590,6 @@ public:
struct Mesh;
struct Surface : public Geometry {
-
struct Attrib {
bool enabled;
bool integer;
@@ -669,7 +653,6 @@ public:
struct MultiMesh;
struct Mesh : public GeometryOwner {
-
bool active;
Vector<Surface *> surfaces;
@@ -740,7 +723,6 @@ public:
/* MULTIMESH API */
struct MultiMesh : public GeometryOwner {
-
RID mesh;
int size;
@@ -814,7 +796,6 @@ public:
/* IMMEDIATE API */
struct Immediate : public Geometry {
-
struct Chunk {
RID texture;
RS::PrimitiveType primitive;
@@ -862,7 +843,6 @@ public:
/* SKELETON API */
struct Skeleton {
-
bool use_2d;
int size;
@@ -972,7 +952,6 @@ public:
/* PROBE API */
struct ReflectionProbe : Instantiable {
-
RS::ReflectionProbeUpdateMode update_mode;
float intensity;
Color interior_ambient;
@@ -1062,7 +1041,6 @@ public:
/* LIGHTMAP */
struct LightmapCapture : public Instantiable {
-
Vector<LightmapCaptureOctree> octree;
AABB bounds;
Transform cell_xform;
@@ -1165,7 +1143,6 @@ public:
Effect copy_screen_effect;
struct MipMaps {
-
struct Size {
GLuint fbo;
GLuint color;
@@ -1252,7 +1229,6 @@ public:
/* CANVAS SHADOW */
struct CanvasLightShadow {
-
int size;
int height;
GLuint fbo;
@@ -1267,7 +1243,6 @@ public:
/* LIGHT SHADOW MAPPING */
struct CanvasOccluder {
-
GLuint vertex_id; // 0 means, unconfigured
GLuint index_id; // 0 means, unconfigured
Vector<Vector2> lines;
@@ -1284,7 +1259,6 @@ public:
virtual bool free(RID p_rid);
struct Frame {
-
RenderTarget *current_rt;
bool clear_request;
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index f6a764c26c..9b57f417cb 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -38,7 +38,6 @@
#define SL ShaderLanguage
static String _mktab(int p_level) {
-
String tb;
for (int i = 0; i < p_level; i++) {
tb += "\t";
@@ -48,12 +47,10 @@ static String _mktab(int p_level) {
}
static String _typestr(SL::DataType p_type) {
-
return ShaderLanguage::get_datatype_name(p_type);
}
static String _prestr(SL::DataPrecision p_pres) {
-
switch (p_pres) {
case SL::PRECISION_LOWP:
return "lowp ";
@@ -68,7 +65,6 @@ static String _prestr(SL::DataPrecision p_pres) {
}
static String _qualstr(SL::ArgumentQualifier p_qual) {
-
switch (p_qual) {
case SL::ARGUMENT_QUALIFIER_IN:
return "in ";
@@ -81,18 +77,15 @@ static String _qualstr(SL::ArgumentQualifier p_qual) {
}
static String _opstr(SL::Operator p_op) {
-
return SL::get_operator_text(p_op);
}
static String _mkid(const String &p_id) {
-
String id = "m_" + p_id.replace("__", "_dus_");
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
static String f2sp0(float p_float) {
-
String num = rtoss(p_float);
if (num.find(".") == -1 && num.find("e") == -1) {
num += ".0";
@@ -101,14 +94,12 @@ static String f2sp0(float p_float) {
}
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) {
-
switch (p_type) {
case SL::TYPE_BOOL:
return p_values[0].boolean ? "true" : "false";
case SL::TYPE_BVEC2:
case SL::TYPE_BVEC3:
case SL::TYPE_BVEC4: {
-
StringBuffer<> text;
text += "bvec";
@@ -131,7 +122,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_UVEC2:
case SL::TYPE_UVEC3:
case SL::TYPE_UVEC4: {
-
StringBuffer<> text;
text += "ivec";
@@ -154,7 +144,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_IVEC2:
case SL::TYPE_IVEC3:
case SL::TYPE_IVEC4: {
-
StringBuffer<> text;
text += "ivec";
@@ -176,7 +165,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_VEC2:
case SL::TYPE_VEC3:
case SL::TYPE_VEC4: {
-
StringBuffer<> text;
text += "vec";
@@ -196,7 +184,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_MAT2:
case SL::TYPE_MAT3:
case SL::TYPE_MAT4: {
-
StringBuffer<> text;
text += "mat";
@@ -231,7 +218,6 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri
ERR_FAIL_COND(fidx == -1);
for (Set<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) {
-
if (r_added.has(E->get())) {
continue;
}
@@ -277,19 +263,14 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri
}
String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning) {
-
StringBuilder code;
switch (p_node->type) {
-
case SL::Node::TYPE_SHADER: {
-
SL::ShaderNode *snode = (SL::ShaderNode *)p_node;
for (int i = 0; i < snode->render_modes.size(); i++) {
-
if (p_default_actions.render_mode_defines.has(snode->render_modes[i]) && !used_rmode_defines.has(snode->render_modes[i])) {
-
r_gen_code.custom_defines.push_back(p_default_actions.render_mode_defines[snode->render_modes[i]].utf8());
used_rmode_defines.insert(snode->render_modes[i]);
}
@@ -326,7 +307,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
// structs
for (int i = 0; i < snode->vstructs.size(); i++) {
-
SL::StructNode *st = snode->vstructs[i].shader_struct;
String struct_code;
@@ -393,7 +373,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
// varyings
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = snode->varyings.front(); E; E = E->next()) {
-
StringBuffer<> varying_code;
varying_code += "varying ";
@@ -448,7 +427,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
Set<StringName> added_fragment;
for (int i = 0; i < snode->functions.size(); i++) {
-
SL::FunctionNode *fnode = snode->functions[i].function;
current_func_name = fnode->name;
@@ -472,14 +450,11 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} break;
case SL::Node::TYPE_STRUCT: {
-
} break;
case SL::Node::TYPE_FUNCTION: {
-
} break;
case SL::Node::TYPE_BLOCK: {
-
SL::BlockNode *bnode = (SL::BlockNode *)p_node;
if (!bnode->single_statement) {
@@ -520,7 +495,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
for (int i = 0; i < var_dec_node->declarations.size(); i++) {
-
if (i > 0) {
declaration += ",";
}
@@ -597,7 +571,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += ")";
} break;
case SL::Node::TYPE_ARRAY_DECLARATION: {
-
SL::ArrayDeclarationNode *arr_dec_node = (SL::ArrayDeclarationNode *)p_node;
StringBuffer<> declaration;
@@ -608,7 +581,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
declaration += _typestr(arr_dec_node->datatype);
}
for (int i = 0; i < arr_dec_node->declarations.size(); i++) {
-
if (i > 0) {
declaration += ",";
}
@@ -736,7 +708,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} else if (op_node->op == SL::OP_CONSTRUCT) {
code += var_node->name;
} else {
-
if (var_node->name == "texture") {
// emit texture call
@@ -764,9 +735,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
} else if (var_node->name == "mix") {
-
switch (op_node->arguments[3]->get_datatype()) {
-
case SL::TYPE_BVEC2: {
code += "select2";
} break;
@@ -783,7 +752,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
case SL::TYPE_VEC3:
case SL::TYPE_VEC4:
case SL::TYPE_FLOAT: {
-
code += "mix";
} break;
@@ -846,7 +814,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} break;
case SL::OP_MOD: {
-
code += "mod(float(";
code += _dump_node_code(op_node->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += "), float(";
@@ -870,7 +837,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
SL::ControlFlowNode *cf_node = (SL::ControlFlowNode *)p_node;
if (cf_node->flow_op == SL::FLOW_OP_IF) {
-
code += _mktab(p_level);
code += "if (";
code += _dump_node_code(cf_node->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
@@ -897,7 +863,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += ")\n";
code += _dump_node_code(cf_node->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
} else if (cf_node->flow_op == SL::FLOW_OP_FOR) {
-
code += _mktab(p_level);
code += "for (";
code += _dump_node_code(cf_node->blocks[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
@@ -948,11 +913,9 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
-
Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types());
if (err != OK) {
-
Vector<String> shader = p_code.split("\n");
for (int i = 0; i < shader.size(); i++) {
print_line(itos(i + 1) + " " + shader[i]);
@@ -985,7 +948,6 @@ Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code,
}
ShaderCompilerGLES2::ShaderCompilerGLES2() {
-
/** CANVAS ITEM SHADER **/
actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h
index 757dcdd4f2..369bf7877b 100644
--- a/drivers/gles2/shader_compiler_gles2.h
+++ b/drivers/gles2/shader_compiler_gles2.h
@@ -40,7 +40,6 @@
class ShaderCompilerGLES2 {
public:
struct IdentifierActions {
-
Map<StringName, Pair<int *, int>> render_mode_values;
Map<StringName, bool *> render_mode_flags;
Map<StringName, bool *> usage_flag_pointers;
@@ -50,7 +49,6 @@ public:
};
struct GeneratedCode {
-
Vector<CharString> custom_defines;
Vector<StringName> uniforms;
Vector<StringName> texture_uniforms;
@@ -71,7 +69,6 @@ private:
ShaderLanguage parser;
struct DefaultIdentifierActions {
-
Map<StringName, String> renames;
Map<StringName, String> render_mode_defines;
Map<StringName, String> usage_defines;
diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp
index 2c335c6c5a..48b98435c4 100644
--- a/drivers/gles2/shader_gles2.cpp
+++ b/drivers/gles2/shader_gles2.cpp
@@ -70,14 +70,12 @@ ShaderGLES2 *ShaderGLES2::active = nullptr;
#endif
GLint ShaderGLES2::get_uniform_location(int p_index) const {
-
ERR_FAIL_COND_V(!version, -1);
return version->uniform_location[p_index];
}
bool ShaderGLES2::bind() {
-
if (active != this || !version || new_conditional_version.key != conditional_version.key) {
conditional_version = new_conditional_version;
version = get_current_version();
@@ -110,7 +108,6 @@ void ShaderGLES2::unbind() {
}
static void _display_error_with_code(const String &p_error, const Vector<const char *> &p_code) {
-
int line = 1;
String total_code;
@@ -121,7 +118,6 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
Vector<String> lines = String(total_code).split("\n");
for (int j = 0; j < lines.size(); j++) {
-
print_line(itos(line) + ": " + lines[j]);
line++;
}
@@ -130,13 +126,11 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
}
static String _mkid(const String &p_id) {
-
String id = "m_" + p_id;
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
ShaderGLES2::Version *ShaderGLES2::get_current_version() {
-
Version *_v = version_map.getptr(conditional_version);
if (_v) {
@@ -457,7 +451,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() {
}
GLint ShaderGLES2::get_uniform_location(const String &p_name) const {
-
ERR_FAIL_COND_V(!version, -1);
return glGetUniformLocation(version->id, p_name.ascii().get_data());
}
@@ -475,7 +468,6 @@ void ShaderGLES2::setup(
const char *p_fragment_code,
int p_vertex_code_start,
int p_fragment_code_start) {
-
ERR_FAIL_COND(version);
conditional_version.key = 0;
@@ -532,7 +524,6 @@ void ShaderGLES2::setup(
String code2;
if (cpos != -1) {
-
fragment_code1 = code.substr(0, cpos).ascii();
code2 = code.substr(cpos + light_code_tag.length(), code.length());
} else {
@@ -617,7 +608,6 @@ void ShaderGLES2::set_custom_shader(uint32_t p_code_id) {
}
void ShaderGLES2::free_custom_shader(uint32_t p_code_id) {
-
ERR_FAIL_COND(!custom_code_map.has(p_code_id));
if (conditional_version.code_version == p_code_id) {
conditional_version.code_version = 0; //do not keep using a version that is going away
@@ -658,7 +648,6 @@ void ShaderGLES2::use_material(void *p_material) {
// bind uniforms
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = material->shader->uniforms.front(); E; E = E->next()) {
-
if (E->get().texture_order >= 0)
continue; // this is a texture, doesn't go here
@@ -673,7 +662,6 @@ void ShaderGLES2::use_material(void *p_material) {
if (V) {
switch (E->get().type) {
case ShaderLanguage::TYPE_BOOL: {
-
bool boolean = V->get();
glUniform1i(location, boolean ? 1 : 0);
} break;
@@ -684,7 +672,6 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_BVEC3: {
-
int flags = V->get();
glUniform3i(location, (flags & 1) ? 1 : 0, (flags & 2) ? 1 : 0, (flags & 4) ? 1 : 0);
@@ -704,7 +691,6 @@ void ShaderGLES2::use_material(void *p_material) {
case ShaderLanguage::TYPE_IVEC2:
case ShaderLanguage::TYPE_UVEC2: {
-
Array r = V->get();
const int count = 2;
if (r.size() == count) {
@@ -776,7 +762,6 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_MAT2: {
-
Transform2D tr = V->get();
GLfloat matrix[4] = {
/* build a 16x16 matrix */
@@ -809,7 +794,6 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_MAT4: {
-
Transform2D tr = V->get();
GLfloat matrix[16] = { /* build a 16x16 matrix */
tr.elements[0][0],
@@ -938,19 +922,15 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_SAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_ISAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_USAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_SAMPLERCUBE: {
-
} break;
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
@@ -1057,19 +1037,15 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_SAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_ISAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_USAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_SAMPLERCUBE: {
-
} break;
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h
index d20d5bc585..3096c1e258 100644
--- a/drivers/gles2/shader_gles2.h
+++ b/drivers/gles2/shader_gles2.h
@@ -53,20 +53,17 @@ class RasterizerStorageGLES2;
class ShaderGLES2 {
protected:
struct Enum {
-
uint64_t mask;
uint64_t shift;
const char *defines[16];
};
struct EnumValue {
-
uint64_t set_mask;
uint64_t clear_mask;
};
struct AttributePair {
-
const char *name;
int index;
};
@@ -77,7 +74,6 @@ protected:
};
struct TexUnitPair {
-
const char *name;
int index;
};
@@ -94,7 +90,6 @@ private:
int attribute_pair_count;
struct CustomCode {
-
String vertex;
String vertex_globals;
String fragment;
@@ -108,7 +103,6 @@ private:
};
struct Version {
-
GLuint id;
GLuint vert_id;
GLuint frag_id;
@@ -130,7 +124,6 @@ private:
Version *version;
union VersionKey {
-
struct {
uint32_t version;
uint32_t code_version;
@@ -141,7 +134,6 @@ private:
};
struct VersionKeyHash {
-
static _FORCE_INLINE_ uint32_t hash(const VersionKey &p_key) { return HashMapHasherDefault::hash(p_key.key); }
};
@@ -252,14 +244,12 @@ public:
// called a lot, made inline
int ShaderGLES2::_get_uniform(int p_which) const {
-
ERR_FAIL_INDEX_V(p_which, uniform_count, -1);
ERR_FAIL_COND_V(!version, -1);
return version->uniform_location[p_which];
}
void ShaderGLES2::_set_conditional(int p_which, bool p_value) {
-
ERR_FAIL_INDEX(p_which, conditional_count);
if (p_value)
new_conditional_version.version |= (1 << p_which);
diff --git a/drivers/gles2/shaders/blend_shape.glsl b/drivers/gles2/shaders/blend_shape.glsl
index 0d0b3e24e4..7a0a7ebe99 100644
--- a/drivers/gles2/shaders/blend_shape.glsl
+++ b/drivers/gles2/shaders/blend_shape.glsl
@@ -110,7 +110,6 @@ out vec4 weight_out; //tfb:ENABLE_SKELETON
uniform float blend_amount;
void main() {
-
#ifdef ENABLE_BLEND
vertex_out = vertex_attrib_blend + vertex_attrib * blend_amount;
diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl
index 3b685b3f0b..1fadf44d97 100644
--- a/drivers/gles2/shaders/canvas.glsl
+++ b/drivers/gles2/shaders/canvas.glsl
@@ -111,7 +111,6 @@ vec2 select(vec2 a, vec2 b, bvec2 c) {
}
void main() {
-
vec4 color = color_attrib;
vec2 uv;
@@ -186,7 +185,6 @@ VERTEX_SHADER_CODE
// look up transform from the "pose texture"
if (bone_weights != vec4(0.0)) {
-
highp mat4 bone_transform = mat4(0.0);
for (int i = 0; i < 4; i++) {
@@ -367,7 +365,6 @@ LIGHT_SHADER_CODE
}
void main() {
-
vec4 color = color_interp;
vec2 uv = uv_interp;
#ifdef USE_FORCE_REPEAT
@@ -499,11 +496,9 @@ FRAGMENT_SHADER_CODE
point = -shadow_vec;
sh = 0.5 + (1.0 / 8.0);
} else if (angle_to_light > 0.0) {
-
point = vec2(shadow_vec.y, -shadow_vec.x);
sh = 0.25 + (1.0 / 8.0);
} else {
-
point = vec2(-shadow_vec.y, shadow_vec.x);
sh = 0.75 + (1.0 / 8.0);
}
diff --git a/drivers/gles2/shaders/canvas_shadow.glsl b/drivers/gles2/shaders/canvas_shadow.glsl
index 7a5ba4f571..2abcd5e67c 100644
--- a/drivers/gles2/shaders/canvas_shadow.glsl
+++ b/drivers/gles2/shaders/canvas_shadow.glsl
@@ -21,7 +21,6 @@ uniform highp float distance_norm;
varying highp vec4 position_interp;
void main() {
-
gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0)));
position_interp = gl_Position;
}
@@ -47,7 +46,6 @@ varying highp vec4 position_interp;
/* clang-format on */
void main() {
-
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias
#ifdef USE_RGBA_SHADOWS
diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl
index aa967115da..e833722ac3 100644
--- a/drivers/gles2/shaders/copy.glsl
+++ b/drivers/gles2/shaders/copy.glsl
@@ -40,7 +40,6 @@ uniform highp mat4 display_transform;
#endif
void main() {
-
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
cube_interp = cube_in;
#elif defined(USE_ASYM_PANO)
@@ -115,7 +114,6 @@ uniform float custom_alpha;
uniform highp mat4 sky_transform;
vec4 texturePanorama(sampler2D pano, vec3 normal) {
-
vec2 st = vec2(
atan(normal.x, normal.z),
acos(normal.y));
@@ -131,7 +129,6 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) {
#endif
void main() {
-
#ifdef USE_PANORAMA
vec3 cube_normal = normalize(cube_interp);
diff --git a/drivers/gles2/shaders/cube_to_dp.glsl b/drivers/gles2/shaders/cube_to_dp.glsl
index 769908c3b4..1612ec3d5a 100644
--- a/drivers/gles2/shaders/cube_to_dp.glsl
+++ b/drivers/gles2/shaders/cube_to_dp.glsl
@@ -17,7 +17,6 @@ attribute vec2 uv_in; // attrib:4
varying vec2 uv_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
}
@@ -49,7 +48,6 @@ uniform highp float z_near;
uniform highp float bias;
void main() {
-
highp vec3 normal = vec3(uv_interp * 2.0 - 1.0, 0.0);
/*
if (z_flip) {
diff --git a/drivers/gles2/shaders/cubemap_filter.glsl b/drivers/gles2/shaders/cubemap_filter.glsl
index db3d8b3a1b..f5c91cc707 100644
--- a/drivers/gles2/shaders/cubemap_filter.glsl
+++ b/drivers/gles2/shaders/cubemap_filter.glsl
@@ -17,7 +17,6 @@ attribute highp vec2 uv; // attrib:4
varying highp vec2 uv_interp;
void main() {
-
uv_interp = uv;
gl_Position = vec4(vertex, 0, 1);
}
@@ -87,7 +86,6 @@ uniform sampler2D radical_inverse_vdc_cache; // texunit:1
#ifdef USE_SOURCE_PANORAMA
vec4 texturePanorama(sampler2D pano, vec3 normal) {
-
vec2 st = vec2(
atan(normal.x, normal.z),
acos(normal.y));
@@ -179,7 +177,6 @@ vec2 Hammersley(int i, int N) {
uniform bool z_flip;
void main() {
-
vec3 color = vec3(0.0);
vec2 uv = (uv_interp * 2.0) - 1.0;
@@ -200,7 +197,6 @@ void main() {
vec4 sum = vec4(0.0);
for (int sample_num = 0; sample_num < SAMPLE_COUNT; sample_num++) {
-
vec2 xi = Hammersley(sample_num, SAMPLE_COUNT);
vec3 H = ImportanceSampleGGX(xi, roughness, N);
diff --git a/drivers/gles2/shaders/effect_blur.glsl b/drivers/gles2/shaders/effect_blur.glsl
index b28d78a6ca..7b607dd76a 100644
--- a/drivers/gles2/shaders/effect_blur.glsl
+++ b/drivers/gles2/shaders/effect_blur.glsl
@@ -23,7 +23,6 @@ uniform vec4 blur_section;
#endif
void main() {
-
uv_interp = uv_in;
gl_Position = vec4(vertex_attrib, 0.0, 1.0);
#ifdef USE_BLUR_SECTION
@@ -127,7 +126,6 @@ uniform float camera_z_far;
uniform float camera_z_near;
void main() {
-
#ifdef GLOW_GAUSSIAN_HORIZONTAL
vec2 pix_size = pixel_size;
pix_size *= 0.5; //reading from larger buffer, so use more samples
@@ -228,7 +226,6 @@ void main() {
float k_accum = 0.0;
for (int i = 0; i < dof_kernel_size; i++) {
-
int int_ofs = i - dof_kernel_from;
vec2 tap_uv = uv_interp + dof_dir * float(int_ofs) * amount * dof_radius;
@@ -265,7 +262,6 @@ void main() {
float max_accum = 0.0;
for (int i = 0; i < dof_kernel_size; i++) {
-
int int_ofs = i - dof_kernel_from;
vec2 tap_uv = uv_interp + dof_dir * float(int_ofs) * dof_radius;
float ofs_influence = max(0.0, 1.0 - abs(float(int_ofs)) / float(dof_kernel_from));
diff --git a/drivers/gles2/shaders/exposure.glsl b/drivers/gles2/shaders/exposure.glsl
index 759adcda06..c20812bfa3 100644
--- a/drivers/gles2/shaders/exposure.glsl
+++ b/drivers/gles2/shaders/exposure.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
}
@@ -34,7 +33,6 @@ uniform highp float max_luminance;
layout(location = 0) out highp float exposure;
void main() {
-
#ifdef EXPOSURE_BEGIN
ivec2 src_pos = ivec2(gl_FragCoord.xy) * source_render_size / target_size;
diff --git a/drivers/gles2/shaders/lens_distorted.glsl b/drivers/gles2/shaders/lens_distorted.glsl
index f4ff80ba9a..d568006ccc 100644
--- a/drivers/gles2/shaders/lens_distorted.glsl
+++ b/drivers/gles2/shaders/lens_distorted.glsl
@@ -19,7 +19,6 @@ uniform vec2 scale;
varying vec2 uv_interp;
void main() {
-
uv_interp = vertex.xy * 2.0 - 1.0;
vec2 v = vertex.xy * scale + offset;
diff --git a/drivers/gles2/shaders/particles.glsl b/drivers/gles2/shaders/particles.glsl
index 5974050fc1..1575db701f 100644
--- a/drivers/gles2/shaders/particles.glsl
+++ b/drivers/gles2/shaders/particles.glsl
@@ -10,7 +10,6 @@ layout(location = 4) in highp vec4 xform_2;
layout(location = 5) in highp vec4 xform_3;
struct Attractor {
-
vec3 pos;
vec3 dir;
float radius;
@@ -64,7 +63,6 @@ VERTEX_SHADER_GLOBALS
/* clang-format on */
uint hash(uint x) {
-
x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b);
x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b);
x = (x >> uint(16)) ^ x;
@@ -72,7 +70,6 @@ uint hash(uint x) {
}
void main() {
-
#ifdef PARTICLES_COPY
out_color = color;
@@ -183,10 +180,8 @@ VERTEX_SHADER_CODE
#if !defined(DISABLE_FORCE)
if (false) {
-
vec3 force = vec3(0.0);
for (int i = 0; i < attractor_count; i++) {
-
vec3 rel_vec = xform[3].xyz - attractors[i].pos;
float dist = length(rel_vec);
if (attractors[i].radius < dist)
@@ -214,7 +209,6 @@ VERTEX_SHADER_CODE
#if !defined(DISABLE_VELOCITY)
if (true) {
-
xform[3].xyz += out_velocity_active.xyz * local_delta;
}
#endif
diff --git a/drivers/gles2/shaders/resolve.glsl b/drivers/gles2/shaders/resolve.glsl
index 5c6f5d6561..071cb37a99 100644
--- a/drivers/gles2/shaders/resolve.glsl
+++ b/drivers/gles2/shaders/resolve.glsl
@@ -8,7 +8,6 @@ layout(location = 4) in vec2 uv_in;
out vec2 uv_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
}
@@ -32,7 +31,6 @@ in vec2 uv2_interp;
layout(location = 0) out vec4 frag_color;
void main() {
-
vec4 specular = texture(source_specular, uv_interp);
#ifdef USE_SSR
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index b720c71cec..d658ccd5cd 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -194,7 +194,6 @@ void light_compute(
vec3 light_color,
vec3 attenuation,
float roughness) {
-
//this makes lights behave closer to linear, but then addition of lights looks bad
//better left disabled
@@ -249,7 +248,6 @@ void light_compute(
diffuse_interp += light_color * diffuse_brdf_NL * attenuation;
if (roughness > 0.0) {
-
// D
float specular_brdf_NL = 0.0;
@@ -325,7 +323,6 @@ uniform mediump float fog_height_curve;
#endif //fog
void main() {
-
highp vec4 vertex = vertex_attrib;
mat4 world_matrix = world_transform;
@@ -394,7 +391,6 @@ void main() {
#else
// look up transform from the "pose texture"
{
-
for (int i = 0; i < 4; i++) {
ivec2 tex_ofs = ivec2(int(bone_ids[i]) * 3, 0);
@@ -512,7 +508,6 @@ VERTEX_SHADER_CODE
float normalized_distance = light_length / light_range;
if (normalized_distance < 1.0) {
-
float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation);
vec3 attenuation = vec3(omni_attenuation);
@@ -532,7 +527,6 @@ VERTEX_SHADER_CODE
float normalized_distance = light_length / light_range;
if (normalized_distance < 1.0) {
-
float spot_attenuation = pow(1.0 - normalized_distance, light_attenuation);
vec3 spot_dir = light_direction;
@@ -541,7 +535,6 @@ VERTEX_SHADER_CODE
float angle = dot(-normalize(light_rel_vec), spot_dir);
if (angle > spot_cutoff) {
-
float scos = max(angle, spot_cutoff);
float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_cutoff));
@@ -645,7 +638,6 @@ VERTEX_SHADER_CODE
#ifdef FOG_DEPTH_ENABLED
{
-
float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a;
@@ -1157,7 +1149,6 @@ void light_compute(
inout vec3 diffuse_light,
inout vec3 specular_light,
inout float alpha) {
-
//this makes lights behave closer to linear, but then addition of lights looks bad
//better left disabled
@@ -1381,7 +1372,6 @@ LIGHT_SHADER_CODE
#define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(texture2DProj(p_shadow, p_pos)))
float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
-
#ifdef SHADOW_MODE_PCF_13
spos.xyz /= spos.w;
@@ -1458,7 +1448,6 @@ uniform mediump float fog_height_curve;
#endif //fog
void main() {
-
#ifdef RENDER_DEPTH_DUAL_PARABOLOID
if (dp_clip > 0.0)
@@ -1653,7 +1642,6 @@ FRAGMENT_SHADER_CODE
// environment BRDF approximation
{
-
#if defined(DIFFUSE_TOON)
//simplify for toon, as
specular_light *= specular * metallic * albedo * 2.0;
@@ -1732,7 +1720,6 @@ FRAGMENT_SHADER_CODE
float normalized_distance = light_length / light_range;
if (normalized_distance < 1.0) {
-
float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation);
light_att = vec3(omni_attenuation);
@@ -1829,7 +1816,6 @@ FRAGMENT_SHADER_CODE
}
} else {
if (depth_z < light_split_offsets.z) {
-
shadow_att = shadow3;
#if defined(LIGHT_USE_PSSM_BLEND)
@@ -1838,7 +1824,6 @@ FRAGMENT_SHADER_CODE
#endif
} else {
-
shadow_att = shadow4;
pssm_fade = smoothstep(light_split_offsets.z, light_split_offsets.w, depth_z);
@@ -1881,7 +1866,6 @@ FRAGMENT_SHADER_CODE
pssm_blend = smoothstep(0.0, light_split_offsets.x, depth_z);
#endif
} else {
-
shadow_att = shadow2;
pssm_fade = smoothstep(light_split_offsets.x, light_split_offsets.y, depth_z);
#ifdef LIGHT_USE_PSSM_BLEND
@@ -1945,7 +1929,6 @@ FRAGMENT_SHADER_CODE
}
} else {
if (depth_z < light_split_offsets.z) {
-
pssm_coord = shadow_coord3;
#if defined(LIGHT_USE_PSSM_BLEND)
@@ -1954,7 +1937,6 @@ FRAGMENT_SHADER_CODE
#endif
} else {
-
pssm_coord = shadow_coord4;
pssm_fade = smoothstep(light_split_offsets.z, light_split_offsets.w, depth_z);
@@ -1968,7 +1950,6 @@ FRAGMENT_SHADER_CODE
#ifdef LIGHT_USE_PSSM2
if (depth_z < light_split_offsets.x) {
-
pssm_coord = shadow_coord;
#ifdef LIGHT_USE_PSSM_BLEND
@@ -1976,7 +1957,6 @@ FRAGMENT_SHADER_CODE
pssm_blend = smoothstep(0.0, light_split_offsets.x, depth_z);
#endif
} else {
-
pssm_coord = shadow_coord2;
pssm_fade = smoothstep(light_split_offsets.x, light_split_offsets.y, depth_z);
#ifdef LIGHT_USE_PSSM_BLEND
@@ -2165,7 +2145,6 @@ FRAGMENT_SHADER_CODE
#ifdef FOG_DEPTH_ENABLED
{
-
float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a;
diff --git a/drivers/gles2/shaders/screen_space_reflection.glsl b/drivers/gles2/shaders/screen_space_reflection.glsl
index a11da10b61..6b5b7c885c 100644
--- a/drivers/gles2/shaders/screen_space_reflection.glsl
+++ b/drivers/gles2/shaders/screen_space_reflection.glsl
@@ -9,7 +9,6 @@ out vec2 uv_interp;
out vec2 pos_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
pos_interp.xy = gl_Position.xy;
@@ -55,7 +54,6 @@ vec2 view_to_screen(vec3 view_pos, out float w) {
#define M_PI 3.14159265359
void main() {
-
vec4 diffuse = texture(source_diffuse, uv_interp);
vec4 normal_roughness = texture(source_normal_roughness, uv_interp);
@@ -142,7 +140,6 @@ void main() {
float steps_taken = 0.0;
for (int i = 0; i < num_steps; i++) {
-
pos += line_advance;
z += z_advance;
w += w_advance;
@@ -174,7 +171,6 @@ void main() {
}
if (found) {
-
float margin_blend = 1.0;
vec2 margin = vec2((viewport_size.x + viewport_size.y) * 0.5 * 0.05); //make a uniform margin
@@ -218,7 +214,6 @@ void main() {
final_color = vec4(0.0);
for (int i = 0; i < 7; i++) {
-
float op_len = 2.0 * tan(cone_angle) * cone_len; //opposite side of iso triangle
float radius;
{
diff --git a/drivers/gles2/shaders/ssao.glsl b/drivers/gles2/shaders/ssao.glsl
index 82eea8f274..0fd29e8dcc 100644
--- a/drivers/gles2/shaders/ssao.glsl
+++ b/drivers/gles2/shaders/ssao.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
gl_Position.z = 1.0;
}
@@ -207,7 +206,6 @@ float sampleAO(in ivec2 ssC, in vec3 C, in vec3 n_C, in float ssDiskRadius, in f
}
void main() {
-
// Pixel being shaded
ivec2 ssC = ivec2(gl_FragCoord.xy);
diff --git a/drivers/gles2/shaders/ssao_blur.glsl b/drivers/gles2/shaders/ssao_blur.glsl
index e4133ad534..f065cd74eb 100644
--- a/drivers/gles2/shaders/ssao_blur.glsl
+++ b/drivers/gles2/shaders/ssao_blur.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
gl_Position.z = 1.0;
}
@@ -58,7 +57,6 @@ uniform float camera_z_near;
uniform ivec2 screen_size;
void main() {
-
ivec2 ssC = ivec2(gl_FragCoord.xy);
float depth = texelFetch(source_depth, ssC, 0).r;
@@ -91,7 +89,6 @@ void main() {
// We already handled the zero case above. This loop should be unrolled and the static branch optimized out,
// so the IF statement has no runtime cost
if (r != 0) {
-
ivec2 ppos = ssC + axis * (r * filter_scale);
float value = texelFetch(source_ssao, clamp(ppos, ivec2(0), clamp_limit), 0).r;
ivec2 rpos = clamp(ppos, ivec2(0), clamp_limit);
diff --git a/drivers/gles2/shaders/ssao_minify.glsl b/drivers/gles2/shaders/ssao_minify.glsl
index 272f3e236e..f654e00a4f 100644
--- a/drivers/gles2/shaders/ssao_minify.glsl
+++ b/drivers/gles2/shaders/ssao_minify.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
}
@@ -33,7 +32,6 @@ uniform int source_mipmap;
layout(location = 0) out mediump uint depth;
void main() {
-
ivec2 ssP = ivec2(gl_FragCoord.xy);
// Rotated grid subsampling to avoid XY directional bias or Z precision bias while downsampling.
diff --git a/drivers/gles2/shaders/subsurf_scattering.glsl b/drivers/gles2/shaders/subsurf_scattering.glsl
index f40fb3a244..d0c34cf1b0 100644
--- a/drivers/gles2/shaders/subsurf_scattering.glsl
+++ b/drivers/gles2/shaders/subsurf_scattering.glsl
@@ -8,7 +8,6 @@ layout(location = 4) in vec2 uv_in;
out vec2 uv_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
}
@@ -102,7 +101,6 @@ uniform sampler2D source_depth; //texunit:2
layout(location = 0) out vec4 frag_color;
void main() {
-
float strength = texture(source_sss, uv_interp).r;
strength *= strength; //stored as sqrt
@@ -110,7 +108,6 @@ void main() {
vec4 base_color = texture(source_diffuse, uv_interp);
if (strength > 0.0) {
-
// Fetch linear depth of current pixel:
float depth = texture(source_depth, uv_interp).r * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp
index 4cb93a821c..8af58a7ed7 100644
--- a/drivers/png/image_loader_png.cpp
+++ b/drivers/png/image_loader_png.cpp
@@ -37,7 +37,6 @@
#include <string.h>
Error ImageLoaderPNG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
const size_t buffer_size = f->get_len();
Vector<uint8_t> file_buffer;
Error err = file_buffer.resize(buffer_size);
@@ -55,12 +54,10 @@ Error ImageLoaderPNG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
}
void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("png");
}
Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) {
-
Ref<Image> img;
img.instance();
@@ -71,7 +68,6 @@ Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) {
}
Ref<Image> ImageLoaderPNG::lossless_unpack_png(const Vector<uint8_t> &p_data) {
-
const int len = p_data.size();
ERR_FAIL_COND_V(len < 4, Ref<Image>());
const uint8_t *r = p_data.ptr();
@@ -80,7 +76,6 @@ Ref<Image> ImageLoaderPNG::lossless_unpack_png(const Vector<uint8_t> &p_data) {
}
Vector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) {
-
Vector<uint8_t> out_buffer;
// add Godot's own "PNG " prefix
@@ -104,7 +99,6 @@ Vector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) {
}
ImageLoaderPNG::ImageLoaderPNG() {
-
Image::_png_mem_loader_func = load_mem_png;
Image::lossless_unpacker = lossless_unpack_png;
Image::lossless_packer = lossless_pack_png;
diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp
index 3f9c824e93..68faff30fc 100644
--- a/drivers/png/png_driver_common.cpp
+++ b/drivers/png/png_driver_common.cpp
@@ -59,7 +59,6 @@ static bool check_error(const png_image &image) {
}
Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
-
png_image png_img;
zeromem(&png_img, sizeof(png_img));
png_img.version = PNG_IMAGE_VERSION;
@@ -121,7 +120,6 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
}
Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) {
-
Ref<Image> source_image = p_image->duplicate();
if (source_image->is_compressed())
@@ -179,7 +177,6 @@ Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) {
ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
}
if (!success) {
-
// buffer was big enough, must be some other error
ERR_FAIL_COND_V(compressed_size <= png_size_estimate, FAILED);
diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp
index 2380c2685f..3a0b319a45 100644
--- a/drivers/png/resource_saver_png.cpp
+++ b/drivers/png/resource_saver_png.cpp
@@ -36,7 +36,6 @@
#include "scene/resources/texture.h"
Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Ref<ImageTexture> texture = p_resource;
ERR_FAIL_COND_V_MSG(!texture.is_valid(), ERR_INVALID_PARAMETER, "Can't save invalid texture as PNG.");
@@ -50,7 +49,6 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32
};
Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img) {
-
Vector<uint8_t> buffer;
Error err = PNGDriverCommon::image_to_png(p_img, buffer);
ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG.");
@@ -72,7 +70,6 @@ Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img
}
Vector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img) {
-
Vector<uint8_t> buffer;
Error err = PNGDriverCommon::image_to_png(p_img, buffer);
ERR_FAIL_COND_V_MSG(err, Vector<uint8_t>(), "Can't convert image to PNG.");
@@ -80,19 +77,16 @@ Vector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img)
}
bool ResourceSaverPNG::recognize(const RES &p_resource) const {
-
return (p_resource.is_valid() && p_resource->is_class("ImageTexture"));
}
void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (Object::cast_to<ImageTexture>(*p_resource)) {
p_extensions->push_back("png");
}
}
ResourceSaverPNG::ResourceSaverPNG() {
-
Image::save_png_func = &save_image;
Image::save_png_buffer_func = &save_image_to_buffer;
};
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index b16408f727..8d704dae7b 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -78,7 +78,6 @@ void AudioDriverPulseAudio::pa_source_info_cb(pa_context *c, const pa_source_inf
}
void AudioDriverPulseAudio::pa_server_info_cb(pa_context *c, const pa_server_info *i, void *userdata) {
-
ERR_FAIL_COND_MSG(!i, "PulseAudio server info is null.");
AudioDriverPulseAudio *ad = (AudioDriverPulseAudio *)userdata;
@@ -88,7 +87,6 @@ void AudioDriverPulseAudio::pa_server_info_cb(pa_context *c, const pa_server_inf
}
void AudioDriverPulseAudio::detect_channels(bool capture) {
-
pa_channel_map_init_stereo(capture ? &pa_rec_map : &pa_map);
String device = capture ? capture_device_name : device_name;
@@ -145,7 +143,6 @@ void AudioDriverPulseAudio::detect_channels(bool capture) {
}
Error AudioDriverPulseAudio::init_device() {
-
// If there is a specified device check that it is really present
if (device_name != "Default") {
Array list = get_device_list();
@@ -236,7 +233,6 @@ Error AudioDriverPulseAudio::init_device() {
}
Error AudioDriverPulseAudio::init() {
-
active = false;
thread_exited = false;
exit_thread = false;
@@ -298,7 +294,6 @@ Error AudioDriverPulseAudio::init() {
}
float AudioDriverPulseAudio::get_latency() {
-
if (latency == 0) { //only do this once since it's approximate anyway
lock();
@@ -324,14 +319,12 @@ float AudioDriverPulseAudio::get_latency() {
}
void AudioDriverPulseAudio::thread_func(void *p_udata) {
-
AudioDriverPulseAudio *ad = (AudioDriverPulseAudio *)p_udata;
unsigned int write_ofs = 0;
size_t avail_bytes = 0;
uint32_t default_device_msec = OS::get_singleton()->get_ticks_msec();
while (!ad->exit_thread) {
-
size_t read_bytes = 0;
size_t written_bytes = 0;
@@ -421,7 +414,6 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
// If we're using the default device check that the current device is still the default
if (ad->device_name == "Default") {
-
uint32_t msec = OS::get_singleton()->get_ticks_msec();
if (msec > (default_device_msec + 1000)) {
String old_default_device = ad->default_device;
@@ -524,17 +516,14 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
}
void AudioDriverPulseAudio::start() {
-
active = true;
}
int AudioDriverPulseAudio::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverPulseAudio::get_speaker_mode() const {
-
return get_speaker_mode_by_total_channels(channels);
}
@@ -551,7 +540,6 @@ void AudioDriverPulseAudio::pa_sinklist_cb(pa_context *c, const pa_sink_info *l,
}
Array AudioDriverPulseAudio::get_device_list() {
-
pa_devices.clear();
pa_devices.push_back("Default");
@@ -583,33 +571,28 @@ Array AudioDriverPulseAudio::get_device_list() {
}
String AudioDriverPulseAudio::get_device() {
-
return device_name;
}
void AudioDriverPulseAudio::set_device(String device) {
-
lock();
new_device = device;
unlock();
}
void AudioDriverPulseAudio::lock() {
-
if (!thread)
return;
mutex.lock();
}
void AudioDriverPulseAudio::unlock() {
-
if (!thread)
return;
mutex.unlock();
}
void AudioDriverPulseAudio::finish_device() {
-
if (pa_str) {
pa_stream_disconnect(pa_str);
pa_stream_unref(pa_str);
@@ -618,7 +601,6 @@ void AudioDriverPulseAudio::finish_device() {
}
void AudioDriverPulseAudio::finish() {
-
if (!thread)
return;
@@ -644,7 +626,6 @@ void AudioDriverPulseAudio::finish() {
}
Error AudioDriverPulseAudio::capture_init_device() {
-
// If there is a specified device check that it is really present
if (capture_device_name != "Default") {
Array list = capture_get_device_list();
@@ -702,7 +683,6 @@ Error AudioDriverPulseAudio::capture_init_device() {
}
void AudioDriverPulseAudio::capture_finish_device() {
-
if (pa_rec_str) {
int ret = pa_stream_disconnect(pa_rec_str);
if (ret != 0) {
@@ -714,7 +694,6 @@ void AudioDriverPulseAudio::capture_finish_device() {
}
Error AudioDriverPulseAudio::capture_start() {
-
lock();
Error err = capture_init_device();
unlock();
@@ -731,7 +710,6 @@ Error AudioDriverPulseAudio::capture_stop() {
}
void AudioDriverPulseAudio::capture_set_device(const String &p_name) {
-
lock();
capture_new_device = p_name;
unlock();
@@ -753,7 +731,6 @@ void AudioDriverPulseAudio::pa_sourcelist_cb(pa_context *c, const pa_source_info
}
Array AudioDriverPulseAudio::capture_get_device_list() {
-
pa_rec_devices.clear();
pa_rec_devices.push_back("Default");
@@ -785,7 +762,6 @@ Array AudioDriverPulseAudio::capture_get_device_list() {
}
String AudioDriverPulseAudio::capture_get_device() {
-
lock();
String name = capture_device_name;
unlock();
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h
index ab55a15076..2f2ad0fc38 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.h
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.h
@@ -40,7 +40,6 @@
#include <pulse/pulseaudio.h>
class AudioDriverPulseAudio : public AudioDriver {
-
Thread *thread = nullptr;
Mutex mutex;
diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp
index dcc7a5c14d..6c1f50d8c2 100644
--- a/drivers/register_driver_types.cpp
+++ b/drivers/register_driver_types.cpp
@@ -37,7 +37,6 @@ static ImageLoaderPNG *image_loader_png;
static Ref<ResourceSaverPNG> resource_saver_png;
void register_core_driver_types() {
-
image_loader_png = memnew(ImageLoaderPNG);
ImageLoader::add_image_format_loader(image_loader_png);
@@ -46,7 +45,6 @@ void register_core_driver_types() {
}
void unregister_core_driver_types() {
-
if (image_loader_png)
memdelete(image_loader_png);
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 00103684c7..5d435d5176 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -50,12 +50,10 @@
#endif
DirAccess *DirAccessUnix::create_fs() {
-
return memnew(DirAccessUnix);
}
Error DirAccessUnix::list_dir_begin() {
-
list_dir_end(); //close any previous dir opening!
//char real_current_dir_name[2048]; //is this enough?!
@@ -70,7 +68,6 @@ Error DirAccessUnix::list_dir_begin() {
}
bool DirAccessUnix::file_exists(String p_file) {
-
GLOBAL_LOCK_FUNCTION
if (p_file.is_rel_path())
@@ -89,7 +86,6 @@ bool DirAccessUnix::file_exists(String p_file) {
}
bool DirAccessUnix::dir_exists(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
if (p_dir.is_rel_path())
@@ -104,7 +100,6 @@ bool DirAccessUnix::dir_exists(String p_dir) {
}
uint64_t DirAccessUnix::get_modified_time(String p_file) {
-
if (p_file.is_rel_path())
p_file = current_dir.plus_file(p_file);
@@ -116,14 +111,12 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) {
if (success) {
return flags.st_mtime;
} else {
-
ERR_FAIL_V(0);
};
return 0;
};
String DirAccessUnix::get_next() {
-
if (!dir_stream)
return "";
@@ -160,17 +153,14 @@ String DirAccessUnix::get_next() {
}
bool DirAccessUnix::current_is_dir() const {
-
return _cisdir;
}
bool DirAccessUnix::current_is_hidden() const {
-
return _cishidden;
}
void DirAccessUnix::list_dir_end() {
-
if (dir_stream)
closedir(dir_stream);
dir_stream = nullptr;
@@ -198,7 +188,6 @@ static bool _filter_drive(struct mntent *mnt) {
#endif
static void _get_drives(List<String> *list) {
-
#if defined(HAVE_MNTENT) && defined(X11_ENABLED)
// Check /etc/mtab for the list of mounted partitions
FILE *mtab = setmntent("/etc/mtab", "r");
@@ -252,7 +241,6 @@ static void _get_drives(List<String> *list) {
}
int DirAccessUnix::get_drive_count() {
-
List<String> list;
_get_drives(&list);
@@ -260,7 +248,6 @@ int DirAccessUnix::get_drive_count() {
}
String DirAccessUnix::get_drive(int p_drive) {
-
List<String> list;
_get_drives(&list);
@@ -270,12 +257,10 @@ String DirAccessUnix::get_drive(int p_drive) {
}
bool DirAccessUnix::drives_are_shortcuts() {
-
return true;
}
Error DirAccessUnix::make_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
if (p_dir.is_rel_path())
@@ -298,7 +283,6 @@ Error DirAccessUnix::make_dir(String p_dir) {
}
Error DirAccessUnix::change_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
p_dir = fix_path(p_dir);
@@ -343,10 +327,8 @@ Error DirAccessUnix::change_dir(String p_dir) {
}
String DirAccessUnix::get_current_dir(bool p_include_drive) {
-
String base = _get_root_path();
if (base != "") {
-
String bd = current_dir.replace_first(base, "");
if (bd.begins_with("/"))
return _get_root_string() + bd.substr(1, bd.length());
@@ -357,7 +339,6 @@ String DirAccessUnix::get_current_dir(bool p_include_drive) {
}
Error DirAccessUnix::rename(String p_path, String p_new_path) {
-
if (p_path.is_rel_path())
p_path = get_current_dir().plus_file(p_path);
@@ -372,7 +353,6 @@ Error DirAccessUnix::rename(String p_path, String p_new_path) {
}
Error DirAccessUnix::remove(String p_path) {
-
if (p_path.is_rel_path())
p_path = get_current_dir().plus_file(p_path);
@@ -389,11 +369,9 @@ Error DirAccessUnix::remove(String p_path) {
}
size_t DirAccessUnix::get_space_left() {
-
#ifndef NO_STATVFS
struct statvfs vfs;
if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
-
return 0;
};
@@ -409,7 +387,6 @@ String DirAccessUnix::get_filesystem_type() const {
}
DirAccessUnix::DirAccessUnix() {
-
dir_stream = nullptr;
_cisdir = false;
@@ -425,7 +402,6 @@ DirAccessUnix::DirAccessUnix() {
}
DirAccessUnix::~DirAccessUnix() {
-
list_dir_end();
}
diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h
index b403d8e356..b897efcafc 100644
--- a/drivers/unix/dir_access_unix.h
+++ b/drivers/unix/dir_access_unix.h
@@ -41,7 +41,6 @@
#include <unistd.h>
class DirAccessUnix : public DirAccess {
-
DIR *dir_stream;
static DirAccess *create_fs();
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index 54a585c6fd..7edafce9e5 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -63,17 +63,14 @@
#endif
void FileAccessUnix::check_errors() const {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (feof(f)) {
-
last_error = ERR_FILE_EOF;
}
}
Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
-
if (f)
fclose(f);
f = nullptr;
@@ -150,7 +147,6 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessUnix::close() {
-
if (!f)
return;
@@ -174,22 +170,18 @@ void FileAccessUnix::close() {
}
bool FileAccessUnix::is_open() const {
-
return (f != nullptr);
}
String FileAccessUnix::get_path() const {
-
return path_src;
}
String FileAccessUnix::get_path_absolute() const {
-
return path;
}
void FileAccessUnix::seek(size_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
last_error = OK;
@@ -198,7 +190,6 @@ void FileAccessUnix::seek(size_t p_position) {
}
void FileAccessUnix::seek_end(int64_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (fseek(f, p_position, SEEK_END))
@@ -206,7 +197,6 @@ void FileAccessUnix::seek_end(int64_t p_position) {
}
size_t FileAccessUnix::get_position() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
long pos = ftell(f);
@@ -218,7 +208,6 @@ size_t FileAccessUnix::get_position() const {
}
size_t FileAccessUnix::get_len() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
long pos = ftell(f);
@@ -232,12 +221,10 @@ size_t FileAccessUnix::get_len() const {
}
bool FileAccessUnix::eof_reached() const {
-
return last_error == ERR_FILE_EOF;
}
uint8_t FileAccessUnix::get_8() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
uint8_t b;
if (fread(&b, 1, 1, f) == 0) {
@@ -248,7 +235,6 @@ uint8_t FileAccessUnix::get_8() const {
}
int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const {
-
ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use.");
int read = fread(p_dst, 1, p_length, f);
check_errors();
@@ -256,31 +242,26 @@ int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const {
};
Error FileAccessUnix::get_error() const {
-
return last_error;
}
void FileAccessUnix::flush() {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
fflush(f);
}
void FileAccessUnix::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
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_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND(!p_src);
ERR_FAIL_COND((int)fwrite(p_src, 1, p_length, f) != p_length);
}
bool FileAccessUnix::file_exists(const String &p_path) {
-
int err;
struct stat st;
String filename = fix_path(p_path);
@@ -310,7 +291,6 @@ bool FileAccessUnix::file_exists(const String &p_path) {
}
uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
-
String file = fix_path(p_file);
struct stat flags;
int err = stat(file.utf8().get_data(), &flags);
@@ -323,7 +303,6 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
}
uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
-
String file = fix_path(p_file);
struct stat flags;
int err = stat(file.utf8().get_data(), &flags);
@@ -336,7 +315,6 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
}
Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
-
String file = fix_path(p_file);
int err = chmod(file.utf8().get_data(), p_permissions);
@@ -348,7 +326,6 @@ Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_per
}
FileAccess *FileAccessUnix::create_libc() {
-
return memnew(FileAccessUnix);
}
diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h
index 1dd080914d..9fe43a2554 100644
--- a/drivers/unix/file_access_unix.h
+++ b/drivers/unix/file_access_unix.h
@@ -41,7 +41,6 @@
typedef void (*CloseNotificationFunc)(const String &p_file, int p_flags);
class FileAccessUnix : public FileAccess {
-
FILE *f = nullptr;
int flags = 0;
void check_errors() const;
diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp
index 56be9a2f74..2015a4041d 100644
--- a/drivers/unix/ip_unix.cpp
+++ b/drivers/unix/ip_unix.cpp
@@ -76,7 +76,6 @@
#endif
static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
-
IP_Address ip;
if (p_addr->sa_family == AF_INET) {
@@ -91,7 +90,6 @@ static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
};
IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
-
struct addrinfo hints;
struct addrinfo *result;
@@ -132,7 +130,6 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
#if defined(UWP_ENABLED)
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
-
using namespace Windows::Networking;
using namespace Windows::Networking::Connectivity;
@@ -140,7 +137,6 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
auto hostnames = NetworkInformation::GetHostNames();
for (int i = 0; i < hostnames->Size; i++) {
-
auto hostname = hostnames->GetAt(i);
if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6)
@@ -167,12 +163,10 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
#else
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
-
ULONG buf_size = 1024;
IP_ADAPTER_ADDRESSES *addrs;
while (true) {
-
addrs = (IP_ADAPTER_ADDRESSES *)memalloc(buf_size);
int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME,
nullptr, addrs, &buf_size);
@@ -190,7 +184,6 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
IP_ADAPTER_ADDRESSES *adapter = addrs;
while (adapter != nullptr) {
-
Interface_Info info;
info.name = adapter->AdapterName;
info.name_friendly = adapter->FriendlyName;
@@ -218,7 +211,6 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
#else // UNIX
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
-
struct ifaddrs *ifAddrStruct = nullptr;
struct ifaddrs *ifa = nullptr;
int family;
@@ -254,12 +246,10 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
#endif
void IP_Unix::make_default() {
-
_create = _create_unix;
}
IP *IP_Unix::_create_unix() {
-
return memnew(IP_Unix);
}
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index 81ea20e5da..957a00703b 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -96,7 +96,6 @@
#endif
size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const IP_Address &p_ip, uint16_t p_port, IP::Type p_ip_type) {
-
memset(p_addr, 0, sizeof(struct sockaddr_storage));
if (p_ip_type == IP::TYPE_IPV6 || p_ip_type == IP::TYPE_ANY) { // IPv6 socket
@@ -132,16 +131,13 @@ size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const
}
void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IP_Address &r_ip, uint16_t &r_port) {
-
if (p_addr->ss_family == AF_INET) {
-
struct sockaddr_in *addr4 = (struct sockaddr_in *)p_addr;
r_ip.set_ipv4((uint8_t *)&(addr4->sin_addr.s_addr));
r_port = ntohs(addr4->sin_port);
} else if (p_addr->ss_family == AF_INET6) {
-
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr;
r_ip.set_ipv6(addr6->sin6_addr.s6_addr);
@@ -216,7 +212,6 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
#endif
bool NetSocketPosix::_can_use_ip(const IP_Address &p_ip, const bool p_for_bind) const {
-
if (p_for_bind && !(p_ip.is_valid() || p_ip.is_wildcard())) {
return false;
} else if (!p_for_bind && !p_ip.is_valid()) {
@@ -228,7 +223,6 @@ bool NetSocketPosix::_can_use_ip(const IP_Address &p_ip, const bool p_for_bind)
}
_FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, String p_if_name, bool p_add) {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(!_can_use_ip(p_ip, false), ERR_INVALID_PARAMETER);
@@ -367,7 +361,6 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) {
}
void NetSocketPosix::close() {
-
if (_sock != SOCK_EMPTY)
SOCK_CLOSE(_sock);
@@ -377,7 +370,6 @@ void NetSocketPosix::close() {
}
Error NetSocketPosix::bind(IP_Address p_addr, uint16_t p_port) {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(!_can_use_ip(p_addr, true), ERR_INVALID_PARAMETER);
@@ -408,7 +400,6 @@ Error NetSocketPosix::listen(int p_max_pending) {
}
Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(!_can_use_ip(p_host, false), ERR_INVALID_PARAMETER);
@@ -416,7 +407,6 @@ Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
size_t addr_size = _set_addr_storage(&addr, p_host, p_port, _ip_type);
if (SOCK_CONNECT(_sock, (struct sockaddr *)&addr, addr_size) != 0) {
-
NetError err = _get_socket_error();
switch (err) {
@@ -438,7 +428,6 @@ Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
}
Error NetSocketPosix::poll(PollType p_type, int p_timeout) const {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
#if defined(WINDOWS_ENABLED)
@@ -699,7 +688,6 @@ bool NetSocketPosix::is_open() const {
}
int NetSocketPosix::get_available_bytes() const {
-
ERR_FAIL_COND_V(!is_open(), -1);
unsigned long len;
@@ -713,7 +701,6 @@ int NetSocketPosix::get_available_bytes() const {
}
Ref<NetSocket> NetSocketPosix::accept(IP_Address &r_ip, uint16_t &r_port) {
-
Ref<NetSocket> out;
ERR_FAIL_COND_V(!is_open(), out);
diff --git a/drivers/unix/net_socket_posix.h b/drivers/unix/net_socket_posix.h
index 4e1fedfcb0..8cefb6544e 100644
--- a/drivers/unix/net_socket_posix.h
+++ b/drivers/unix/net_socket_posix.h
@@ -45,7 +45,6 @@
#endif
class NetSocketPosix : public NetSocket {
-
private:
SOCKET_TYPE _sock; // NOLINT - the default value is defined in the .cpp
IP::Type _ip_type = IP::TYPE_NONE;
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 53c60951b7..920d594ea1 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -91,7 +91,6 @@ static void _setup_clock() {
#endif
void OS_Unix::debug_break() {
-
assert(false);
};
@@ -104,7 +103,6 @@ static void handle_interrupt(int sig) {
}
void OS_Unix::initialize_debugging() {
-
if (EngineDebugger::is_active()) {
struct sigaction action;
memset(&action, 0, sizeof(action));
@@ -114,12 +112,10 @@ void OS_Unix::initialize_debugging() {
}
int OS_Unix::unix_initialize_audio(int p_audio_driver) {
-
return 0;
}
void OS_Unix::initialize_core() {
-
#ifdef NO_THREADS
ThreadDummy::make_default();
RWLockDummy::make_default();
@@ -144,17 +140,14 @@ void OS_Unix::initialize_core() {
}
void OS_Unix::finalize_core() {
-
NetSocketPosix::cleanup();
}
void OS_Unix::alert(const String &p_alert, const String &p_title) {
-
fprintf(stderr, "ERROR: %s\n", p_alert.utf8().get_data());
}
String OS_Unix::get_stdin_string(bool p_block) {
-
if (p_block) {
char buff[1024];
String ret = stdin_buf + fgets(buff, 1024, stdin);
@@ -166,12 +159,10 @@ String OS_Unix::get_stdin_string(bool p_block) {
}
String OS_Unix::get_name() const {
-
return "Unix";
}
uint64_t OS_Unix::get_unix_time() const {
-
return time(nullptr);
};
@@ -188,7 +179,6 @@ uint64_t OS_Unix::get_system_time_msecs() const {
}
OS::Date OS_Unix::get_date(bool utc) const {
-
time_t t = time(nullptr);
struct tm *lt;
if (utc)
@@ -250,13 +240,11 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const {
}
void OS_Unix::delay_usec(uint32_t p_usec) const {
-
struct timespec rem = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 };
while (nanosleep(&rem, &rem) == EINTR) {
}
}
uint64_t OS_Unix::get_ticks_usec() const {
-
#if defined(__APPLE__)
uint64_t longtime = mach_absolute_time() * _clock_scale;
#else
@@ -272,19 +260,16 @@ uint64_t OS_Unix::get_ticks_usec() const {
}
Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
-
#ifdef __EMSCRIPTEN__
// Don't compile this code at all to avoid undefined references.
// Actual virtual call goes to OS_JavaScript.
ERR_FAIL_V(ERR_BUG);
#else
if (p_blocking && r_pipe) {
-
String argss;
argss = "\"" + p_path + "\"";
for (int i = 0; i < p_arguments.size(); i++) {
-
argss += String(" \"") + p_arguments[i] + "\"";
}
@@ -300,7 +285,6 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
char buf[65535];
while (fgets(buf, 65535, f)) {
-
if (p_pipe_mutex) {
p_pipe_mutex->lock();
}
@@ -345,14 +329,12 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
}
if (p_blocking) {
-
int status;
waitpid(pid, &status, 0);
if (r_exitcode)
*r_exitcode = WEXITSTATUS(status);
} else {
-
if (r_child_id)
*r_child_id = pid;
}
@@ -362,7 +344,6 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
}
Error OS_Unix::kill(const ProcessID &p_pid) {
-
int ret = ::kill(p_pid, SIGKILL);
if (!ret) {
//avoid zombie process
@@ -373,17 +354,14 @@ Error OS_Unix::kill(const ProcessID &p_pid) {
}
int OS_Unix::get_process_id() const {
-
return getpid();
};
bool OS_Unix::has_environment(const String &p_var) const {
-
return getenv(p_var.utf8().get_data()) != nullptr;
}
String OS_Unix::get_locale() const {
-
if (!has_environment("LANG"))
return "en";
@@ -395,7 +373,6 @@ String OS_Unix::get_locale() const {
}
Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
-
String path = p_path;
if (FileAccess::exists(path) && path.is_rel_path()) {
@@ -442,7 +419,6 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S
}
Error OS_Unix::set_cwd(const String &p_cwd) {
-
if (chdir(p_cwd.utf8().get_data()) != 0)
return ERR_CANT_OPEN;
@@ -450,24 +426,20 @@ Error OS_Unix::set_cwd(const String &p_cwd) {
}
String OS_Unix::get_environment(const String &p_var) const {
-
if (getenv(p_var.utf8().get_data()))
return getenv(p_var.utf8().get_data());
return "";
}
bool OS_Unix::set_environment(const String &p_var, const String &p_value) const {
-
return setenv(p_var.utf8().get_data(), p_value.utf8().get_data(), /* overwrite: */ true) == 0;
}
int OS_Unix::get_processor_count() const {
-
return sysconf(_SC_NPROCESSORS_CONF);
}
String OS_Unix::get_user_data_dir() const {
-
String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name"));
if (appname != "") {
bool use_custom_dir = ProjectSettings::get_singleton()->get("application/config/use_custom_user_dir");
@@ -486,7 +458,6 @@ String OS_Unix::get_user_data_dir() const {
}
String OS_Unix::get_executable_path() const {
-
#ifdef __linux__
//fix for running from a symlink
char buf[256];
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 90679ddf1d..7d235803dc 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -37,7 +37,6 @@
#include "drivers/unix/ip_unix.h"
class OS_Unix : public OS {
-
protected:
// UNIX only handles the core functions.
// inheriting platforms under unix (eg. X11) should handle the rest
diff --git a/drivers/unix/rw_lock_posix.cpp b/drivers/unix/rw_lock_posix.cpp
index f219a0905c..50b74e84f7 100644
--- a/drivers/unix/rw_lock_posix.cpp
+++ b/drivers/unix/rw_lock_posix.cpp
@@ -37,7 +37,6 @@
#include <stdio.h>
void RWLockPosix::read_lock() {
-
int err = pthread_rwlock_rdlock(&rwlock);
if (err != 0) {
perror("Acquiring lock failed");
@@ -46,12 +45,10 @@ void RWLockPosix::read_lock() {
}
void RWLockPosix::read_unlock() {
-
pthread_rwlock_unlock(&rwlock);
}
Error RWLockPosix::read_try_lock() {
-
if (pthread_rwlock_tryrdlock(&rwlock) != 0) {
return ERR_BUSY;
} else {
@@ -60,13 +57,11 @@ Error RWLockPosix::read_try_lock() {
}
void RWLockPosix::write_lock() {
-
int err = pthread_rwlock_wrlock(&rwlock);
ERR_FAIL_COND(err != 0);
}
void RWLockPosix::write_unlock() {
-
pthread_rwlock_unlock(&rwlock);
}
@@ -79,23 +74,19 @@ Error RWLockPosix::write_try_lock() {
}
RWLock *RWLockPosix::create_func_posix() {
-
return memnew(RWLockPosix);
}
void RWLockPosix::make_default() {
-
create_func = create_func_posix;
}
RWLockPosix::RWLockPosix() {
-
//rwlock=PTHREAD_RWLOCK_INITIALIZER; fails on OSX
pthread_rwlock_init(&rwlock, nullptr);
}
RWLockPosix::~RWLockPosix() {
-
pthread_rwlock_destroy(&rwlock);
}
diff --git a/drivers/unix/rw_lock_posix.h b/drivers/unix/rw_lock_posix.h
index b12d373db5..056fcaea1c 100644
--- a/drivers/unix/rw_lock_posix.h
+++ b/drivers/unix/rw_lock_posix.h
@@ -37,7 +37,6 @@
#include <pthread.h>
class RWLockPosix : public RWLock {
-
pthread_rwlock_t rwlock;
static RWLock *create_func_posix();
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index c227aec6d6..dda1edc3c3 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -54,17 +54,14 @@ pthread_key_t ThreadPosix::thread_id_key = _create_thread_id_key();
Thread::ID ThreadPosix::next_thread_id = 0;
Thread::ID ThreadPosix::get_id() const {
-
return id;
}
Thread *ThreadPosix::create_thread_posix() {
-
return memnew(ThreadPosix);
}
void *ThreadPosix::thread_callback(void *userdata) {
-
ThreadPosix *t = reinterpret_cast<ThreadPosix *>(userdata);
t->id = atomic_increment(&next_thread_id);
pthread_setspecific(thread_id_key, (void *)memnew(ID(t->id)));
@@ -79,7 +76,6 @@ void *ThreadPosix::thread_callback(void *userdata) {
}
Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
-
ThreadPosix *tr = memnew(ThreadPosix);
tr->callback = p_callback;
tr->user = p_user;
@@ -92,7 +88,6 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_
return tr;
}
Thread::ID ThreadPosix::get_thread_id_func_posix() {
-
void *value = pthread_getspecific(thread_id_key);
if (value)
@@ -103,7 +98,6 @@ Thread::ID ThreadPosix::get_thread_id_func_posix() {
return new_id;
}
void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
-
ThreadPosix *tp = static_cast<ThreadPosix *>(p_thread);
ERR_FAIL_COND(!tp);
ERR_FAIL_COND(tp->pthread == 0);
@@ -113,7 +107,6 @@ void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
}
Error ThreadPosix::set_name_func_posix(const String &p_name) {
-
#ifdef PTHREAD_NO_RENAME
return ERR_UNAVAILABLE;
@@ -142,7 +135,6 @@ Error ThreadPosix::set_name_func_posix(const String &p_name) {
};
void ThreadPosix::make_default() {
-
create_func = create_func_posix;
get_thread_id_func = get_thread_id_func_posix;
wait_to_finish_func = wait_to_finish_func_posix;
@@ -150,7 +142,6 @@ void ThreadPosix::make_default() {
}
ThreadPosix::ThreadPosix() {
-
pthread = 0;
}
diff --git a/drivers/unix/thread_posix.h b/drivers/unix/thread_posix.h
index e852dcf3d5..6607dbd111 100644
--- a/drivers/unix/thread_posix.h
+++ b/drivers/unix/thread_posix.h
@@ -38,7 +38,6 @@
#include <sys/types.h>
class ThreadPosix : public Thread {
-
static pthread_key_t thread_id_key;
static ID next_thread_id;
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 71be891b1d..f8b0eafcd0 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -40,7 +40,6 @@
//#define FORCE_FULL_BARRIER
void RenderingDeviceVulkan::_add_dependency(RID p_id, RID p_depends_on) {
-
if (!dependency_map.has(p_depends_on)) {
dependency_map[p_depends_on] = Set<RID>();
}
@@ -55,12 +54,10 @@ void RenderingDeviceVulkan::_add_dependency(RID p_id, RID p_depends_on) {
}
void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
-
//direct dependencies must be freed
Map<RID, Set<RID>>::Element *E = dependency_map.find(p_id);
if (E) {
-
while (E->get().size()) {
free(E->get().front()->get());
}
@@ -71,7 +68,6 @@ void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
E = reverse_dependency_map.find(p_id);
if (E) {
-
for (Set<RID>::Element *F = E->get().front(); F; F = F->next()) {
Map<RID, Set<RID>>::Element *G = dependency_map.find(F->get());
ERR_CONTINUE(!G);
@@ -630,9 +626,7 @@ int RenderingDeviceVulkan::get_format_vertex_size(DataFormat p_format) {
}
uint32_t RenderingDeviceVulkan::get_image_format_pixel_size(DataFormat p_format) {
-
switch (p_format) {
-
case DATA_FORMAT_R4G4_UNORM_PACK8:
return 1;
case DATA_FORMAT_R4G4B4A4_UNORM_PACK16:
@@ -906,7 +900,6 @@ uint32_t RenderingDeviceVulkan::get_image_format_pixel_size(DataFormat p_format)
// https://www.khronos.org/registry/DataFormat/specs/1.1/dataformat.1.1.pdf
void RenderingDeviceVulkan::get_compressed_image_format_block_dimensions(DataFormat p_format, uint32_t &r_w, uint32_t &r_h) {
-
switch (p_format) {
case DATA_FORMAT_BC1_RGB_UNORM_BLOCK:
case DATA_FORMAT_BC1_RGB_SRGB_BLOCK:
@@ -987,7 +980,6 @@ void RenderingDeviceVulkan::get_compressed_image_format_block_dimensions(DataFor
}
uint32_t RenderingDeviceVulkan::get_compressed_image_format_block_byte_size(DataFormat p_format) {
-
switch (p_format) {
case DATA_FORMAT_BC1_RGB_UNORM_BLOCK:
case DATA_FORMAT_BC1_RGB_SRGB_BLOCK:
@@ -1072,7 +1064,6 @@ uint32_t RenderingDeviceVulkan::get_compressed_image_format_block_byte_size(Data
}
uint32_t RenderingDeviceVulkan::get_compressed_image_format_pixel_rshift(DataFormat p_format) {
-
switch (p_format) {
case DATA_FORMAT_BC1_RGB_UNORM_BLOCK: //these formats are half byte size, so rshift is 1
case DATA_FORMAT_BC1_RGB_SRGB_BLOCK:
@@ -1118,7 +1109,6 @@ bool RenderingDeviceVulkan::format_has_stencil(DataFormat p_format) {
}
uint32_t RenderingDeviceVulkan::get_image_format_required_size(DataFormat p_format, uint32_t p_width, uint32_t p_height, uint32_t p_depth, uint32_t p_mipmaps, uint32_t *r_blockw, uint32_t *r_blockh, uint32_t *r_depth) {
-
ERR_FAIL_COND_V(p_mipmaps == 0, 0);
uint32_t w = p_width;
uint32_t h = p_height;
@@ -1158,7 +1148,6 @@ uint32_t RenderingDeviceVulkan::get_image_format_required_size(DataFormat p_form
}
uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uint32_t p_height, uint32_t p_depth) {
-
//formats and block size don't really matter here since they can all go down to 1px (even if block is larger)
int w = p_width;
int h = p_height;
@@ -1167,7 +1156,6 @@ uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uin
int mipmaps = 1;
while (true) {
-
if (w == 1 && h == 1 && d == 1) {
break;
}
@@ -1337,7 +1325,6 @@ Error RenderingDeviceVulkan::_buffer_free(Buffer *p_buffer) {
}
Error RenderingDeviceVulkan::_insert_staging_block() {
-
VkBufferCreateInfo bufferInfo;
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.pNext = nullptr;
@@ -1375,7 +1362,6 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
r_alloc_size = p_amount;
while (true) {
-
r_alloc_offset = 0;
//see if we can use current block
@@ -1431,7 +1417,6 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
//block_until_next_frame()
continue;
} else {
-
//flush EVERYTHING including setup commands. IF not immediate, also need to flush the draw commands
_flush(true);
@@ -1476,7 +1461,6 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
//block_until_next_frame()
continue; //and try again
} else {
-
_flush(false);
for (int i = 0; i < staging_buffer_blocks.size(); i++) {
@@ -1506,13 +1490,11 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
}
Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, const uint8_t *p_data, size_t p_data_size, bool p_use_draw_command_buffer, uint32_t p_required_align) {
-
//submitting may get chunked for various reasons, so convert this to a task
size_t to_submit = p_data_size;
size_t submit_from = 0;
while (to_submit > 0) {
-
uint32_t block_write_offset;
uint32_t block_write_amount;
@@ -1553,7 +1535,6 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c
}
void RenderingDeviceVulkan::_memory_barrier(VkPipelineStageFlags p_src_stage_mask, VkPipelineStageFlags p_dst_stage_mask, VkAccessFlags p_src_access, VkAccessFlags p_dst_sccess, bool p_sync_with_draw) {
-
VkMemoryBarrier mem_barrier;
mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
mem_barrier.pNext = nullptr;
@@ -1600,7 +1581,6 @@ void RenderingDeviceVulkan::_full_barrier(bool p_sync_with_draw) {
}
void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_from, uint64_t p_size, VkPipelineStageFlags p_src_stage_mask, VkPipelineStageFlags p_dst_stage_mask, VkAccessFlags p_src_access, VkAccessFlags p_dst_sccess, bool p_sync_with_draw) {
-
VkBufferMemoryBarrier buffer_mem_barrier;
buffer_mem_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
buffer_mem_barrier.pNext = nullptr;
@@ -1620,7 +1600,6 @@ void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_f
/*****************/
RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t>> &p_data) {
-
_THREAD_SAFE_METHOD_
VkImageCreateInfo image_create_info;
@@ -1750,7 +1729,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
"Too many mipmaps requested for texture format and dimensions (" + itos(image_create_info.mipLevels) + "), maximum allowed: (" + itos(required_mipmaps) + ").");
if (p_data.size()) {
-
ERR_FAIL_COND_V_MSG(!(p_format.usage_bits & TEXTURE_USAGE_CAN_UPDATE_BIT), RID(),
"Texture needs the TEXTURE_USAGE_CAN_UPDATE_BIT usage flag in order to be updated at initialization or later");
@@ -1858,7 +1836,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
texture.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
} else if (p_format.usage_bits & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
texture.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
} else {
@@ -1866,7 +1843,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
}
if (p_format.usage_bits & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
texture.read_aspect_mask = VK_IMAGE_ASPECT_DEPTH_BIT;
texture.barrier_aspect_mask = VK_IMAGE_ASPECT_DEPTH_BIT;
@@ -1961,7 +1937,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
RID id = texture_owner.make_rid(texture);
if (p_data.size()) {
-
for (uint32_t i = 0; i < image_create_info.arrayLayers; i++) {
texture_update(id, i, p_data[i]);
}
@@ -1970,7 +1945,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
}
RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID p_with_texture) {
-
_THREAD_SAFE_METHOD_
Texture *src_texture = texture_owner.getornull(p_with_texture);
@@ -2050,7 +2024,6 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID
}
RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type) {
-
_THREAD_SAFE_METHOD_
Texture *src_texture = texture_owner.getornull(p_with_texture);
@@ -2150,7 +2123,6 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p
}
Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_sync_with_draw) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(draw_list && p_sync_with_draw, ERR_INVALID_PARAMETER,
@@ -2221,7 +2193,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
uint32_t mipmap_offset = 0;
for (uint32_t mm_i = 0; mm_i < texture->mipmaps; mm_i++) {
-
uint32_t depth;
uint32_t image_total = get_image_format_required_size(texture->format, texture->width, texture->height, texture->depth, mm_i + 1, &width, &height, &depth);
@@ -2234,7 +2205,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
for (uint32_t x = 0; x < width; x += region_size) {
for (uint32_t y = 0; y < height; y += region_size) {
-
uint32_t region_w = MIN(region_size, width - x);
uint32_t region_h = MIN(region_size, height - y);
@@ -2295,7 +2265,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
uint32_t dst_offset = (yr * region_w + xr) * pixel_size;
//copy block
for (uint32_t i = 0; i < pixel_size; i++) {
-
write_ptr[dst_offset + i] = read_ptr[src_offset + i];
}
}
@@ -2359,7 +2328,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
}
Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d) {
-
uint32_t width, height, depth;
uint32_t image_size = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, tex->mipmaps, &width, &height, &depth);
@@ -2379,7 +2347,6 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex
uint32_t mipmap_offset = 0;
for (uint32_t mm_i = 0; mm_i < tex->mipmaps; mm_i++) {
-
uint32_t image_total = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, mm_i + 1, &width, &height, &depth);
uint8_t *write_ptr_mipmap = w + mipmap_offset;
@@ -2426,7 +2393,6 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex
}
Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t p_layer) {
-
_THREAD_SAFE_METHOD_
Texture *tex = texture_owner.getornull(p_texture);
@@ -2447,7 +2413,6 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
//does not need anything fancy, map and read.
return _texture_get_data_from_image(tex, tex->image, tex->allocation, p_layer);
} else {
-
//compute total image size
uint32_t width, height, depth;
uint32_t buffer_size = get_image_format_required_size(tex->format, tex->width, tex->height, tex->depth, tex->mipmaps, &width, &height, &depth);
@@ -2485,7 +2450,6 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
uint32_t prev_size = 0;
uint32_t offset = 0;
for (uint32_t i = 0; i < tex->mipmaps; i++) {
-
VkBufferImageCopy buffer_image_copy;
uint32_t image_size = get_image_format_required_size(tex->format, tex->width, tex->height, tex->depth, i + 1);
@@ -2542,7 +2506,6 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
Vector<uint8_t> buffer_data;
{
-
buffer_data.resize(buffer_size);
uint8_t *w = buffer_data.ptrw();
copymem(w, buffer_mem, buffer_size);
@@ -2569,7 +2532,6 @@ bool RenderingDeviceVulkan::texture_is_valid(RID p_texture) {
}
Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, bool p_sync_with_draw) {
-
_THREAD_SAFE_METHOD_
Texture *src_tex = texture_owner.getornull(p_from_texture);
@@ -2620,7 +2582,6 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
VkCommandBuffer command_buffer = p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer;
{
-
//PRE Copy the image
{ //Source
@@ -2667,7 +2628,6 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
//COPY
{
-
VkImageCopy image_copy_region;
image_copy_region.srcSubresource.aspectMask = src_tex->read_aspect_mask;
image_copy_region.srcSubresource.baseArrayLayer = p_src_layer;
@@ -2773,7 +2733,6 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
VkCommandBuffer command_buffer = p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer;
{
-
//PRE Copy the image
{ //Source
@@ -2820,7 +2779,6 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
//COPY
{
-
VkImageResolve image_copy_region;
image_copy_region.srcSubresource.aspectMask = src_tex->read_aspect_mask;
image_copy_region.srcSubresource.baseArrayLayer = src_tex->base_layer;
@@ -2894,7 +2852,6 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
}
Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, bool p_sync_with_draw) {
-
_THREAD_SAFE_METHOD_
Texture *src_tex = texture_owner.getornull(p_texture);
@@ -3027,14 +2984,12 @@ bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_f
/********************/
VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentFormat> &p_format, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, int *r_color_attachment_count) {
-
Vector<VkAttachmentDescription> attachments;
Vector<VkAttachmentReference> color_references;
Vector<VkAttachmentReference> depth_stencil_references;
Vector<VkAttachmentReference> resolve_references;
for (int i = 0; i < p_format.size(); i++) {
-
VkAttachmentDescription description;
description.flags = 0;
@@ -3051,7 +3006,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
bool is_storage = p_format[i].usage_flags & TEXTURE_USAGE_STORAGE_BIT;
switch (is_depth_stencil ? p_initial_depth_action : p_initial_color_action) {
-
case INITIAL_ACTION_CLEAR: {
description.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
@@ -3109,13 +3063,11 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
switch (is_depth_stencil ? p_final_depth_action : p_final_color_action) {
case FINAL_ACTION_READ: {
-
if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
} else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
@@ -3131,7 +3083,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
} else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
description.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
@@ -3147,7 +3098,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
} else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
description.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
@@ -3222,7 +3172,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
}
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_create(const Vector<AttachmentFormat> &p_format) {
-
_THREAD_SAFE_METHOD_
FramebufferFormatKey key;
@@ -3264,7 +3213,6 @@ RenderingDevice::TextureSamples RenderingDeviceVulkan::framebuffer_format_get_te
/***********************/
RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check) {
-
_THREAD_SAFE_METHOD_
Vector<AttachmentFormat> attachments;
@@ -3312,7 +3260,6 @@ RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attac
}
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_get_format(RID p_framebuffer) {
-
_THREAD_SAFE_METHOD_
Framebuffer *framebuffer = framebuffer_owner.getornull(p_framebuffer);
@@ -3326,7 +3273,6 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_get_form
/*****************/
RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
-
_THREAD_SAFE_METHOD_
VkSamplerCreateInfo sampler_create_info;
@@ -3372,7 +3318,6 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
/**********************/
RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
@@ -3391,7 +3336,6 @@ RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vec
// Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated
RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(const Vector<VertexAttribute> &p_vertex_formats) {
-
_THREAD_SAFE_METHOD_
VertexDescriptionKey key;
@@ -3443,7 +3387,6 @@ RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(cons
}
RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!vertex_formats.has(p_vertex_format), RID());
@@ -3500,7 +3443,6 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo
}
RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBufferFormat p_format, const Vector<uint8_t> &p_data, bool p_use_restart_indices) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_index_count == 0, RID());
@@ -3550,7 +3492,6 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff
}
RID RenderingDeviceVulkan::index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!index_buffer_owner.owns(p_index_buffer), RID());
@@ -3814,7 +3755,6 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
#endif
RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages) {
-
//descriptor layouts
Vector<Vector<VkDescriptorSetLayoutBinding>> set_bindings;
Vector<Vector<UniformInfo>> uniform_info;
@@ -3831,7 +3771,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
bool is_compute = false;
for (int i = 0; i < p_stages.size(); i++) {
-
if (p_stages[i].shader_stage == SHADER_STAGE_COMPUTE) {
is_compute = true;
ERR_FAIL_COND_V_MSG(p_stages.size() != 1, RID(),
@@ -3855,7 +3794,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
uint32_t stage = p_stages[i].shader_stage;
if (binding_count > 0) {
-
//Parse bindings
Vector<SpvReflectDescriptorBinding *> bindings;
@@ -4006,7 +3944,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
}
if (stage == SHADER_STAGE_VERTEX) {
-
uint32_t iv_count = 0;
result = spvReflectEnumerateInputVariables(&module, &iv_count, nullptr);
ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(),
@@ -4029,7 +3966,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
}
if (stage == SHADER_STAGE_FRAGMENT) {
-
uint32_t ov_count = 0;
result = spvReflectEnumerateOutputVariables(&module, &ov_count, nullptr);
ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(),
@@ -4142,9 +4078,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
//proceed to create descriptor sets
if (success) {
-
for (int i = 0; i < set_bindings.size(); i++) {
-
//empty ones are fine if they were not used according to spec (binding count will be 0)
VkDescriptorSetLayoutCreateInfo layout_create_info;
layout_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
@@ -4253,7 +4187,6 @@ uint32_t RenderingDeviceVulkan::shader_get_vertex_input_attribute_mask(RID p_sha
/******************/
RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
@@ -4271,7 +4204,6 @@ RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Ve
}
RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
@@ -4290,7 +4222,6 @@ RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Ve
}
RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
uint32_t element_size = get_format_vertex_size(p_format);
@@ -4447,7 +4378,6 @@ void RenderingDeviceVulkan::_descriptor_pool_free(const DescriptorPoolKey &p_key
}
RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_uniforms.size() == 0, RID());
@@ -4537,7 +4467,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
} break;
case UNIFORM_TYPE_SAMPLER_WITH_TEXTURE: {
-
if (uniform.ids.size() != set_uniform.length * 2) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "SamplerTexture (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") sampler&texture elements, so it should provided twice the amount of IDs (sampler,texture pairs) to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4591,7 +4520,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
} break;
case UNIFORM_TYPE_TEXTURE: {
-
if (uniform.ids.size() != set_uniform.length) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "Texture (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") textures, so it should be provided equal number of texture IDs to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4642,7 +4570,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
type_size = uniform.ids.size();
} break;
case UNIFORM_TYPE_IMAGE: {
-
if (uniform.ids.size() != set_uniform.length) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "Image (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") textures, so it should be provided equal number of texture IDs to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4722,7 +4649,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
} break;
case UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER: {
-
if (uniform.ids.size() != set_uniform.length * 2) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "SamplerBuffer (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") sampler buffer elements, so it should provided twice the amount of IDs (sampler,buffer pairs) to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4804,7 +4730,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
write.pTexelBufferView = nullptr;
} break;
case UNIFORM_TYPE_INPUT_ATTACHMENT: {
-
} break;
default: {
}
@@ -4928,7 +4853,6 @@ Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint
}
Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
-
_THREAD_SAFE_METHOD_
Buffer *buffer = nullptr;
@@ -4961,7 +4885,6 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
Vector<uint8_t> buffer_data;
{
-
buffer_data.resize(buffer->size);
uint8_t *w = buffer_data.ptrw();
copymem(w, buffer_mem, buffer->size);
@@ -4979,7 +4902,6 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
/*************************/
RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags) {
-
_THREAD_SAFE_METHOD_
//needs a shader
@@ -5389,7 +5311,6 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader) {
}
bool RenderingDeviceVulkan::compute_pipeline_is_valid(RID p_pipeline) {
-
return compute_pipeline_owner.owns(p_pipeline);
}
@@ -5409,7 +5330,6 @@ int RenderingDeviceVulkan::screen_get_height(DisplayServer::WindowID p_screen) c
return context->window_get_height(p_screen);
}
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuffer_format() const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(local_device.is_valid(), INVALID_ID, "Local devices have no screen");
@@ -5439,7 +5359,6 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuff
/*******************/
RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(DisplayServer::WindowID p_screen, const Color &p_clear_color) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(local_device.is_valid(), INVALID_ID, "Local devices have no screen");
@@ -5503,7 +5422,6 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(Di
}
Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass) {
-
Framebuffer::VersionKey vk;
vk.initial_color_action = p_initial_color_action;
vk.final_color_action = p_final_color_action;
@@ -5548,7 +5466,6 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu
}
Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_colors, float p_clear_depth, uint32_t p_clear_stencil, Point2i viewport_offset, Point2i viewport_size, VkFramebuffer vkframebuffer, VkRenderPass render_pass, VkCommandBuffer command_buffer, VkSubpassContents subpass_contents) {
-
VkRenderPassBeginInfo render_pass_begin;
render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
render_pass_begin.pNext = nullptr;
@@ -5625,7 +5542,6 @@ void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list,
clear_at.colorAttachment = color_index++;
clear_at.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
} else if (p_clear_depth && texture->usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
clear_at.clearValue.depthStencil.depth = p_depth;
clear_at.clearValue.depthStencil.stencil = p_stencil;
clear_at.colorAttachment = 0;
@@ -5651,7 +5567,6 @@ void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list,
}
RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time.");
@@ -5742,7 +5657,6 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
}
Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, DrawListID *r_split_ids, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_splits < 1, ERR_INVALID_DECLARATION);
@@ -5789,7 +5703,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
uint32_t from = split_draw_list_allocators.size();
split_draw_list_allocators.resize(p_splits);
for (uint32_t i = from; i < p_splits; i++) {
-
VkCommandPoolCreateInfo cmd_pool_info;
cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
cmd_pool_info.pNext = nullptr;
@@ -5800,7 +5713,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
ERR_FAIL_COND_V_MSG(res, ERR_CANT_CREATE, "vkCreateCommandPool failed with error " + itos(res) + ".");
for (int j = 0; j < frame_count; j++) {
-
VkCommandBuffer command_buffer;
VkCommandBufferAllocateInfo cmdbuf;
@@ -5837,7 +5749,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
draw_list_split = true;
for (uint32_t i = 0; i < p_splits; i++) {
-
//take a command buffer and initialize it
VkCommandBuffer command_buffer = split_draw_list_allocators[p_splits].command_buffers[frame];
@@ -5906,7 +5817,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
}
RenderingDeviceVulkan::DrawList *RenderingDeviceVulkan::_get_draw_list_ptr(DrawListID p_id) {
-
if (p_id < 0) {
return nullptr;
}
@@ -5936,7 +5846,6 @@ RenderingDeviceVulkan::DrawList *RenderingDeviceVulkan::_get_draw_list_ptr(DrawL
}
void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RID p_render_pipeline) {
-
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -6007,7 +5916,6 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI
}
void RenderingDeviceVulkan::draw_list_bind_uniform_set(DrawListID p_list, RID p_uniform_set, uint32_t p_index) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(p_index >= limits.maxBoundDescriptorSets || p_index > MAX_UNIFORM_SETS,
"Attempting to bind a descriptor set (" + itos(p_index) + ") greater than what the hardware supports (" + itos(limits.maxBoundDescriptorSets) + ").");
@@ -6071,7 +5979,6 @@ void RenderingDeviceVulkan::draw_list_bind_vertex_array(DrawListID p_list, RID p
vkCmdBindVertexBuffers(dl->command_buffer, 0, vertex_array->buffers.size(), vertex_array->buffers.ptr(), vertex_array->offsets.ptr());
}
void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_index_array) {
-
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -6096,7 +6003,6 @@ void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_
}
void RenderingDeviceVulkan::draw_list_set_line_width(DrawListID p_list, float p_width) {
-
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -6125,7 +6031,6 @@ void RenderingDeviceVulkan::draw_list_set_push_constant(DrawListID p_list, const
}
void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices, uint32_t p_instances, uint32_t p_procedural_vertices) {
-
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -6158,13 +6063,11 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
//Bind descriptor sets
for (uint32_t i = 0; i < dl->state.set_count; i++) {
-
if (dl->state.sets[i].pipeline_expected_format == 0) {
continue; //nothing expected by this pipeline
}
#ifdef DEBUG_ENABLED
if (dl->state.sets[i].pipeline_expected_format != dl->state.sets[i].uniform_set_format) {
-
if (dl->state.sets[i].uniform_set_format == 0) {
ERR_FAIL_MSG("Uniforms were never supplied for set (" + itos(i) + ") at the time of drawing, which are required by the pipeline");
} else if (uniform_set_owner.owns(dl->state.sets[i].uniform_set)) {
@@ -6183,7 +6086,6 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
}
if (p_use_indices) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(p_procedural_vertices > 0,
"Procedural vertices can't be used together with indices.");
@@ -6211,7 +6113,6 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
#endif
vkCmdDrawIndexed(dl->command_buffer, to_draw, p_instances, dl->validation.index_array_offset, 0, 0);
} else {
-
uint32_t to_draw;
if (p_procedural_vertices > 0) {
@@ -6221,7 +6122,6 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
#endif
to_draw = p_procedural_vertices;
} else {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(dl->validation.pipeline_vertex_format == INVALID_ID,
"Draw command lacks indices, but pipeline format does not use vertices.");
@@ -6280,7 +6180,6 @@ void RenderingDeviceVulkan::draw_list_disable_scissor(DrawListID p_list) {
}
void RenderingDeviceVulkan::draw_list_end() {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_MSG(!draw_list, "Immediate draw list is already inactive.");
@@ -6334,7 +6233,6 @@ void RenderingDeviceVulkan::draw_list_end() {
/***********************/
RenderingDevice::ComputeListID RenderingDeviceVulkan::compute_list_begin() {
-
ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time.");
ERR_FAIL_COND_V_MSG(compute_list != nullptr, INVALID_ID, "Only one draw/compute list can be active at the same time.");
@@ -6436,7 +6334,6 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list,
for (uint32_t i = 0; i < textures_to_sampled_count; i++) {
if (textures_to_sampled[i]->layout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
-
VkImageMemoryBarrier image_memory_barrier;
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
image_memory_barrier.pNext = nullptr;
@@ -6467,7 +6364,6 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list,
for (uint32_t i = 0; i < textures_to_storage_count; i++) {
if (textures_to_storage[i]->layout != VK_IMAGE_LAYOUT_GENERAL) {
-
VkImageMemoryBarrier image_memory_barrier;
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
image_memory_barrier.pNext = nullptr;
@@ -6560,13 +6456,11 @@ void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t
//Bind descriptor sets
for (uint32_t i = 0; i < cl->state.set_count; i++) {
-
if (cl->state.sets[i].pipeline_expected_format == 0) {
continue; //nothing expected by this pipeline
}
#ifdef DEBUG_ENABLED
if (cl->state.sets[i].pipeline_expected_format != cl->state.sets[i].uniform_set_format) {
-
if (cl->state.sets[i].uniform_set_format == 0) {
ERR_FAIL_MSG("Uniforms were never supplied for set (" + itos(i) + ") at the time of drawing, which are required by the pipeline");
} else if (uniform_set_owner.owns(cl->state.sets[i].uniform_set)) {
@@ -6599,7 +6493,6 @@ void RenderingDeviceVulkan::compute_list_end() {
ERR_FAIL_COND(!compute_list);
for (Set<Texture *>::Element *E = compute_list->state.textures_to_sampled_layout.front(); E; E = E->next()) {
-
VkImageMemoryBarrier image_memory_barrier;
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
image_memory_barrier.pNext = nullptr;
@@ -6691,7 +6584,6 @@ void RenderingDeviceVulkan::draw_list_render_secondary_to_framebuffer(ID p_frame
#endif
void RenderingDeviceVulkan::_free_internal(RID p_id) {
-
//push everything so it's disposed of next time this frame index is processed (means, it's safe to do it)
if (texture_owner.owns(p_id)) {
Texture *texture = texture_owner.getornull(p_id);
@@ -6755,7 +6647,6 @@ void RenderingDeviceVulkan::_free_internal(RID p_id) {
}
}
void RenderingDeviceVulkan::free(RID p_id) {
-
_THREAD_SAFE_METHOD_
_free_dependencies(p_id); //recursively erase dependencies first, to avoid potential API problems
@@ -6763,7 +6654,6 @@ void RenderingDeviceVulkan::free(RID p_id) {
}
void RenderingDeviceVulkan::_finalize_command_bufers() {
-
if (draw_list) {
ERR_PRINT("Found open draw list at the end of the frame, this should never happen (further drawing will likely not work).");
}
@@ -6779,7 +6669,6 @@ void RenderingDeviceVulkan::_finalize_command_bufers() {
}
void RenderingDeviceVulkan::_begin_frame() {
-
//erase pending resources
_free_pending_resources(frame);
@@ -6826,7 +6715,6 @@ void RenderingDeviceVulkan::_begin_frame() {
}
void RenderingDeviceVulkan::swap_buffers() {
-
ERR_FAIL_COND_MSG(local_device.is_valid(), "Local devices can't swap buffers.");
_THREAD_SAFE_METHOD_
@@ -6853,7 +6741,6 @@ void RenderingDeviceVulkan::submit() {
}
void RenderingDeviceVulkan::sync() {
-
ERR_FAIL_COND_MSG(local_device.is_null(), "Only local devices can submit and sync.");
ERR_FAIL_COND_MSG(!local_device_processing, "sync can only be called after a submit");
@@ -6959,7 +6846,6 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) {
//buffers
while (frames[p_frame].buffers_to_dispose_of.front()) {
-
_buffer_free(&frames[p_frame].buffers_to_dispose_of.front()->get());
frames[p_frame].buffers_to_dispose_of.pop_front();
@@ -6983,7 +6869,6 @@ uint64_t RenderingDeviceVulkan::get_memory_usage() const {
}
void RenderingDeviceVulkan::_flush(bool p_current_frame) {
-
if (local_device.is_valid() && !p_current_frame) {
return; //flushign previous frames has no effect with local device
}
@@ -6994,7 +6879,6 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) {
}
if (local_device.is_valid()) {
-
VkCommandBuffer command_buffers[2] = { frames[frame].setup_command_buffer, frames[frame].draw_command_buffer };
context->local_device_push_command_buffers(local_device, command_buffers, 2);
context->local_device_sync(local_device);
@@ -7040,7 +6924,6 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) {
}
void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_device) {
-
context = p_context;
device = p_context->get_device();
if (p_local_device) {
@@ -7066,7 +6949,6 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de
frame = 0;
//create setup and frame buffers
for (int i = 0; i < frame_count; i++) {
-
frames[i].index = 0;
{ //create command pool, one per frame is recommended
@@ -7190,7 +7072,6 @@ void RenderingDeviceVulkan::_free_rids(T &p_owner, const char *p_type) {
}
void RenderingDeviceVulkan::capture_timestamp(const String &p_name, bool p_sync_to_draw) {
-
ERR_FAIL_COND(frames[frame].timestamp_count >= max_timestamp_query_elements);
{
@@ -7370,7 +7251,6 @@ int RenderingDeviceVulkan::limit_get(Limit p_limit) {
}
void RenderingDeviceVulkan::finalize() {
-
//free all resources
_flush(false);
@@ -7396,7 +7276,6 @@ void RenderingDeviceVulkan::finalize() {
WARN_PRINT(itos(owned.size()) + " RIDs of type 'Texture' were leaked.");
//free shared first
for (List<RID>::Element *E = owned.front(); E;) {
-
List<RID>::Element *N = E->next();
if (texture_is_shared(E->get())) {
free(E->get());
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 87af5d03d4..6b75154a8d 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -51,7 +51,6 @@
class VulkanContext;
class RenderingDeviceVulkan : public RenderingDevice {
-
_THREAD_SAFE_CLASS_
// Miscellaneous tables that map
@@ -123,7 +122,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
// for a framebuffer to render into it.
struct Texture {
-
VkImage image;
VmaAllocation allocation;
VmaAllocationInfo allocation_info;
@@ -204,7 +202,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
Error _insert_staging_block();
struct Buffer {
-
uint32_t size;
VkBuffer buffer;
VmaAllocation allocation;
@@ -237,7 +234,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct FramebufferFormatKey {
Vector<AttachmentFormat> attachments;
bool operator<(const FramebufferFormatKey &p_key) const {
-
int as = attachments.size();
int bs = p_key.attachments.size();
if (as != bs) {
@@ -521,9 +517,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
// does not submit something invalid.
struct Shader {
-
struct Set {
-
Vector<UniformInfo> uniform_info;
VkDescriptorSetLayout descriptor_set_layout;
};
@@ -685,7 +679,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
RID_Owner<RenderPipeline, true> render_pipeline_owner;
struct ComputePipeline {
-
RID shader;
Vector<uint32_t> set_formats;
VkPipelineLayout pipeline_layout; // not owned, needed for push constants
@@ -719,7 +712,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
Vector<SplitDrawListAllocator> split_draw_list_allocators;
struct DrawList {
-
VkCommandBuffer command_buffer; //if persistent, this is owned, otherwise it's shared with the ringbuffer
Rect2i viewport;
@@ -836,7 +828,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
/**********************/
struct ComputeList {
-
VkCommandBuffer command_buffer; //if persistent, this is owned, otherwise it's shared with the ringbuffer
struct SetState {
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index 9471b4604c..875ace32a5 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -49,7 +49,6 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanContext::_debug_messenger_callback(
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) {
-
// This error needs to be ignored because the AMD allocator will mix up memory types on IGP processors.
if (strstr(pCallbackData->pMessage, "Mapping an image with layout") != nullptr &&
strstr(pCallbackData->pMessage, "can result in undefined behavior if this memory is used by the device") != nullptr) {
@@ -163,7 +162,6 @@ VkBool32 VulkanContext::_check_layers(uint32_t check_count, const char **check_n
}
Error VulkanContext::_create_validation_layers() {
-
VkResult err;
const char *instance_validation_layers_alt1[] = { "VK_LAYER_KHRONOS_validation" };
const char *instance_validation_layers_alt2[] = { "VK_LAYER_LUNARG_standard_validation" };
@@ -218,7 +216,6 @@ Error VulkanContext::_create_validation_layers() {
}
Error VulkanContext::_initialize_extensions() {
-
VkResult err;
uint32_t instance_extension_count = 0;
@@ -275,7 +272,6 @@ Error VulkanContext::_initialize_extensions() {
}
Error VulkanContext::_create_physical_device() {
-
/* Look for validation layers */
if (use_validation_layers) {
_create_validation_layers();
@@ -513,7 +509,6 @@ Error VulkanContext::_create_physical_device() {
}
Error VulkanContext::_create_device() {
-
VkResult err;
float queue_priorities[1] = { 0.0 };
VkDeviceQueueCreateInfo queues[2];
@@ -552,7 +547,6 @@ Error VulkanContext::_create_device() {
}
Error VulkanContext::_initialize_queues(VkSurfaceKHR surface) {
-
// Iterate over each queue to learn whether it supports presenting:
VkBool32 *supportsPresent = (VkBool32 *)malloc(queue_family_count * sizeof(VkBool32));
for (uint32_t i = 0; i < queue_family_count; i++) {
@@ -705,7 +699,6 @@ Error VulkanContext::_create_semaphores() {
}
Error VulkanContext::_window_create(DisplayServer::WindowID p_window_id, VkSurfaceKHR p_surface, int p_width, int p_height) {
-
ERR_FAIL_COND_V(windows.has(p_window_id), ERR_INVALID_PARAMETER);
if (!queues_initialized) {
@@ -766,7 +759,6 @@ void VulkanContext::window_destroy(DisplayServer::WindowID p_window_id) {
}
Error VulkanContext::_clean_up_swap_chain(Window *window) {
-
if (!window->swapchain) {
return OK;
}
@@ -1136,7 +1128,6 @@ Error VulkanContext::_update_swap_chain(Window *window) {
}
Error VulkanContext::initialize() {
-
Error err = _create_physical_device();
if (err) {
return err;
@@ -1150,7 +1141,6 @@ void VulkanContext::set_setup_buffer(const VkCommandBuffer &pCommandBuffer) {
}
void VulkanContext::append_command_buffer(const VkCommandBuffer &pCommandBuffer) {
-
if (command_buffer_queue.size() <= command_buffer_count) {
command_buffer_queue.resize(command_buffer_count + 1);
}
@@ -1160,14 +1150,12 @@ void VulkanContext::append_command_buffer(const VkCommandBuffer &pCommandBuffer)
}
void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) {
-
// ensure everything else pending is executed
vkDeviceWaitIdle(device);
//flush the pending setup buffer
if (p_flush_setup && command_buffer_queue[0]) {
-
//use a fence to wait for everything done
VkSubmitInfo submit_info;
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
@@ -1186,7 +1174,6 @@ void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) {
}
if (p_flush_pending && command_buffer_count > 1) {
-
//use a fence to wait for everything done
VkSubmitInfo submit_info;
@@ -1208,7 +1195,6 @@ void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) {
}
Error VulkanContext::prepare_buffers() {
-
if (!queues_initialized) {
return OK;
}
@@ -1220,7 +1206,6 @@ Error VulkanContext::prepare_buffers() {
vkResetFences(device, 1, &fences[frame_index]);
for (Map<int, Window>::Element *E = windows.front(); E; E = E->next()) {
-
Window *w = &E->get();
if (w->swapchain == VK_NULL_HANDLE) {
@@ -1256,7 +1241,6 @@ Error VulkanContext::prepare_buffers() {
}
Error VulkanContext::swap_buffers() {
-
if (!queues_initialized) {
return OK;
}
@@ -1551,7 +1535,6 @@ VkDevice VulkanContext::local_device_get_vk_device(RID p_local_device) {
}
void VulkanContext::local_device_push_command_buffers(RID p_local_device, const VkCommandBuffer *p_buffers, int p_count) {
-
LocalDevice *ld = local_device_owner.getornull(p_local_device);
ERR_FAIL_COND(ld->waiting);
@@ -1582,7 +1565,6 @@ void VulkanContext::local_device_push_command_buffers(RID p_local_device, const
}
void VulkanContext::local_device_sync(RID p_local_device) {
-
LocalDevice *ld = local_device_owner.getornull(p_local_device);
ERR_FAIL_COND(!ld->waiting);
@@ -1591,7 +1573,6 @@ void VulkanContext::local_device_sync(RID p_local_device) {
}
void VulkanContext::local_device_free(RID p_local_device) {
-
LocalDevice *ld = local_device_owner.getornull(p_local_device);
vkDestroyDevice(ld->device, nullptr);
local_device_owner.free(p_local_device);
diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h
index 51c3febb47..ff1215ff5d 100644
--- a/drivers/vulkan/vulkan_context.h
+++ b/drivers/vulkan/vulkan_context.h
@@ -40,7 +40,6 @@
#include <vulkan/vulkan.h>
class VulkanContext {
-
enum {
MAX_EXTENSIONS = 128,
MAX_LAYERS = 64,
@@ -81,7 +80,6 @@ class VulkanContext {
} SwapchainImageResources;
struct Window {
-
bool is_minimzed;
VkSurfaceKHR surface;
VkSwapchainKHR swapchain;
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index 1fc01ce76e..707e55cfcb 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -139,7 +139,6 @@ public:
static CMMNotificationClient notif_client;
Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_capture, bool reinit) {
-
WAVEFORMATEX *pwfex;
IMMDeviceEnumerator *enumerator = nullptr;
IMMDevice *device = nullptr;
@@ -311,7 +310,6 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
}
Error AudioDriverWASAPI::init_render_device(bool reinit) {
-
Error err = audio_device_init(&audio_output, false, reinit);
if (err != OK)
return err;
@@ -350,7 +348,6 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) {
}
Error AudioDriverWASAPI::init_capture_device(bool reinit) {
-
Error err = audio_device_init(&audio_input, true, reinit);
if (err != OK)
return err;
@@ -366,7 +363,6 @@ Error AudioDriverWASAPI::init_capture_device(bool reinit) {
}
Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
-
if (p_device->active) {
if (p_device->audio_client) {
p_device->audio_client->Stop();
@@ -383,17 +379,14 @@ Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
}
Error AudioDriverWASAPI::finish_render_device() {
-
return audio_device_finish(&audio_output);
}
Error AudioDriverWASAPI::finish_capture_device() {
-
return audio_device_finish(&audio_input);
}
Error AudioDriverWASAPI::init() {
-
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
Error err = init_render_device();
@@ -410,17 +403,14 @@ Error AudioDriverWASAPI::init() {
}
int AudioDriverWASAPI::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverWASAPI::get_speaker_mode() const {
-
return get_speaker_mode_by_total_channels(channels);
}
Array AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
-
Array list;
IMMDeviceCollection *devices = nullptr;
IMMDeviceEnumerator *enumerator = nullptr;
@@ -468,12 +458,10 @@ Array AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
}
Array AudioDriverWASAPI::get_device_list() {
-
return audio_device_get_list(false);
}
String AudioDriverWASAPI::get_device() {
-
lock();
String name = audio_output.device_name;
unlock();
@@ -482,7 +470,6 @@ String AudioDriverWASAPI::get_device() {
}
void AudioDriverWASAPI::set_device(String device) {
-
lock();
audio_output.new_device = device;
unlock();
@@ -550,13 +537,11 @@ void AudioDriverWASAPI::write_sample(WORD format_tag, int bits_per_sample, BYTE
}
void AudioDriverWASAPI::thread_func(void *p_udata) {
-
AudioDriverWASAPI *ad = (AudioDriverWASAPI *)p_udata;
uint32_t avail_frames = 0;
uint32_t write_ofs = 0;
while (!ad->exit_thread) {
-
uint32_t read_frames = 0;
uint32_t written_frames = 0;
@@ -583,19 +568,16 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
ad->start_counting_ticks();
if (avail_frames > 0 && ad->audio_output.audio_client) {
-
UINT32 cur_frames;
bool invalidated = false;
HRESULT hr = ad->audio_output.audio_client->GetCurrentPadding(&cur_frames);
if (hr == S_OK) {
-
// Check how much frames are available on the WASAPI buffer
UINT32 write_frames = MIN(ad->buffer_frames - cur_frames, avail_frames);
if (write_frames > 0) {
BYTE *buffer = nullptr;
hr = ad->audio_output.render_client->GetBuffer(write_frames, &buffer);
if (hr == S_OK) {
-
// We're using WASAPI Shared Mode so we must convert the buffer
if (ad->channels == ad->audio_output.channels) {
for (unsigned int i = 0; i < write_frames * ad->channels; i++) {
@@ -766,7 +748,6 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
}
void AudioDriverWASAPI::start() {
-
if (audio_output.audio_client) {
HRESULT hr = audio_output.audio_client->Start();
if (hr != S_OK) {
@@ -778,17 +759,14 @@ void AudioDriverWASAPI::start() {
}
void AudioDriverWASAPI::lock() {
-
mutex.lock();
}
void AudioDriverWASAPI::unlock() {
-
mutex.unlock();
}
void AudioDriverWASAPI::finish() {
-
if (thread) {
exit_thread = true;
Thread::wait_to_finish(thread);
@@ -802,7 +780,6 @@ void AudioDriverWASAPI::finish() {
}
Error AudioDriverWASAPI::capture_start() {
-
Error err = init_capture_device();
if (err != OK) {
ERR_PRINT("WASAPI: init_capture_device error");
@@ -819,7 +796,6 @@ Error AudioDriverWASAPI::capture_start() {
}
Error AudioDriverWASAPI::capture_stop() {
-
if (audio_input.active) {
audio_input.audio_client->Stop();
audio_input.active = false;
@@ -831,19 +807,16 @@ Error AudioDriverWASAPI::capture_stop() {
}
void AudioDriverWASAPI::capture_set_device(const String &p_name) {
-
lock();
audio_input.new_device = p_name;
unlock();
}
Array AudioDriverWASAPI::capture_get_device_list() {
-
return audio_device_get_list(true);
}
String AudioDriverWASAPI::capture_get_device() {
-
lock();
String name = audio_input.device_name;
unlock();
diff --git a/drivers/wasapi/audio_driver_wasapi.h b/drivers/wasapi/audio_driver_wasapi.h
index 2fcf8936fa..41ff7c9895 100644
--- a/drivers/wasapi/audio_driver_wasapi.h
+++ b/drivers/wasapi/audio_driver_wasapi.h
@@ -42,7 +42,6 @@
#include <windows.h>
class AudioDriverWASAPI : public AudioDriver {
-
class AudioDeviceWASAPI {
public:
IAudioClient *audio_client = nullptr;
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index a8618b05d7..52ba8527ab 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -53,7 +53,6 @@
*/
struct DirAccessWindowsPrivate {
-
HANDLE h; //handle for findfirstfile
WIN32_FIND_DATA f;
WIN32_FIND_DATAW fu; //unicode version
@@ -62,7 +61,6 @@ struct DirAccessWindowsPrivate {
// CreateFolderAsync
Error DirAccessWindows::list_dir_begin() {
-
_cisdir = false;
_cishidden = false;
@@ -73,7 +71,6 @@ Error DirAccessWindows::list_dir_begin() {
}
String DirAccessWindows::get_next() {
-
if (p->h == INVALID_HANDLE_VALUE)
return "";
@@ -83,7 +80,6 @@ String DirAccessWindows::get_next() {
String name = p->fu.cFileName;
if (FindNextFileW(p->h, &p->fu) == 0) {
-
FindClose(p->h);
p->h = INVALID_HANDLE_VALUE;
}
@@ -92,29 +88,23 @@ String DirAccessWindows::get_next() {
}
bool DirAccessWindows::current_is_dir() const {
-
return _cisdir;
}
bool DirAccessWindows::current_is_hidden() const {
-
return _cishidden;
}
void DirAccessWindows::list_dir_end() {
-
if (p->h != INVALID_HANDLE_VALUE) {
-
FindClose(p->h);
p->h = INVALID_HANDLE_VALUE;
}
}
int DirAccessWindows::get_drive_count() {
-
return drive_count;
}
String DirAccessWindows::get_drive(int p_drive) {
-
if (p_drive < 0 || p_drive >= drive_count)
return "";
@@ -122,7 +112,6 @@ String DirAccessWindows::get_drive(int p_drive) {
}
Error DirAccessWindows::change_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
p_dir = fix_path(p_dir);
@@ -136,7 +125,6 @@ Error DirAccessWindows::change_dir(String p_dir) {
String base = _get_root_path();
if (base != "") {
-
GetCurrentDirectoryW(2048, real_current_dir_name);
String new_dir;
new_dir = String(real_current_dir_name).replace("\\", "/");
@@ -146,7 +134,6 @@ Error DirAccessWindows::change_dir(String p_dir) {
}
if (worked) {
-
GetCurrentDirectoryW(2048, real_current_dir_name);
current_dir = real_current_dir_name; // TODO, utf8 parser
current_dir = current_dir.replace("\\", "/");
@@ -160,7 +147,6 @@ Error DirAccessWindows::change_dir(String p_dir) {
}
Error DirAccessWindows::make_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
p_dir = fix_path(p_dir);
@@ -190,10 +176,8 @@ Error DirAccessWindows::make_dir(String p_dir) {
}
String DirAccessWindows::get_current_dir(bool p_include_drive) {
-
String base = _get_root_path();
if (base != "") {
-
String bd = current_dir.replace("\\", "/").replace_first(base, "");
if (bd.begins_with("/"))
return _get_root_string() + bd.substr(1, bd.length());
@@ -217,7 +201,6 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) {
}
bool DirAccessWindows::file_exists(String p_file) {
-
GLOBAL_LOCK_FUNCTION
if (!p_file.is_abs_path())
@@ -239,7 +222,6 @@ bool DirAccessWindows::file_exists(String p_file) {
}
bool DirAccessWindows::dir_exists(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
if (p_dir.is_rel_path())
@@ -260,7 +242,6 @@ bool DirAccessWindows::dir_exists(String p_dir) {
}
Error DirAccessWindows::rename(String p_path, String p_new_path) {
-
if (p_path.is_rel_path())
p_path = get_current_dir().plus_file(p_path);
@@ -298,7 +279,6 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) {
}
Error DirAccessWindows::remove(String p_path) {
-
if (p_path.is_rel_path())
p_path = get_current_dir().plus_file(p_path);
@@ -347,7 +327,6 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const {
}
*/
size_t DirAccessWindows::get_space_left() {
-
uint64_t bytes = 0;
if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr))
return 0;
@@ -377,7 +356,6 @@ String DirAccessWindows::get_filesystem_type() const {
&dwFileSystemFlags,
szFileSystemName,
sizeof(szFileSystemName)) == TRUE) {
-
return String(szFileSystemName);
}
@@ -385,7 +363,6 @@ String DirAccessWindows::get_filesystem_type() const {
}
DirAccessWindows::DirAccessWindows() {
-
p = memnew(DirAccessWindowsPrivate);
p->h = INVALID_HANDLE_VALUE;
current_dir = ".";
@@ -401,7 +378,6 @@ DirAccessWindows::DirAccessWindows() {
DWORD mask = GetLogicalDrives();
for (int i = 0; i < MAX_DRIVES; i++) {
-
if (mask & (1 << i)) { //DRIVE EXISTS
drives[drive_count] = 'A' + i;
@@ -414,7 +390,6 @@ DirAccessWindows::DirAccessWindows() {
}
DirAccessWindows::~DirAccessWindows() {
-
memdelete(p);
}
diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h
index f59e4d7030..47aedfecf5 100644
--- a/drivers/windows/dir_access_windows.h
+++ b/drivers/windows/dir_access_windows.h
@@ -42,7 +42,6 @@
struct DirAccessWindowsPrivate;
class DirAccessWindows : public DirAccess {
-
enum {
MAX_DRIVES = 26
};
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index f1326abb7b..b74e89e2dc 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -49,17 +49,14 @@
#endif
void FileAccessWindows::check_errors() const {
-
ERR_FAIL_COND(!f);
if (feof(f)) {
-
last_error = ERR_FILE_EOF;
}
}
Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
-
path_src = p_path;
path = fix_path(p_path);
if (f)
@@ -83,7 +80,6 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
struct _stat st;
if (_wstat(path.c_str(), &st) == 0) {
-
if (!S_ISREG(st.st_mode))
return ERR_FILE_CANT_OPEN;
};
@@ -99,7 +95,6 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
if (f != INVALID_HANDLE_VALUE) {
String fname = d.cFileName;
if (fname != String()) {
-
String base_file = path.get_file();
if (base_file != fname && base_file.findn(fname) == 0) {
WARN_PRINT("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms.");
@@ -135,7 +130,6 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessWindows::close() {
-
if (!f)
return;
@@ -143,7 +137,6 @@ void FileAccessWindows::close() {
f = nullptr;
if (save_path != "") {
-
bool rename_error = true;
int attempts = 4;
while (rename_error && attempts) {
@@ -185,21 +178,17 @@ void FileAccessWindows::close() {
}
String FileAccessWindows::get_path() const {
-
return path_src;
}
String FileAccessWindows::get_path_absolute() const {
-
return path;
}
bool FileAccessWindows::is_open() const {
-
return (f != nullptr);
}
void FileAccessWindows::seek(size_t p_position) {
-
ERR_FAIL_COND(!f);
last_error = OK;
if (fseek(f, p_position, SEEK_SET))
@@ -207,14 +196,12 @@ void FileAccessWindows::seek(size_t p_position) {
prev_op = 0;
}
void FileAccessWindows::seek_end(int64_t p_position) {
-
ERR_FAIL_COND(!f);
if (fseek(f, p_position, SEEK_END))
check_errors();
prev_op = 0;
}
size_t FileAccessWindows::get_position() const {
-
size_t aux_position = 0;
aux_position = ftell(f);
if (!aux_position) {
@@ -223,7 +210,6 @@ size_t FileAccessWindows::get_position() const {
return aux_position;
}
size_t FileAccessWindows::get_len() const {
-
ERR_FAIL_COND_V(!f, 0);
size_t pos = get_position();
@@ -235,13 +221,11 @@ size_t FileAccessWindows::get_len() const {
}
bool FileAccessWindows::eof_reached() const {
-
check_errors();
return last_error == ERR_FILE_EOF;
}
uint8_t FileAccessWindows::get_8() const {
-
ERR_FAIL_COND_V(!f, 0);
if (flags == READ_WRITE || flags == WRITE_READ) {
if (prev_op == WRITE) {
@@ -259,7 +243,6 @@ uint8_t FileAccessWindows::get_8() const {
}
int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const {
-
ERR_FAIL_COND_V(!f, -1);
if (flags == READ_WRITE || flags == WRITE_READ) {
if (prev_op == WRITE) {
@@ -273,12 +256,10 @@ int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const {
};
Error FileAccessWindows::get_error() const {
-
return last_error;
}
void FileAccessWindows::flush() {
-
ERR_FAIL_COND(!f);
fflush(f);
if (prev_op == WRITE)
@@ -286,7 +267,6 @@ void FileAccessWindows::flush() {
}
void FileAccessWindows::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND(!f);
if (flags == READ_WRITE || flags == WRITE_READ) {
if (prev_op == READ) {
@@ -313,23 +293,19 @@ void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) {
}
bool FileAccessWindows::file_exists(const String &p_name) {
-
FILE *g;
//printf("opening file %s\n", p_fname.c_str());
String filename = fix_path(p_name);
_wfopen_s(&g, filename.c_str(), L"rb");
if (g == nullptr) {
-
return false;
} else {
-
fclose(g);
return true;
}
}
uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
-
String file = fix_path(p_file);
if (file.ends_with("/") && file != "/")
file = file.substr(0, file.length() - 1);
@@ -338,7 +314,6 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
int rv = _wstat(file.c_str(), &st);
if (rv == 0) {
-
return st.st_mtime;
} else {
ERR_FAIL_V_MSG(0, "Failed to get modified time for: " + file + ".");
diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h
index 34a7e400a0..98c0efe576 100644
--- a/drivers/windows/file_access_windows.h
+++ b/drivers/windows/file_access_windows.h
@@ -39,7 +39,6 @@
#include <stdio.h>
class FileAccessWindows : public FileAccess {
-
FILE *f = nullptr;
int flags = 0;
void check_errors() const;
diff --git a/drivers/windows/rw_lock_windows.cpp b/drivers/windows/rw_lock_windows.cpp
index 438f4bf10d..757c7661f5 100644
--- a/drivers/windows/rw_lock_windows.cpp
+++ b/drivers/windows/rw_lock_windows.cpp
@@ -38,17 +38,14 @@
#include <stdio.h>
void RWLockWindows::read_lock() {
-
AcquireSRWLockShared(&lock);
}
void RWLockWindows::read_unlock() {
-
ReleaseSRWLockShared(&lock);
}
Error RWLockWindows::read_try_lock() {
-
if (TryAcquireSRWLockShared(&lock) == 0) {
return ERR_BUSY;
} else {
@@ -57,12 +54,10 @@ Error RWLockWindows::read_try_lock() {
}
void RWLockWindows::write_lock() {
-
AcquireSRWLockExclusive(&lock);
}
void RWLockWindows::write_unlock() {
-
ReleaseSRWLockExclusive(&lock);
}
@@ -75,17 +70,14 @@ Error RWLockWindows::write_try_lock() {
}
RWLock *RWLockWindows::create_func_windows() {
-
return memnew(RWLockWindows);
}
void RWLockWindows::make_default() {
-
create_func = create_func_windows;
}
RWLockWindows::RWLockWindows() {
-
InitializeSRWLock(&lock);
}
diff --git a/drivers/windows/rw_lock_windows.h b/drivers/windows/rw_lock_windows.h
index 3705c1eb38..61dd679d32 100644
--- a/drivers/windows/rw_lock_windows.h
+++ b/drivers/windows/rw_lock_windows.h
@@ -38,7 +38,6 @@
#include <windows.h>
class RWLockWindows : public RWLock {
-
SRWLOCK lock;
static RWLock *create_func_windows();
diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp
index c36437d891..adc3a9a019 100644
--- a/drivers/windows/thread_windows.cpp
+++ b/drivers/windows/thread_windows.cpp
@@ -35,17 +35,14 @@
#include "core/os/memory.h"
Thread::ID ThreadWindows::get_id() const {
-
return id;
}
Thread *ThreadWindows::create_thread_windows() {
-
return memnew(ThreadWindows);
}
DWORD ThreadWindows::thread_callback(LPVOID userdata) {
-
ThreadWindows *t = reinterpret_cast<ThreadWindows *>(userdata);
ScriptServer::thread_enter(); //scripts may need to attach a stack
@@ -60,7 +57,6 @@ DWORD ThreadWindows::thread_callback(LPVOID userdata) {
}
Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
-
ThreadWindows *tr = memnew(ThreadWindows);
tr->callback = p_callback;
tr->user = p_user;
@@ -71,11 +67,9 @@ Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void
return tr;
}
Thread::ID ThreadWindows::get_thread_id_func_windows() {
-
return (ID)GetCurrentThreadId(); //must implement
}
void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
-
ThreadWindows *tp = static_cast<ThreadWindows *>(p_thread);
ERR_FAIL_COND(!tp);
WaitForSingleObject(tp->handle, INFINITE);
@@ -84,7 +78,6 @@ void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
}
void ThreadWindows::make_default() {
-
create_func = create_func_windows;
get_thread_id_func = get_thread_id_func_windows;
wait_to_finish_func = wait_to_finish_func_windows;
diff --git a/drivers/windows/thread_windows.h b/drivers/windows/thread_windows.h
index 93de4c6e8c..502c418ce0 100644
--- a/drivers/windows/thread_windows.h
+++ b/drivers/windows/thread_windows.h
@@ -39,7 +39,6 @@
#include <windows.h>
class ThreadWindows : public Thread {
-
ThreadCreateCallback callback;
void *user;
ID id;
diff --git a/drivers/winmidi/midi_driver_winmidi.cpp b/drivers/winmidi/midi_driver_winmidi.cpp
index 57fb9b0e57..9cbc7f43e2 100644
--- a/drivers/winmidi/midi_driver_winmidi.cpp
+++ b/drivers/winmidi/midi_driver_winmidi.cpp
@@ -35,14 +35,12 @@
#include "core/print_string.h"
void MIDIDriverWinMidi::read(HMIDIIN hMidiIn, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) {
-
if (wMsg == MIM_DATA) {
receive_input_packet((uint64_t)dwParam2, (uint8_t *)&dwParam1, 3);
}
}
Error MIDIDriverWinMidi::open() {
-
for (UINT i = 0; i < midiInGetNumDevs(); i++) {
HMIDIIN midi_in;
@@ -67,7 +65,6 @@ Error MIDIDriverWinMidi::open() {
}
PackedStringArray MIDIDriverWinMidi::get_connected_inputs() {
-
PackedStringArray list;
for (int i = 0; i < connected_sources.size(); i++) {
@@ -87,7 +84,6 @@ PackedStringArray MIDIDriverWinMidi::get_connected_inputs() {
}
void MIDIDriverWinMidi::close() {
-
for (int i = 0; i < connected_sources.size(); i++) {
HMIDIIN midi_in = connected_sources[i];
midiInStop(midi_in);
@@ -100,7 +96,6 @@ MIDIDriverWinMidi::MIDIDriverWinMidi() {
}
MIDIDriverWinMidi::~MIDIDriverWinMidi() {
-
close();
}
diff --git a/drivers/winmidi/midi_driver_winmidi.h b/drivers/winmidi/midi_driver_winmidi.h
index c240c8c7aa..934eb5a493 100644
--- a/drivers/winmidi/midi_driver_winmidi.h
+++ b/drivers/winmidi/midi_driver_winmidi.h
@@ -42,7 +42,6 @@
#include <mmsystem.h>
class MIDIDriverWinMidi : public MIDIDriver {
-
Vector<HMIDIIN> connected_sources;
static void CALLBACK read(HMIDIIN hMidiIn, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index d12ebf8d94..9ff1030165 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -38,7 +38,6 @@ const char *AudioDriverXAudio2::get_name() const {
}
Error AudioDriverXAudio2::init() {
-
active = false;
thread_exited = false;
exit_thread = false;
@@ -85,19 +84,15 @@ Error AudioDriverXAudio2::init() {
}
void AudioDriverXAudio2::thread_func(void *p_udata) {
-
AudioDriverXAudio2 *ad = (AudioDriverXAudio2 *)p_udata;
while (!ad->exit_thread) {
-
if (!ad->active) {
-
for (int i = 0; i < AUDIO_BUFFERS; i++) {
ad->xaudio_buffer[i].Flags = XAUDIO2_END_OF_STREAM;
}
} else {
-
ad->lock();
ad->audio_server_process(ad->buffer_size, ad->samples_in);
@@ -105,7 +100,6 @@ void AudioDriverXAudio2::thread_func(void *p_udata) {
ad->unlock();
for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
-
ad->samples_out[ad->current_buffer][i] = ad->samples_in[i] >> 16;
}
@@ -128,24 +122,20 @@ void AudioDriverXAudio2::thread_func(void *p_udata) {
}
void AudioDriverXAudio2::start() {
-
active = true;
HRESULT hr = source_voice->Start(0);
ERR_FAIL_COND_MSG(hr != S_OK, "Error starting XAudio2 driver. Error code: " + itos(hr) + ".");
}
int AudioDriverXAudio2::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverXAudio2::get_speaker_mode() const {
-
return speaker_mode;
}
float AudioDriverXAudio2::get_latency() {
-
XAUDIO2_PERFORMANCE_DATA perf_data;
xaudio->GetPerformanceData(&perf_data);
if (perf_data.CurrentLatencyInSamples) {
@@ -156,20 +146,17 @@ float AudioDriverXAudio2::get_latency() {
}
void AudioDriverXAudio2::lock() {
-
if (!thread)
return;
mutex.lock();
}
void AudioDriverXAudio2::unlock() {
-
if (!thread)
return;
mutex.unlock();
}
void AudioDriverXAudio2::finish() {
-
if (!thread)
return;
diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h
index 9182fa4172..7fc1bb428d 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.h
+++ b/drivers/xaudio2/audio_driver_xaudio2.h
@@ -41,13 +41,11 @@
#include <xaudio2.h>
class AudioDriverXAudio2 : public AudioDriver {
-
enum {
AUDIO_BUFFERS = 2
};
struct XAudio2DriverVoiceCallback : public IXAudio2VoiceCallback {
-
HANDLE buffer_end_event;
XAudio2DriverVoiceCallback() :
buffer_end_event(CreateEvent(nullptr, FALSE, FALSE, nullptr)) {}