Commit Graph

1578 Commits

Author SHA1 Message Date
bjorn 4892d228b3 WIP; 2023-07-24 15:34:44 -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 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
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 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 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 2bc90d2106 Add lovr.audio.getDevice; 2023-07-06 13:50:34 -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 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
bjorn 581c42b906 Implement mousearm simulator controls; 2023-07-01 00:40:04 -07:00
bjorn 447e746d41 Rename desktop driver to simulator internally;
The HeadsetDriver enumerant remains the same for now.
2023-06-29 16:24:51 -07:00
bjorn 6d8dba4657 Fix Quest hand mesh animation;
Quest added a thing where they emulate grip pose when hand tracking is
active.  This is actually pretty cool, and maybe LÖVR should do it too
on other runtimes, but it messed up the Quest hand mesh animation, for
some complicated reasons:

- Previously, getPose('hand/*') was returning the wrist pose because
  LÖVR fell back to hand tracking data when the controller wasn't
  tracked.
- Because of this, coupled with the fact that hand/controller models are
  expected to be drawn at the hand pose, hand meshes were animated such
  that the root node was located at the wrist pose.
- When Oculus added grip pose emulation for hand tracking, it caused a
  discrepancy:
  - Hand meshes were still being animated relative to their wrist pose
  - getPose was now returning grip-style poses
- This resulted in hand meshes being off by approximately 90 degrees.

The fix is to locate skeletal joints relative to the grip pose when
animating Oculus hand meshes, and to place the origin/wrist at its real
pose instead of assuming it's the origin.
2023-06-28 21:19:40 -07:00
bjorn 0daf85a7d9 Fix recentering bugs; 2023-06-28 21:04:56 -07:00
bjorn 21b8557ee9 lovr.system.has/setKeyRepeat; 2023-06-28 18:45:34 -07:00
bjorn 6e018b8c96 Replace HeadsetOrigin with 'seated' flag;
Origin type used to be a query-able property of the VR system that
indicated whether the tracking was roomscale or seated-scale.

The t.headset.offset config value could be used to design an
origin-agnostic experience, which by default shifted content up 1.7
meters when tracking was seated-scale.  That way, stuff rendered at
y=1.7m was always at "eye level".  It worked pretty well.

It's getting replaced with a t.headset.seated flag.

- If seated is false (the default), the origin of the coordinate space
  will be on the floor, enabling the y=1.7m eye level paradigm.  If
  tracking is not roomscale, a floor offset of 1.7m will be emulated.
- If seated is true, the origin of the coordinate space will be y=0
  at eye level (where the headset was when the app started).  This is
  the case on both roomscale and seated-scale tracking.

So basically 'seated' is an opt-in preference for where the app wants
its vertical origin to be.

One advantage of this is that it's possible to consistently get a y=0
eye level coordinate space, which was not possible before.  This makes
it easier to design simpler experiences that only need to render a
floating UI and don't want to render a full environment or deal with
offsetting everything relative to a 'floor'.  This also makes it easier
to implement hybrid VR+flatscreen experiences, because the camera is at
y=0 when the headset module is disabled.

The opt-in nature of the flag, coupled with the fact that it is
consistent across all types of tracking and hardware, is hopefully a
more useful design.
2023-06-28 16:38:36 -07:00
bjorn 3f0dbeb595 Add lovr.headset.stopVibration; 2023-06-27 20:45:44 -07:00
bjorn 88628ad8a8 Add 'floor' device;
You can do lovr.headset.getPose('floor') to get the offset of the stage
relative to the local origin if you want to draw something at the center
of the play area.

