Commit graph

2580 commits

Author SHA1 Message Date
Max Hilbrunner a5c179e4f8 FileAccessWindows: Cosmetic improvements 2021-08-09 14:43:09 +02:00
Max Hilbrunner b48cbb5da9 Fix Windows platform file access
This restores Windows platform file handling back to open files non-exlusively by default, as was the case before October 2018. (See b902a2f2a7)
Back then, while fixing warnings for MSVC, the function used for opening files was changed from _wfopen() to _wfopen_s() as suggsted by the warning C4996. ("This function may be unsafe, consider using _wfopen_s instead.")

This new function
1. did parameter validation and thus avoided some possible security issues due to nil pointers or wrongly terminated strings
2. it also changed the default file sharing for opened files from _SH_DENYNO (which was the implicit default for the previous _wfopen()) to _SH_SECURE.

_SH_DENYNO means every opened file could be opened by other calls (like is the default on other operating systems).
_SH_SECURE means if the file is opened with READ access, others can still read the same file, but if it is opened with WRITE access, others can't open it at all, not even to read.

This led to rarely occuring bugs on Windows, i.e. due to random access by Antivirus processes, or Godot/Windows not closing a file handle fast enough while trying to open it again elsewhere (i.e. project.godot, instead showing the Project manager, or saving shaders/debugging the game).

