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).
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.
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.
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
* 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
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.
- RESF_UNSAFE is removed.
- Resources that don't have to be finalized on the main thread can load
completely asynchronously.
- A thread waiting for a concurrent task to complete can start executing
that task itself if it hasn't started yet.
- Refactor the resource loading interface, add support for load-time
dependencies.
- Main-thread finalization of asynchronously loaded resources is now
spread out across multiple frames to mitigate frametime spikes.
- Remove some archaisms from the resource management code.
- Fix potential hashtable synchronization issue.
- Fix some deadlock edge cases.
- Don't spawn more worker threads than there are CPU cores (degrades
performance).
- Add TAISEI_AGGRESSIVE_PRELOAD env variable to attempt to aggressively
discover and preload every possible resource.
- Make r_texture_fill{,_region} expect optimal pixmaps, so that it's
never forced to convert them on the main thread. The optimal format may
be queried with the new r_texture_optimal_pixmap_format_for_type API.
These functions will also no longer needlessly copy the entire image
into a staging buffer - previously they did this even if no conversion
was needed.
- Other random changes to facilitate the stuff above.
The overall effect is somewhat faster load times.
Of course it's still all terrible and full of lock contention because I
suck at concurrent programming, but it's not worse than it was.
Probably.
http://sauerbraten.org/iqm/
The iqms were converted from the objs with the official iqm "compiler",
but can be also exported directly from Blender with a script from the
SDK.
In addition, indexed rendering was fixed (it's not useless anymore), and
the winding order convention changed from counter-clockwise to clockwise
to facilitate faster model loading.
A limited subset of IQM functionality is currently supported:
- One mesh per model.
- Only floating point data in vertex arrays.
- Only standard vertex arrays: positions, UVs, normals,
tangents.
- No animations etc.
The "standard" shader interface now receives an additional vec4 tangent
attribute. This attribute is currently ignored by shaders. The bitangent
vector can be computed in a vertex shader as:
vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
* iqm: remove axis scrambling and re-export models
* remove debug stuff
* Implement Robin Hood hashing
This replaces the previous separate chaining implementation. This
approach is more memory-efficient, cache-friendly, and puts much less
stress on the memory allocator.
* Replace crc32 with fnva1
Also attempt to make the compiler pre-hash as much stuff as possible at
build time.