Commit Graph

196 Commits

Author SHA1 Message Date
bjorn 775b6e4ff7 Rename some buffer helper functions; 2023-04-29 18:31:03 -07:00
bjorn 8f654ed408 Simplify fill shaders;
Now there's 2 instead of 3!  Behavior is the same, fill goes
layer-by-layer onto each view until either the texture or canvas run out
of layers.
2023-04-26 22:18:06 -07:00
bjorn f3448d3167 Improve error when buffer fields are missing; 2023-04-02 13:00:32 -07:00
bjorn 4f1e3a17e1 Improve error message for invalid first buffer arg; 2023-04-02 12:58:39 -07:00
bjorn 36e8ded0d8 Add helper function for getBuffer/newBuffer; 2023-04-02 12:54:19 -07:00
bjorn 8b30dc73d3 Fix backwards compatibility behavior;
Fixes (data, format) order when fields are given using integer keys
instead of string keys.
2023-03-20 13:54:38 -07:00
bjorn 92e9efd882 More flexible Buffer formats; Deprecate temp buffers;
- Pass:mesh accepts tables for vertices/indices
- Add Pass:setVertexFormat to set format used for table-based meshes
- Pass:send accepts tables for buffers
- Pass:send supports arbitrarily nested structs/arrays for push constants
- Buffer formats support arbitrarily nested structs/arrays
  - Zero-length buffers are valid and represent structs
  - Fields can have names using 'name'
  - Field types can be tables of other fields (structs)
  - Fields can have 'length' key
- newBuffer syntax has been changed to put format first (old version
  still works)
- Buffers can be created from shader variables, avoiding need to declare
  matching format.
- Pass:clear/Pass:read use byte offsets instead of indices
- Pass:copy uses byte offsets when copying a Buffer to a Buffer
- Deprecate lovr.graphics.getBuffer (tables can be used instead)
2023-03-20 13:54:37 -07:00
bjorn b76d9bbfe5 Ensure mipmap count is consistently 1 for render targets;
Currently if you create a texture from dimensions (assumed to be a
render target), its mipmap count differs depending on whether you
provide an options table.  Now it will consistently be 1.
2023-02-05 16:02:58 -08:00
bjorn 4e01f84070 Depth resolves;
- Allow multisampled render pass to have a single-sample depth attachment
- Add a new depthResolve feature, indicating whether it's supported
- Fix stencil load/save
- Minor changes to render pass caching
- Currently the depth resolve is done using the first sample.  A future
  improvement would be to expose/use the min/max/average resolve modes.
