Commit graph

81 commits

Author SHA1 Message Date
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
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
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
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 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
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
Bojidar Marinov eec7702711
Flip cull mode when rendering flipped Light2D and LightOccluder2D
Fixes #32993
2019-12-11 23:28:35 +02:00
PouleyKetchoupp e6ebc43d72 Fixed antialiased option for Polygon2D / Line2D
Polygon2D:
The property wasn't used anymore after switching from canvas_item_add_polygon() to canvas_item_add_triangle_array() for drawing.

Line2D:
Added the same property as for Polygon2D & fixed smooth line drawing to use indices correctly.

Fixes #26823
2019-11-28 22:57:27 +01:00
Rémi Verschelde 083d088de3
Merge pull request #33583 from qarmin/fix_overflows_unitialized
Fix some overflows and unitialized variables
2019-11-20 21:31:12 +01:00
Rafał Mikrut 99d8626f4a Fix some overflows and unitialized variables 2019-11-20 16:22:16 +01:00
clayjohn 1253a33423 Improve glBufferSubData usage where safe 2019-11-11 16:38:41 -08:00
Rémi Verschelde 47389c3a16 Partial revert of #32657, undoing line shifting by 0.5
As discussed in #32657, this can't be done here as lines can be used
with a canvas scale, and this breaks them.
A suggestion is to do the pixel shifting at matrix level instead.

Fixes #33393.
Fixes #33421.
2019-11-07 15:43:04 +01:00
Rémi Verschelde 3eb8bd08ec
Merge pull request #32657 from ptrojahn/lines
Fix draw_rect
2019-10-26 23:09:24 +02:00
Paul Trojahn bdaedb601c Fix draw_rect
OpenGL uses the diamond exit rule to rasterize lines. If we don't shift
the points down and to the right by 0.5, the line can sometimes miss a
pixel when it shouldn't. The final fragment of a line isn't drawn. By
drawing the lines clockwise, we can avoid a missing pixel in the rectangle.
See section 3.4.1 in the OpenGL 1.5 specification.
Fixes #32279
2019-10-11 10:26:53 +02:00
Valentin Zagura 6ee84f53a9 GLES2 Fixes for ninepatch margins when patch size is smaller than the patch texture resolution..
Scaled ninepatch margins in screen space to be relative of the ninepatch size when the patch size is smaller than the patch texture resolution.
2019-09-17 09:51:54 +01:00
Braden Bodily 71d71d55b5 Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in 'core/' and 'editor/'
Condensed some if and ERR statements. Added dots to end of error messages

