Commit Graph

4132 Commits

Author SHA1 Message Date
bjorn b1deeda0ce Fix issue with buffer recycling; 2023-08-15 10:18:48 -07:00
bjorn 339e6cf94b Shrink DrawData from 128 to 64 bytes!;
- Last row of transform matrix is unused, make it 4x3
  - Requires funny row-major packing due to vec3 std140 padding.
  - Teach spirv parser to tolerate non-square matrix types, though
    they aren't supported anywhere else yet.
- Compute cofactor in shader for normal matrix, ALU is free,
  optimize out many terms, rm maf_cofactor.
- Take out complex UBO alignment logic since stuff is PO2 these days.

This was a common bottleneck for some workloads, so there are measurable
performance gains (up to 2x faster pass submission on CPU).  GPU time is
identical, at least on desktop.
2023-08-01 18:57:09 -07:00
bjorn 874f438621 Add back lovr.headset.getDirection;
It's useful.  quat(lovr.headset.getOrientation()):direction() is
verbose, noob-unfriendly, and somewhat wasteful.  I think this was
originally removed because something about not exposing the full
rotation basis.
2023-07-31 18:38:04 -07:00
bjorn 715edfd431 Add hand/*/pinch and hand/*/poke devices; 2023-07-31 18:30:35 -07:00
bjorn 5fddd28137 Add hand/left/grip and hand/right/grip devices; 2023-07-31 18:08:56 -07:00
bjorn c6cb5451ee Set XR_LOADER_DEBUG environment variable to none;
LOVR doesn't require OpenXR to run.  When the headset module is enabled
and the openxr headset driver is enabled, LOVR tries to initialize
OpenXR, and if it fails then it will try the next driver.

The OpenXR loader will print error messages to stderr by default.  This
is undesirable because someone who is unfamiliar with OpenXR will see a
bunch of messages in their console that say "ERROR" and think something
is wrong, even though the messages are innocuous and don't indicate an
actual problem.

The only way to silence these messages from the OpenXR loader, to my
knowledge, is to set the XR_LOADER_DEBUG environment variable to 'none'.
This is only done when the environment variable isn't set, so it's still
possible to set XR_LOADER_DEBUG to see the logs.
2023-07-31 17:32:31 -07:00
Bjorn c38165a154
Merge pull request #688 from bjornbytes/mesh
Mesh
2023-07-29 18:21:01 -07:00
bjorn 53ae77f123 Merge branch 'master' into dev 2023-07-29 03:40:36 -07:00
bjorn 072452a4da Fix issue where OBJ UVs are upside down;
Most OBJ loaders use OpenGL texture coordinate conventions.

After switching to Vulkan, the UV origin became upper-left and images no
longer needed to be flipped on import.  This means that the OBJ importer
now needs to flip its UVs to compensate.  Somehow, no one noticed until
now!  Most people are using glTF I guess.
2023-07-29 03:37:18 -07:00
bjorn 2f90255d1a physics no longer depends on maf;
So little is used, may as well make it more self-contained.
2023-07-28 16:16:14 -07:00
bjorn 4892d228b3 WIP; 2023-07-24 15:34:44 -07:00
bjorn f960141fd7 Add :type method to vectors; Change Mat4 __tostring; 2023-07-24 15:12:25 -07:00
xiejiangzhi ee10e22402 World query: Rename should_stop to shouldStop, early stop queryCallback if no give a callback 2023-07-21 08:00:58 +08:00
xiejiangzhi 91e586bbd4 Fix early exit logic for raycast & querySphere 2023-07-20 16:46:40 +08:00
xiejiangzhi a4dc1d9ffb Support early exit for world:raycast world:queryBox world:querySphere 2023-07-20 16:34:56 +08:00
bjorn 5c322d3403 Include temp buffer offset in draw range; 2023-07-17 18:45:37 -07:00
bjorn 534d47904e World:queryBox/World:querySphere callback is optional;
They also return a bool indicating if any intersections occurred.
2023-07-17 13:23:57 -07:00
bjorn 9b7433c1de Add :type method to objects;
NYI for vectors.
2023-07-17 13:18:19 -07:00
bjorn cc67e06d3c Make keyboard input functions variadic; 2023-07-17 13:13:17 -07:00
Bjorn 8ac6c4dbb0
Merge pull request #685 from xiejiangzhi/get_set_shape_pose
Add getPose/setPose for shape. #650
2023-07-17 01:59:33 -07:00
xiejiangzhi 98ee9739b4 Fix luax_readquat for lovrShapeSetPose 2023-07-17 16:42:58 +08:00
xiejiangzhi c880ed529a Add getPose/setPose for shape. #650 2023-07-17 14:34:54 +08:00
bjorn 61ffd5716f Disable LOCAL reference space on SteamVR;
Recent SteamVR versions have bugs with it, especially after triggering a
recenter operation.

In SteamVR, recentering fires referenceSpaceChangePending for the LOCAL
space, then the STAGE space, then the LOCAL space again, all with
different changeTimes.  No poseInPreviousSpace is given.