2023-01-22 23:30:57 -08:00
bjorn e63d142009 Fix refcounting when creating Font from Rasterizer; 2022-12-10 13:35:03 -08:00
bjorn efc81e4cec Fix some gcc warnings; 2022-12-03 01:20:02 -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 7b3e1a02eb Fix newShader when nil is used as a stage's code; 2022-11-16 18:12:06 -08:00
bjorn b61dbab21b newTexture resets usage when table is provided; 2022-11-14 20:03:58 -08:00
s-ol 22ff6dab94 Fix wrong loop limit in lovr.graphics.newShader; 2022-11-09 17:00:08 -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 c59c242b7b Fix newTexture; 2022-10-12 00:46:48 -07:00
bjorn dd336b7473 Render target textures don't have mipmaps by default; 2022-09-21 21:18:32 -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 a31ae6a68f Fix compileShader; 2022-09-13 17:22:48 -07:00
bjorn d8c6c47e00 Add normal DefaultShader;
It's a pretty normal shader.
2022-09-10 11:07:55 -07:00
bjorn 5c4fc79242 mv lovr.graphics.init lovr.graphics.initialize;
init is undocumentable due to Lua conventions.
2022-09-10 10:22:52 -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 ea30100c31 rm texture variant of newMaterial;
Does not make sense anymore now that Pass:setMaterial(Texture) exists.
2022-09-02 15:05:01 -07:00
bjorn 7aebde2f92 Fix StencilAction; 2022-08-26 22:23:04 -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 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 f45706f875 Change Buffer format 'name' to 'location' string;
Name is confusing because it seems like it supports key/value setting.
2022-08-23 19:17:54 -07:00
bjorn f914b6fcf1 Fix memory leak with shader cache; 2022-08-22 20:18:34 -07:00
bjorn ba7bdd11c3 Fix index FieldType shorthand; 2022-08-19 20:51:50 -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 5799b0effb Rename setBackground back to setBackgroundColor;
The "fancy background" idea won't go here.
2022-08-13 21:10:58 -07:00
bjorn 143b0ba664 Fix DefaultShader initialization; 2022-08-12 18:26:47 -07:00
bjorn 7e5221492d rm pointSize from Material;
It's weird, and about as inconvenient as just putting it in the shader.
2022-08-09 19:54:54 -07:00
bjorn 3c71828afa Revert "Change the way modules are destroyed;"
This reverts commit 019814e2c1.
2022-08-08 23:16:34 -07:00
bjorn a2ee485d41 Fix most windows warnings in graphics code;
Co-authored-by: mcc <andi.m.mcclure@gmail.com>
2022-08-06 18:05:30 -07:00
bjorn 642388709b Shader helper improvements; 2022-08-06 13:06:42 -07:00
bjorn fcbeccdfb1 Fix background colors; 2022-08-05 21:05:02 -07:00
bjorn 019814e2c1 Change the way modules are destroyed;
They are now destroyed explicitly after tearing down the Lua state
instead of relying on finalizers.  It's definitely annoying to make it
coordinated in a centralized way like this instead of being distributed,
but there's not really any reliabel way to ensure that graphics objects
are destroyed before the graphics module/device is destroyed, which is a
problem.
2022-08-04 21:44:34 -07:00
bjorn 16860e8ef5 rm stats;
These stats don't make sense right now.
2022-08-04 07:59:07 -07:00
bjorn acd87a5e5c lovr.graphics.present;
It's nice to have an explicit action for presentation.
2022-08-04 00:06:54 -07:00
bjorn 89312c1c4b Add on-disk shader cache;
Set t.graphics.shadercache to true (the default) and lovr will
read/write a shader cache file from/to disk.
2022-08-02 22:06:44 -07:00
bjorn 4ee092e81b Make Pass a regular object;
It uses newPass instead of getPass.  Temporary objects had lifetime
issues that were nearly impossible to solve.  And normal objects are
easier to understand because they behave like all other LÖVR objects.

However, Pass commands are not retained from frame to frame.  Pass
objects must be re-recorded before every submit, and must be reset
before being recorded again.

Pass objects now provide a natural place for render-pass-related info
like clears and texture handles.  They also allow more information to be
precomputed which should reduce overhead a bit.

It is now possible to request a stencil buffer and antialiasing on the
window and headset textures, via conf.lua.

lovr.graphics.setBackground should instead set the clear color on the
window pass.  Though we're still going to try to do spherical harmonics
in some capacity.

There are still major issues with OpenXR that are going to be ironed
out, and the desktop driver hasn't been converted over to the new
headset Pass system yet.  So lovr.headset integration is a bit WIP.
2022-08-02 22:06:44 -07:00
bjorn c0dfb414d6 Per-stage default shaders; 2022-08-01 22:10:06 -07:00
bjorn 2414f5f269 Material uvShift can be a single number too; 2022-07-31 10:39:49 -07:00
bjorn 9e4765818a Rename texture depth to layer count; 2022-07-31 10:39:49 -07:00
bjorn 571c71b76e Rename pipeline stack to state; 2022-07-31 10:39:49 -07:00
bjorn 92201b87a1 Rename timer tally type to time; 2022-07-17 13:17:33 -07:00
bjorn 83fa750a4d Support and default to reverse-z with infinite far plane; 2022-07-17 12:37:59 -07:00