Commit Graph

319 Commits

Author SHA1 Message Date
bjorn b5c14da4a6 Pass:line errors if only 1 point is provided; 2022-12-04 18:01:20 -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 58dc7ee9dd Add missing check for sample usage in material textures; 2022-11-14 20:10:23 -08:00
s-ol 773d22f40d Check bounds in luax_checkanimation / luax_checknodeindex 2022-11-14 08:02:13 -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
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
bjorn df8f52a71b Fix gcc warnings; 2022-10-12 10:57:43 -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 28869431fb Fix stereo mirror window; 2022-09-15 20:45:26 -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 0da84894e8 Fix gamma correction of multicolor text; 2022-09-10 14:55:15 -07:00
bjorn d8c6c47e00 Add normal DefaultShader;
It's a pretty normal shader.
2022-09-10 11:07:55 -07:00
bjorn 5f921f1251 Unable to mipmap multisampled textures; 2022-09-10 11:02:03 -07:00
bjorn f30e37a2e3 Error if testing/writing non-existent stencil buffer; 2022-09-10 10:20:41 -07:00
bjorn a3beccb14e Fixup 3D texture blit validation; 2022-09-10 10:12:06 -07:00
bjorn 8697466009 Shader flag adjustments;
- glowTexture is on by default, but still requires the glow flag.
- occlusionTexture is named ambientOcclusion, and is on by default,
  but is still not used by any builtin shaders/helpers.
2022-09-02 15:33:18 -07:00
bjorn 63fbd4d223 Rebind descriptor sets if push constant ranges change; 2022-08-28 15:02:46 -07:00
bjorn 54a5ca1c36 Initialize stencil mask state slightly better;
Not sure this has an effect but it seems better.
2022-08-26 22:23:28 -07:00
bjorn cf474fe392 Shader flags can start with flag_;
It will be ignored for matching purposes.
2022-08-26 10:22:53 -07:00
bjorn 8e44a271df Fix default mipmap count for texture views; 2022-08-26 09:58:01 -07:00
bjorn 5a2fe54c04 Improve Pass:fill;
It can now fill an array texture to a multiview pass, copying to
the corresponding layers.
2022-08-26 09:57:51 -07:00
bjorn f4f95a64d7 Pass blends by default; 2022-08-25 22:01:12 -07:00
bjorn 78214988a4 Model only reskins when needed;
Saves a barriers when not animating models.
2022-08-25 21:59:10 -07:00
bjorn ede1036694 Temporary Passes;
Sigh, back to getPass.  I don't even know at this point.  Basically now
that we came up with a half-solution for temp buffers, it makes sense to
apply this to passes as well, since we aren't going with the workstream
idea and temp passes are more convenient than retained passes.
2022-08-25 21:57:15 -07:00
bjorn 1c48578e95 Fix automipmap synchronization; 2022-08-23 18:49:11 -07:00
bjorn e4024d82c4 Improve error messages for invalid view index; 2022-08-23 18:18:44 -07:00
bjorn 8dfc67d59c Add missing checks for automipmap transfer usage; 2022-08-23 18:17:38 -07:00
bjorn 79cd7c10a1 Improve temporary buffers;
- They no longer live in temporary memory, but in a dedicated pool.
- There are error checks for using a temporary buffer after it's invalid
  - However, these are imperfect, and could be improved.  One idea is to
    avoid recycling a temporary buffer until its refcount decays (i.e.
    Lua finally decides to garbage collect it).  This would explode
    memory usage sometimes, so it could only be enabled when
    t.graphics.debug is true.
2022-08-22 20:30:09 -07:00
bjorn dd5e89523d Fix BC1/BC4 sizes; 2022-08-19 23:15:18 -07:00
Josip Miskovic fcc684ac28 Handle fullscreen fill without texture 2022-08-18 09:04:42 -07:00
bjorn f515346e20 Rename CoordinateSpace;
It's now OriginType, and global -> root and local -> parent.
2022-08-17 22:33:43 -07:00
bjorn 3e8b1681df Pass:mesh supports baseVertex; 2022-08-17 18:09:04 -07:00
bjorn 8bbff5dd77 lovr.graphics.present idempotence; 2022-08-14 12:02:51 -07:00
bjorn 5799b0effb Rename setBackground back to setBackgroundColor;
The "fancy background" idea won't go here.
2022-08-13 21:10:58 -07:00
bjorn 6052ed7a95 Rename ModelData enums;
To better match graphics.
2022-08-13 21:10:03 -07:00
bjorn f679d602bd Fix cone winding; 2022-08-12 23:30:33 -07:00
bjorn 3cbf85c98a Adjust error screen font size and default perspective; 2022-08-12 21:08:25 -07:00
bjorn ad6360d2fd Clean up boot.lua;
A lot of clean up can happen now that C doesn't push delayed errors to
Lua.  This was happening for Pico and WebVR, neither of which are used
anymore.

Also default vsync to true but force it off if VR is active.
2022-08-12 20:18:55 -07:00
bjorn 0be94e0f1a Set default material normalScale to 1; 2022-08-12 17:44:29 -07:00
bjorn 3b33f4917e Fix vertex format binding; 2022-08-12 17:43:41 -07:00
bjorn 63a327c0b2 Add getLighting builtin function to shaders; 2022-08-09 19:49:47 -07:00
bjorn 31d49fe8c6 When graphics module is destroyed, stop XR session;
Terrible, but better.
2022-08-08 23:27:35 -07:00
bjorn 0436a5deae Rework automipmapping;
The sync was totally wrong here.  It's a bit better now.  However there
are some general sync issues that need to be fixed.  Basically a Pass
that does reads and writes or multiple writes doesn't work properly, for
various reasons.  I think sync needs to be split into 2 phases -- first
process all the reads and merge barrier bits into the barrier of the
last writer, then process all the writes and set 'final' resource state
for stuff in the pass.  Due to branch prediction it may be better to
have 2 separate lists -- one for reads and one for writes.  And I'm not
100% sure on how to reconcile a Pass that is doing reads and writes to
the same resource yet, still thinking about it.
2022-08-08 21:26:07 -07:00