Commit Graph

1578 Commits

Author SHA1 Message Date
bjorn 44b250a517 Fix issue with texture readback layer count; 2023-10-04 13:12:55 -07:00
bjorn 842df4b305 Fix buffer readback issues; 2023-10-04 08:52:05 -07:00
bjorn f0686f0115 Update msdfgen; Orient contours properly;
This fixes issues where some fonts would have glyphs with weird windings
and they would get rendered inside-out.

Unfortunately updating msdfgen increased its size by a factor of 2-3x.
2023-10-03 11:12:38 -07:00
bjorn 9a276e5f9a Tally fixups;
- rm :getTallyData, it's totally lame, just do a readback
  - rm gpu_tally_get_data too, webgpu doesn't support it anyway
- Clamp tally copy count so it doesn't overflow buffer
- Tally buffer offset's gotta be a multiple of 4
- Return nil instead of 2 values when tally buffer isn't set
- Copy correct number of tallies (multiply by view count instead of max
  view count)
- Skip occlusion queries entirely if no tally buffer was set
2023-10-02 10:20:52 -07:00
bjorn 9c28eab732 Fix crash when drawing with an active compute shader; 2023-10-02 09:56:33 -07:00
bjorn 6462c7bc07 getBundle takes bindings; 2023-10-02 09:07:50 -07:00
bjorn d901481cdc Clear canvas info properly when setting canvas to nil; 2023-09-30 13:19:31 -07:00
bjorn d7c6461916 Render targets with mipmaps get transfer usage;
Also I think no mipmaps is more sane default for render targets.
2023-09-29 05:22:03 -07:00
bjorn 4e6effceff lovr.graphics.wait updates timing stats and readbacks; 2023-09-28 23:26:04 -07:00
bjorn a2f539de56 Update glslang; Shader #include uses virtual filesystem;
This update seemed to increased glslang's binary size even more...
2023-09-28 22:04:05 -07:00
bjorn c3b99a397a Mesh bounding box uses same convention as everyone else;
It was using

minx, miny, minz, maxx, maxy, maxz

Instead of

minx, maxx, miny, maxy, minz, maxz
2023-09-28 02:26:53 -07:00
bjorn 19c4aed465 Fix crash when headset module is disabled; 2023-09-27 23:04:55 -07:00
bjorn c3c5284f11 Improve viewport/scissor accessors;
- Better validation
- Can set to nil to "disable"
- Getter returns nil when "disabled"
- Negative viewport height works again
2023-09-27 00:24:01 -07:00
bjorn 73b1b951f5 Model:clone has separate blend shape state; 2023-09-24 23:51:42 -07:00
bjorn a478f417f2 Pass:draw(Texture) bounds; 2023-09-24 23:31:57 -07:00
bjorn d021596e6d Mark blend passthrough mode as supported on Quest; 2023-09-24 22:07:37 -07:00
bjorn 1d91ea1fde Replace tinycthread with C11 threads.h polyfill; 2023-09-21 23:26:16 -07:00
Bjorn 5db7d4a914
Merge pull request #704 from bjornbytes/surface
Surface Improvements
2023-09-21 22:34:45 -07:00
bjorn 94cdb9ae4e Fix GCC warning;
GCC warns when passing a pointer to a float to lovrModelSetNodeTransform
(currently done in OpenXR driver when updating model poses from an
XrPose).
2023-09-21 22:24:57 -07:00
bjorn b03e3244c3 LÖVR no longer requires 64KB uniform buffers;
Due to per-draw data size reduction from 144 -> 64 bytes.
2023-09-21 15:58:04 -07:00
bjorn 479983fede gpu: surface improvements;
Restores ability to open window after initializing graphics module.

Surface is created lazily instead of being required upfront.

Use native platorm handles instead of GLFW's callbacks.

Some minor reorganization around core/gpu present API and xr transitions.

