Commit Graph

127 Commits

Author SHA1 Message Date
bjorn d6abcdfb0e Fix 2 memory leaks; 2020-05-23 13:03:16 -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 75e26f0051 Move core/hash to core/util; 2020-05-19 13:49:40 -06:00
bjorn 92ac93e6b8 Improve image uniform errors; 2020-05-18 15:14:17 -06:00
bjorn 1e78ac8669 Add r16, rg16, rgba16 texture formats; 2020-05-10 01:59:58 -06:00
pendingchaos 28a2e5fd4c Fix when depth test is disabled but depth write is enabled
GL_DEPTH_TEST controls both whether depth testing and depth writes are
enabled. So if depth testing is disabled and depth writes are enabled,
GL_DEPTH_TEST has to be enabled and the compare mode should be GL_ALWAYS.
2020-04-21 23:39:16 +01:00
bjorn 37d8df4784 Allow initializing empty TextureData with Blob; 2020-03-29 13:47:57 -06:00
bjorn c02839f5c2 Allow anisotropy to be used with any TextureFilter;
Instead of anisotropic being its own filter, it is now removed and
anisotropy settings can be used with any of the other filter modes.
2020-03-05 09:46:49 -08:00
bjorn 45648baa1c Scope a variable better; 2020-03-02 22:23:59 -08:00
bjorn fa771b04bd Fix CMake; 2020-02-23 01:01:34 -08:00
bjorn f8b8d427d7 Opaque Mesh; Opaque OpenGL; 2020-02-23 00:29:21 -08:00
bjorn aabb8cb830 Opaque Shader; 2020-02-23 00:29:21 -08:00
bjorn d034e8c01b Opaque Canvas; 2020-02-23 00:29:21 -08:00
bjorn 52d4f7e520 Opaque Texture; 2020-02-23 00:29:21 -08:00
bjorn b045d42782 Opaque Buffer; 2020-02-23 00:29:21 -08:00
bjorn 81f4232da5 opengl: Init compareMode for native textures; 2020-02-19 15:34:32 -08:00
bjorn aa0e01ddab Cleanup; 2020-02-17 17:27:57 -08:00
bjorn bfdebffb34 Fix volume textures; 2020-02-17 17:27:57 -08:00
bjorn 2db1f2b743 Fix erroneous GLES enables;
None of these exist in OpenGL ES.  These were throwing seemingly
innocuous GL errors, so this is mostly just a matter of correctness.
2020-02-16 01:23:27 -08:00
bjorn c502f5b62a Add highp shader flag that sets default fragment precision to highp;
Also, precision qualifier is required to work on desktop GL, so
we don't need ifdefs for it!
2020-02-07 19:44:51 -08:00
bjorn 67ba5f3a82 Add more graphics stats; 2020-01-31 03:43:52 -08:00
bjorn be4db58fa3 "Fix" compute blocks on GLES;
There can only be one compute block.
2020-01-30 19:14:25 -08:00
bjorn 78f272247b newCanvas creates array textures when multiview; 2020-01-30 17:48:01 -08:00
bjorn f8d3172868 opengl: Prefer state.features.compute to ARB_compute_shader; 2020-01-29 18:22:16 -08:00
bjorn c73fadf5a3 Mark compute shaders as available on ES3.2; 2020-01-29 14:08:09 -08:00
Cassie Jones 3e09120173 Compile shaders using source lengths
The previous implementation relied on glShaderSource inferring source
lengths when the lengths weren't specified. This relies on the sources
being properly null-terminated, however, which isn't the case due to
file loading changes which now use pointer + length. This could cause
intermittent crashes.

Changing this on the shader side meant adding some extra arguments for
passing around shader source lengths. For most of the other cases, where
we're using string literals as the sources, we can just specify -1 as
the length, since OpenGL will calculate the string length for you any
time the length is negative.
2020-01-27 16:13:21 -05:00
bjorn 8c429e89ac Fix -Wshadow; 2020-01-23 11:18:04 -08:00
Nevyn Bengtsson 95edb43654 TextureData: holds Blob instead of being Blob, just like SoundData
also replaces TextureData:getPointer with TextureData;getBlob
2020-01-19 22:59:44 +01:00
bjorn c0d1e28deb Fix ifdef for glTexStorage;
It's always present on GLES.
2020-01-14 19:39:10 -08:00
bjorn 541400e0fe oculus_mobile: Create framebuffers from bridged swapchain textures;
This is a change that shifts the responsibility regarding the creation
of OpenGL framebuffers from vrapi-provided swapchain texture handles.
Previously, the LovrApp component of lovr-oculus-mobile was creating
framebuffers and passing native framebuffer IDs to lovr.  With this
change, lovr-oculus-mobile passes vrapi's swapchain textures to lovr
unmodified.  This allows lovr to create canvases using its conventional
method and also means that the properties of the canvases are no longer
hardcoded, so things like resolution and multisampling can be
customized.

