Commit Graph

1173 Commits

Author SHA1 Message Date
bjorn efc81e4cec Fix some gcc warnings; 2022-12-03 01:20:02 -08:00
bjorn f9d7742dfd Add support for headless headset rendering;
Although the name is unfortunate, this allows access to lovr.headset
when no window is opened or when the graphics module is disabled.  This
requires the XR_MND_headless extension to be supported by the runtime.
2022-11-26 14:40:39 -08:00
bjorn 4422df2a47 Variant small string optimization; 2022-11-24 15:40:43 -08:00
bjorn 8f74778c19 Error if require path is too long instead of truncating; 2022-11-23 14:08:32 -08:00
bjorn 53da4dd1dc rm File again;
forks please yell if you still need it
2022-11-23 11:58:42 -08:00
bjorn dbdd22ae95 Compute passes release their shaders properly;
Active shader was only getting released for render passes.
2022-11-21 19:52:41 -08:00
bjorn 7f2618227f Fix off-by-one tick number in readbacks;
Only when a readback is read back before a pass is created.

Should really change gpu to know if the frame has started yet and adjust
the tick index accordingly.
2022-11-21 19:42:41 -08:00
bjorn 6d1bbe9c5c Fix Android build on new NDKs;
Some Android header defines DEPTH, which clashes with a symbol in the
OpenXR driver.  This change just stops using Android headers in there
and declares more granular private functions.  It also removes a few
unused private os functions.
2022-11-15 20:35:39 -08:00
bjorn 58dc7ee9dd Add missing check for sample usage in material textures; 2022-11-14 20:10:23 -08:00
bjorn 9277b38273 Use fancy syntax for model data map indices;
Matches nodes.
2022-11-14 19:20:29 -08:00
bjorn c61d6b059b Merge branch 'master' into dev 2022-11-14 19:19:17 -08:00
s-ol 7dbdda1205 Fix node indexing for GLTF models with multiple root nodes 2022-11-14 08:02:13 -08:00
s-ol 773d22f40d Check bounds in luax_checkanimation / luax_checknodeindex 2022-11-14 08:02:13 -08:00
bjorn cacc5eae71 ModelData:getTriangles reuses vertices better;
ModelData:getTriangles currently adds a fresh set of vertices for every
mesh in a node.  This is technically correct, but it wastes space when 2
nodes reference the same set of vertices with different index buffers,
which is pretty common when a node has multiple materials.  It also
breaks ODE, who doesn't like it when vertices outnumber indices too
much.
2022-11-09 22:22:51 -08:00
bjorn 00aa4e3a23 TerrainShape mass fix; 2022-11-09 22:22:26 -08:00
bjorn f8f748320e Minor Shape improvements;
- Add helper functions for creating shapes to avoid duplication between
  newShape and newShapeCollider.
- Add lovr.physics.newMeshShape and lovr.physics.newTerrainShape
- Register TerrainShape so it has all the base Shape methods
- Smooth out a few TerrainShape warnings
2022-11-09 20:53:42 -08:00
bjorn 9783140725 Fix window resize; 2022-11-09 19:05:01 -08:00
bjorn 3775ed1be6 gpu: use distinct allocator/memory for staging buffers;
Fixes easily-encounterable GPU OOM on discrete cards.

Currently when mapping CPU-accessible GPU memory, there are only two
types of memory: write and read.

The "write" allocations try to use the special 256MB pinned memory
region, with the thought that since this memory is usually for vertices,
uniforms, etc. it should be fast.

However, this memory is also used for staging buffers for buffers and
textures, which can easily exceed the 256MB (or 246MB on NV) limit upon
creating a handful of large textures.

To fix this, we're going to separate WRITE mappings into STREAM and
STAGING.  STREAM will act like the old CPU_WRITE mapping type and use
the same memory type.  STAGING will use plain host-visible memory and
avoid hogging the precious 256MB memory region.