Recreating the main reference space whenever this event is received
leads to strange, inconsistent issues.  Sometimes the local/stage spaces
end up on top of each other, other times one or both will be way up in
the air (putting the headset at negative y coordinates).

This bug is even present when recentering in the compositor, so it's not
an issue with lovr.  Cautiously disabling the local-floor emulation on
SteamVR runtimes and just always using the STAGE space until things are
sorted out.
2023-07-16 14:43:23 -07:00
bjorn 83d6e64c6e Use reference space change time when recreating reference spaces;
This doesn't fix any observed issue, but should be more correct.
2023-07-16 14:29:25 -07:00
Josip Miskovic 1e475d122b Restore w normalization in mat4:mul(vec3) 2023-07-15 18:06:36 +02:00
bjorn b268cd1776 World:queryBox; World:querySphere; 2023-07-10 23:20:01 -07:00
bjorn 9bf2def86d Rename box shape dimensions to be more clear; 2023-07-10 23:11:14 -07:00
bjorn 5210d474b8 Source pitchable flag defaults to true; 2023-07-10 20:09:16 -07:00
bjorn 74325d81a1 Expose runtime name in lovr.headset.getDriver; 2023-07-10 19:35:21 -07:00
bjorn dabbd449a8 Format support considers both linear/srgb encodings; 2023-07-10 19:21:11 -07:00
bjorn be795c0ebd Change vec3 back to 3 floats; Clean up maf/vectors;
The "vec3 is 4 floats" thing was consistently confusing to people.  It's
reverted everywhere except for Curve.

maf now has full sets of methods for vec2/vec3/vec4, for consistency.

Vector bindings now use luax_readvec* helper functions for the
number/vector variants, and use maf for most functionality, which cleans
things up a lot.
2023-07-10 17:51:24 -07:00
bjorn 0d30055dd7 webgpu/wasm updates;
Some compile fixes and a rename from gpu_wgpu to gpu_web, since wgpu
refers to a specific implementation of WebGPU and I'm really bad at
typing it for some reason.
2023-07-09 13:13:58 -07:00
bjorn 22202af27f Revert "gpu: prefer rgb10a2 for window swapchains;"
This reverts commit b7a00c82d1.

I think srgb-encoded rgb10a2 swapchains require manual gamma correction
in shaders (?!), which we aren't quite ready for yet because shaders don't
know the "color space" of their canvas textures.
2023-07-08 15:47:58 -07:00
bjorn b7a00c82d1 gpu: prefer rgb10a2 for window swapchains;
We don't support transparent desktop windows, so losing alpha bits is fine.
2023-07-08 15:02:42 -07:00
bjorn c52f09cdc2 Fix some gcc warnings; 2023-07-08 14:49:35 -07:00
bjorn 10c2c75482 Frustum culling;
- Adds Pass:setViewCull to enable/disable frustum culling.
- Renames Pass:setCullMode to Pass:setFaceCull (with backcompat).

Some stuff currently missing:

- Text is not culled, but should be.
- VR view frusta are not merged yet.
2023-07-07 14:51:22 -07:00
bjorn 48a9bb0384 rm some unused maf methods; 2023-07-07 14:05:44 -07:00
bjorn 237a4c19e2 Ignore empty tables when writing arrays; 2023-07-07 14:03:16 -07:00
bjorn e9af3d9167 Fix bug when writing tables of numbers to nested arrays; 2023-07-07 14:02:58 -07:00
bjorn 1ab791d89d Automatically unwrap single-field buffer structs; 2023-07-07 14:02:36 -07:00
bjorn 2bc90d2106 Add lovr.audio.getDevice; 2023-07-06 13:50:34 -07:00
bjorn 9d24d0173d Fix issue with lightuserdata in Buffer:setData; 2023-07-05 20:16:16 -07:00
bjorn fd0d3fc1ec Fix number + lightuserdata binary vector ops; 2023-07-03 19:17:09 -07:00
bjorn c5afb32ad2 Fix temporary vector memory layout;
It's important that the bits for the vector type occupy the least
significant bits, so that vectors can be distinguished from pointer
lightuserdata.

When the vector pool was expanded, this broke, causing e.g. Blob
pointers to exhibit undefined behavior when trying to use them as
vectors.

tbh I still don't understand the union/bitfield memory layout.
2023-07-03 19:14:27 -07:00
bjorn d109518c27 Fix number - vector math;
It still errors on temporary vectors, but that's a separate issue.
2023-07-03 18:49:57 -07:00
bjorn d4842d3502 Fix vec3 3-char swizzles; 2023-07-03 18:45:09 -07:00
bjorn 38be62c103 Use mat4_fromPose more; 2023-07-03 13:16:35 -07:00
bjorn 85ed9b9ca5 Scroll wheel changes simulated hand distance; 2023-07-02 16:08:00 -07:00
bjorn e9a9056b8c Return linear velocity for head; 2023-07-02 15:56:43 -07:00
bjorn 5b8d3e0cc8 Fix hand orientation; 2023-07-02 15:33:25 -07:00