Commit Graph

319 Commits

Author SHA1 Message Date
bjorn dc9e93103f Pass:sphere; 2022-06-23 21:23:16 -07:00
bjorn dc73d2309a Pass:donut; 2022-06-23 19:52:37 -07:00
bjorn 8c63f47b8a Fix default shader switching; 2022-06-23 17:07:39 -07:00
bjorn 173c9a258e Sketch render pass automipmap; 2022-06-22 19:05:36 -07:00
bjorn c1d8c64c45 Pass:copy can copy tables to buffers; 2022-06-22 00:39:56 -07:00
bjorn cb4275bff7 Add DrawStyle; 2022-06-22 00:05:26 -07:00
bjorn 499cf9c0dc More Font APIs; 2022-06-21 15:28:03 -07:00
bjorn 71f6a88a62 Font uses padding; 2022-06-20 19:24:41 -07:00
bjorn ad0595ff35 lovr.graphics.getDefaultFont; 2022-06-20 18:58:12 -07:00
bjorn cfc0f52449 Support tab codepoints; 2022-06-20 18:52:10 -07:00
bjorn 362b389131 Pass:text;
Code is still messy, but it works okay.
2022-06-20 18:26:15 -07:00
bjorn af8c061c50 Default buffer can be used for colors; 2022-06-18 23:31:51 -07:00
bjorn a654cec40f lovr.graphics.newFont; 2022-06-18 17:43:12 -07:00
bjorn cb121d3d36 Material fixes; Pass cleanup; 2022-06-17 17:43:26 -07:00
bjorn 86b2c934e8 Materials, mostly; 2022-06-16 23:49:09 -07:00
bjorn 7de6bdf242 Shaders; Rework vertex formats; 2022-06-15 20:46:43 -07:00
bjorn 70e0f5c5cf Synchronization; 2022-06-11 22:55:43 -07:00
bjorn d9b5237851 Sync cleanup; 2022-06-11 19:07:46 -07:00
bjorn 3d83d0fcfe Pass:multimesh;
IT'S ALIVE
2022-06-09 23:38:33 -07:00
bjorn fc616f92c2 Pass:mesh; Pass:setMeshMode; 2022-06-09 23:05:32 -07:00
bjorn 3009e1d45c Rename transfers to uploads; 2022-06-09 22:44:23 -07:00
bjorn ab2c52bc05 Fix attachment cache; 2022-06-09 20:05:31 -07:00
bjorn 1cc8cf9f4a Update glslang to accept array of shader strings; 2022-06-09 17:44:46 -07:00
bjorn 6f16385fa1 Improve graphics error handling; 2022-06-08 23:59:36 -07:00
bjorn 0d4d7bc0e3 Fix vertex shader draw count; Simplify upload sync; 2022-06-08 21:23:30 -07:00
bjorn ef19a334a9 Pass:setSampler;
This is an experimental take on the "default filter" system.  Each
render Pass has its own "global sampler", initialized to trilinear.  The
global sampler will be used by default to sample textures/materials in
shaders.  You can set it to a filter mode or a full Sampler object.  You
can always send your own Sampler objects to Shaders if you want
per-texture sampler settings.  The global sampler is designed to be set a
small number of times per pass instead of on every draw.  Basically,
just do Pass:setSampler('nearest') and draw your minecraft world.
2022-06-07 20:42:10 -07:00
bjorn 2b65b50ed9 Pass:setViewport; Pass:setScissor;
It pretends to be like a pipeline state even though it isn't.
Might be nice for nil to mean "the framebuffer size" which is the default.
2022-06-06 12:38:15 -07:00
bjorn d5325b87b4 Headset support; 2022-06-05 20:38:14 -07:00
bjorn a8b35074e0 Pass:send supports push constants; 2022-06-05 18:54:26 -07:00
bjorn 8effa7424f Pass:circle; 2022-06-05 13:12:49 -07:00
bjorn 7b5c816345 More efficient resource tracking;
- Temporary buffers are not tracked
- Sample-only textures are not tracked, but their initial upload is synchronized.
- Default texture something something
2022-06-04 14:54:04 -07:00
bjorn 3a43d44460 Pass tracks resources for sync purposes; 2022-06-04 14:28:23 -07:00
bjorn ea80936af7 Pass:compute; 2022-06-04 11:54:05 -07:00
bjorn d3a1a0ec22 Pass:cube; Pass:box; 2022-06-04 11:28:35 -07:00
bjorn e07a2691e0 Clean up plane; 2022-06-04 11:19:28 -07:00
bjorn 62f2d9a800 Organization; 2022-06-04 09:57:06 -07:00
bjorn e652ae67af Pass:plane; 2022-06-04 01:34:13 -07:00
bjorn ebc6d9d3a3 Pass:line; 2022-06-04 01:33:50 -07:00
bjorn a2668a1632 Fix canvas always trying to add depth buffer; 2022-06-04 01:33:11 -07:00
bjorn ac3801902b Pipeline stack; 2022-05-31 21:57:55 -07:00
bjorn ec8b7f9727 Adjust; 2022-05-31 21:45:54 -07:00
bjorn 8431fc72ba Adjust; 2022-05-31 21:41:43 -07:00
bjorn 513a1876c9 Simplify vertex buffers;
The default buffer is always bound to slot 0 once at the beginning of
command buffers, reducing the amount of rebinding.
2022-05-31 21:20:01 -07:00
bjorn ab04577495 Enforce maximum spirv version; 2022-05-31 20:47:47 -07:00
bjorn 1f39ed8c51 Ensure binding numbers are less than 32;
We use u32 masks...
2022-05-31 20:24:43 -07:00
bjorn 99e45c22ad Add some descriptor set limits; 2022-05-31 20:16:16 -07:00
bjorn 42a924b0ee lovrPassDraw; Pass:points; 2022-05-30 15:36:31 -07:00
bjorn dd043cbf07 Fix bundle allocation; 2022-05-30 15:06:57 -07:00
bjorn 32fb5e63ac Destroy descriptor pools properly; 2022-05-30 13:12:04 -07:00
bjorn e59a75fce8 Pass camera functions; 2022-05-30 12:29:52 -07:00
bjorn 205767bc81 VertexFormat; 2022-05-30 12:18:42 -07:00
bjorn 541ebc1b61 Bundle allocator; 2022-05-30 12:17:17 -07:00
bjorn ff77a30f01 Default shaders; 2022-05-27 20:47:20 -07:00
bjorn 6440bc68f3 Pass:mipmap; 2022-05-26 00:07:10 -07:00
bjorn af0e388e91 Pass:copy; Pass:blit; 2022-05-25 23:52:24 -07:00
bjorn 6771ff64b5 Pass:clear; 2022-05-25 19:45:01 -07:00
bjorn a5f37f7d7d better lovrBufferIsTemporary; 2022-05-25 19:23:01 -07:00
bjorn 73f13ef3c7 Initialize buffer data properly; 2022-05-24 22:30:59 -07:00
bjorn 99ecd04e27 Pass:send; 2022-05-23 23:10:11 -07:00
bjorn 5c0b9e51ed Pass:setShader clears/resets bindings; 2022-05-23 22:32:36 -07:00
bjorn d9e8b81b72 Default buffer/texture/sampler; 2022-05-23 22:32:12 -07:00
bjorn 6dce0be2da pipeline lookup; 2022-05-23 21:44:42 -07:00
bjorn e054218713 gpu_bundle; gpu_bundle_pool; layouts; 2022-05-23 21:40:57 -07:00
bjorn a0db01959d Shader:clone; 2022-05-22 15:10:07 -07:00
bjorn a64fd216ea newShader; 2022-05-22 15:09:09 -07:00
bjorn 355b2bf85b Switch to glslang fork;
The reason is that the glslang C API doesn't support the extra
overloads that let you provide multiple strings or the lengths for
strings.  In our case our shader blobs are not null terminated, so
sending them to glslang would overrun the buffer.  I forked glslang
and modified the C API to support a length parameter.
2022-05-22 14:58:07 -07:00
bjorn 4f568ed84d s/setColorMask/setColorWrite; Pass:setColor; 2022-05-11 17:30:08 -07:00
bjorn 070e4f304d lovr.graphics.get/setBackground; 2022-05-11 15:38:05 -07:00
bjorn 970a84a514 Surface, swapchain, window texture, vsync; 2022-05-11 15:28:04 -07:00
bjorn f7b4ec725f Render passes; 2022-05-11 12:51:13 -07:00
bjorn bfa0d94f2d Pass pipeline API; 2022-05-11 12:50:26 -07:00
bjorn d9e5ba8b9f Slightly broken compileShader/newShader; 2022-05-09 11:47:06 -07:00
bjorn 5d078461a2 Rename copy texture usage to transfer; 2022-05-06 17:26:59 -07:00
bjorn 1fde5a36d0 Transform stack; 2022-05-06 17:26:38 -07:00
bjorn 22e15513f9 Sampler; 2022-05-01 15:47:17 -07:00
bjorn 211e3ef0f8 Compile fixes; 2022-05-01 15:18:56 -07:00
bjorn ebe77e5924 Sketch out Texture uploads; 2022-04-30 18:49:46 -07:00
bjorn 0316378f74 Fix renderView precedence; 2022-04-30 09:13:21 -07:00
bjorn e80d254dc6 Texture API;
Except newTexture because it's hard or something
2022-04-29 20:56:23 -07:00
bjorn 4be958195d Start Texture; 2022-04-29 20:38:34 -07:00
bjorn e53ddfa03b isFormatSupported; 2022-04-29 17:16:16 -07:00
bjorn 48e2509a3c lovr.graphics.wait; 2022-04-28 22:37:03 -07:00
bjorn 7aee0a4656 Add Pass; Buffer transfers; lovr.graphics.submit; Bugfixes; 2022-04-28 22:30:31 -07:00
bjorn a97193caac Buffer stride can not be smaller than the size of a single item; 2022-04-28 15:39:45 -07:00
bjorn a8b7bc75a8 Adjust; 2022-04-27 00:35:09 -07:00
bjorn e8c809a870 Temporary buffers; 2022-04-27 00:28:39 -07:00
bjorn 43f56c223c Tell Vulkan about the engine name and version; 2022-04-27 00:21:04 -07:00
bjorn d2110af83a Fixup; 2022-04-26 22:51:24 -07:00
bjorn 39418b8393 Add temp frame allocator; 2022-04-26 22:44:44 -07:00
bjorn a3438274b5 Add non-scratchpad Buffers;
This includes the memory allocator and the morgue.

