Commit graph

67 commits

Author SHA1 Message Date
Andrei Alexeyev
68871bbe88
renderer/glcommon: remove dead code 2024-10-06 07:09:01 +02:00
Andrei Alexeyev
7c82cbba9b
gl33: remove avoid_sampler_uniform_updates workaround and make it the default 2024-10-04 16:27:28 +02:00
Andrei Alexeyev
5274cec283
gl33: use glTexStorage* and glInvalidateTexImage* when available
glTexStorage is mostly intended to work around a regression in ANGLE's
Metal backend; see https://issues.chromium.org/issues/355605685

Potentially fixes #386
2024-10-01 04:22:30 +02:00
Andrei Alexeyev
8b37d1cbf2
src: the great #include massacre of 2024 2024-05-17 14:11:48 +02:00
Andrei Alexeyev
be7905d6a3
src: run upkeep 2024-05-17 04:58:47 +02:00
Andrei Alexeyev
f5553a2125
renderer/glcommon: add glcommon_get_texture_formats() 2024-04-29 00:53:30 +02:00
Andrei Alexeyev
c15934f666
dynarray: get rid of memset and add optional initializer arg to dynarray_append 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
5d54618667
glcommon: disable norm16 formats on nouveau
These seem to be broken
2023-08-31 00:51:49 +02:00
Andrei Alexeyev
cab432f843
gles: create angle context in webgl mode on windows
Cubemaps are broken in ANGLE's D3D11 backend, except in WebGL mode for
some reason. This is a terrible workaround, but it beats fucked up
rendering in stage backgrounds.
2023-08-28 19:15:40 +02:00
Andrei Alexeyev
77dc94bb71
menu,renderer,vfs: fix -Wcast-function-type-strict on clang 16 2023-03-22 22:38:52 +01:00
Andrei Alexeyev
b6978178b1
memory: use custom memory allocation wrappers
Introduces wrappers around memory allocation functions in `memory.h`
that should be used instead of the standard C ones.

These never return NULL and, with the exception of `mem_realloc()`,
zero-initialize the allocated memory like `calloc()` does.

All allocations made with the memory.h API must be deallocated with
`mem_free()`. Although standard `free()` will work on some platforms,
it's not portable (currently it won't work on Windows). Likewise,
`mem_free()` must not be used to free foreign allocations.

The standard C allocation functions are now diagnosed as deprecated.
They are, however, available with the `libc_` prefix in case interfacing
with foreign APIs is required. So far they are only used to implement
`memory.h`.