STAGING also uses a different allocation strategy.  Instead of creating
a big buffer with a zone for each tick, it's a more traditional linear
allocator that allocates in 4MB chunks and condemns the chunk if it ever
fills up.  This is a better fit for staging buffer lifetimes since there's
usually a bunch of them at startup and then a small/sporadic amount
afterwards.  The buffer doesn't need to double in size, and it doesn't
need to be kept around after the transfers are issued.  The memory
really is single-use and won't roll over from frame to frame like the
other scratchpads.
2022-11-09 19:05:01 -08:00
mcc c682ced654 Minor comments on audio.c 2022-11-09 19:05:01 -08:00
Josip Miskovic 34611f2069 Add physics heightfield shape 2022-11-08 18:46:49 -08:00
bjorn 36e1471cf0 lovr.graphics.isInitialized;
Returns whether the graphics module is initialized.  Used by the default
error handler to know if it's safe to try to render the error screen.
2022-11-07 19:12:11 -08:00
bjorn d36a6a22d9 Don't skip GPU submits if there's nothing to do;
- It can still be useful to do an empty submit
- It's good to still do validation of the passes
2022-11-03 13:53:06 -07:00
bjorn 67627f4aab Fix shader slot type assignment; 2022-10-31 17:55:26 -07:00
bjorn 3958c006fa Don't generate mipmaps for textures without initial contents; 2022-10-20 19:37:00 -07:00
Josip Miskovic 9b6e884f7f Remove problematic bindings from Index controller
The "system" button on Valve Index controller may not be exposed to
applications through OpenXR. Oculus runtime throws error when binding
for that button is attempted.
2022-10-18 21:50:48 -07:00
bjorn df8f52a71b Fix gcc warnings; 2022-10-12 10:57:43 -07:00
bjorn 1c3be230c0 Desktop driver implements hand/left/point device; 2022-10-12 00:46:48 -07:00
bjorn 0d7ed04789 Fix Quest pinch axis; 2022-10-02 14:00:52 -07:00
bjorn b5620fb185 Revert "Fix Quest hand model orientation;"
This reverts commit a766bf4a35.
2022-09-26 14:58:34 -07:00
bjorn a766bf4a35 Fix Quest hand model orientation; 2022-09-23 17:52:21 -07:00
bjorn d2ceb6b81a Fix skeletal animation on some GPUs;
The animation compute shader was not specializing the workgroup size
properly, so it was only working on GPUs with a subgroup size of 32.

The Quest 1 has a subgroup size of 32 and the Quest 2 has a subgroup
size of 64, so this resulted in hand models breaking on Quest 2 only!
2022-09-23 14:36:20 -07:00
bjorn 2e0b5a4efa Flip msdf glyphs;
They don't look right when using a negative y scale for some reason,
even though the rendering was still working.
2022-09-22 20:30:04 -07:00
bjorn 311d1511bc Fix quest keyboard tracking; 2022-09-21 14:58:30 -07:00
Josip Miskovic da9328e72c Fix sending strings with \0 through channels
A null-char is valid part of Lua string. When such a string is sent
through the channel, its length should be stored as well to be able to
correctly reconstruct it on the other thread.

The bug was triggered with this code:

    s1 = 'a \0 b'
    print(#s1) -- 5
    ch:push(s1)
    s2 = ch:pop()
    print(#s2) -- 2
2022-09-21 09:15:20 -07:00
bjorn ece73be868 lovr.headset.getPose works with keyboard device on Quest; 2022-09-20 20:16:58 -07:00
bjorn d1b6bd3d15 OpenXR: fall back to d24s8 when d32fs8 isn't supported;
Window was already doing this.

Quest currently doesn't work with stencil = true because of this.
2022-09-20 19:09:04 -07:00
bjorn 28869431fb Fix stereo mirror window; 2022-09-15 20:45:26 -07:00
bjorn 6444aba832 OpenXR: Map Index system buttons to menu;
SteamVR doesn't expose these, but monado does, so might as well bind them.
2022-09-14 21:35:43 -07:00
bjorn 1dd737d8a4 Make the logo a default shader;
Improves build system, improves filesize, seemingly improves startup time
2022-09-13 17:36:10 -07:00
bjorn b5651f9193 Fix lod range of default samplers; 2022-09-12 18:09:29 -07:00
bjorn d8c23bacec Source:setPitch;
Co-authored-by: Nevyn Bengtsson <nevyn@alloverse.com>
2022-09-11 20:41:58 -07:00
bjorn 1c9adea2e2 Simplify channel hash table; 2022-09-10 23:59:14 -07:00
bjorn bcde681710 Mark ASTC textures as sRGB;
They don't contain this metadata, but marking as sRGB is more reasonable
than not.
2022-09-10 23:55:15 -07:00
bjorn 0da84894e8 Fix gamma correction of multicolor text; 2022-09-10 14:55:15 -07:00
bjorn d8c6c47e00 Add normal DefaultShader;
It's a pretty normal shader.
2022-09-10 11:07:55 -07:00
bjorn 5f921f1251 Unable to mipmap multisampled textures; 2022-09-10 11:02:03 -07:00
bjorn 7e1d9f1dd2 Fix desktop driver crash when window isn't open; 2022-09-10 10:58:11 -07:00
bjorn f30e37a2e3 Error if testing/writing non-existent stencil buffer; 2022-09-10 10:20:41 -07:00
bjorn a3beccb14e Fixup 3D texture blit validation; 2022-09-10 10:12:06 -07:00
bjorn 8697466009 Shader flag adjustments;
- glowTexture is on by default, but still requires the glow flag.
- occlusionTexture is named ambientOcclusion, and is on by default,
  but is still not used by any builtin shaders/helpers.
2022-09-02 15:33:18 -07:00