Commit graph

2222 commits

Author SHA1 Message Date
lawnjelly
dcb19ed735 Add Nvidia Workaround for GLES3
Ported GLES2 workaround code to GLES3.
2020-05-07 14:54:14 +01:00
Avril
5e320816f6 fix mistyped setting path 2020-05-07 15:48:43 +02:00
lawnjelly
17bb7af425 GLES3 - add counts for 2d drawcall and 2d items to performance monitor
This had already been implemented for GLES2 but not GLES3.
2020-05-07 11:31:43 +01:00
lawnjelly
bda20edb76 GLES2 Batching - fix item reordering bug
There was a bug in the initial logic for item reordering, whereby it would check for overlaps between the mover (item being moved back) and sandwiched items, but there was no check for overlaps between the movee (item moved forward) and the sandwich items. This extra check is now done.

Also a minor addition to the diagnose frame info (godot texture ID).
2020-05-06 12:55:18 +01:00
Rémi Verschelde
ef715f37d5
Merge pull request #35091 from Faless/dtls/enet
[3.2] DTLS support + optional ENet encryption
2020-05-05 13:40:59 +02:00
Rémi Verschelde
d20485039c
Merge pull request #38453 from lawnjelly/ios_halffloat_hacky
GLES2 disable half-float project setting
2020-05-04 16:29:27 +02:00
Rémi Verschelde
41b836cb3d
Merge pull request #38450 from lawnjelly/shaper_modulate
GLES2 batching - prevent color baking with MODULATE or COLOR
2020-05-04 15:13:35 +02:00
lawnjelly
30a3f16e34 GLES2 disable half-float project setting
It seems that particles (and some other features) do not work correctly on iOS in GLES2 because either many of the devices do not support half float compression, or the GL constant used to reference it from Godot is incorrect.

This PR adds a project setting in rendering/gles2/ to disable half-float compression on iOS.
2020-05-04 13:11:23 +01:00
lawnjelly
b08ad9ef64 GLES2 batching - prevent color baking with MODULATE or COLOR
Adding the ability to access MODULATE in the shader breaks when final_modulate is baked into vertex colors (this is a technique used to batch together different colored items). This PR prevents baking vertex colors when MODULATE is detected in the shader.

It also prevents baking when COLOR is read in canvas shaders, which could currently produce the wrong result in the shader if colors were baked. It does not prevent baking if COLOR is only written, which happens in most shaders, and will operate correctly without baking.
2020-05-04 11:19:55 +01:00
Pedro J. Estébanez
d8be5a9986 Add MODULATE builtin to canvas item shaders 2020-05-04 00:10:24 +02:00
Rémi Verschelde
01a085d05f
Merge pull request #38320 from lawnjelly/kessel_pr_light_join
GLES2 2D batching - item reordering, light joining and light modulate fix
2020-05-01 15:03:03 +02:00
lawnjelly
451c3fc0fb GLES2 2D batching - item reordering, light joining and light modulate fix
Although 2D draws in painters order with strict ordering, in certain circumstances items can be reordered to increase batching / decrease state changes, without affecting the end result. This can be determined by an overlap test.

In situation with item:
A-B-A
providing the third item does not overlap the second, they can be reordered:
A-A-B

Items already contain an AABB which can be used for this overlap test.

1)
To utilise this, I have implemented item reordering (only for single rects for now), with the lookahead adjustable in project settings. This can increase performance in situations where items may not be grouped in the scene tree by texture. It can also be switched off (by setting lookahead to 0).

2)
This same trick can be used to help join items that are lit. Lit items previously would prevent joining completely, thus missing out on performance gains other than multi-command items such as tilemaps.

In this PR, lights are assigned as bits in a bitfield (up to 64, the optimization is disabled above this), and on each try_item (for joining), the bitfield for lights and shadows is constructed and compared with the previous items. If these match the 2 items can potentially be joined. However, this can only be done without changing the rendered result if an overlap test is successful.

This overlap test can be adjusted to join items up to a specific number of item references, selectable in project settings, or turned off.

