Commit Graph

4422 Commits

Author SHA1 Message Date
bjorn cdecc1bae7 Add defer system; Rework exceptions; util cleanup;
Defer can be used to clean up resources when an error occurs.
2024-03-29 18:10:22 -07:00
bjorn 67e228125b Add d24 TextureFormat;
LÖVR uses d32f by default, but that's not guaranteed to be supported.

However, GPUs must support either d32f or d24, so we can fall back to
d24 reliably.
2024-03-29 18:07:25 -07:00
bjorn b7e1b5111e jolt: fix some shape memory leaks; 2024-03-29 15:26:10 -07:00
bjorn c5d6bb6b48 jolt: rm matrix copies;
JoltC now uses floats for its RVec/RMatrix structs in single precision
mode, so we can operate on them as mat4's directly, copy/cast them, etc.
2024-03-29 15:26:03 -07:00
bjorn 87cd13d95c jolt: adjust includes; 2024-03-29 15:25:41 -07:00
bjorn abd2eddf0d Fix some strict prototype warnings; 2024-03-23 13:12:26 -07:00
bjorn cc4567652e Merge branch 'stable' into dev 2024-03-17 13:59:31 -07:00
bjorn d50f661ce6 Fix possible negative dt when restarting simulator; 2024-03-17 13:59:13 -07:00
bjorn 2b218d09d0 Merge branch 'stable' into dev 2024-03-12 11:58:34 -07:00
bjorn 66f6ee9bb9 v0.17.1; 2024-03-12 11:56:30 -07:00
Josip Miskovic a84385a030 Fix Model:getMesh()
(cherry picked from commit 37fdb39e73)
2024-03-12 11:05:22 -07:00
bjorn b09d612e6b Validate that intra-buffer copy has non-overlapping ranges;
(cherry picked from commit 06bfbbaa6b)
2024-03-12 11:04:14 -07:00
bjorn 561b20699a Fix error when loading a Model without any vertices;
(cherry picked from commit 3712bc3fba)
2024-03-12 11:03:33 -07:00
bjorn aff97b7a30 glTF: support glb models without BIN chunk;
(cherry picked from commit 35f97f08f3)
2024-03-12 11:02:21 -07:00
Josip Miskovic 8c3c0f8136 Bound check the number of sphere segments
(cherry picked from commit 3db04db05a)
2024-03-12 11:00:42 -07:00
bjorn 1e02de6cda Fix depth write not working when depth test is disabled;
A classic

(cherry picked from commit 5c46d6169a)
2024-03-12 10:55:21 -07:00
bjorn 24c13e88d3 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.

(cherry picked from commit 83f106b89f)
2024-03-12 10:55:16 -07:00
bjorn 35228f1838 Create files/directories with more permissions;
Files are created with 664 (though usually modified by umask).

Directories are created with 755 permissions.

Main motivation is to allow adb to access files on Android 12+

(cherry picked from commit 9445331df8)
2024-03-12 10:46:14 -07:00
Josip Miskovic 0e9171e2dd Use virtual memory in vector pools
(cherry picked from commit a1d7bf5fbc)
2024-03-12 10:44:43 -07:00
bjorn ae1edd95e7 Skip creating texture views for transfer-only textures;
Vulkan forbids it!

(cherry picked from commit eac68d2fe4)
2024-03-12 10:41:20 -07:00
bjorn d097d9819d Add wrappers for malloc functions; 2024-03-11 14:38:00 -07:00
bjorn 2d7b636a90 Change more asserts to checks; 2024-03-11 00:58:21 -07:00
bjorn 0d8d6f579b rm unused lovrImageClear prototype; 2024-03-11 00:57:59 -07:00
bjorn aa79822edb Fix VertexIndex;
Adding an offset to VertexIndex/BaseVertex breaks those builtins for
shader code.  Instead, go back to binding the vertex buffer at an
appropriate offset.

