Commit graph

172 commits

Author SHA1 Message Date
Andrei Alexeyev
6cc8bf2d47
gl33: shut up -Wunreachable-code on emscripten builds 2023-07-30 03:01:58 +02:00
Andrei Alexeyev
c74ac7874a
gles30: alternative webgl framebuffer_copy impl to work around chrome bug 2023-06-18 14:56:00 +02:00
Andrei Alexeyev
9dade8ad33
resource: lifetime management redesign (WIP) 2023-04-29 20:01:50 +02:00
Andrei Alexeyev
ad295005db
resource: more consistent API function names 2023-04-29 20:01:50 +02:00
Andrei Alexeyev
190da85628
gl33,glescommon: fix screenshots
Broken by b50b57803e
2023-04-18 12:47:19 +02:00
Andrei Alexeyev
b50b57803e
renderer: add r_framebuffer_copy 2023-04-10 06:47:55 +02:00
Andrei Alexeyev
3dc0faec9e
renderer/api: rename ClearBufferFlags to BufferKindFlags 2023-04-10 06:47:55 +02:00
Andrei Alexeyev
711edc218f
util/assert: add optional message to assert, assume, and static_assert
Removed static_assert_nomsg, since static_assert's message argument is
optional now. In C2X mode this uses the native _Static_assert
functionality, otherwise it falls back to a macro-based overload.