Perhaps the most important change is the introduction of the `ALLOC()`,
`ALLOC_ARRAY()`, and `ALLOC_FLEX()` macros. They take a type as a
parameter, and allocate enough memory with the correct alignment for
that type. That includes overaligned types as well. In most
circumstances you should prefer to use these macros. See the `memory.h`
header for some usage examples.
2023-01-18 13:23:22 +01:00
Andrei Alexeyev
267f47fc0e
build,ci: Build system maintenance (#350)
Squashed commit of the following:

commit 9ab0197ee1
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 28 23:05:58 2022 +0100

    build: add dummy descriptions for deprecated options

commit b0c41d4719
Author: Alice D <alice@starwitch.productions>
Date:   Mon Dec 26 15:18:09 2022 -0500

    update docker containers with ones containing meson 0.63.3

commit a2dd4173fc
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:20:44 2022 +0100

    build: featurize audio options

commit 7c59e2a569
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:20:35 2022 +0100

    build: remove dead code

commit cf500af137
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 19:07:37 2022 +0100

    doc: update BUILD.rst

commit 9764ac706f
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sun Dec 25 17:12:37 2022 +0100

    ci: disable WGI joystick backend for SDL

    Fails to build with latest llvm-mingw

commit 2d4f310b90
Author: p-sam <p-sam@d3vs.net>
Date:   Sun Dec 25 17:03:47 2022 +0100

    switch: fix missing include

commit 9264f1649d
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 24 14:36:41 2022 +0100

    ci: update meson to 0.63.3 due to a bug

commit 3e37be3d8f
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 24 13:42:34 2022 +0100

    ci: update build options

commit 281a39a4f5
Author: Alice D <alice@starwitch.productions>
Date:   Sun Dec 18 00:17:07 2022 -0500

    ci: change when apt is cleaned up for switch image

commit 2f2100a84c
Author: Alice D <alice@starwitch.productions>
Date:   Sun Dec 18 00:11:08 2022 -0500

    ci: bump switch homebrew container version

commit ebaff59260
Author: Alice D <alice@starwitch.productions>
Date:   Sat Dec 17 22:55:39 2022 -0500

    ci: bump windows container version

commit 7ce6f23419
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 07:36:28 2022 +0100

    build: featurize renderer options

commit a345f21b35
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 07:33:30 2022 +0100

    build: revert to explicit fallback for libzstd

    Implicit fallback causes conflicts in the basis_universal subproject

    https://github.com/mesonbuild/meson/issues/11189

commit b2de61f5c5
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Sat Dec 17 05:29:29 2022 +0100

    build: remove debug_opengl

    This option was always misdocumented, as it only controlled whether GL
    debugging is on by default. You can still control it with the
    TAISEI_GL_DEBUG environment variable, which is set to 1 in meson devenv.

commit 4c659ba195
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Fri Dec 16 08:03:37 2022 +0100

    build: set up useful env vars for meson devenv

    Makes Taisei load resources from the source tree, making live reload
    work; enables OpenGL debugging by default; works around ASan stack use
    after return false positives.

commit 1ddc58b84a
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 08:06:32 2022 +0100

    build: featurize docs; always install licenses

commit c3a94d7f5b
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:46:28 2022 +0100

    build: featurize shader_transpiler

commit 619d82ae36
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:38:30 2022 +0100

    build: allow libzip fallback by default

commit 79ab72292a
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 07:35:51 2022 +0100

    build: featurize use_libcrypto

commit b393077f71
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 05:03:20 2022 +0100

    build: featurize validate_glsl

commit 7d76484079
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 04:34:31 2022 +0100

    build: featurize some more installation options

commit 17c0bda205
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 03:24:46 2022 +0100

    build: deprecate enable_zip for vfs_zip; convert package_data into feature

commit 9a4ef8c091
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 02:37:55 2022 +0100

    build: deprecate developer=auto; default to false

commit 807240e508
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 02:24:04 2022 +0100

    build: move subproject fallback info into wraps

commit 08c953f487
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:57:33 2022 +0100

    build: deprecate 'static' option

    Meson has a built-in `prefer_static` now

commit c575601537
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:49:31 2022 +0100

    build: remove complicated shaderc detection logic

    Meson does all of this internally since 0.51.0

commit cd2d460d4b
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Wed Dec 14 01:45:17 2022 +0100

    build: Require meson >=0.63.0

commit 10abd790f7
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 05:16:47 2022 +0100

    ci: remove meson dist version workaround from release workflow

    Meson should know the correct version now

commit 31a07d8c3c
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 03:46:28 2022 +0100

    build: use built-in summary() function

commit 0c47f6d14b
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 04:33:01 2022 +0100

    build: remove -Dversion_fallback and introduce .VERSION file

    The version script will now first try to read the version from a
    .VERSION file in the source root. If that file does not exist, it will
    query git. The .VERSION file is not included in the git repository, it
    is generated for inclusion in source tarballs.

    Package maintainers who had any use for -Dversion_fallback may want to
    create the .VERSION file themselves.

    Additionally, some git-specific files have been removed from source
    tarballs.

commit d32332a5e3
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 03:00:07 2022 +0100

    build: set the "real" version in project()

commit f9a3fbc729
Author: Andrei Alexeyev <akari@taisei-project.org>
Date:   Mon Dec 12 01:50:08 2022 +0100

    build: raise meson_version and remove some legacy workarounds

    Effectively 0.56.0 was already required since we started using some of
    its features at some point.

    This also fixes all current meson warnings.
2022-12-28 23:15:55 +01:00
Andrei Alexeyev
8d2ee76710
replace include guards with #pragma once 2021-08-31 23:34:46 +03:00
Andrei Alexeyev
d10c5d0e7e
renderer: fix gles30/webgl breakage 2021-07-18 11:16:16 +03:00
Andrei Alexeyev
087f1ab0d9
renderer,texture_loader: Add support for cubemap textures
On the renderer side, the concept of a "texture class" has been
introduced. There are currently two texture classes: 2D and Cubemap.
These map to `sampler2D` and `samplerCube` in shaders, respectively.
Textures now also have an additional `layers` property. Its meaning
depends on the texture class. For simple 2D textures, there is always
only 1 layer. Cubemaps always have 6 layers, one for each face. In the
future, layers could be used to represent depth in 3D textures and
individual images in array textures.

Much of the texture loading code has been refactored, as it wasn't
adequate for loading multiple images for a single texture. Both Basis
Universal cubemaps and traditional image-based cubemaps are supported,
although no runtime preprocessing is implemented for cubemaps. The Basis
Universal format is strongly recommended.

The mkbasis utility can now convert 2:1 equirectangular panoramas into
`.basis` cubemaps with the --equirect-cubemap map.

A `vec3 fixCubeCoord(vec3 v)` function has been added to `utils.glslh`,
to convert a vector into the suitable coordinate system for sampling a
cubemap. The vector doesn't need to be normalized.
2021-07-11 18:08:00 +03:00
Andrei Alexeyev
88bec7008f
glcommon: ignore GL_EXT_texture_norm16 on WebGL
Works around a Chromium bug. See comment for details.

Related: #287
2021-05-07 00:25:08 +03:00
Andrei Alexeyev
97c3ccef87
glcommon: fix logging in glcommon_ext_flag 2021-04-30 03:34:36 +03:00
Andrei Alexeyev
491cbe353b
glcommon: shut up some warnings 2021-04-30 03:26:38 +03:00
Andrei Alexeyev
6072a72046
glcommon: remove unused variable 2021-01-19 06:04:37 +02:00
Andrei Alexeyev
50efbede34
glcommon: more robust texture format feature detection
Make less assumptions about support beyond the spec guarantees, and use
GL_ARB_internalformat_query2 to get the actual set of supported features
from the driver, if available.

Follow-up to #274
2021-01-19 05:42:24 +02:00
Andrei Alexeyev
212640c515
glcommon: don't assume that any RGB formats are color-renderable
fixes #274
2021-01-17 05:31:14 +02:00
Andrei Alexeyev
a5fd6fe5d9
Texturing overhaul: GPU compression, sRGB sampling, swizzles, etc. (#240)
* WIP compressed textures, swizzles, sRGB sampling, ...

* refactor texture type info & fix random bugs

* fix preprocessing of sRGB textures

* handle y-flipped basis textures

* glcommon: better WebGL compat for compressed format detection

* missed WEBGL_compressed_texture_pvrtc

* implement compressed texture xcoding and uploading

* Add basis_universal submodule

* Reorganize texture loader code

Clean up some code
Isolate Basis Universal loader into a separate module

* Add wrapper script for encoding .basis textures

* basisu: honor custom metadata written by the mkbasis.py script

* mkbasis.py: add --incredibly-slow and --dry-run

* Move pixmap code from util/ to pixmap/

* Add an on-disk transcode cache for basis textures to speed up loads

* Compress texture cache with zlib

* Use readable format names for basisu cache filenames

* basisu: mip bias test code

* basisu: small caching cleanup

* add TAISEI_BASISU_MIP_BIAS env variable

* Improve OpenGL format matching heuristics

* Document considerations for compressed format priority

* Remove dead code

* Enable two forgotten formats, BC3_RGBA and ATC_RGBA

Also prefer BC7 over BC1/BC3

* Recognize GL_ANGLE_compressed_texture_etc for ETC2 textures

* Default depth buffers to 24-bit; remove ANGLE hack

* Fix glcommon_check_extension for GLES2/legacy gl

* Add renderer feature bit for texture swizzle masks

* glcommon: Fixup internal formats for GLES2

Sized internal formats are not allowed in GLES2

* Fix emscripten compile errors

* Update basis_universal

* remove more dead code

* revert irrelevant stage4 change

* shut up UBSan

* basisu: shut up some debug spam

* Add normalmap sampling helper to util.glslh

* basisu: add a gray-alpha mode

* mkbasis.py: Abort if image dimansions aren't multiples of 4

* Add basic Basis Universal encoding documentation (WIP)

* doc/basisu: Add paragraph about modes; minor tweaks

* basisu: workarounds for GL texture size requirements

* gles20: fix uncompressed sRGB formats

* Partial workaround for missing swizzles in gles2 and webgl

* remove invalid assertion

* New renderer API to expose glDrawBuffers-like functionality

* stagedraw: disable all color outputs for copy_depth pass

required for WebGL compatibility

* support GL_ANGLE_request_extension

* emscripten: include *.basis in gfx package

Also fix a potential problem when more than one .pkgdir is used to
construct emscripten packages

* Don't rely on emscripten runtime to enable webgl extensions
2020-08-15 14:51:12 +03:00
Andrei Alexeyev
46bd7244a9
Remove glDrawElementsInstancedBaseInstance support
This extension is unimportant, and actually severely degrades ANGLE
performance over Direct3D to unacceptable levels. This also removes the
alternative sprite batching codepath making use of this functionality.
The renderer API hasn't changed yet; attempting to use the extension
will trigger an assertion failure.

This commit also regenerates glad with a new version. Apparently the old
one had a bug and ended up pulling a lot of unrequested functionality,
which is now removed.
2020-07-31 17:19:39 +03:00
Andrei Alexeyev
7d7f1b157f
Migrate OpenGL loader to glad2 (#217)
* Migrate to glad2

* basic OpenGL 2.1+ fallback support
2020-04-26 04:10:00 +03:00
Andrei Alexeyev
0cbc86c66e
Add generic type-safe facility for dynamic arrays (#207)
Replace most ad-hoc opencoded dynamic arrays across the codebase
2020-04-05 05:51:00 +03:00
Andrei Alexeyev
b56f3eeb54
fix broken logic 2020-03-21 04:26:18 +02:00
Andrei Alexeyev
5435971a08
bunch of emscripten crap 2020-03-19 08:58:51 +02:00
Andrei Alexeyev
02eb72608e
Fix various warnings 2020-03-19 05:04:11 +02:00
Andrei Alexeyev
38d21bbb1f
fix some bad function pointer casts 2020-03-08 18:55:46 +02:00
Andrei Alexeyev
a8bf8012f6
shut up some anal-retentive warnings 2020-03-07 18:47:02 +02:00
Alice
0b29dd473b
OpenGL ES 3.0/ANGLE support on macOS (#190)
* fixing OpenGL ES 3.0 support in macOS

* make GLES libraries loaded via buildconf vars

* fix relative install paths for macOS

* fix indenting, add comments

* fix indentation for REAL this time (thanks editorconfig)
2020-02-20 04:16:28 +02:00
Andrei Alexeyev
5d02fa4e47
webgl: enable WEBGL_debug_renderer_info 2020-02-18 06:00:29 +02:00
Andrei Alexeyev
58f7dc7d7b
Workaround for macOS AMD performance issues (#188)
fixes #182
2020-02-18 05:56:36 +02:00
Andrei Alexeyev
f4a3207f61
support GL_ANGLE_base_vertex_base_instance 2020-02-15 20:58:15 +02:00
Andrei Alexeyev
7474ff3a25
OpenGL ES 2.0 support (#187)
* WIP gles2 compat

* More gles2 compat. Playable with ANGLE now, with some rendering bugs.

* fix matrix mult. order in generic laser shader

* gles20: fix indexed rendering

* Update docs about gles20 status

* fix formatting
2020-02-15 19:45:09 +02:00
Andrei Alexeyev
1cca9173b8
renderer: expose half-float and depth{24,32} pixel formats 2020-01-16 21:58:25 +02:00
Andrei Alexeyev
80b1026d08
Don't redefine standard complex macro; use a new cmplx typedef
This also introduces `float32`, `float64`, and `real` typedefs to be
used in place of `float` and `double` later. `real` is for game code and
other places where we don't particularly care about the precision and
format of the underlying type, and is currently defined to `double`.
`float32` and `float64` should replace `float` and `double` respectively
2019-11-22 05:38:48 +02:00
Andrei Alexeyev
7fe3f8ff90
windows: detect intel's shitty driver and fall back to ANGLE 2019-09-21 16:46:22 +03:00
Andrei Alexeyev
4bd2d32826
Support shader translation into legacy GLSL versions 2019-09-16 22:53:43 +03:00
Andrei Alexeyev
2b58c3515f
glcommon: more robust glsl versions detection 2019-09-10 18:53:46 +03:00
Andrei Alexeyev
0bd00116a1
gl33: fix glObjectLabel called on nonexistent buffer objects 2019-09-10 18:37:17 +03:00
Andrei Alexeyev
c0d0ca9710
hackish static linking mode for GLES3 (webgl; not really good for anything else) 2019-09-09 04:39:33 +03:00
Andrei Alexeyev
5a23fb95fc
make upkeep script preserve existing copyrights 2019-08-03 20:44:22 +03:00
Andrei Alexeyev
3055901998
update my email 2019-07-03 21:00:56 +03:00
Andrei Alexeyev
52388df53f
improve viewport scaling and positioning 2019-04-04 02:43:03 +03:00
Andrei Alexeyev
180f9e3856
Emscripten compatibility (#161)
* Major refactoring of the main loop(s) and control flow (WIP)

run_at_fps() is gone 🦀

Instead of nested blocking event loops, there is now an eventloop API
that manages an explicit stack of scenes. This makes Taisei a lot more
portable to async environments where spinning a loop forever without
yielding control simply is not an option, and that is the entire point
of this change.

A prime example of such an environment is the Web (via emscripten).
Taisei was able to run there through a terrible hack: inserting
emscripten_sleep calls into the loop, which would yield to the browser.
This has several major drawbacks: first of all, every function that
could possibly call emscripten_sleep must be compiled into a special
kind of bytecode, which then has to be interpreted at runtime, *much*
slower than JITed WebAssembly. And that includes *everything* down the
call stack, too! For more information, see
https://emscripten.org/docs/porting/emterpreter.html

Even though that method worked well enough for experimenting, despite
suboptimal performance, there is another obvious drawback:
emscripten_sleep is implemented via setTimeout(), which can be very
imprecise and is generally not reliable for fluid animation. Browsers
actually have an API specifically for that use case:
window.requestAnimationFrame(), but Taisei's original blocking control
flow style is simply not compatible with it. Emscripten exposes this API
with its emscripten_set_main_loop(), which the eventloop backend now
uses on that platform.

Unfortunately, C is still C, with no fancy closures or coroutines.
With blocking calls into menu/scene loops gone, the control flow is
reimplemented via so-called (pun intended) "call chains". That is
basically an euphemism for callback hell. With manual memory management
and zero type-safety. Not that the menu system wasn't shitty enough
already. I'll just keep telling myself that this is all temporary and
will be replaced with scripts in v1.4.

* improve build system for emscripten + various fixes

* squish menu bugs

* improve emscripten event loop; disable EMULATE_FUNCTION_POINTER_CASTS

Note that stock freetype does not work without
EMULATE_FUNCTION_POINTER_CASTS; use a patched version from the
"emscripten" branch here:

    https://github.com/taisei-project/freetype2/tree/emscripten

* Enable -Wcast-function-type

Calling functions through incompatible pointers is nasal demons and
doesn't work in WASM.

* webgl: workaround a crash on some browsers

* emscripten improvements:

    * Persist state (config, progress, replays, ...) in local IndexDB
    * Simpler HTML shell (temporary)
    * Enable more optimizations

* fix build if validate_glsl=false

* emscripten: improve asset packaging, with local cache

Note that even though there are rules to build audio bundles, audio
does *not* work yet. It looks like SDL2_mixer can not work without
threads, which is a problem. Yet another reason to write an OpenAL
backend - emscripten supports that natively.

* emscripten: customize the html shell

* emscripten: force "show log" checkbox unchecked initially

* emscripten: remove quit shortcut from main menu (since there's no quit)

* emscripten: log area fixes

* emscripten/webgl: workaround for fullscreen viewport issue

* emscripten: implement frameskip

* emscripter: improve framerate limiter

* align List to at least 8 bytes (shut up warnings)

* fix non-emscripten builds

* improve fullscreen handling, mainly for emscripten

* Workaround to make audio work in chromium

emscripten-core/emscripten#6511

* emscripten: better vsync handling; enable vsync & disable fxaa by default
2019-03-09 21:32:32 +02:00
Andrei Alexeyev
4a440ab79b
OpenGL (mostly GLES) spec compliance fixes 2019-02-22 08:37:52 +02:00
Andrei Alexeyev
c8e057e388
basic emscripten compat and various fixes 2019-02-22 01:56:48 +02:00
Andrei Alexeyev
089b74cfae
opengl: fix missing ext vendor (APPLE) 2019-02-17 20:44:43 +02:00
Andrei Alexeyev
b91b85c42a
Logging: colors, non-fatal error level, alt. format for log file
Also removed traceback support entirely as it never produced useful
output.
2019-02-15 01:58:40 +02:00