Linux links against libxcb/libX11/libX11-xcb for XGetXCBConnection.
2023-09-20 21:17:24 -07:00
bjorn f318c68796 Buffers can be cleared to values other than zero; 2023-09-18 23:05:27 -07:00
bjorn 38dbc46e8b Pass:append also copies draw bounding boxes; 2023-09-18 17:49:19 -07:00
bjorn d7e7449e5a Fix message box;
oops I thought windows was already in graphics.c
2023-09-17 19:04:15 -07:00
bjorn c98f945cae rm os_window_message_box;
The message box is meant to be a hack to improve UX on Windows, not an
officially supported feature of core/os.  So it's more appropriate to
inline it in the one place/platform where it's used.
2023-09-17 17:22:08 -07:00
bjorn 181427eee4 glfw: filter resize events and cache window size;
GLFW reports window size as zero on Windows when the desktop window is
minimized.  This is by design.  Using zero width/height for window
textures isn't valid.  The fix is to ignore resize events where the
width or height is zero and also cache the last-valid window size so it
can be reported by os_window_get_size.  Sighs...
2023-09-13 18:56:06 -07:00
bjorn f6216415e6 Rename pass memory stats to indicate they're CPU; 2023-09-11 20:19:36 -07:00
bjorn 5b6d882475 Add Image:mapPixel; 2023-09-11 18:48:46 -07:00
bjorn be213cc32d Cleanup; 2023-09-11 17:24:27 -07:00
bjorn 9542d46f33 Buffer format cleanup; 2023-09-11 03:01:11 -07:00
bjorn fe93018627 Fix issue with DrawData UBO size; 2023-09-11 00:35:26 -07:00
bjorn de268ef2d9 simulator: hand stays tracked while rotating;
It continues to use the mouse position of the click to compute the pose.
2023-09-09 12:29:32 -07:00
bjorn 5badf6d8db DPI fix; 2023-09-05 16:27:18 -07:00
bjorn 14cb2ed368 Add os_thread_attach/os_thread_detach;
These are called when creating/destroying Thread objects.  It's
currently only implemented on Android, where it attaches/detaches the
Java VM to the thread.  This allows JNI calls to be used on threads.

However I don't think e.g. `lovr.system.requestPermission` will work on
a thread yet, because it uses the global JNI env from the main thread
instead of the thread's JNI env.  Still, attaching/detaching the VM is
an improvement and will allow well-behaved JNI methods to work on
threads now.

I don't know how expensive this is, yolo.
2023-09-05 16:20:32 -07:00
bjorn 78308acfa4 Fix Pass:capsule when its length is zero;
Just draw a sphere.  The transform is rotated so the sphere segments
line up better, because spheres and capsules use different orientations
for their sphere parts.  Also the "degenerate" z axis is reconstructed
to be perpendicular to the x/z axes.  This doesn't seem like it will be
particularly fast, but hopefully people aren't drawing zero-length
capsules too often.  There might be an opportunity to shortcut the
rotation since it's 90 degrees and would just involve swapping columns.
2023-08-22 20:36:17 -07:00
bjorn 0fcbdcbf5d Fixup overlay order;
- state.features.overlay should remain a bool since it just indicates
  whether the extension is supported/enabled.
- split the config value into a bool/u32 pair so the full u32 range can
  be used for the order (seems important to coordinate with other apps).
  - Also you can use a boolean now like before, which uses 0 as the order.
2023-08-21 15:15:39 -07:00
Bjorn f8f9c833b1
Merge branch 'dev' into master 2023-08-21 14:59:53 -07:00
bjorn 2d94841db6 Pass:skybox takes nil; 2023-08-21 14:37:05 -07:00
BabbleBones 6fbfc16f7d feat: overlay layers 2023-08-18 11:30:58 -04:00
bjorn 6f566f2125 Show a message box when Vulkan initialization fails on Windows; 2023-08-17 15:02:53 -07:00
bjorn 0d6c9a1def World:isCollisionEnabledBetween takes nils;
They act like wildcards, just like nil tags do otherwise.
2023-08-15 18:24:19 -07:00
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 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
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