Commit graph

13 commits

Author SHA1 Message Date
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
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
c0d0ca9710
hackish static linking mode for GLES3 (webgl; not really good for anything else) 2019-09-09 04:39:33 +03:00
Andrei Alexeyev
52388df53f
improve viewport scaling and positioning 2019-04-04 02:43:03 +03:00
Andrei Alexeyev
1365293334
Some gles20 progress; minor gl refactor and fixes 2018-10-23 10:51:56 +03:00
Andrei Alexeyev
1fd1b6671d
Conditional support for more texture formats in GLES 2018-10-22 10:21:17 +03:00
Andrei Alexeyev
2414474c89
OpenGL ES 3.0 rendering backend (#148)
* First steps towards shader transpilation

Needs to be manually enabled via -Dshader_transpiler=true.

Requires shaderc. https://github.com/google/shaderc

Not yet functional due to missing SPIRV-Cross integration. SPIRV-Cross
currently does not have an official C API, and crossc is too minimal to
be useful. The current plan is to extend crossc and vendor it, while
also sending PRs upstream.

* Integrate crossc; shader transpilation for GLES now works

* fix leak

* gles30 backend now playable on Mesa with 3.2 context

Some rendering issues are present. Identified so far:
    - Marisa's lasers are invisible
    - Death effect looks wrong

Also, a small pixmap manipulation library has been written, and the
texture uploading API redesigned around it.

* fix marisa lasers in GLES (uniform name clashed with builtin)

* fix player death effect in GLES (another name clash)

* Dump ANGLE's translated shader code in debug log

* fix screenshots

* Drop support for triangle fans, switch to strips

Fans offer no advantage over strips, and they've been removed in D3D10+,
so ANGLE has to emulate them.

* crude workaround for an ANGLE bug

* Re-enable GL debug labels, fix an issue with them that affected ANGLE (but was always technically a bug)

* fix race condition in shaderc initialization

* New SDL_RWops interface for vertex buffers

* Optimize VBO streaming via buffering updates

Measurable performance improvement even with the main gl33 renderer,
drastic improvement with ANGLE.

* Fix the depth texture binding problem under ANGLE

Apparently it hates GL_DEPTH_COMPONENT16 for some reason. Sized internal
formats are not supported in GLES 2.0 anyway, so not using them is
probably a good idea.

* fix GLES2.0 segfault (the backend still doesn't work, though)

* dump GL extensions at info log level, not debug

* get around a Mesa bug; more correct texture format table for GLES2

* Correct GLES3 texture format table according to the spec

Not a Mesa bug after all

* require crossc>=1.5.0, fallback to subproject

* Request at least 8bit per color channel in GL backends

* Forbid lto for static windows builds with shader_transpiler=true

* fix edge case segfault

* Add basic ANGLE bundling support to the build system

Windows only, and no NSIS support yet

* Fix various windows-related build system and installer brokenness

* Disable gles backends by default

* update documentation
2018-10-02 01:36:10 +03:00
Andrei Alexeyev
9b3779ebb4
Some renderer refactoring (mostly API and GLES preparations) (#144)
* Refacor uniforms API:

    - More complete and consistent
    - Type-safety
    - Usage correctess assertions missing for now, planned

* Redesign texturing API: texunits gone, assign textures to sampler uniforms directly

r_texture_create now allocates memory and returns an opaque Texture
pointer; similar changes to the other renderer APIs will follow.

* Framebuffers: make _create return an opaque pointer, add debug label APIs (unused for now)

* opaque pointers and debug label APIs for vertex arrays and buffers

* fix null renderer

* Refactor glsl preprocessing into an independent module

* Separate shader resource management from renderer backend

This makes it possible to add more shading languages and/or include a
transpiler, which will be useful for the GLES backend.

* refactor r_clear into a stateless API

* add r_texture_clear API; fix gl33_framebuffer_clear

* Replace deprecated glsl_objects with objects in all *.prog files

* fix missing texture_clear implementation in null renderer

* remove some dead code in null renderer

* fix GLES segfault

* GLES 3.0 actually has glVertexAttribDivisor

* Query GL for supported GLSL versions (preparing to add shader transcompilation)
2018-09-14 10:37:20 +03:00
Andrei Alexeyev
c57d1130aa
support mipmaps and anisotropy (not used until we have premultiplied alpha) 2018-07-11 14:55:08 +03:00
Andrei Alexeyev
5d293393b8
meson woes: prevent internal error if glad is missing (not actually required for build) 2018-07-01 11:47:13 +03:00
Andrei Alexeyev
cc33fdd4fd
Use GLAD to set up GL function pointers 2018-06-30 23:11:54 +03:00