Also lovr.headset.isTracked('floor') basically tells you if it's roomscale.
2023-06-27 20:23:44 -07:00
bjorn c65eddb7cc Fix space leak after recenter; 2023-06-27 20:14:28 -07:00
bjorn 9798f14182 Add back spaces that accidentally got removed; 2023-06-27 20:09:29 -07:00
bjorn 8a9a05a3b9 lovr.recenter event; Use local-floor space by default; 2023-06-26 16:41:42 -07:00
bjorn 6a915a2993 Fix issue with mesh-multiple-skin check; 2023-06-25 19:16:34 -07:00
bjorn 98729912a8 Add GL_EXT_samplerless_texture_functions; 2023-06-24 14:00:22 -07:00
bjorn 116d14cdf8 Details; 2023-06-24 11:26:09 -07:00
bjorn ad5d00fb2f Bugfixes; 2023-06-23 22:56:33 -07:00
bjorn 3ed3a1b2f9 Store align on stack instead of in field; 2023-06-23 21:35:39 -07:00
bjorn 68878f9197 Rename/refactor more Buffer stuff;
BufferField -> DataField
fields -> format
decontaminate buffer constructor
2023-06-23 21:14:19 -07:00
bjorn 0ff633fa56 mv FieldType DataType; 2023-06-23 19:11:30 -07:00
bjorn 3804d15184 rm Pass:setVertexFormat and table variant of Pass:mesh;
The complexity/convenience tradeoff isn't satisfactory.
2023-06-23 19:05:42 -07:00
bjorn d17232bac5 Fix warning; 2023-06-23 18:28:17 -07:00
bjorn a511064987 Collider:isDestroyed; 2023-06-22 15:48:23 -07:00
bjorn b9e14a8f2d Merge branch 'master' into dev 2023-06-21 16:52:10 -07:00
bjorn 06811dcb1a Fix lovr.graphics.newModel when model has unused meshes;
Prefer n^2 loop over a weird sentinel value that wasn't always getting written over.
2023-06-21 16:50:24 -07:00
bjorn b086b3d236 Fix issue where models sometimes wouldn't reanimate;
If the very first graphics-related thing done in a frame is drawing a
model, the reanimation logic would skip because a new frame hasn't
started yet.  lovrModelAnimateVertices needs to unconditionally start a
new frame.  (Previously, a new frame was guaranteed to be started
because all passes were temporary, but this is no longer the case).
2023-06-20 21:46:04 -07:00
bjorn 065fc7b1d5 Rename variable to avoid shadowing; 2023-06-20 21:45:58 -07:00
bjorn 97cc7d9137 Fix issue with blend shape compute shader;
It was only copying the raw vertex data for the first blend shape,
not the first blend shape in each group.
2023-06-20 21:42:44 -07:00
bjorn 4ec065757d Optimize blendshapes;
To initialize the vertices to their default state, it's way faster to
use a branch in the compute shader rather than using a copy.
2023-06-17 17:14:00 -07:00
Josip Miskovic f0d916787a Add wheelmoved callback 2023-06-17 12:42:18 +02:00
bjorn 8b1b262760 lovr.visible; lovr.headset.isVisible; 2023-06-13 21:06:05 -07:00
bjorn d36b2d334e Put back stencil validation checks; 2023-06-12 23:07:35 -07:00
bjorn 313fc953cc Pass:append;
Copies draws from one pass onto another one.  Experimental.
2023-06-09 21:34:39 -07:00
bjorn efb7edeb08 Pass:draw(Texture); 2023-06-09 20:15:22 -07:00
bjorn 0a255af337 Add materials flag to newModel; 2023-06-09 18:32:54 -07:00
bjorn 82340f5da1 Mesh mode defaults to triangles;
Not sure where this went.
2023-06-06 22:39:22 -07:00
bjorn c9576bc98c Fix automaterial refcounting;
A little weird, but workable for now.
2023-06-05 19:54:44 -07:00
bjorn b57d7c2488 Per-draw cameras; Reset pass when canvas changes; 2023-06-05 19:45:20 -07:00
bjorn f17e2c790e Ensure draw index buffer is always set properly; 2023-06-05 00:01:52 -07:00
bjorn aa12263a29 Fix 24-bit WAV import; 2023-06-03 22:55:40 -07:00
bjorn 6ef16afee3 Tally fixup;
- rm Pass:getTallyCount.  It's unclear if this reports the current tally
  count, or the number of tallies in the last submit.  lovr was even
  getting this confused internally (fixed).
- rm tally index argument from Pass:beginTally and Pass:finishTally.
  The tally index is now an autoincremented value managed internally,
  and both :beginTally/:finishTally return it.  If someone wants to use
  their own indices, a lookup table can be used to do the mapping.