Couldn't figure out EXPLAINC. These files gave me trouble: core/error_macros.h, core/io/file_access_buffered_fa.h (where is it?),
core/os/memory.cpp,
drivers/png/png_driver_common.cpp,
drivers/xaudio2/audio_driver_xaudio2.cpp (where is it?)
2019-08-17 12:33:15 +02:00
RaphaelHunter 48f28c68bc fix gles2 canvas shader uniform error,close #31201 2019-08-10 21:52:51 +08:00
Hugo Locurcio 707ce08cdd
Implement CanvasItem line antialiasing in GLES2
This is a straight copy-paste of the code from
`drivers/gles3/rasterizer_canvas_gles3.cpp`. It is subject to the
same restrictions as the GLES3 implementation: it only works
on desktop platforms as they use OpenGL instead of OpenGL ES.
2019-07-12 16:49:12 +02:00
clayjohn 2b8b1d7c46 added MultiMeshInstance2D node for using MultiMesh in 2D 2019-06-03 12:11:54 -07:00
clayjohn 65c211d303 Implement ability to render viewports directly to screen 2019-05-13 15:20:15 -07:00
Rémi Verschelde c8994b56f9 Style: Apply new changes from clang-format 8.0
It seems to stay compatible with formatting done by clang-format 6.0 and 7.0,
so contributors can keep using those versions for now (they will not undo those
changes).
2019-04-09 17:09:48 +02:00
marxin e7f22ebdcd Enable warnings=extra on clang and GCC testers.
And remove 2 warnings from warnings=extra.
2019-04-02 17:14:47 +02:00
Juan Linietsky 34dd772054 Properly redraw if something animated is visible 2019-03-03 13:43:54 -03:00
Juan Linietsky 8a9119ad7f Fix non initialized variable. 2019-03-01 16:45:38 -03:00
marxin e5f665c718 Fix -Wsign-compare warnings.
I decided to modify code in a defensive way. Ideally functions
like size() or length() should return an unsigned type.
2019-02-27 07:45:57 +01:00
Juan Linietsky a32b26dfa2 Several fixes to make GLES2 on HTML5 work much better.
Changed math class error reporting to be a bit less paranoid.
2019-02-25 21:47:29 -03:00
Juan Linietsky 74d0ed2236 Many separate fixes to ensure non power of 2 textures work on GLES2, closes #25897 and many others 2019-02-24 22:36:53 -03:00
Juan Linietsky aab8f443f9 -Support DEPTH_TEXTURE in GLES2, fixes #25106
-Fix use of transparent framebuffers in GLES2
-Fix use of ambient color clearing in GLES2 when no environment exists.
2019-02-22 11:35:39 -03:00
Juan Linietsky 5784caae73 Make alpha 1.0 when using texscreen, fixes #25850 2019-02-21 19:43:34 -03:00
marxin 8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
Rémi Verschelde 5aff990354 Fix infinite recursion in GLES2 _copy_texscreen
Bug introduced in 9430e68cf3,
likely a typo.
2019-02-12 23:38:33 +01:00
Juan Linietsky 9430e68cf3 Support SCREEN_TEXTURE in GLES2, fixes #25405 2019-02-12 18:49:57 -03:00
Juan Linietsky 0d0d074c4d Use UVs with the nvidia rendering hack, fixes #24563 2019-02-12 15:31:10 -03:00
Juan Linietsky 8fd6a02d3e Missing canvas end left mask turned on, fixes #25666 2019-02-12 09:55:22 -03:00
Juan Linietsky 953cd03ea6 Use transparent framebuffer only when set to transparent, closes #21827 2019-01-27 15:47:17 -03:00
Juan Linietsky 7fa41f17a6 Makes screen texture work in GLES2 (2D for now), fixes #23604 2019-01-24 17:00:33 -03:00
Juan Linietsky 682fdf0f74 Use 16 bit indices on phones that dont support 32, fixes #19797 2019-01-18 17:30:12 -03:00
Juan Linietsky 7478f468b2 Fixes to 2D lights, closes #24750 2019-01-17 10:40:36 -03:00
Juan Linietsky ffcb5cd18c Ensure texture hints are obeyed, fixes #24875 2019-01-16 00:37:00 -03:00
Rémi Verschelde 72f501de13 GLES2: Fix typo in project setting
It used a different name than the equivalent GLES3 parameter.
2019-01-15 13:26:54 +01:00
Juan Linietsky ee3eadf345 Implement black margins in GLES2, which was missing, fixes #24556 2019-01-14 19:00:36 -03:00
Rémi Verschelde 02ffc59270 GLES2: Make Nvidia flicker workaround opt-in
It has a big impact on 2D and text rendering performance (cf. #24466)
so the solution seems worse than the bug it aims to work around.

It's now opt-in via "rendering/quality/2d/gles2_use_nvidia_rect_flicker_workaround"
for those who need it and have a simple enough game for the performance
drop not to be an issue.

Fixes #24466.
2019-01-14 19:02:07 +01:00
Juan Linietsky b3dc02b5df Was not properly re-setting light uniforms, fixes #24976 2019-01-14 12:04:26 -03:00
Juan Linietsky 6d8083ea65 Do not use the workaround for desktop nvidia on mobile and html5. 2019-01-14 11:24:00 -03:00
Daeil Kim ecf520b70e Change blend equation for canvasitems 2019-01-06 00:57:52 +09:00
Marcin Zawiejski 4e73274837
Fix negative size rectangle drawing
Fixes rectangle being drawn as it was a non-negative size in case it actually is. This can be observed e.g. when drawing a negative size selection rectangle (i.e. press mouse button and move cursor up and left).
2019-01-02 14:47:28 +01:00