Commit Graph

5409 Commits

Author SHA1 Message Date
Josip Miskovic 8a5b88e851 Allow joltc fns without explicit argument list
The C4255 warning in MSVC complains about function lacking explicit list
of arguments (`f()` instead of `f(void)`). Disabling this warning allows
joltc to build on windows platform.
2024-03-04 19:03:22 +01:00
Bjorn b3b523cdbf
Merge pull request #754 from brainrom/patch-2
Make lovrAssert act like a function
2024-03-03 03:54:13 -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 fd331090c9
Merge pull request #751 from brainrom/patch-1
Fixed nogame.zip creatrion
2024-02-29 10:36:34 -08:00
Ilya f77a8f6cb2
Fixed nogame.zip creatrion
logo.spv wasn't packed in nogame.zip, therefore nogame is failed to start. Now all files in nogame folder are packed.
2024-02-29 11:35:55 +03:00
Bjorn 6c7ca1e275
Merge pull request #750 from bjornbytes/job
Job System
2024-02-28 12:51:25 -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
bjorn 466a052ded Cleanup; 2024-02-24 15:45:30 -08:00
bjorn 2fe5ba8f3b Ensure all binding fields are fully initialized; 2024-02-24 15:45:10 -08:00
bjorn ae19b7aad3 Fix resource binding numbers; 2024-02-24 15:33:09 -08:00
bjorn 652a074677 Update resource invalidation when switching shaders;
Previously, when switching shaders, resource bindings would be preserved
for resources with matching slots/types.  This doesn't make sense in a
world where binding numbers are internal.  Instead, match up resources
by name/type.

Additionally, rewire all the uniforms by name/size so uniforms with the
same name get preserved (name/type would be too hard for e.g. structs).
This seems like it would be horribly slow and may need to be optimized,
optional, or removed.

I didn't test any of this lol, but I will I promise.
2024-02-24 14:34:29 -08:00
bjorn bd83ad6eb4 Cleanup; 2024-02-24 11:49:11 -08:00
bjorn 48e484ed8a Update OpenXR to 1.0.34; 2024-02-24 11:05:39 -08:00
Bjorn f3cae5f80e
Merge pull request #748 from bjornbytes/rm-msaa-textures
Remove Multisample Textures
2024-02-23 12:38:23 -08:00
Bjorn bad3d8b78a
Merge pull request #747 from bjornbytes/changelog
Changelog
2024-02-23 12:38:12 -08:00
Bjorn f1158b2159
Merge pull request #745 from bjornbytes/xr-swapchain-colorspace
Fix OpenXR Swapchain Colorspaces
2024-02-23 12:37:54 -08:00
bjorn 114109ab54 rm multisample texture objects; 2024-02-22 14:40:32 -08:00
bjorn b65fa0d1f6 Add changelog; 2024-02-22 14:16:54 -08:00
bjorn b63ec6e137 Graphics shader requires fragment stage for now;
The vertex-only shader requires too much juggling of shader stage flags
and pipeline layout compatibility when e.g. binding push constants and
descriptor sets.
2024-02-21 10:37:59 -08:00
bjorn 6a669bd967 rm var shader macro;
It is no longer necessary, and wasn't widely used/documented.
2024-02-21 10:28:30 -08:00
bjorn ada33c6620 Downgrade glslang to 13.0.0 with lovr cherrypicks; 2024-02-21 10:25:00 -08:00
bjorn cbc9312716 Fix memory leak; 2024-02-21 10:21:42 -08:00
bjorn 728b166d69 Fix binding numbers; 2024-02-21 10:21:42 -08:00
bjorn 64e253a8ef mv logo shader to nogame bundle; 2024-02-21 10:21:42 -08:00
bjorn 81ef58d032 Use push constant instead of BaseInstance for DrawID;
This is a little slower, but means indirect draws can use Transform and Color.

There are other solutions for this.  For example LÖVR could reserve
BaseInstance and use a compute shader to rewrite indirect buffers.

For now we choose to be correct and a little slower.
2024-02-21 10:21:42 -08:00
bjorn 875a7f8237 Shader rework;
- Undeprecate ShaderType (it's good actually, kinda like a pipeline bind
  point and more specific than having lovr trying to make sense of a
  random set of stages).
- Use a default uniform block instead of push constants.  The Constants
  macro now maps to a uniform block declaration.
- It is no longer possible to create a shader by giving a single
  DefaultShader string (you can still give a per-stage DefaultShader
  though).
- lovr.graphics.compileShader now takes all stages instead of a single
  stage.  In general we need all stages when compiling GLSL because
  default uniforms require linking across stages.
2024-02-21 10:21:41 -08:00
bjorn 8b78a4d3b5 core/gpu: depth-only passes can include fragment shader; 2024-02-20 10:19:16 -08:00
bjorn d4e2736e0b Update glslang;
Includes a fix for generating SPIRV for multiple shader stages.

Also reverts a buggy upstream commit temporarily.
2024-02-20 10:17:20 -08:00
bjorn 45eba2fe85 rm ability to send resources by slot number; 2024-02-20 10:16:41 -08:00
bjorn 93348499e9 Binding numbers are assigned explicitly and merged across stages; 2024-02-20 10:16:41 -08:00
bjorn 035d359133 Add relaxed Vulkan flag; 2024-02-20 10:16:41 -08:00