2023-05-31 18:56:09 -07:00
bjorn 4100be4f23 Fix vertex color import when model stores it as VEC3; 2023-05-27 12:04:35 -07:00
bjorn bd96b6afba Re-enable headless support on Android;
monado bug has since been fixed.
2023-05-26 17:04:18 -07:00
bjorn 9092545e9a Add bindings for Magic Leap 2 controller;
Notably, shoulder button is mapped to grip for now.
2023-05-26 17:03:11 -07:00
bjorn 4f29e3992c Don't bind pico4 actions if extension is unsupported; 2023-05-26 16:44:14 -07:00
duinodu 773c021d2d Add Pico4 support. 2023-05-18 15:27:18 +08:00
bjorn 77403a0908 rm unused prototype; 2023-05-17 20:29:46 -07:00
bjorn f9866f6771 Merge branch 'master' into dev 2023-05-17 20:29:10 -07:00
bjorn 4e4184cfc2 Pass:skybox requires a texture; 2023-05-17 20:26:38 -07:00
bjorn 08b911e142 Fix OpenXR interface; 2023-05-12 18:23:23 +01:00
bjorn 895f282241 Rename headet display frequencies to refresh rates;
Old API remains in deprecated state.
2023-05-12 18:01:42 +01:00
bjorn 440591746d Change default camera fov;
.6 is way too narrow, 1.2 is closer to previous versions
2023-05-12 17:35:19 +01:00
bjorn 18e327b135 Fix font wrap when camera is flipped to 2d; 2023-05-12 17:02:18 +01:00
bjorn 60ff2de78b Fix default projection matrix fov ratio;
Doubling the aspect doesn't really make sense.
2023-05-12 14:52:15 +01:00
bjorn 3f5e3bb0ed Improve passthrough API;
- lovr.headset.getPassthrough returns current passthrough mode
- lovr.headset.setPassthrough sets the passthrough mode
  - nil --> uses the default passthrough mode for the headset
  - bool --> false = opaque, true = one of the transparent modes
  - string --> explicit PassthroughMode
- lovr.headset.getPassthroughModes returns a table of supported modes
2023-05-12 14:18:22 +01:00
bjorn c9291d4401 Rename picoNeo3Controller flag to picoController;
It includes Pico 4 as well.
2023-05-12 10:47:47 +01:00
bjorn 4028b233a1 Model:clone;
Creates a lightweight copy of a Model, for situations where a single
model needs to be rendered with multiple poses in a single frame, which
is currently not possible.
2023-05-10 18:14:09 +01:00
bjorn 0bb16d24ef lovr.system.wasKeyPressed/Released; 2023-05-10 18:14:09 +01:00
bjorn be2502b3f2 Details; 2023-05-10 18:14:09 +01:00
bjorn da107f4387 Rename lovr.event.pump to lovr.system.pollEvents; 2023-05-10 18:14:09 +01:00
bjorn 98e648871e lovr.graphics.is/setTimingEnabled;
Enables automatic CPU/GPU timing for all passes.  Defaults to true
when graphics debugging is active, but can be enabled/disabled manually.

When active, Pass:getStats will return submitTime and gpuTime table
keys, respectively indicating CPU time the Pass took to record and the
time the Pass took to run on the GPU.  These have a delay of a few
frames.

This doesn't include a way to get "global" timing info for a submit.
This information would be useful because it doesn't require lovrrs to
sum all the timing info for all the passes and it would include other
work like transfers, synchronization, and CPU waits.  However, this is
more challenging to implement under the current architecture and will be
deferred to later.  Even if this were added, these per-pass timings will
remain useful.
2023-05-06 23:36:33 -07:00
bjorn 2e29ff1ecf Handle multiple compute writes to a resource properly; 2023-05-06 20:36:11 -07:00
bjorn 68808d991e Fix some bugs in lovr.graphics.submit;
- Make sure to reset barriers for compute/canvas resources too
- Delay stream ending so OpenXR layout transitions actually go in an
  active command buffer.