What this PR does it change the file access to a third method, _wfsopen(). This is still secure, doing parameter validation and thus avoids the warning, but it allows us to actually SET the file sharing parameter. And we set it to _SH_DENYNO, as it was implicitely before the change. (And as it currently is on all non-Windows platforms, where file sharing restrictions don't exist by default.)

Warning C4996 should really have been pointing this out. It should've been _wfsopen() all along. Let's hope this banishes those annoying, rare errors for all eternity.

Fixes #28036.
2021-08-09 14:41:38 +02:00
Bastiaan Olij b920bf05a4 Use subpasses to do 3D rendering and resolve in mobile renderer 2021-08-06 23:43:26 +10:00
Rémi Verschelde a12f832060
Merge pull request #51103 from Calinou/vulkan-detect-intel-title-case
Use title case instead of uppercase for Vulkan Intel GPU detection
2021-07-31 21:19:30 +02:00
Rémi Verschelde 00ce2d41ca
Merge pull request #51108 from Calinou/vulkan-print-verbose
Move Vulkan debugging prints to verbose
2021-07-31 20:48:54 +02:00
Hugo Locurcio 1bf402c061
Use title case instead of uppercase for Vulkan Intel GPU detection
This matches how the vendor name is displayed in most places.

The Apple GPU vendor was also added for the M1.
2021-07-31 16:43:54 +02:00
Hugo Locurcio 500ba02e90
Move Vulkan debugging prints to verbose
These messages can now be displayed in release builds if the
`--verbose` command line argument is specified, which is useful for
troubleshooting.
2021-07-31 16:28:35 +02:00
Hugo Locurcio 5920bc32c3
Print the Vulkan device name in release builds too
This is important information to include in bug reports for exported
projects, and is consistent with the behavior found in the GLES3 and
GLES2 renderers in `3.x`.
2021-07-31 14:31:31 +02:00
Rémi Verschelde 8f6c16e4a4
Merge pull request #50847 from reduz/implement-binary-shader-compilation
Implement Binary Shader Compilation
2021-07-26 17:09:48 +02:00
reduz cf3f404d31 Implement Binary Shader Compilation
* Added an extra stage before compiling shader, which is generating a binary blob.
* On Vulkan, this allows caching the SPIRV reflection information, which is expensive to parse.
* On other (future) RenderingDevices, it allows caching converted binary data, such as DXIL or MSL.

This PR makes the shader cache include the reflection information, hence editor startup times are significantly improved.
I tested this well and it appears to work, and I added a lot of consistency checks, but because it includes writing and reading binary information, rare bugs may pop up, so be aware.
There was not much of a choice for storing the reflection information, given shaders can be a lot, take a lot of space and take time to parse.
2021-07-26 08:40:39 -03:00
luz paz 5cf3bed0c8 Fix various typos
Follow-up typos found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-25 07:18:25 -04:00
Rémi Verschelde ff0b5f8fa1
Merge pull request #50809 from akien-mga/iterators-const-references 2021-07-25 12:52:58 +02:00
Rémi Verschelde ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
luz paz 3564c16cb8
Fix various typos with codespell
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-25 11:21:51 +02:00
Rémi Verschelde 2b1e6e303e
Merge pull request #50786 from reduz/implement-resource-uids
Implement Resource UIDs
2021-07-24 17:18:12 +02:00
reduz 32b43cfeb3 Implement Resource UIDs
* Most resource types now have unique identifiers.
* Applies to text, binary and imported resources.
* File formats reference both by text and UID (when available). UID always has priority.
* Resource UIDs are 64 bits for better compatibility with the engine.
* Can be represented and used textually, example `uuid://dapwmgsmnl28u`.
* A special binary cache file is used and exported, containing the mappings.

Example of how it looks:

```GDScript
[gd_scene load_steps=2 format=3 uid="uid://dw86wq31afig2"]

[ext_resource type="PackedScene" uid="uid://bt36ojelx8q6c" path="res://subscene.scn" id="1_t56hs"]
```

GDScript, shaders and other special resource files can't currently provide UIDs, but this should be doable with special keywords on the files.
This will be reserved for future PRs.
2021-07-24 09:16:52 -03:00
Aaron Franke 4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
bruvzg 618eb27e8b Move alert function from DisplayServer to OS. 2021-07-22 21:50:35 +03:00
bruvzg 53f84e39fd Fix MoltenVK static linking on macOS (add missing include path, Vulkan SDK path option, use xcframework instead of static framework). 2021-07-22 16:29:24 +03:00
reduz 76e25438c9 Fixes to forward mobile
* use valid format for framebuffer: VK_FORMAT_A2B10G10R10_UNORM_PACK32
* Unfortunately cant be used for compute.
* Mobile will need to do refprobe, sky, mipmapblurring using raster.
2021-07-15 21:05:58 -03:00
reduz ad9f606ed8 Use specialization constants in clustered renderer
* Keep track of when projector, softshadow or directional sofshadow were enabled.
* Enable them via specializaton constant where it makes sense.
* Re-implements soft shadows.
* Re-implements light projectors.
2021-07-12 20:33:52 -03:00
reduz b2f6db7aa8
Implement Specialization Constants
* Added support to our local copy of SpirV Reflect (which does not support it).
* Pass them on render or compute pipeline creation.
* Not implemented in our shaders yet.
2021-07-11 23:16:09 +02:00
Hugo Locurcio a2d5f191d8
Merge pull request #48622 from Geometror/reimplement-disableable-vsync 2021-07-10 01:02:23 +02:00
reduz 83addd6ee5 Fix material invalidation on reimport.
* IF a texture was reimported (calling replace as an example), it would invalidate all materials using it, causing plenty of errors.
* Added the possibility to get a notification when a uniform set is erased.
* With this notification, materials can be queued for update properly.
2021-07-07 19:55:20 -03:00
reduz 24efb13f7e Fix threaded update for textures
* Previews and other stuff now works again.
* Not the best solution, will have to be improved in the future usinc async queues where supported.
2021-07-07 18:06:06 -03:00
Hendrik Brucker 043ae91560 Restructure and reimplement vsync options
-Add a v-sync mode setting which allows to choose between DISABLED, ON, ADAPTIVE and MAILBOX
-Removed the V-Sync via Compositor option
2021-07-06 16:34:26 +02:00
Rémi Verschelde ffab3949e3
Merge pull request #50048 from Calinou/remove-travis-code
Remove unused code related to Travis CI
2021-07-05 14:15:24 +02:00
reduz 6c55d2aad2 Fix Render Info
* Fixed and redone the process to obtain render information from a viewport
* Some stats, such as material changes are too difficult to guess on Vulkan, were removed.
* Separated visible and shadow stats, which causes confusion.
* Texture, buffer and general video memory can be queried now.
* Fixed the performance metrics too.
2021-07-03 10:15:04 -03:00
Hugo Locurcio 257a8a337e
Remove unused code related to Travis CI 2021-07-01 18:02:00 +02:00
K. S. Ernest (iFire) Lee d87526b391 Enum constant in boolean context
error: enum constant in boolean context [-Werror=int-in-bool-context]
2021-06-30 01:38:56 -07:00
reduz 4d19c052f7 Fix Context Validation Layer Errors
* Multisampling was wrongly selected, possibly fixes #49937
* Image semaphore acquisition is now per window, possibly fixes #41614

Please make sure to test the above two issues again, since I can't reproduce either anyway.
2021-06-28 17:43:10 -03:00
reduz bde6f5eed1 Implement Framebuffer Subpass support
* Required for better optimizing mobile platforms
* Will be used by the Vulkan mobile renderer.
2021-06-24 15:59:15 -03:00
Lightning_A e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Bastiaan Olij 15c1a76361 Add stereoscopic rendering through multiview 2021-06-13 22:52:20 +10:00
Rémi Verschelde ac73059b56
Merge pull request #49123 from aaronfranke/it-is-time
Add a Time singleton
2021-06-12 22:55:25 +02:00
Rémi Verschelde 50d1e0ea99
Merge pull request #47835 from mortarroad/master-lossless-webp
Implement lossless WebP encoding
2021-06-11 19:34:36 +02:00
Morris Tabor 1bc1e94208 Implement lossless WebP encoding 2021-06-11 18:46:04 +02:00
Rémi Verschelde 8d4046929c
Merge pull request #49511 from akien-mga/core-diraccess-fileaccess-io
Core: Move DirAccess and FileAccess to `core/io`
2021-06-11 16:51:10 +02:00
Rémi Verschelde 6b0183ec89
Merge pull request #49279 from Calinou/rename-string-is-abs-path-method
Rename `String.is_abs_path()` to `String.is_absolute_path()`
2021-06-11 15:58:16 +02:00
Aaron Franke f64fea1b23
Add Time singleton 2021-06-11 09:32:39 -04:00
Rémi Verschelde 9e328bb5b7
Core: Move DirAccess and FileAccess to core/io
File handling APIs are typically considered part of I/O, and we did have most
`FileAccess` implementations in `core/io` already.
2021-06-11 14:52:39 +02:00
Rémi Verschelde ba82626c2c
Merge pull request #49506 from akien-mga/vulkan_prefer_discrete_gpu
Prefer discrete GPU over integrated one
2021-06-11 13:34:38 +02:00
Blazej Floch 36130e5a05
Prefer discrete GPU over integrated one
This unblocks launching on Linux laptops that default to the integrated
GPU which can not handle Vulkan in many instances.
Ideally a manual device selection, or an option for the optimal selection
strategy should be provided via CLI or config, but for the time being
this will unblock the Linux devs.

Partially addresses #42348 and #43714
2021-06-11 13:02:30 +02:00
Rémi Verschelde 01d5c463be
FileAccess: Don't err in store_buffer with buffer of size 0
The error check was added for `FileAccessUnix` but it's not an error when both
`p_src` and `p_length` are zero.

Added correct error checks to all implementations to prevent the actual
erroneous case: `p_src` is nullptr but `p_length > 0` (risk of null pointer
indexing).

Fixes #33564.
2021-06-07 18:34:00 +02:00
Rémi Verschelde c1c76850cb
Style: Cleanup uses of double spaces between words
Or after punctuation. Tried to leave third-party stuff alone, unless it has
been heavily modified for Godot.
2021-06-07 11:03:08 +02:00
Hugo Locurcio 5ea1c75d63
Rename String.is_abs_path() to String.is_absolute_path()
This is more consistent with `NodePath.is_absolute()`.
2021-06-03 16:00:06 +02:00
Rémi Verschelde 8c23236e1d
Merge pull request #48350 from RandomShaper/fix_alsamidi_crash
Fix crash when using ALSA MIDI with PulseAudio
2021-06-03 10:59:29 +02:00
Pedro J. Estébanez 958d79828b Fix crash when using ALSA MIDI with PulseAudio 2021-06-03 10:10:10 +02:00
Rémi Verschelde 9990f28d84
Merge pull request #49026 from sarchar/multiple-dns-resolves 2021-06-01 18:41:41 +02:00
Fabio Alessandrelli 8cdef21d6c Move remaining dummy drivers to servers. 2021-06-01 16:50:32 +02:00
Fabio Alessandrelli 8594613f94 LinuxBSD now compiles without vulkan/x11. 2021-06-01 16:27:54 +02:00
Fabio Alessandrelli ae04dac2db Remove server platform 2021-06-01 16:27:54 +02:00
Fabio Alessandrelli 801aadb401 Add DisplayServerDummy for headless display.
Uses RasterizerDummy internally. This is always compiled in, maybe we
should add a switch to enable/disable it via scons?
2021-06-01 16:27:54 +02:00
Fabio Alessandrelli 9fb18e4998 Sync RasterizerDummy changes. 2021-06-01 16:20:38 +02:00
Chuck dd8fa11ac1 Support multiple address resolution in DNS requests
Add two new functions to the IP class that returns all addresses/aliases associated with a given address.

This is a cherry-pick merge from 010a3433df which was merged in 2.1, and has been updated to build with the latest code.

This merge adds two new methods IP.resolve_hostname_addresses and IP.get_resolve_item_addresses that returns a List of all addresses returned from the DNS request.
2021-06-01 11:24:34 +07:00
bruvzg 1d7a63fb8f
Fix Directory::get_space_left() result on macOS and Linux. 2021-05-31 12:57:18 +03:00
Marcel Admiraal da5d7db610 Rename File::get_len() get_length() 2021-05-25 11:54:28 +01:00
bruvzg a1cb6f07a1
Add GDNative Framework loading and export support. 2021-05-24 12:49:05 +03:00
bruvzg 139a9d6370
Add symlink API to the DirAccess (on macOS and Linux). 2021-05-22 17:33:34 +03:00
Tomasz Chabora b1859510ab Change behavior of String.right 2021-05-20 23:07:57 +02:00
Rémi Verschelde aa5552278d
Merge pull request #48719 from Faless/js/4.x_interfaces
[HTML5] Implement Godot <-> JavaScript interface.
2021-05-20 17:13:02 +02:00
Rémi Verschelde 4219a4cb6f
Fix typos with codespell
Using codespell 2.0.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:38:56 +02:00
Pedro J. Estébanez 469fa47e06
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-17 15:06:19 +02:00
Fabio Alessandrelli eed483c481 Sync DummyRasterizer. 2021-05-14 13:36:29 +02:00
R. Alex Hofer 65a10f4db5 Handle having no sinks in the PulseAudio driver.
Also make PulseAudio errors more verbose.
2021-05-13 18:28:22 -04:00
Hugo Locurcio 064ca9adae
Remove debugging prints in the Linux DisplayServer
Some Vulkan debugging prints were also changed to be printed only
in verbose mode.
2021-05-08 19:07:50 +02:00
Fabio Alessandrelli 9a98c09bb2 Sync RasterizerDummy with latest changes. 2021-05-07 17:57:40 +02:00
Rémi Verschelde 42b07f713f
Merge pull request #37700 from Calinou/rename-ip-unix-tcp-server
Rename `IP_Unix`, `IP_Address` and `TCP_Server` to remove underscores
2021-05-06 08:36:30 +02:00
Bastiaan Olij 90ef5d73c4 Cleanup vulkan capabilities check and add multiview check 2021-05-06 12:06:07 +10:00
Hugo Locurcio 3f078c99f6
Rename IP_Unix, IP_Address and TCP_Server to remove underscores 2021-05-06 02:52:01 +02:00
Ben Armstrong 880d4703a4 Fixed the audio 'output latency' project setting not appearing when using the WASAPI audio driver. Added variable output latency support to the WASAPI audio driver for systems that support it. 2021-05-04 20:20:36 +10:00
Hugo Locurcio bf7c4da804
Tweak warning messages related to leaked RIDs
- Use hardcoded pluralization for messages.
  - Since these messages are English-only, it's fine to hardcode it.
- Use double quotes for consistency with other messages.
2021-05-03 16:05:38 +02:00
Rémi Verschelde d12e0b6ef1
Merge pull request #48336 from bruvzg/fix_mixed_url_decode
Fix `url_decode` with mixed percent-encoding/Unicode strings.
2021-04-30 23:02:51 +02:00
bruvzg b6a21f85a7
Fix url_decode with mixed percent-encoding/Unicode strings. Treat Unix drive names as UTF-8 encoded. 2021-04-30 21:22:39 +03:00
Fabio Alessandrelli f0e6a02108 Sync RasterizerDummy. 2021-04-29 16:46:10 +02:00
Rémi Verschelde 5b16020846
Replace remaining uses of NULL with nullptr
Follow-up to #38736 (these uses were likely added after this PR was merged).
2021-04-29 11:53:27 +02:00
Rémi Verschelde 305b2a15bf
Merge pull request #48239 from akien-mga/goodbye-copymem
Core: Drop custom `copymem`/`zeromem` defines
2021-04-28 11:04:05 +02:00
Rémi Verschelde 95cfce661b
Merge pull request #48050 from JFonS/occlusion_culling 2021-04-27 19:07:12 +02:00
Rémi Verschelde 8247667a3e
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
2021-04-27 16:26:27 +02:00
Rémi Verschelde 72bd64c1d5
Merge pull request #47398 from Faless/feature/network-local-port-salvaged 2021-04-27 15:04:30 +02:00
Fabio Alessandrelli 46f7b0f74b [Net] Fix socket poll timeout on Windows.
Now correctly computes the timeout value in milliseconds.
2021-04-26 07:23:39 +02:00
jfons 4d9d99bb82 Implement occlusion culling
Added an occlusion culling system with support for static occluder meshes.
It can be enabled via `Project Settings > Rendering > Occlusion Culling > Use Occlusion Culling`.

Occluders are defined via the new `Occluder3D` resource and instanced using the new
`OccluderInstance3D` node. The occluders can also be automatically baked from a
scene using the built-in editor plugin.
2021-04-23 21:45:23 +02:00
dam da8c2310b5 Allow local port control on net_socket connections 2021-04-12 21:05:33 +02:00
Szymon Majewski 0a29322991 Validation layers on Android 2021-04-12 10:09:06 -07:00
Rémi Verschelde 9e8acb3897
Merge pull request #47640 from BastiaanOlij/fix_vulkan_format
Chose format from supported ones that we support
2021-04-05 14:55:32 +02:00
Bastiaan Olij ceebe4b565 Chose format from supported ones that we support 2021-04-05 22:39:17 +10:00
Rémi Verschelde 9bbe51dc27
Style: Apply clang-tidy's modernize-use-nullptr 2021-04-05 14:05:07 +02:00
Szymon Majewski 1328208063 Removed debug code 2021-04-01 20:09:48 -07:00
Rémi Verschelde 8621c86f4d
Merge pull request #47283 from Panquesito7/fix_lgtm_alerts
fix: 3 LGTM alerts/warnings
2021-03-31 18:52:04 +02:00
David Leal a31626ae0b
fix: 3 LGTM alerts/warnings 2021-03-31 10:34:40 -06:00
Rémi Verschelde 9cd1e50969
Merge pull request #47250 from BastiaanOlij/check_vulkan_version
Obtain supported Vulkan API
2021-03-31 13:45:43 +02:00
Szymon Majewski c3de4aeb75 WIP: Add support for VK_EXT_debug_report in Vulkan 2021-03-30 10:18:16 -07:00
Marcel Admiraal fd30c36985 Rename Texture.get_data() to get_image() 2021-03-28 13:00:46 +01:00
Bastiaan Olij a6c989bc1b Obtain supported Vulkan API 2021-03-26 12:06:57 +11:00
bruvzg b202a0dd2a
FileDialog: add Back/Forward buttons, add message for inaccessible folders. 2021-03-23 08:03:41 +02:00
Alex Hirsch c28428fe4d Allow nullptr with zero length in FileAccess get_buffer
fix #47071
2021-03-16 22:55:11 +01:00
Rémi Verschelde 7a64819c2f
Thread: Re-add pthread_np.h include for FreeBSD/OpenBSD
Was a regression from #45315.

Fixes #46998.
2021-03-14 22:42:48 +01:00
Rémi Verschelde 8051307efe
Merge pull request #46810 from W4RH4WK/file-access-get-buffer-parameter-checks
Add parameter checks to FileAccess get_buffer functions
2021-03-14 01:11:55 +01:00
Rémi Verschelde 7015027cbf
Merge pull request #46900 from Ev1lbl0w/bugfix-malloc_calls
Replace malloc's with Godot's memalloc macro
2021-03-13 21:55:52 +01:00
Ev1lbl0w 838e7d0a8d
Replace malloc's with Godot's memalloc macro 2021-03-13 11:51:45 +00:00