3)
The legacy uniform single rect drawing routine seems to have been identified as the source of flicker, particularly on nvidia. However, it can also be up to 2x as fast. Because of the speed the batching contains a fallback where it can use the legacy single rect method, but I have now added a project setting to make this switchable. In most cases with batching it should not be necessary (as single rects are drawn less frequently) and thus the flickering can be totally avoided.

4)
This PR also fixes a color modulate bug when drawing light passes, in certain situations (particularly custom _draw routines with multiple rects).

5)
This PR also fixes #38291, a bug in the legacy renderer where light passes could draw rects in wrong position.
2020-05-01 07:47:33 +01:00
Pedro J. Estébanez
7cc0f181c9 Improve shader time roll over
- Resurrect it for GL ES 2
- Apply roll over with `fmod()` instead of resetting it to 0
- Expose the setting from the `VisualServer`, since it does not belong in any specific rasterizer
2020-04-29 22:33:03 +02:00
Rémi Verschelde
f2150d1766
Merge pull request #37462 from Chaosus/shader_fix_const_order
[3.2] Fix shader constant sorting
2020-04-29 09:41:49 +02:00
Fredia Huya-Kouadio
7c559afe29 Restrict GL_TEXTURE_EXTERNAL_OES to Android platform 2020-04-27 10:18:31 -07:00
Hugo Locurcio
708184c402 Add more extensions to the dummy texture loader
This should make headless exporting work in projects using textures
in any format.

Error messages should no longer appear when running a project
that used image formats that were previously not present in the list.

(cherry picked from commit 3007c7e2a3)
2020-04-27 10:09:17 +02:00
Rémi Verschelde
0233b7e51f
Merge pull request #38251 from clayjohn/GLES2-shader-defines
Avoid duplicating shader defines in GLES2
2020-04-27 08:47:46 +02:00
clayjohn
782fd5fab6 Avoid duplicating shader defines in GLES2 2020-04-26 23:28:24 -07:00
lawnjelly
a75c1ed1df GLES2 Batching fix canvas texscreen (SCREEN_TEXTURE)
When reading SCREEN_TEXTURE in a shader, this previously only worked succesfully for the first read of the screen, because state.canvas_texscreen_used was never getting reset. This PR resets state.canvas_texscreen_used at the beginning of each joined item, so that further screen reads can happen.
2020-04-25 13:40:43 +01:00
lawnjelly
b954a8c099 Fix batching z_indices with z ranged lights
Joining items across z_indices can interfere with light culling for lights which only affect certain z ranges. This PR disables joining across z_indices when lights are present, except specifically for lights with both z_min set to the global minimum (-4096) and z_max set to the global maximum (4096).

In addition, the z_index is now stored on the joined_item for accurate light culling. The z_index is also displayed in frame diagnostics.
2020-04-23 11:58:06 +01:00
Rémi Verschelde
3b44f34166
Merge pull request #38114 from lawnjelly/kessel_rulerfix
Fix batch translate to colored synchronization error
2020-04-22 21:42:00 +02:00
lawnjelly
54cd6d3077 Fix batch translate to colored synchronization error
In rare circumstances default batches were being joined incorrectly, causing visual regressions. This logic has been fixed.

In addition slightly more output information has been added to frame diagnosis mode.
2020-04-22 18:52:42 +01:00
Rémi Verschelde
ade57c4bf0
Merge pull request #38099 from clayjohn/GLES2-skeleton-rebind
Rebind material when skeleton changes in GLES2
2020-04-22 08:23:43 +02:00
clayjohn
6f322af3fb Rebind material when skeleton changes in GLES2 2020-04-21 17:46:40 -07:00
clayjohn
7fc2cba47d Use proper depth buffer format for rgba shadows
(cherry picked from commit 123dd390e4)
2020-04-21 14:15:49 +02:00
lawnjelly
a9ae0fac86 Fixes incorrectly joining batch items from earlier z_index layers
Batching across z_index layers was not preserving the batch_break flag, which determines whether to not join the previous item. This is fixed by storing the flag in RenderItemState and preserving it across canvas_render_items calls.
2020-04-19 19:32:14 +01:00
Rémi Verschelde
008e0748c1
Merge pull request #37349 from lawnjelly/kessel32_1
GLES2 2d Batch rendering (across items)
2020-04-17 12:55:33 +02:00
lawnjelly
72adefa5cf Add frame diagnostics for GLES2 Batch renderer
Added project setting to enable / disable print frame diagnostics every 10 seconds. This prints out a list of batches and info, which is useful to optimize games and identify performance problems.
2020-04-17 08:54:33 +01:00
lawnjelly
b6d652367b Items and draw calls added to IDE Monitor in '2d' section
This adds 2 new values (items and draw calls) to the performance monitor in a '2d' section, rather than reusing the 3d values in the 'raster' section.