Additionally, rewrote the assert macro so it correctly marks the failing
branch as a dead end.
2023-03-26 01:52:41 +01: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
c12b41fa3b
resource: remove deprecated getters 2023-02-24 18:15:02 +01:00
Stone Tickle
08c4723f92
build: fix errors found by muon analyze (#358)
I found a few small errors while testing muon analyze on this project.
2023-02-23 22:06:56 +02: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
95363b9c0e
build: auto-disable shader_transpiler if offline translation used 2023-01-05 04:25:21 +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
0adaf17d5f
sprite: handle virtual paddings transparently
Most client code no longer needs to care about paddings at all, aside
from some very special cases involving dynamic creation of padded
sprites. So far we only have one known example of this in portrait_render().

This should let us optimize most of our sprites with autotrimming in the
future.

Additionally, support for deprecated offset_{x,y} keys in sprite files
has been removed.
2022-11-27 20:14:05 +01:00
Andrei Alexeyev
3fd3c33371
gl33: fix inverted logic in gl33_framebuffer_attach 2022-09-05 06:23:35 +02:00
Andrei Alexeyev
52a75e1610
renderer: destroy static models idx buffer on shutdown 2022-02-09 05:51:41 +02:00
Andrei Alexeyev
7d9603f0da
gl33: index buffer fixes
* Allow updates before VAO association happens
* Fix array out of bounds on destroy
2022-02-09 05:51:41 +02:00
Andrei Alexeyev
fb18c3b7cd
renderer: add r_index_buffer_invalidate() 2022-02-09 05:51:41 +02:00
Andrei Alexeyev
de09759d31
renderer: support specifying index size for index buffers
Sizes of 2 (uint16_t) and 4 (uint32_t) are supported.

Moved most of the logic for appending indices into renderer/api.c
2022-02-09 05:51:41 +02:00
Andrei Alexeyev
a82b63045c
renderer: add scissor test API 2022-02-09 05:51:41 +02:00
Andrei Alexeyev
b39c9ba78e
resource: partial support for resource reloading 2022-01-02 08:28:02 +02:00
Andrei Alexeyev
5dc3379361
shaderlib/glsl: allow specifying a custom file opener callback for glsl_load_source 2021-12-28 09:00:20 +02:00
Andrei Alexeyev
dc52836af7
gl33: enable sRGB conversion when rendering to sRGB textures
This matches the gles30 behavior, which can not be changed without
relying on extensions. It also lets us simplify the texture_post_load
shader.
2021-12-22 22:46:59 +02:00
Andrei Alexeyev
c448e3f584
shaderlib/cache: bump content size limit to 1MiB
Apparently SPIR-V can be beefy
2021-12-21 23:43:36 +02:00
Andrei Alexeyev
0b776b0649
renderer: preload monotiny font in developer mode 2021-12-17 14:40:31 +02:00
Andrei Alexeyev
845df89431
renderer: let sprite batch buffer grow when exhausted
Gets rid of warning spam and allows us to submit arbitrarily large
batches, at the cost of slightly more VRAM usage.
2021-10-25 14:03:40 +03:00
Andrei Alexeyev
630929a4a5
gl33: dynamically grow buffers when running out of space
Prevents crashes from loading too many models (happens in normal
gameplay!)
2021-10-25 14:03:35 +03:00
Andrei Alexeyev
142b4f25d4
Remove some trivial dead code 2021-08-31 23:34:48 +03:00
Andrei Alexeyev
8d2ee76710
replace include guards with #pragma once 2021-08-31 23:34:46 +03:00
Andrei Alexeyev
593f756a70
renderer/null: return a more sensible fake viewport value
Avoids an assertion failure in r_framebuffer_viewport_rect
2021-08-22 03:07:42 +03:00
Andrei Alexeyev
defb32fb74
renderer: add function to retrieve the default quad model 2021-08-11 14:06:41 +03:00
Andrei Alexeyev
61d2d18731
gl33: only regen auto mipmaps if texture is to be used in the next draw 2021-07-20 14:16:15 +03:00
Andrei Alexeyev
7e58ebe8b9
gl33: fix linear-to-nearest filter remapping for unfilterable textures 2021-07-19 15:10:35 +03:00
Andrei Alexeyev
9666bae1bc
Fix gcc11 warnings 2021-07-18 19:09:12 +03:00
Andrei Alexeyev
d10c5d0e7e
renderer: fix gles30/webgl breakage 2021-07-18 11:16:16 +03:00
Andrei Alexeyev
cbbaa3eb7f
renderer: Add API to dump texture data into a pixmap 2021-07-18 10:39:05 +03:00
Andrei Alexeyev
20ec3e62e9
gl33: fix even more texture management issues
We still can't have two incompatible samplers bound to the same
texturing unit, even if there is no texture bound to it.
2021-07-13 00:24:46 +03:00
Andrei Alexeyev
b45b2c22ce
renderer,gl33: fix texture management issues
Previously we assumed that we generally do not need to unbind textures
from shader samplers: if a sampler had no Taisei-level texture binding,
we would simply not update its OpenGL-level binding. This assumption is
no longer valid after introduction of cubemap textures. Shader samplers
always have an OpenGL-level binding to a texturing unit (0 by default).
If the sampler type is not compatible with the type of texture bound to
its texturing unit (e.g. 2D texture with a cube sampler), the draw call
will raise an error, even if the shader does not actually use the
invalid sampler.

For that reason, we now make sure that all samplers without a
Taisei-level texture binding are assigned a texturing unit with no
OpenGL-level texture binding. The texunit juggling logic had to be fixed
quite a bit to correctly handle unbinding textures.

Additionally, some assertions have been added to prevent assigning
incompatible textures to samplers via the renderer API, and the number
of minimum required texturing units has been raised to 8 (we sometimes
need more than 4 bound textures at a time).
2021-07-13 00:21:03 +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
4bebd1ab5d
gl33: don't try to create context if SDL_CreateWindow fails 2021-07-11 18:07:37 +03:00
Andrei Alexeyev
9bb51687c3
renderer/api: workaround for ASan false positive 2021-06-27 12:02:29 +03:00
Andrei Alexeyev
659ed15e43
Fix some issues found by clang static analysis 2021-06-18 16:11: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
326e499f7e
shaderlib/cache: switch to zstd compression 2021-03-28 15:18:11 +03:00
Andrei Alexeyev
8706426ea2
rwops_zlib: various improvements:
* Add compression level parameter to writer wrappers
* Add APIs for raw deflate streams
* Add optional seeking emulation for reader wrappers
* Handle inflate/deflate init errors
2021-03-23 12:05:47 +02:00
Andrei Alexeyev
937cb3bea7
I have no idea why/how this ever worked
Now it doesn't. It's also not very useful anyway, since the static gles3
mode only works with emscripten, for which we manually specify GL
linking flags.
2021-02-25 08:55:39 +02:00
Andrei Alexeyev
0115c55f51
gl33: fix incorrect handling of uniform array offsets 2021-02-20 00:04:20 +02:00