2023-05-06 20:32:16 -07:00
bjorn 5d342f3712 Fix readbacks never finishing; 2023-05-06 20:00:43 -07:00
bjorn d18109b6ce Use XR_BD_controller_interaction for Pico Neo 3 input;
Replaces nonstandard interaction profile.  Removed thumbrest paths and
applied menu to both hands, to align with the published extension.
2023-05-04 19:06:51 -07:00
bjorn a75086d0e4 Fix lovr.graphics.getWindowPass when there's no window; 2023-05-04 18:27:02 -07:00
bjorn f90cd237ca Add new occlusion query API; 2023-05-03 23:08:45 -07:00
bjorn 04a96f828b Clear bindings when switching shader types;
If you switch to/from a compute shader and the other shader is either
nil or a graphics shader, clear bindings.

Maybe if you switch to/from nil the bindings shouldn't be cleared, but
this is a bit more complicated to implement and it's not clear that
there's any reason not to treat nil shaders as graphics shaders.
2023-05-03 20:16:30 -07:00
bjorn 0c99572f61 Fix/simplify push constant tracking; 2023-05-03 20:15:48 -07:00
bjorn 5131544221 Don't track temporary buffers;
This was accidentally removed.
2023-05-03 19:35:03 -07:00
bjorn 6fe9e0151f Add Pass:barrier function;
Previously, if you wanted to run compute operations that depend on the
results of prior compute operations, you had to put these in 2 different
passes, because logically all of the compute calls in a pass run "at the
same time" (or we're at least giving the GPU the freedom to do that).

Having to set up an entirely new pass just to synchronize 2 :compute
calls is pretty cumbersome, and incurs extra overhead.  It would be
possible to change things so *every* :compute call waits for previous
computes to finish, but this would destroy GPU parallelism.

The Pass:barrier method lets compute calls within a pass synchronize
with each other, without requiring multiple passes.  Adding a barrier
basically means "hey, wait for all the :compute calls before the barrier
to finish before running future :computes".

This lets things remain highly parallel but allows them to be easily
synchronized when needed.
2023-05-03 16:45:01 -07:00
bjorn 07276f9351 Fix Pass:setClear color space and headset background; 2023-05-03 16:35:09 -07:00
bjorn 452ee5c7c6 Pass rework;
Pass stores draw commands rather than sending them to Vulkan
immediately.

The main motivation is to allow more flexibility in the Lua API.  Passes
are now regular objects, aren't invalidated whenever submit is called,
and can cache their draws across multiple frames.  Draws can also be
internally culled, sorted, and batched.

Some API methods (tallies) are missing, and there are still some bugs to
fix, notably with background color.
2023-05-02 00:06:01 -07:00
bjorn 24a68ba648 OpenXR: Add an epoch so headset time starts at zero;
32-bit float precision can't handle huge XrTimes.
2023-05-01 19:09:35 -07:00
bjorn f96b915767 OpenXR: lastDisplayTime should be an XrTime; 2023-05-01 19:09:33 -07:00
bjorn f370da90d5 OpenXR: Always return a valid view count;
View count is well-defined to be 2 with the current view configuration,
and people should be able to rely on getViewCount even before the views
are tracked.  It returns the number of views in the view configuration,
not the number of views with valid data.
2023-05-01 18:59:15 -07:00
bjorn 784440f5cb OpenXR: Handle zero timestamps; Handle tracking loss better;
- If timestamp is zero (before .update is called), return empty data
  instead of erroring.
- Check for valid position/orientation separately, and return empty data
  for anything that's invalid.  Previously both position/orientation
  were used if either was valid, which returns undefined results.
2023-05-01 18:49:59 -07:00
bjorn c115fd9c3a Simplify shader resource tracking; 2023-04-29 19:06:08 -07:00
bjorn f898a6f6b8 Linear allocator is no longer global to the graphics module;
Each Pass is gonna have its own allocator soon!
2023-04-29 18:35:01 -07:00
bjorn f98306e786 rm transfer passes; rm Tally for now;
- Add Buffer:newReadback
- Add Buffer:getData
- Buffer:getPointer works with permanent buffers
- Buffer:setData works with permanent buffers
- Buffer:clear works with permanent buffers
- Add Texture:newReadback
- Add Texture:getPixels
- Add Texture:setPixels
- Add Texture:clear
- Add Texture:generateMipmaps
- Buffer readbacks can now return tables in addition to Blobs using Readback:getData