This makes it far easier to optimize games to minimize drawcalls.
2020-04-16 11:52:22 +01:00
lawnjelly
a4cd274ca7 Batching with Extra Matrix commands
Defers sending 'transform' commands within a RasterizerCanvas::Item until they are needed for default batches. Instead locally caches the extra matrix and applies it using software transform, preventing unnecessary batch breaks.

The logic is relatively complex, and the whole 'extra matrix' of the legacy renderer in addition to the final_transform is not ideal. However this is required to accelerate some user drawing techniques, and later the lines in the IDE.
2020-04-15 12:48:36 +01:00
lawnjelly
93af8e7d1b Batching across z_indices
Extra functions canvas_render_items_begin and canvas_render_items_end are added to RasterizerCanvas, with noop stubs for non-GLES2 renderers. This enables batching to be spready over multiple z_indices, and multiple calls to canvas_render_items.

It does this by only performing item joining within canvas_render_items, and deferring rendering until canvas_render_items_end().
2020-04-12 13:52:25 +01:00
Rémi Verschelde
4dadec331e
Merge pull request #37815 from clayjohn/reset-sky-flags
Reset texture flags after radiance map generation
2020-04-12 11:35:07 +02:00
clayjohn
193b0bf1e3 Reset texture flags after radiance map generation 2020-04-11 16:10:34 -07:00
lawnjelly
1fb6181ba6 Revert to default Rect drawing code for single rects
Determined that a large reason for the decrease in performance in unbatchable scenes was due to the new routine being analogous to the 'nvidia workaround' code, that is about half the speed. So this simply uses the old routine in the case of single unbatchable rects. Hopefully we will be able to remove the old path at a later stage.
2020-04-11 17:40:30 +01:00
clayjohn
4d32652851 Avoid material rebind when using skeleton 2020-04-07 10:35:58 -07:00
lawnjelly
e7bec77ef3 Bake final_modulate uniform into vertex colors
Where the final_modulate color varies between render_items this can prevent batching. This PR solves this by baking final_modulate into the vertex colors, and setting the uniform 'final_modulate' to white, and allowing the joining of items that have different final_modulate values. The previous batching system can then cope with vertex color changes as normal.
2020-04-06 12:49:47 +01:00
lawnjelly
45b0b8bff8 GLES2 2d Batch rendering (across items)
2d rendering is currently bottlenecked by drawing primitives one at a time, limiting OpenGL efficiency. This PR batches primitives and renders in fewer drawcalls, resulting in significant performance improvements. This also speeds up text rendering.

This PR batches across canvas items as well as within items.

The code dynamically chooses between a vertex format with and without color, depending on the input data for a frame, in order to optimize throughput and maximize batch size. It also adds an option to use glScissor to reduce fillrate in light passes.
2020-04-04 17:13:58 +01:00
Pedro J. Estébanez
21703aefee Fix res:// trimmed to s:// on Windows 2020-04-01 10:22:05 +02:00
Yuri Roubinsky
ee93c85ef1 Fix shader constant sorting 2020-03-31 14:32:33 +03:00
Rajat Goswami
19e71f94d8 Adding missing include guards to header files identified by LGTM.
This addresses the issue godotengine/godot#37143