This means we rebind the vertex buffer and makes it harder to batch
draws.  In the future we'd like to go back to binding all vertex buffers
at zero and incorporating per-draw vertex offsets, but we'll need to
adjust the VertexIndex macro to subtract that offset.
2024-03-10 10:36:13 -07:00
bjorn 1cda2d59a7 gpu: increase max number of memory blocks to 1024;
We are allocating buffers in smaller chunks now (4MB), and only 256 of
those would limit GPU memory usage to 1GB (in reality the cap is much
higher since static buffers and textures are still suballocated, and any
allocation bigger than 4MB will use its own block).  Still, in some
degenerate cases with huge amounts of temporary buffer memory, we are
hitting this limit earlier than we'd like.
2024-03-08 12:03:55 -08:00
bjorn f93fb0c0c7 Set buffer tick properly when destroying pass;
This was causing one of the pass's buffers to be unrecyclable.
2024-03-08 11:56:23 -08:00
bjorn 4719dbdd10 Fix crash with timestamp readback; 2024-03-07 10:26:35 -08:00
bjorn 9068c8daee rm map_remove;
It's no longer used.
2024-03-07 10:13:00 -08:00
bjorn dc643ad166 Shader:getBufferFormat improvements;
- Returns nil instead of erroring if variable does not exist.
- For runtime-sized arrays, returns nil for length instead of 4 billion.
2024-03-05 09:01:01 -08:00
Ilya 4139f0f180
Make lovrAssert act like a function
`do {} while(0)` is the perfect way to make function-like macro act like a real function (require ;, encapsulate local variables)
2024-03-03 14:37:14 +03:00
bjorn 1ec0a41bb8 Also avoid allocating empty uniform buffer for indirect/compute; 2024-03-01 17:14:08 -08:00
bjorn c3d81debe8 Clean up GPU submission; 2024-03-01 17:13:06 -08:00
bjorn 80b596daf6 job: return NULL if queue is full when starting job;
The current implementation might spin forever if only one thread is
starting/waiting on jobs, since nothing will be waiting on the jobs
(i.e. freeing up queue slots) while spinning.

The correct thing to do is to return NULL and let the caller handle
backpressure.  It's a bit more annoying to program since you might not
get a job back and need to handle it, but it's the right thing to do.
2024-03-01 16:48:28 -08:00
bjorn 79e28eb7e3 Fix issue with shader uniforms;
Shader == NULL wasn't clearing the dirty uniform flag, so if the
uniforms were dirty when you set a default shader we would try to
allocate and bind a zero-size uniform buffer.

Instead, let's avoid making a new uniform buffer if the shader doesn't
have any uniforms!
2024-03-01 12:46:08 -08:00
bjorn 224b6a495d Simplify job error string memory stuff;
Comparison against string literal isn't good.  I wish there was a way to
not heap allocate so much though, but exceptions are exceptional anyway.
2024-02-28 12:31:34 -08:00
bjorn 901dd268f2 job copies errors; add variadic version of job_abort;
I caved and depended on malloc/sprintf because I couldn't find anywhere
else good to put it...
2024-02-28 12:31:34 -08:00
bjorn f6af859984 job system error handling;
- Jobs can now throw exceptions using job_abort.  This will store an
  error message on the job and immediately stop the job.  The method
  will never return.  It must be called from the worker thread running
  the job, so in practice it should only be called by the job function.
- After waiting for the job to complete or abort using job_wait, the
  error message can be checked using job_get_error.  This is the raw
  pointer passed to job_abort, caller is responsible for freeing it or
  doing whatever necessary cleanup is required.
- job_free must be used to recycle the job after waiting on it.

Yes it uses longjmp.

There's also some general cleanup, and job_start just does random jobs
when the queue is full instead of returning NULL.
2024-02-28 12:31:34 -08:00
bjorn b32ac1c5a5 Details; 2024-02-28 12:31:34 -08:00
bjorn 1701409763 threads polyfill defines thread_local;
Might need to be removed for C23.
2024-02-28 12:31:34 -08:00
bjorn a4c1d9fce6 Thread module initializes job system;
Worker count can be set from conf.lua.

A negative worker count is relative to the number of cores.

-1 is the default.
2024-02-28 12:31:34 -08:00
bjorn d017ca0fac Details; 2024-02-28 12:31:34 -08:00
bjorn 35b5693a19 Add some more windows atomics; 2024-02-28 12:31:34 -08:00
bjorn e8dc1484d3 Cleanup; 2024-02-28 12:31:34 -08:00
bjorn 98e2e94ea8 Job done counter uses atomic loads/stores; 2024-02-28 12:31:34 -08:00
bjorn 4a175c4cf8 Fix atomic intrinsics; 2024-02-28 12:31:34 -08:00
bjorn 6347114030 Job system; 2024-02-28 12:31:34 -08:00
Bjorn 73eae189ae
Merge pull request #749 from bjornbytes/shader-rework
Shader Rework
2024-02-26 15:35:39 -08:00
bjorn 792fd75204 Texture view improvements;
- You can nest texture views (make a view of a view).
- You can do transfers on views (copies, clears, blits, etc.).
- You can give labels to views.
- API changes
  - Rename Texture:newView to lovr.graphics.newTextureView.
  - Constructor takes a table of options (order was too confusing).
  - Remove Texture:isView/getParent, since views can be used for everything now.
  - Better matches what LÖVE ended up doing.
- Fix bug where :getType on a view returned parent type.
2024-02-26 15:24:09 -08:00
bjorn ec380e0cfd rm pass uniformSize;
It's no longer necessary.
2024-02-25 14:58:11 -08:00
bjorn fa8ea6732b rm pass binding mask;
It's no longer necessary.
2024-02-25 14:57:27 -08:00