Tally is coming back soon with an improved API, it's temporarily removed
since it made the transfer rework a bit easier.

Note that synchronous readbacks (Buffer:getData, Texture:getPixels)
internally call lovr.graphics.submit, so they invalidate existing Pass
objects.  This will be improved soon.
2023-04-29 18:31:03 -07:00
bjorn dbc59b6749 Trailing comma nit; 2023-04-28 20:36:43 -07:00
bjorn 6862b8c970 Change cofactor/normal matrix to mat3;
This means per-draw uniform data is 128 bytes now!
2023-04-27 20:22:31 -07:00
bjorn e9d61bd254 Fix error typo; 2023-04-27 20:17:30 -07:00
bjorn b64fdc937f Move mapped buffers from core/gpu into graphics module; 2023-04-27 19:48:12 -07:00
bjorn 4563959ed1 Rename scratch buffers to temp buffers internally; 2023-04-27 19:15:56 -07:00
bjorn 8f654ed408 Simplify fill shaders;
Now there's 2 instead of 3!  Behavior is the same, fill goes
layer-by-layer onto each view until either the texture or canvas run out
of layers.
2023-04-26 22:18:06 -07:00
bjorn ad20289595 Make default compute shaders regular default shaders;
Minor cleanup;
2023-04-26 21:36:30 -07:00
bjorn cb44549205 Fix more prototypes; 2023-04-25 21:45:30 -07:00
bjorn ad4978f692 Fix prototypes; 2023-04-25 21:37:14 -07:00
bjorn 6a030ef4f2 Add shader debug info when t.graphics.debug is set; 2023-04-19 20:49:34 -07:00
bjorn 56851fd0f2 Make builtin layouts constant instead of variable; 2023-04-14 21:27:47 -07:00
bjorn 70e5a69576 Cleanup; 2023-04-14 21:25:48 -07:00
bjorn 4bfab067ae Make shader input/output locations optional; 2023-04-14 21:21:14 -07:00
bjorn 024ea094a4 Fix Pass:roundrect bug;
It would draw a plane when radius was zero, even if it was supposed to
be thick.
2023-04-04 17:40:24 -07:00
bjorn 34c3e2c309 Fix Mesh validation and issues with untyped buffers; 2023-04-02 15:09:37 -07:00
bjorn 9c054c0515 Add mouse input to lovr.system; 2023-04-01 13:08:47 -07:00
bjorn 94879c1529 Rebase fixes; 2023-03-31 18:45:40 -07:00
bjorn 07a6d11c46 Split vertex animation into multiple dispatches as needed;
If the number of skinned vertices in a Model doesn't fit in a single
dispatch (~2M vertices on 32-sized subgroups or ~500K vertices on
8-sized subgroups), split it into multiple dispatches.
2023-03-31 18:45:16 -07:00
bjorn ff10461e69 Reduce blend shape chunk size from 128 to 64; 2023-03-31 18:45:16 -07:00
bjorn f56b48b3a7 Blend shapes and skinning work at the same time; 2023-03-31 18:45:16 -07:00
bjorn 4a6de6caf5 Write blend shape compute shader; Bugfixes; 2023-03-31 18:45:16 -07:00
bjorn 530db8c7f8 WIP blend shape compute dispatch; 2023-03-31 18:45:16 -07:00
bjorn 086aef1a79 Convert pipeline type bool into enum;
It's a little more readable.
Also batch compute passes for models with multiple skins, since they can
all run at the same time.
2023-03-31 18:44:31 -07:00
bjorn ce645c0285 Shader stores compute pipeline as pointer; 2023-03-31 18:44:31 -07:00
bjorn 3b1414deac Ok redesign blend shapes but they're good now; 2023-03-31 18:44:29 -07:00
bjorn b118ac1938 Terrible blend shape Lua API; 2023-03-31 18:43:16 -07:00
bjorn e1908f4a49 Blend shape weight accessors; 2023-03-31 18:42:48 -07:00
bjorn f8f3a78d11 Model:animate can animate blend shape weights; 2023-03-31 18:42:48 -07:00
bjorn b1b78319b5 Model loads blend shape data and weights; 2023-03-31 18:42:45 -07:00
bjorn 21bb3eb096 ModelData parses blend shapes; 2023-03-31 18:39:39 -07:00
bjorn 9722800d67 Fix blend mode merge; 2023-03-30 19:51:59 -07:00
bjorn 6bca4663ee Merge branch 'master' into dev 2023-03-30 19:51:38 -07:00
bjorn 7b6618310a Fix blend mode merge; 2023-03-30 19:51:17 -07:00
bjorn e9c79417c7 Merge branch 'master' into dev 2023-03-30 19:40:39 -07:00
bjorn 7f5ab081f5 Use runtime preferred environment blend mode; 2023-03-30 19:39:50 -07:00
bjorn bfbd17fc9f Zero-initialize spv_field memory;
Not all fields are guaranteed to get filled in.
2023-03-21 22:26:14 -07:00
bjorn aa2f620c89 Fix issue where changing shaders doesn't reset vertex format; 2023-03-20 13:54:38 -07:00
bjorn fa0576e42c Fix some magic numbers; 2023-03-20 13:54:38 -07:00
bjorn 92e9efd882 More flexible Buffer formats; Deprecate temp buffers;
- Pass:mesh accepts tables for vertices/indices
- Add Pass:setVertexFormat to set format used for table-based meshes
- Pass:send accepts tables for buffers
- Pass:send supports arbitrarily nested structs/arrays for push constants
- Buffer formats support arbitrarily nested structs/arrays
  - Zero-length buffers are valid and represent structs
  - Fields can have names using 'name'
  - Field types can be tables of other fields (structs)
  - Fields can have 'length' key