You can't actually write any data to the buffer yet, since we don't have
commands or temp buffers.  Temp buffers (scratchpads) are coming soon.
2022-04-26 15:32:54 -07:00
bjorn 50ebed697e Update some features and limits;
- rm dynamicIndexing and nonUniformIndexing, for now (arrays aren't well
  supported)
- rename compressed texture features
- move clip/cull distance to limit instead of feature (limit can be 0)
2022-04-26 15:31:51 -07:00
bjorn 3ae0ff568f Rework device info; 2022-04-22 13:28:59 -07:00
bjorn be1cedc922 Always enable fullIndexBufferRange feature; 2022-04-22 01:07:07 -07:00
bjorn f37c1824da lovr.graphics.getDevice/getFeatures/getLimits; 2022-04-21 17:39:59 -07:00
bjorn 40e9a4ab73 core/gpu; 2022-04-21 17:39:59 -07:00
bjorn cf2f63f147 Add missing include; 2022-04-21 17:39:59 -07:00
bjorn 37221afbc6 rm graphics module; 2022-04-21 17:39:58 -07:00
bjorn d1dc2f3199 rm pico;
Notes:

- We can actually use a single Activity.java file for oculus/pico now
- We can unconditionally compile os_android.c on Android
- No need for including extra jars in build system
- Headset rendering is guaranteed synchronous now, no need to ref L
- Add an "android flavor" build setting to differentiate between oculus
  and pico devices, since they both use OpenXR.