(cherry picked from commit 2ecf928ae3)
2020-03-25 11:38:54 +01:00
Rémi Verschelde
cc70b2fa0a
Merge pull request #36342 from m4gr3d/external_texture_support_for_godot_3_2
Add support for opengl external textures
2020-03-17 16:29:14 +01:00
Rémi Verschelde
c01e840f03
Merge pull request #36639 from RandomShaper/imvu/improve_drives_ux_3.2
Improve UX of drive letters (3.2)
2020-03-17 16:27:33 +01:00
Pedro J. Estébanez
6105dfdac9 Improve UX of drive letters
Namely, move the drive dropdown to just the left of the path text box and don't include the former
in the latter.

This improves the UX on Windows.

In the UNIX case, since its concept of drives is (ab)used to provide shortcuts to useful paths, its
dropdown is kept at the original location.
2020-03-17 14:48:54 +01:00
fhuya
30d738eda7 Add support for opengl external textures as defined by https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt 2020-03-05 13:09:49 -08:00
Mateo Dev .59
d6c94fd527 os: execute parse the command output from utf8
(cherry picked from commit 8a88637705)
2020-03-04 12:40:15 +01:00
Fabio Alessandrelli
6b9240aa84 Add peek option to NetSocket recv_from. 2020-02-25 11:26:34 +01:00
Twarit
6d78636163 Remove unused driver/dummy/audio_driver_dummy.h
(cherry picked from commit 04882a481b)
2020-02-20 08:00:34 +01:00
Fabio Alessandrelli
ec4abf421a Disable NetSocket reuse address on Windows.
It actually means reuse port -.- ...

(cherry picked from commits cae0d8853d
and 19ef28a614)
2020-02-20 07:57:50 +01:00
Yuri Roubinsky
786b1cc7ff Fix shader crash if using multiple underscores in identifier names
(cherry picked from commit 15358b808b)
2020-02-06 13:02:07 +01:00
clayjohn
eb5cb5d016 Add project setting for max irradiance size 2020-01-25 13:27:13 -08:00
Eric Rybicki
3d4a2a09f6 Fix Softbody always spawns from world center [gles2]
Fixes #35373
2020-01-24 09:25:05 +01:00
clayjohn
3631a3cc9e Fix recently introduced crash in viewport size 2020-01-23 08:11:01 -08:00
Hugo Locurcio
90a1f8d8a7
Make OS.execute() blocking by default if not specified
This makes `OS.execute()` calls quicker to set up when calling programs
in a blocking fashion.
2020-01-23 01:26:32 +01:00
Rémi Verschelde
a8460bffd2
Merge pull request #35414 from Ovnuniarchos/AlsaMidiBadPitchBend
ALSA MIDI: Pitch bend and System Common messages
2020-01-22 22:12:57 +01:00
Rémi Verschelde
37897dba80
Merge pull request #35406 from lawnjelly/ortho-shadow
Replace CameraMatrix::get_viewport_size with get_viewport_half_extents, shadow culling with ortho camera and other affected issues
2020-01-22 22:02:09 +01:00
Ovnuniarchos
9c48eb1c59 ALSA MIDI driver:
Pith bend message now has correct size (was 2 bytes instead of 3).
	Recognized (but not implemented) 0xF? messages. SysEx messages will be reocognized as such, but their contents will be ignored.
2020-01-22 21:41:48 +01:00
lawnjelly
eaf8e5ce52 Change CameraMatrix::get_viewport_size to get_viewport_half_extents
Fixes #26637.
Fixes #19900.

The viewport_size returned by get_viewport_size was previously incorrect, being half the correct value. The function is renamed to get_viewport_half_extents, and now returns a Vector2.

Code which called this function has also been modified accordingly.

This PR also fixes shadow culling when using ortho cameras, because the correct input for CameraMatrix::set_orthogonal should be the full HEIGHT from get_viewport_half_extents, and not half the width.

It also fixes state.ubo_data.viewport_size in rasterizer_scene_gles3.cpp to be the width and the height of the viewport in pixels as stated in the documentation, rather than the current value which is half the viewport extents in worldspace, presumed to be a bug.
2020-01-22 18:22:00 +00:00
Rémi Verschelde
00284a75e8 GLES3: Fix invalid value for GL_TEXTURE_MAG_FILTER parameter
`GL_LINEAR_MIPMAP_LINEAR` can be used for `GL_TEXTURE_MIN_FILTER`,
but not for `GL_TEXTURE_MAG_FILTER`.