- newBuffer syntax has been changed to put format first (old version
  still works)
- Buffers can be created from shader variables, avoiding need to declare
  matching format.
- Pass:clear/Pass:read use byte offsets instead of indices
- Pass:copy uses byte offsets when copying a Buffer to a Buffer
- Deprecate lovr.graphics.getBuffer (tables can be used instead)
2023-03-20 13:54:37 -07:00
bjorn d2b2523306 Improve sampler2D error message;
- core/spv just returns the type of image variables instead of trying to
  validate them.
- When Shader is loading resources, it will reject combined image
  samplers, uniform/texel buffers, and input attachments, with better
  error messages that include the binding number of the invalid resource.
2023-03-20 13:15:47 -07:00
bjorn ffd6396aae Error when model uses absolute path; Ignore ./ in model paths;
Fixes #652
2023-03-13 21:14:47 -07:00
bjorn a2da95031b Merge branch 'master' into dev 2023-03-13 20:49:33 -07:00
bjorn 1d1470f042 Fix directory archive path normalization;
Fixes non-normalized paths not behaving as expected.
2023-03-09 21:27:04 -08:00
bjorn fe524452f3 Merge branch 'master' into dev 2023-03-09 18:37:25 -08:00
bjorn b33cc99374 Fix potential crash when creating textures;
beginFrame needs to be called a little bit earlier (before getting the
buffer to write the texture contents).
2023-03-09 18:36:23 -08:00
bjorn 2ad2fd6d90 OpenXR: Improve error messages;
- Error messages say what went wrong instead of file/line
- Instead of silently failing during startup, log a warning
2023-03-07 20:16:59 -08:00
Bjorn d8e856e6e0
Merge pull request #645 from mcclure/size-t-narrow
Address various MSVC warnings (casts, comparisons, function pointers)
2023-03-03 17:25:48 -08:00
mcc e4e8c5476b Warning fixes (fix style) 2023-03-03 15:48:41 -05:00
bjorn aba5f328fe Throttle when OpenXR session is idle; 2023-03-02 19:33:35 -08:00
mcc 52a7a51b8e Silence spurious function-pointer mismatch warning 2023-03-01 19:14:22 -05:00
mcc d00d908520 Silence signed/unsigned warning on rounded rectangle loop 2023-03-01 19:13:15 -05:00
mcc a5216347a0 Address size_t narrowing warnings in MSVC by adding casts. Add some asserts to make sure the casts are safe. 2023-03-01 18:15:04 -05:00
bjorn 886db5f91d Stop using isdigit in obj importer; 2023-02-25 00:00:04 -08:00
bjorn abbc6a6dc6 Merge branch 'master' into dev 2023-02-21 21:12:33 -08:00
bjorn af4f1c1dea Fix compilation with glslang disabled; 2023-02-07 22:48:50 -08:00
bjorn 41dd24edc4 Organize math module files; 2023-02-07 21:44:43 -08:00
bjorn 89edccbf4c Add lovr.headset.isPassthroughEnabled and lovr.headset.setPassthroughEnabled; 2023-02-05 19:51:12 -08:00
bjorn e4eb336bd6 Prevent creation of unrenderable texture views;
There were certain cases where an unrenderable texture view could be
created from a renderable parent texture (e.g. it has multiple mipmap
levels).  This would leave renderView as NULL, which would cause a
crash.
2023-02-05 17:34:24 -08:00
bjorn e076a582ce 3D depth textures can not have the 'render' flag;
Vulkan said so!!
2023-02-05 17:18:45 -08:00
bjorn a160def4e3 rm unreachable mipmap assert;
It's clamped earlier.
2023-02-05 17:15:15 -08:00
bjorn 06c150ce4e Pass:setBlendMode/Pass:setColorWrite take optional target index;
If the target index is missing, the state will apply to all targets.
Fixes undefined behavior when setting color state in a pass with
multiple color attachments.
2023-02-05 15:07:33 -08:00
bjorn b0c3bd6e4c Lightuserdata can be pushed to channels; 2023-02-04 14:08:22 -08:00
bjorn 8337dd9caf Vectors work with channels;
They are copied by value.  Upon popping, they are pushed as temporary
vectors.  Matrices are allocated on the heap, everything else is stored
in the Variant itself.
2023-02-04 14:03:12 -08:00
bjorn fbc591802a Details; 2023-02-01 19:26:18 -08:00
bjorn 66cb43a665 Support elbow poses from hand tracking;
Via XR_ULTRALEAP_hand_tracking_forearm
2023-02-01 18:36:05 -08:00
bjorn bf31072d0d Cleanup; 2023-01-30 19:44:23 -08:00
Ilya Chelyadin d84d358de7 Minor fixes 2023-01-31 06:03:53 +03:00
Ilya Chelyadin f0265a6f48 Disable headless OpenXR extension for Android 2023-01-29 23:45:23 +03:00
Ilya 933ae3a9ba
Merge branch 'bjornbytes:master' into picofix 2023-01-29 23:33:48 +03:00
bjorn d973020ce4 Add UVs to roundrect; 2023-01-27 00:32:21 -08:00
bjorn 2bccc4bf08 Increase max size of vector pool;
16k vec3s -> 4 million vec3s
2023-01-26 21:44:01 -08:00
bjorn 132b8d6003 Pass:roundrect; 2023-01-26 21:24:37 -08:00
bjorn 017c2136fd Merge branch 'master' into dev 2023-01-24 18:36:27 -08:00
bjorn 4e01f84070 Depth resolves;
- Allow multisampled render pass to have a single-sample depth attachment
- Add a new depthResolve feature, indicating whether it's supported
- Fix stencil load/save
- Minor changes to render pass caching
- Currently the depth resolve is done using the first sample.  A future
  improvement would be to expose/use the min/max/average resolve modes.
