Commit Graph

5075 Commits

Author SHA1 Message Date
Bjorn 30cb0c19a0
Merge pull request #733 from xiejiangzhi/slow_move_32_tag_and_other_fix
Slow movement for sim, fix bug of tag, add max number of tag to 32
2024-01-20 21:56:38 -08:00
xiejiangzhi 45a6333afb Slow movement for sim, fix bug of tag, add max number of tag to 32
Holding ctrl to slowly movement for Sim
Check null for findTag
Increment max number of tags to 32
Fix newWorld error if tags > MAX_TAGS
2024-01-21 13:50:59 +08:00
bjorn a90c4092f8 glslang: Add -gVS when compiling default shaders for debug build;
This allows RenderDoc to debug the default shaders.
2024-01-20 21:47:27 -08:00
bjorn 1e02c16c5d 'sample' TextureFeature no longer implies linear filtering support;
Basically it's somewhat common for depth-stencil formats to not support
linear filtering and that is kind of annoying because you can't create
depth textures with the `sample` usage.  Instead we'll just ignore the
LINEAR format feature bit for now.

In the future I'd like to fix this by silently demoting individual
texture's filtering to nearest when linear is not supported for the
format, but this requires per-texture sampler settings which isn't done
yet.
2024-01-20 21:21:00 -08:00
bjorn 4e2c0111c7 Quat euler fixup; 2024-01-20 03:45:21 -08:00
bjorn 7b72c64de4 Quat:SetEuler -> :setEuler; 2024-01-20 03:43:18 -08:00
bjorn a4c57193d5 Details; 2024-01-20 03:42:51 -08:00
Bjorn 5bbd093cf1
Merge pull request #730 from jmiskovic/fix/sphere_segments
Bound check the number of sphere segments
2024-01-19 17:27:42 -08:00
Bjorn 0f64de7d2c
Merge pull request #722 from xiejiangzhi/quat_euler
Add quat:ToEuler and quat:fromEuler
2024-01-19 17:27:18 -08:00
Josip Miskovic 3db04db05a Bound check the number of sphere segments 2024-01-19 23:18:58 +01:00
xiejiangzhi 165dac6130 Rename toEuler -> getEuler & fromEuler -> setEuler for Quat
Use float instead of double for quat euler calc
2024-01-19 19:04:57 +08:00
bjorn fd771f6420 Fix newBuffer crash when created with initial contents on some GPUs; 2024-01-17 15:52:56 -08:00
bjorn dfa231ebc0 Fix memory leak in pass lookup; 2024-01-17 15:48:34 -08:00
bjorn 65f1370314 Update flushTransfers comment;
No longer applies to buffers.
2024-01-17 15:41:27 -08:00
bjorn 5c60f068db Blend mode usess a lookup table; 2024-01-17 15:40:42 -08:00
bjorn 435d2676cd Fix issue with buffer destruction; 2024-01-14 02:28:10 -08:00
bjorn 6fa8e41c92 Merge branch 'stable' into dev 2024-01-13 18:11:47 -08:00
bjorn d4a17eee4c Actions: Update Android build-tools version to 34.0.0; 2024-01-13 18:11:22 -08:00
bjorn fd3b0c365d Actions: update sdkmanager path; 2024-01-13 18:09:54 -08:00
bjorn 358abdcd86 Actions: update sdkmanager path; 2024-01-13 18:06:40 -08:00
bjorn b45856b744 Actions: use ANDROID_SDK_ROOT instead of ANDROID_HOME; 2024-01-13 18:04:54 -08:00
bjorn 33fa6ed623 Fix skeletal animation; 2024-01-13 18:01:04 -08:00
bjorn e1abf0b332 Refactor render passes for thread safety;
Currently pipeline compilation accesses the render pass cache, which
presents thread safety challenges.  The framebuffer and render pass
caches are also slow and gross.

This adds a `gpu_pass` object which is basically just a VkRenderPass
object.  The graphics module creates and caches these in
`lovrPassSetCanvas`.  They are used when compiling pipelines and
beginning render passes.

Framebuffers are no longer cached but are just created and immediately
condemned dynamically when beginning a render pass.  This is fine,
because framebuffers are super cheap.

There's still technically a thread safety issue with the `gpu_pass`
object caching, but it's much easier to solve that with a lock in
`lovrPassSetCanvas` compared to trying to make core/gpu's render pass
cache thread safe.

This is all still a temporary measure until we can use a more
"ergonomic" render pass API like dynamic rendering.

Oh also we stopped using automatic layout transitions because they seem
to be pessimistic in drivers and require tying render pass objects to
texture usage which is annoying.  So now we do attachment layout
transitions manually before/after beginning/ending a render pass, which
isn't so bad.
2024-01-13 17:35:43 -08:00
bjorn 5c46d6169a Fix depth write not working when depth test is disabled;
A classic
2024-01-13 03:05:39 -08:00
bjorn 0c528ff3de Merge branch 'stable' into dev 2024-01-09 15:27:54 -08:00
bjorn 1122f6419b Actions: rm sudo from Android install command; 2024-01-09 15:12:42 -08:00
bjorn 3216573f0b Actions: Manually install Android SDK;
GitHub removed Android versions v30 and below.
2024-01-09 15:10:15 -08:00
bjorn 83f106b89f Fix render pass cache when compiling pipelines;
Comparing the lower 32 bits to the full hash was producing false
negatives and causing unnecessary render pass creation when creating
pipelines.
2024-01-09 14:53:27 -08:00
bjorn f1530e4d29 Disable fragment stage if there are no color attachments;
Fixes a validation layer, and may result in performance improvement.  I
think this technically means you can't do discard/FragDepth to adjust
depth buffer values, but that's kinda niche.
2024-01-09 11:56:30 -08:00
bjorn 49752f851a More fixes for Shader clones; 2024-01-07 17:06:26 -08:00
bjorn ea232969c1 Year; 2024-01-07 14:07:35 -08:00
bjorn d5d75d58e5 Shader clones set stage mask properly; 2024-01-07 13:43:22 -08:00
bjorn 1b1bc182bf Fix cubemap orientation;
+Z is the front face in a cubemap, not -Z.  Currently cubemap faces are
flipped in both the X and Z directions.