There were also some issues with multiview canvases in LÖVR due to some
misconceptions about how multisampled multiview rendering works.  These
issues have also been fixed in this commit.
2020-01-14 18:26:01 -08:00
Bjorn 16b93869ee
Merge pull request #143 from bjornbytes/shadow-samplers
Shadow samplers;
2019-12-14 11:34:38 -08:00
bjorn 5957d07448 Fix warnings; 2019-12-13 03:41:35 -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 3e347f0521 Properly initialize uniform.dirty; 2019-11-28 15:31:27 -08:00
bjorn 2ecc1c552f Fix uniform array hashing; 2019-11-26 11:34:39 -08:00
bjorn bd169a4a4d Fix readable buffers;
Unsynchronized/invalidated mapping doesn't work if the read bit is set.
2019-11-14 12:42:52 -08:00
bjorn d21911d010 Add core/map hash table; rm lib/map; 2019-10-30 00:07:05 -07:00
bjorn 4d2aa81647 Reset active texture in lovrGpuInit; 2019-10-15 11:34:49 -07:00
bjorn d93e17e800 Texture:setCompareMode; Shadow samplers; 2019-10-14 17:12:34 -07:00
bjorn 5f404e2b1f WebVR fixes;
- Re-add the maf.c file that exports all the maf symbols.
- Fix lovrGpuTock for WebGL.
2019-10-07 19:50:17 -07:00
bjorn 1902787b1b Modify GPU timer API;
- lovr.graphics.tock returns the latest value of the timer, or 0.
- Timers are not in the stats table anymore.

This is to prepare for an upcoming internal change that affects timers.
2019-09-18 18:21:38 -07:00
bjorn 28344928c9 Simplify arr; 2019-08-21 23:16:58 -07:00
bjorn 948363e7df OpenGL: Enable seamless cubemap filtering;
It is always used in WebGL 2 and OpenGL ES 3.
2019-08-09 17:22:00 -07:00
bjorn b5be93b94b Fix problem with falsy shader flags; 2019-08-07 15:56:13 -07:00
bjorn 54d58c79cd Fix issue where multiple shader flags don't work; 2019-08-06 14:38:49 -07:00
bjorn 7690db28af Windows: Fix all the int warnings; 2019-07-31 17:51:49 -07:00
bjorn 4b9e6849c8 Better boolean shader flags; Multicanvas flag;
Instead of boolean shader flags turning into actual booleans defines
in the shader source, for GLSL they turn into defines.  This lets you
use ifdef, which is the more common intended usage.

Also MULTICANVAS is now a boolean shader flag.  The old MULTICANVAS
define is deprecated.
2019-07-28 18:08:23 -07:00
bjorn f564444641 Fix some WebGL issues; 2019-07-28 17:28:18 -07:00
bjorn 84cdc592bc Make sure lovrBufferUnmap always unmaps; 2019-07-12 20:16:18 -07:00
bjorn f208a5e067 Fix array initialization;
Because the new arr.h contains an array on the stack, we can't
initialize it and then copy it, or the pointer to the stack array
will be pointing to the wrong thing, causing incorrect behavior.
2019-07-09 09:06:11 -07:00
bjorn 57f97056da Use I4ui instead of I1ui for lovrDrawID constant value;
glVertexAttribI1ui isn't supported on GLES for some reason.
2019-07-02 12:51:36 -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 afe4d8c0e3 Fix GL error with buffer unmapping;
This doesn't seem to fix any of the macOS rendering bugs though...
2019-06-29 20:08:31 -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 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 b3080ae5d9 rm macos instancing hack;
I haven't been able to see adverse affects from it anymore.  Can
always put it back if it resurfaces.
2019-06-27 13:27:43 -07:00
bjorn 2baa8d03ee Make singlepass detection more readable; 2019-06-26 21:47:22 -07:00
bjorn 6b2de4a0a1 Temporary implementation for persistent buffer discard;
Should fix potential crashes with persistent buffers.
2019-06-25 19:16:08 -07:00
bjorn 312a7617c3 Fix typo in shader; 2019-06-25 19:15:11 -07:00
bjorn 09b6f74acf Native textures: initialize mipmapCount; 2019-06-25 18:59:31 -07:00
bjorn 749774e2fc Native texture depth must be explicitly specified;
To fix validation errors when attaching them to Canvases.
2019-06-25 18:57:18 -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 5881bdd5b1 Fix gpu timer array; 2019-06-20 14:44:28 -07:00
bjorn 612f699aa4 Rename default shader to unlit; 2019-06-20 14:09:55 -07:00
bjorn d856f6d592 opengl: Create default texture at startup;
More predictable performance, fixes an obscure bug.
2019-06-20 11:35:46 -07:00
bjorn eb1e257209 Add new array implementation; Upgrade filesystem;
Filesystem:

- Uses streaming file IO.
- Uses less memory when requiring files.
- Simplifies its require path implementation.
2019-06-16 13:30:30 -07:00
bjorn 909ee1ad79 Use highp in vertex shaders on GLES; 2019-06-10 08:12:36 -07:00
bjorn 98f4365474 Add astc and dxt GraphicsFeatures; 2019-06-09 23:59:57 -07:00
bjorn b0a7d5c122 ASTC textures;
I like typing numbers.
2019-06-09 09:11:29 -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 d2bff7d239 lovr.graphics.tick and tock;
Initial support for GPU timer queries.
2019-06-01 17:29:53 -07:00
bjorn 4cc154fdfa More number conversions; 2019-05-20 20:35:07 -07:00
bjorn 57aad490ae Start sized int conversions; 2019-05-20 14:34:03 -07:00
bjorn a17f10e273 Add modules folder; 2019-05-19 00:38:35 -07:00
Renamed from src/graphics/opengl.c (Browse further)