2023-01-22 23:30:57 -08:00
bjorn bee8d16427 Add error when render pass/texture sample counts don't match; 2023-01-21 12:16:35 -08:00
bjorn ffa4beb21c Fix thread refcounting;
Minor race condition between thread starting and thread getting released.
2023-01-19 15:05:04 -08:00
bjorn 4675dfb3e9 Fix build; 2023-01-18 18:21:53 -08:00
bjorn 3e0d2a1ecf core/os: window size is always in framebuffer units;
pixel density is exposed as a separate accessor.
2023-01-10 19:54:48 -08:00
undef bc7a541279 Fix constrained rendering in windowed mode on macOS #620 2023-01-06 20:30:05 +01:00
Ilya f3837d99fd
Merge branch 'bjornbytes:master' into picofix 2023-01-04 23:03:54 +03:00
bjorn b6d8546a6f Merge branch 'master' into dev 2023-01-02 16:46:55 -08:00
bjorn dd65a59602 Fix some literals in Curve:evaluate; 2023-01-02 14:43:27 -08:00
bjorn b885f2abf5 rm AUTO_MAP_LOCATIONS flag from glslang options;
It doesn't work properly, and silently produces broken shaders when the location is left off.
2022-12-26 07:21:54 -08:00
bjorn 305213bfb4 Error if shader push constants are too big; 2022-12-25 17:18:05 -08:00
Josip Miskovic bc1308c463 Check if torus shape is cached 2022-12-22 17:26:21 +01:00
bjorn 886e3bb42f Fix some windows warnings; 2022-12-19 14:01:30 -08:00
bjorn e12563ad25 Merge branch 'master' into dev 2022-12-16 21:21:05 -08:00
Ilya 5b36c44cfc
Merge branch 'bjornbytes:master' into picofix 2022-12-11 11:19:06 +03:00
bjorn f013831b73 Reorganize thread code;
- Put channel into thread module file.
- Make thread internals private.
- Handle more thread bookkeeping in thread module instead of Lua API.
- Fix a few race conditions/leaks nobody was probably ever going to hit.
2022-12-10 20:13:39 -08:00
bjorn 06dad182db Fix mounted directories with non-empty mountpoints;
Mounting directories with mountpoints wasn't treating the components
in the mountpoint path as virtual directories.
2022-12-10 18:25:09 -08:00
bjorn 74a9b90e93 Fix zip archive enumeration;
Zip archives weren't enumerating in the root directory when they were
mounted with a non-empty mountpoint.  Additionally, zips mounted at the
root directory weren't listing files properly.  This fixes both by
normalizing the mountpoint prefix (it had a prepended slash when it was
empty, which messed up hashing), and ensuring there is a "root node" in
the tree with an empty string.
2022-12-10 18:25:09 -08:00
Ilya 10675761e2
Check for thread handle 2022-12-11 00:47:20 +03:00
bjorn 36070e828c Add missing validation for rendering to depth textures; 2022-12-10 11:20:56 -08:00
Ilya Chelyadin 48aad15b1f Fix comma 2022-12-08 07:12:59 +03:00
Ilya Chelyadin f62c99e469 Fix typos, indentation, minor issues 2022-12-08 07:05:30 +03:00
Ilya bd767092f3
Merge branch 'bjornbytes:master' into picofix 2022-12-07 19:50:13 +03:00
bjorn b5c14da4a6 Pass:line errors if only 1 point is provided; 2022-12-04 18:01:20 -08:00
Bjorn 78a70670bb
Merge branch 'dev' into MSFT_controller_model 2022-12-03 19:34:49 -08:00
bjorn 3553982bad gpu: rm GPU_STAGE_ALL;
It wasn't very useful and probably doesn't do what was intended.
2022-12-03 15:02:55 -08:00
bjorn efc81e4cec Fix some gcc warnings; 2022-12-03 01:20:02 -08:00
Ilya 92c136bc73
Merge branch 'bjornbytes:master' into picofix 2022-12-01 21:20:33 +03: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
Ilya Chelyadin 13d8c4a207 Interaction profiles suggestion improvement
At least one profile should be supported. Monado fails on Neo 3 profile.
2022-11-25 21:16:42 +03: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
Ilya Chelyadin 3f20364c3f Pico is back!
Tested on Pico Neo 3 with PUI v4.9.3
Also included generic (Monado-Android) Android flavor.
2022-11-22 22:01:13 +03:00
s-ol 043f9c7920 store headset model metadata for animations 2022-11-22 12:24:57 +01:00
s-ol 533e02771e throw when model references external asset but no 'io' is given 2022-11-22 12:24:31 +01:00
s-ol 3f8e137469 implement XR_MSFT_controller_model 2022-11-22 12:24:25 +01: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