- Update the pico manifest to reflect their OpenXR sample
- Remove some OpenGL hacks that aren't necessary anymore
2022-03-22 16:03:21 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn a4faad39f8 Font:getFilter; Font:setFilter; 2022-03-15 16:02:35 -07:00
bjorn fdfcb5539f Merge branch 'master' into dev 2022-03-14 13:19:59 -07:00
murat g ee3ba6ef3e Font filtering now respects the default setting. 2022-03-03 22:41:47 -08:00
bjorn 20e4567bd6 Merge branch 'master' into dev 2021-12-20 17:12:39 +02:00
bjorn 0a2f968850 Fix circle uvs;
After changing circle scale from diameter to radius, the uvs broke,
since they are calculated from the position.
2021-10-09 03:52:11 -07:00
bjorn 04d6996b94 Font:getWidth also returns width of last line; 2021-09-06 16:14:47 -07:00
bjorn a3b791a7e7 Fix Canvas flushing; 2021-03-07 21:19:24 -07:00
bjorn 4f5adbc64c lovr.system; 2021-02-25 09:00:12 -07:00
bjorn 39a4d2c1d5 rm lovr.graphics.triangle; 2021-02-24 17:45:31 -07:00
bjorn 0919da4091 Improve MSDF font shader; Add spread/padding settings to Font; 2021-02-10 07:08:29 -07:00
bjorn 8c714c45b0 Clean up some includes; 2021-02-08 11:16:00 -07:00
bjorn bc4cde1653 Adjust lovrRelease signature; 2021-02-08 17:52:26 -07:00
bjorn 3ded60948f rm core/ref; rm lovrAlloc; util does refcounting; 2021-02-08 17:26:44 -07:00
bjornbytes 80a33c0544 mat4_multiply -> mat4_mul;
quat_mul vs. mat4_multiply is inconsistent.  Going with mul over
multiply is consistent with vec3_sub and Lua's __mul metamethod.
2020-11-21 14:32:59 -07:00
bjorn e8db2f8187 Basic cylinder uvs; 2020-11-12 18:08:05 -07:00
bjornbytes 5c381ead34 Force set vsync in lovrGraphicsCreateWindow;
Headset drivers are allowed to override the vsync setting if vsync
messes up their frame timing.  The vsync property is effectively a
global piece of state in core/os and doesn't change across restarts
because the window is persistent.  This can mean that if you switch
from a headset driver that wants vsync off (anything except desktop)
to a headset driver that doesn't care what the vsync is (desktop),
you could end up with a vsync setting that doesn't match t.window.vsync.
I think this is a symptom of poor design somewhere and the best solution
to this probem is "to just not have it".  Similar issues exist for, e.g.
the window size (but that one is less weird because at least you were
the one who changed it).  For now we are just going to ensure that
lovr.graphics.createWindow always modifies the vsync property.
Untested, may need to adjust this fix later.
2020-11-02 11:57:02 -07:00
bjorn 38875cb399 Fix buffer flushing;
lovrGraphicsMapBuffer had the potential to cause a flush.  Flushing
unmaps buffers.  This meant that during any of the calls to map while
creating a Batch, it was possible to cause a flush and unmap other
buffers that expected to be mapped.  This caused writes to unmapped
pointers and subsequent skipping of calls to glFlushMappedBufferRange.