Some kind of flip is required because cubemaps use a left-handed
coordinate space instead of lovr's/vulkan's right-handed coordinate
space.

Equirect does not need any changes.
2024-01-06 13:58:14 -08:00
bjorn 3cf76c81e7 Refactor shader stages; rm ShaderType;
Goal is to support more combinations of shader stages, both for
vertex-only shaders and mesh/raytracing shaders in the future.  In
general most of the logic that conflated "stage count" with "shader
type" has been changed to look at individual shader stages.
2024-01-05 14:59:19 -08:00
bjorn d29e6c2ec3 Fix warning message when requiring module fails; 2024-01-05 14:23:34 -08:00
bjorn da763c8786 rm ability to create shaders from tables of spirv opcodes;
I don't think anyone was using this, and it adds ambiguity to
the newShader argument logic.
2023-12-30 19:52:41 -08:00
bjorn 8ea2b11939 Buffer suballocation;
Now all regular Buffer objects are suballocated from big 4MB buffers,
like the temporary buffers.

Each of the big buffers is refcounted.

Wherever a `gpu_buffer` is used, the offset of the "view" into the big
buffer needs to be taken into account as well.

A practical advantage of this is that vertex/index buffers usually do
not need to be rebound between draws when drawing a different model/mesh.
2023-12-30 14:28:45 -08:00
bjorn e8e7c2afc1 Refactor buffer allocation;
Pretty much the same, but fixes an obscure lifetime issue with pass
buffer allocation.

If a pass's buffer fills up, it can't be recycled immediately because
that might cause the buffer to get reused too soon if the pass is
submitted multiple times (with draws added in between that exceed 4MB of
temp buffer allocations).

Instead, the strategy is to have the pass keep track of "full" buffers
in a pass-local freelist.

Whenever the pass is submitted, the tick of each full buffer is set to
the current tick, so we know the tick when it's safe to reuse them.

When a pass is reset (or destroyed), all of its full buffers are
returned to the global freelist of stream buffers.  The current one can
remain in use.

Pooling the buffers of all the passes globally like this increases reuse
opportunities but also increases contention.

These changes also serve as preparation to suballocate Buffer objects in
the graphics module, which makes it easier to batch more stuff.
2023-12-30 14:28:45 -08:00
bjorn 655ebfe626 Something something core/gpu supports descriptor arrays;
Arrays of bindings is really bad for API usability so the existing
single-descriptor API remains backwards compatible -- if you specify a
count of zero then the old "by-value" union entry is used, but you can
specify a count > 0 and then it will use an array of bindings.
2023-12-08 21:45:34 -08:00
bjorn a36e17b632 Error when shaders have arrays of buffers/textures;
It's not currently supported and results in undefined behavior.
2023-12-08 20:13:42 -08:00
bjorn 8dddd8376d Fix spv comment; 2023-12-08 20:13:38 -08:00
bjorn cbc671f48d Fix query pool memory leak; 2023-12-03 06:35:38 -08:00
bjorn 3a2d453ce8 Fix thread module destruction; 2023-12-03 06:34:22 -08:00
bjorn 6c93e87560 Add back --console argument; 2023-12-02 18:23:16 -08:00
bjorn 375866d3d4 lovr.system.openConsole; 2023-12-02 18:17:36 -08:00
bjorn 761a454291 Fix previous commit after more testing;
lastTransferRead/Write isn't always a reliable indicator of whether a
resource has pending transfers.
2023-12-02 17:27:31 -08:00
bjorn fbae4d1961 Fix possible crash with Font:getLines and Pass:text;
- Font:getLines/Pass:text use temp memory for strings/vertices.
- Due to the recent morgue fix, resizing the atlas will now do a GPU
  submit to flush the transfers before destroying the atlas.
- This GPU submit also rewinds the temp allocator, invalidating the
  temp memory used for the lines/vertices, causing a use-after-free.

There are 2 changes here:

- Only flush transfers if the destroyed resource actually has pending
  work (we're already tracking this w/ lastTransferRead/Write).
- Restore the allocator cursor after doing the submit.

Having to restore the allocator offset is kinda tricky/complicated,
which sucks.  Other solutions might be:

- Avoid using temp memory in those Font methods.  More generally, adopt
  a rule where you can't use temp memory if it's possible that there
  will be a submit while you're using the temp memory.
- Find some way to stop destroying the old font atlas during a resize?
- Don't rewind the temp allocator on every GPU submit.  Instead only
  rewind it at the end of a frame, or only when Lua does the submit.
2023-12-02 17:11:22 -08:00
bjorn 987c029479 Add back graphics module check to errhand; 2023-12-01 16:50:45 -08:00
Bjorn 4da1f26153
Merge pull request #719 from bjornbytes/boot-rework
Boot rework
2023-12-01 00:29:44 -08:00
bjorn edecbc50b1 Fix texture view synchronization/refcounting;
We were conflating "parent struct of Sync pointer" and "object to be
refcounted", which isn't the case for texture views.

To fix it, add both pointers to the Access struct.  This sucks because
it increases the size from 16 bytes to 24 bytes.

There might be other solutions like a "texture view mask" or having
buffers/textures store a pointer to their sync or something.  But these
have some drawbacks as well.  May revisit in future.
2023-11-30 19:30:02 -08:00