Cf. https://www.khronos.org/opengl/wiki/GLAPI/glTexParameter

Fixes #35436.
2020-01-22 15:18:56 +01:00
Rémi Verschelde
4faaf6089a Remove unused #if 0'ed code 2020-01-21 21:41:54 +01:00
Rémi Verschelde
837adb30fd Revert "Exposes capture methods to AudioServer + documentation" #30468
Reverts the following commits:

- c81ec6f26d:
  "Exposes capture methods to AudioServer, variable renames for
  consistency, added documentation."
- 47c558b98a:
  "Expose audio callbacks as signals."
- dabaa11b3c:
  "Fix to make sure the capture buffers are deallocated at shutdown.
  Silences warnings."

Some documentation improvements were kept for pre-existing methods.

See rationale for reverting these changes in #30468.
2020-01-20 13:18:01 +01:00
Rémi Verschelde
90a224c6eb
Merge pull request #35310 from akien-mga/gles3-irradiance-small-optimization
GLES3: Slight optimization to irradiance compute
2020-01-19 18:55:51 +01:00
Rémi Verschelde
4d052e51a2
Merge pull request #35302 from clayjohn/GLES3-env-map
Reduce complexity of irradiance map generation
2020-01-19 12:39:36 +01:00
Rémi Verschelde
dc4db4ab45 GLES3: Slight optimization to irradiance compute
All the calculations leading up to `mipLevel` are only relevant for
Panorama mode. Similarly, the `source_resolution` uniform is only
needed for that mode.
2020-01-19 11:03:11 +01:00
Rémi Verschelde
43caf83c09
Merge pull request #35284 from Ovnuniarchos/MidiNoReopen
Alsa MIDI input thread gets properly reinitialized on open_midi_input.
2020-01-19 09:34:38 +01:00
clayjohn
0979411cad reduce complexity of irradiance map generation 2020-01-18 16:51:52 -08:00
Ovnuniarchos
af95554aff Alsa MIDI input thread gets properly reinitialized on open. 2020-01-18 15:59:59 +01:00
Rémi Verschelde
669cd46495
Merge pull request #35215 from clayjohn/multimesh-error
Add multimesh format max for proper error checking
2020-01-16 23:06:20 +01:00
clayjohn
041fa57a88 Add multimesh format max for proper error checking 2020-01-16 13:31:17 -08:00
clayjohn
f3af81b059 Gracefully handle 3D textures in GLES2 2020-01-16 11:28:14 -08:00
Yuri Roubinsky
5098232ee6 Disabled array initialization, const array and arr.length in shaders 2020-01-16 11:46:11 +03:00
Rémi Verschelde
3af0400a32
Merge pull request #35176 from clayjohn/csg-crash
Fix light related crashes
2020-01-16 08:03:56 +01:00
Rémi Verschelde
318445c548
Merge pull request #35178 from clayjohn/GLES2-fix-lightmap
Fix array constructor for lightmaps
2020-01-16 07:47:49 +01:00
clayjohn
f1d0c391c7 fix light related crashes 2020-01-15 21:40:05 -08:00
clayjohn
910f8719a0 Fix array constructor for lightmaps 2020-01-15 17:41:46 -08:00
clayjohn
a345088433 Add background mode keep to GLES2 2020-01-15 15:59:00 -08:00
Rémi Verschelde
8130decfe4
Merge pull request #35064 from clayjohn/rendering_crashes
Fix light and multimesh crashes
2020-01-13 09:13:18 +01:00
clayjohn
179193775b Fix light and multimesh crashes 2020-01-12 17:45:06 -08:00
clayjohn
796d35d8b3 Fix generation of irradiance map 2020-01-12 14:45:31 -08:00
Rémi Verschelde
815bf761a5 RasterizerCanvas: Use getornull to fetch light occluder polygon
Fixes #21286 when the occluder is not fully configured.
2020-01-08 11:29:15 +01:00
Rémi Verschelde
377ae2af97
Merge pull request #34808 from Calinou/no-color-in-non-tty
Disable colored console output when standard output isn't a TTY
2020-01-06 16:39:47 +01:00
Hugo Locurcio
0cad2c0cd1
Add VisualServer methods to get the video adapter name and vendor
These methods can be used in scripts to retrieve the OpenGL
`GL_RENDERER` and `GL_VENDOR` strings (respectively).