The fix is to figure out if we need to flush upfront and get it out
of the way before mapping any buffers.
2020-10-29 12:12:34 -06:00
bjorn 0388213be4 Reset camera after lovr.headset.renderTo; 2020-10-02 19:50:00 -06:00
bjorn f1447fd69a lovr.graphics.get/setViewPose; lovr.graphics.get/setProjection; 2020-09-24 19:03:37 -07:00
bjorn 82159a9885 rm persistent mapping; sync Mesh and ShaderBlock; 2020-08-17 03:29:30 -06:00
Nevyn Bengtsson b938a839e0 fix crash in lovrGraphicsGetPixelDensity
Neither Quest nor Pico check for null on its out-params.
Better to send in dummy params to avoid nulls.
2020-08-05 14:48:58 +02:00
bjorn e3aa4c7d5d t.graphics.debug flag; 2020-07-28 16:12:15 -06:00
bjorn ac58a1aeba Pico: Draw the rest of the owl;
Add entrypoints, headset backend code, fill in the Activity, and
add various special cases to account for the asynchronous render loop,
lack of sRGB support, and OpenGL state resets.
2020-07-27 14:56:21 -06:00
bjorn a1aa3c8ae8 Finish vrapi driver; 2020-06-09 18:02:03 -06:00
bjorn 1185fcf6e1 Autodetect integer attribute types;
Fixes inability to use integer attributes with Mesh.
2020-05-21 00:31:49 -06:00
bjorn c0d73ab541 Add resize event; lovr.resize callback; 2020-05-02 13:09:10 -06:00
bjorn 90b605f012 Add restart cookie; lovr.event.restart; arg.restart; 2020-02-26 14:40:40 -08:00
bjorn d034e8c01b Opaque Canvas; 2020-02-23 00:29:21 -08:00
bjorn 56dc8d0b9e Handle stereo shaders better;
- Creating a shader from a DefaultShader will respect the stereo flags.
- Auto shaders will properly be stereo/nonstereo based on the target Canvas.
2020-01-27 16:33:15 -08:00
bjorn 0841268d45 Fix garbled text when printing out spaces;
Apparently requesting/rendering zero vertices was clogging stuff
somewhere.  It seems good enough to just explicitly not render
anything if we weren't gonna do it anyway.
2020-01-14 00:37:09 -08:00
bjorn 48b887f7ee Always pass identity matrix for animated shader;
So at least something shows up if you have an unskinned mesh with
a skinned shader.
2020-01-13 20:47:47 -08:00
bjorn e316e6156b lovr.graphics.get/setColorMask; 2019-12-10 13:44:51 -08:00
bjorn c87d6dec3d lovrPlatformGetProcAddress;
Seems nicer than a global and allows for logging/hooks;
2019-12-10 13:15:12 -08:00
bjorn d21911d010 Add core/map hash table; rm lib/map; 2019-10-30 00:07:05 -07:00
bjorn ac441ec15b lovrGraphicsGetCamera; 2019-10-12 12:45:11 -07:00
bjorn 17ae64baec Fix sphere winding; 2019-08-31 03:00:40 -07:00
bjorn a4781c7013 Fix cylinder winding; 2019-08-12 20:03:32 -07:00
bjorn edd162052c Fix diffuse texture batching; 2019-08-06 11:38:12 -07:00
bjorn 96c47d590c rm lovrEnvironmentTexture from Material; 2019-08-05 15:20:17 -07:00
bjorn aab987dbef Fix WebGL gamma correction;
Ugh, WebGL doesn't have sRGB backbuffers.
2019-08-01 13:26:45 -07:00
bjorn af29e29e4d Fix lovr.graphics.setProjection;
Needed to be using new frameData stuff.
2019-07-08 14:35:54 -07:00
bjorn 2d6aa18069 Be a little more correct about when draw id is written; 2019-07-02 00:14:01 -07:00
bjorn 775cf5cda1 Don't accidentally draw meshes too many times;
Oops!
2019-07-02 00:09:43 -07:00
bjorn 44da36b610 Write draw ids at the right time (fix flicker); 2019-07-01 02:47:59 -07:00
bjorn 2fb393306c rm skybox args;
They used to always be necessary, now they are almost never necessary.
2019-06-29 21:01:03 -07:00
bjorn e3e930d6cc Set index buffer at the right time;
Just a small ordering issue with previous commit.
2019-06-29 20:39:01 -07:00
bjorn 6256acfc6d Ahhh fix everything;
- If you have an instanced batch, it will use the instanced mesh.  That
  has a drawID attribute that uses the identity buffer, which has a vertex
  divisor.  BUT if you only have one instance, then we won't emit an
  instanced draw, and the use of a divisor'd attribute w/ a non-instanced
  draw is causing mega problems on macOS.
