Commit Graph

4427 Commits

Author SHA1 Message Date
bjorn b4b2b56c90 CMake: Don't recompile shaders on every build;
Recompile them only when needed.
2022-11-26 14:20:09 -08:00
bjorn 4422df2a47 Variant small string optimization; 2022-11-24 15:40:43 -08:00
bjorn 0c281bca50 Change default setProjection far plane to 0;
It was accidentally left at 100, which will cause problems.
2022-11-24 14:58:40 -08:00
bjorn e9776f98c6 Fix compatibility with Lua 5.2, 5.3, 5.4;
Part of this involved putting the Lua header back in api.h, since we
need to know the Lua version to define some macros properly.
2022-11-24 14:33:55 -08:00
bjorn 23f747d4c3 Fix CMake; 2022-11-23 14:12:58 -08:00
bjorn 8f74778c19 Error if require path is too long instead of truncating; 2022-11-23 14:08:32 -08:00
bjorn e426520144 Blob:getString takes an optional byte range; 2022-11-23 12:21: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 0c966ba216 gpu: destroy readback scratchpads properly; 2022-11-21 19:42:13 -08:00
bjorn be3faf8822 Fixes for Vulkan initialization; 2022-11-17 20:32:24 -08:00
bjorn 3879ce926d Improve Vulkan initialization;
- Check for layers before enabling
- Check for instance/device extensions before enabling

Fixes unfriendly errors when running on a system without validation layers
installed.

Uses same table approach as OpenXR code.
2022-11-16 20:21:03 -08:00
bjorn 7b3e1a02eb Fix newShader when nil is used as a stage's code; 2022-11-16 18:12:06 -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 b9ef1772da LÖVR no longer depends on system-installed Vulkan;
Experimental.
2022-11-14 20:54:43 -08:00
bjorn 58dc7ee9dd Add missing check for sample usage in material textures; 2022-11-14 20:10:23 -08:00
bjorn b61dbab21b newTexture resets usage when table is provided; 2022-11-14 20:03:58 -08:00
bjorn c2f12f1fd4 Fix matrix rotation decomposition when matrix has scale;
Similar to mat4_getAngleAxis, quat_fromMat4 and mat4_getOrientation need
to divide by the scale.
2022-11-14 19:46:01 -08:00
bjorn 9277b38273 Use fancy syntax for model data map indices;
Matches nodes.
2022-11-14 19:20:29 -08:00
bjorn d5ebb796b3 Mat4:set uses TRS order when scale is present; 2022-11-14 19:19:23 -08:00
bjorn c61d6b059b Merge branch 'master' into dev 2022-11-14 19:19:17 -08:00
s-ol c3494d3d30 Fix Model:getNodeScale() 2022-11-14 08:02:13 -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 7d3cc45cc2 LÖVR submodule improvements;
- Allow parent CMake projects to expose symbols more easily
- Allow for custom plugins folder
- Include directories are always relative to lovr's source dir

Co-authored-by: Ilya Chelyadin <ilya77105@gmail.com>
2022-11-09 22:42:50 -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 29f2a66bf0 Merge branch 'master' into dev 2022-11-09 19:06:02 -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
bjorn b047daa712 gpu: only set portability enumeration flag if extension is enabled;
There's a "portability enumeration" extension and flag you have to set
to get Vulkan to work on macOS.  If you don't set it, Vulkan hides the
MoltenVK runtime since it's not 100% conformant.  The flag was added
unconditionally, but it needs to only be added when the extension is
active.
2022-11-09 17:22:42 -08:00
s-ol 22ff6dab94 Fix wrong loop limit in lovr.graphics.newShader; 2022-11-09 17:00:08 -08:00
bjorn b81f86b5ad rm Android flavors for now;
There used to be oculus and pico but pico doesn't work anymore.

Eventually things will converge on the standard loader and we won't
need different loaders, but manifests may require flavors.
2022-11-09 00:21:49 -08:00
bjorn 8dc1d3192b Update README screenshot URLs; 2022-11-08 19:08:47 -08:00
Josip Miskovic 34611f2069 Add physics heightfield shape 2022-11-08 18:46:49 -08:00
bjorn e263086ae9 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-07 20:46:41 -08:00
bjorn 27b2d111c1 Merge branch 'master' into dev 2022-11-07 20:45:58 -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 5e2b44ad08 Fix stereo mirror window;
For some reason this was rendering both layers of a multi-layer
texture all squished.  I think it was supposed to just render the
first layer.
2022-11-07 17:14:27 -08:00
bjorn c021fc40ef gpu: fix memory type selection;
When a fallback memory type is found, don't skip the check for a perfect
match.
2022-11-06 11:19:33 -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
Josip Miskovic 92975d34fc Cannot use Android-built glslang on desktop 2022-10-31 17:59:42 -07:00
bjorn 67627f4aab Fix shader slot type assignment; 2022-10-31 17:55:26 -07:00
bjorn 64591c02ed gpu: Also try to load libvulkan.so.1;
Some systems don't have libvulkan.so
2022-10-24 22:12:54 -07:00
bjorn 56b091227d tup: rm cc override; 2022-10-20 21:28:54 -07:00
bjorn 1a12904800 Fix gpu_release; rm morgue flush; increase morgue size;
- When a memory block was freed, any allocators that were using it need
  to null out their memory blocks.  Otherwise it would just keep using
  the freed block.
- The emergency morgue expunge doesn't work.  It would be nice if it
  did, but if the emergency expunge deletes an object that exists in a
  command buffer that's still being recorded, it causes all kinds of
  problems and corrupts the command buffer.  You'd either need to submit
  these command buffers early before deleting the object (this is super
  tricky) or just prevent this entirely, maybe by growing the morgue
  infinitely or throwing an error if it fills up.  Either way, creating
  and releasing textures in a loop without submitting work will
  eventually throw an 'out of memory' error.  None of this is
  satisfactory and I'm not sure how to solve this well yet.
- To compromise, increase the size of the morgue a bit so emergency
  flushes happen slightly less often.
2022-10-20 20:21:55 -07:00
bjorn 3958c006fa Don't generate mipmaps for textures without initial contents; 2022-10-20 19:37:00 -07:00