This closes #28404.
2020-01-06 00:37:56 +01:00
Hugo Locurcio
785af45d8e
Disable colored console output when standard output isn't a TTY
This prevents Godot from writing ANSI escape codes when redirecting
stdout and stderr to a file.
2020-01-04 04:04:08 +01:00
Rémi Verschelde
94658de1ff
Merge pull request #34794 from clayjohn/GLES2-trimesh-crash
Fix crash on trimesh_create
2020-01-03 22:53:57 +01:00
clayjohn
906b5e7f3f Fix crash on trimesh_create by making surface->data available in non-tool builds 2020-01-03 13:39:40 -08:00
Rémi Verschelde
fa82664419
Merge pull request #34726 from nekomatata/polygon2d-antialiasing-fix
Fixed antialiasing option for Polygon2D with concave/hollow shapes
2020-01-03 14:17:05 +01:00
Rémi Verschelde
2d6586ec78
Merge pull request #34551 from MadEqua/fix-light-with-skeleton
Fix 2D lighting when using skeleton.
2020-01-03 08:32:29 +01:00
Tritium Oxide
bb6f04c9f5
Fix wrong return type
`ERROR: _display_error_with_code: CanvasShaderGLES3: Fragment Program Compilation Failed:
0:166(2): error: `return' with wrong type int, in function `map_ninepatch_axis' returning float`  caused by #34704
2020-01-01 19:14:51 +07:00
Rémi Verschelde
e4907e50fe GLES3: Fix false positive in ninepatch axis stretch code
See #34704.
2020-01-01 11:49:58 +01:00
PouleyKetchoupp
1591677eb8 Fixed antialiasing option for Polygon2D
Some cases were not handled properly for Polygon2D after making changes in common code to fix Line2D antialiasing. Added an option for drawing polygons to differentiate the two use cases.

Fixes #34568
2020-01-01 11:40:14 +01:00
Rémi Verschelde
a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Rémi Verschelde
162bebcafa
Merge pull request #34647 from madmiraal/pulse-audio-null-pointer
Check for null pointer in PulseAudio server info callback.
2019-12-30 17:41:28 +01:00
Rémi Verschelde
a96c95f1ef
Merge pull request #34685 from winston-yallow/fix_omnilight_attenuation
Use correct omni light attenuation
2019-12-30 16:11:58 +01:00
Winston
c9fe11dec1
Use correct omni light attenuation
fixes godotengine/godot#34683
2019-12-29 17:22:34 +01:00
Bruno Lourenço
16429a4289 Reset GLES3 MultiMesh buffer id when reallocating. 2019-12-28 18:38:25 +00:00
Marcel Admiraal
32eccb87e0 Check for null pointer in PulseAudio server info callback. 2019-12-28 08:38:29 +01:00
Bruno Lourenço
65195f505f Fix canvas GLES3 skeleton transform uniform updating. 2019-12-23 18:40:48 +00:00
Bruno Lourenço
f26c9d650b Fix 2D lighting when using skeleton. 2019-12-23 00:00:18 +00:00
Rémi Verschelde
e21872f4b9
Merge pull request #34527 from MadEqua/fix-gles3-light-cutoff
Fix GLES3 light cutoff.
2019-12-21 23:40:15 +01:00
Bruno Lourenço
d47374385c Fix GLES3 light cutoff. 2019-12-21 20:52:54 +00:00
Bruno Lourenço
d7f9d71be2 Fix contact shadow when light is outside of viewport. 2019-12-21 16:55:41 +00:00