- This also fixes observed macOS bugs like:
  - Needing to have a small UBO
  - Flickering at startup
  - Flicker when writing to the last byte of a UBO
  - etc.
- Also make the generic attribute value for lovrDrawID more correct (scalar instead of vector).
2019-06-29 20:24:36 -07:00
bjorn 4222be88b5 Use UBO for Camera matrices;
Ugh I don't like the "Camera" concept anymore, but I can't figure
out how to easily get rid of it.  Maybe wait till displays are a thing.
2019-06-27 22:17:50 -07:00
bjorn fa6c4a6b39 Organization; 2019-06-27 21:04:15 -07:00
bjorn 370124c88d Batching cleanup;
- Rename drawMode to topology in some places.
- Batch uses DrawCommand internally to simplify stuff.
- Do less work while flushing.
- Store global head/tail cursors instead of unused per-batch cursors.
2019-06-27 20:58:42 -07:00
bjorn 779949964f More small batching changes;
- Reduce number of batches to 4.  Yeah it's arbitrary, will monitor.
- Just use memcmp for BatchParams.  Since we're using designated initializers,
  we aren't running into issues with memcmp+struct padding bits, and in the
  event it does lead to false positives on some platforms, at worst we'll just
  experience a harmless reduction in batching efficiency.
2019-06-27 19:05:54 -07:00
bjorn 6da17b0a91 Optimize gamma correction;
Currently, we gamma correct colors on every clear and every draw.
It's taking a lot of time.  Instead, we'll gamma correct colors
when they're changed using lovr.graphics.setColor/setBackgroundColor.
2019-06-27 15:41:57 -07:00
bjorn 7e067da8e7 Add defaultCanvas;
Having a normal Canvas object that represents the backbuffer reduces
some indirection where we have to last-minute check if a Canvas is
set.  It also means that all of the draw-related info that was _sometimes_
on the Canvas is now _always_ on the Canvas, which reduces the amount
of redundant information we need to provide for a draw call.

There may be some issues related to changing the width/height/stereo
of the default Canvas.
2019-06-27 15:36:51 -07:00
bjorn 26e474bcfc Simplify Mesh handling;
Removes some indirection from flush (I guess moves it into batch,
not sure what's better).
2019-06-27 14:14:31 -07:00
bjorn 551dea8c86 Adjust includes; 2019-06-27 13:44:09 -07:00
bjorn b8e63adcbf graphics: Cleanup;
Make batching structs and defines private.
2019-06-27 13:38:38 -07:00
bjorn fe21de403b lovrGraphicsDrawMesh; 2019-06-27 13:35:43 -07:00
bjorn 39b0d2d754 graphics: Minor refactoring; 2019-06-27 13:26:39 -07:00
bjorn 297208c205 Minor cleanup to stream buffer code; 2019-06-27 13:01:04 -07:00
bjorn 052990aa47 Make some graphics structs private; 2019-06-27 01:48:35 -07:00
bjorn 928ccee5f1 Multiview; 2019-06-25 01:21:59 -07:00
bjorn a691192af9 lovrBufferDiscard; 2019-06-25 01:21:59 -07:00
bjorn 5cd93b66c6 rm fence syncs;
They are too buggy and are not as efficient as orphaning.
2019-06-24 19:17:55 -07:00
bjorn 879c789a08 Polyfill M_PI;
It technically isn't part of C, which is causing problems on some systems.
2019-06-20 21:43:40 -07:00
bjorn 06c6b172de vec3 has 4 elements; 2019-06-03 07:20:03 -07:00
bjorn 22fe333150 Update refcounting (again);
- Ref struct only stores refcount now and is more general.
- Proxy stores a hash of its type name instead of an enum.
- Variants store additional information instead of using a vtable.
- Remove the concept of superclasses from the API.
- Clean up some miscellaneous includes.
2019-06-02 01:02:26 -07:00
bjorn 29b2420dea Work around macOS flicker bug;
At this point I don't know if maybe I'm just using UBOs wrong but whatever.
2019-05-27 19:05:47 -07:00
bjorn 3bf08f0ca3 Add the ability to create default shaders;
lovr.graphics.newShader('font')
2019-05-22 18:00:02 -07:00
bjorn 7645f4c014 Add core folder; 2019-05-20 02:47:33 -07:00
bjorn a17f10e273 Add modules folder; 2019-05-19 00:38:35 -07:00
Renamed from src/graphics/graphics.c (Browse further)