Commit Graph

200 Commits

Author SHA1 Message Date
bjorn 80f9514295 Shader:sendImage only checks srgb flag for RGBA textures;
It doesn't need to check it for RGB and compressed textures because
those are already rejected.

It may also be a good idea to zero-out the srgb flag for formats that
it doesn't apply to.
2020-08-18 20:20:48 -06:00
bjorn 82159a9885 rm persistent mapping; sync Mesh and ShaderBlock; 2020-08-17 03:29:30 -06:00
bjorn 4177202cc7 Don't enable GL debug output in WebGL; 2020-08-08 17:38:12 -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 b45baacb66 Handle active attributes that don't have a location;
There are some attributes that don't have a location (gl_InstanceID
is being reported for some reason).  Their location is -1 and this
causes a left shift of a negative value which is undefined.
2020-07-30 02:46:17 -06:00
bjorn 99fdcc8287 Fix calling convention of GL debug callback; 2020-07-29 14:56:46 -06:00
bjorn f0a5a8838b OpenGL debug messages and contexts;
The new t.graphics.debug flag controls the following:

- If enabled, a debug context is created
- If disabled, a no-error context is created
- If enabled, GL debug messages are forwarded to lovr.log
2020-07-28 16:12:30 -06: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 d045929065 ShaderBlock:getShaderCode: add namespace support; 2020-07-04 17:50:00 -06:00
bjorn a1aa3c8ae8 Finish vrapi driver; 2020-06-09 18:02:03 -06:00
bjorn 90e985c45b Fix MSAA Canvas readback; 2020-05-26 09:53:26 -06:00
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
bjorn b0289de9a6 Error instead of crashing when skin has too many joints;
ModelData is still allowed to load skins with more joints, since
the limitation is in the graphics side of things (Model).

Eventually we will use a buffer for joints to alleviate this.
2020-05-02 14:14:29 -06:00
bjorn c0d73ab541 Add resize event; lovr.resize callback; 2020-05-02 13:09:10 -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 90b605f012 Add restart cookie; lovr.event.restart; arg.restart; 2020-02-26 14:40:40 -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 443376efde ModelData: Use union for transform fields;
Nodes can have either a transform matrix, or decomposed transform
properties, but never both.  Using a union means we can store both
of those variants in the same piece of memory, using the existing
matrix boolean to figure out which one to use.

This reduces the size of the struct by 48 bytes (152 -> 104), which
ends up speeding up some model operations, I'm guessing due to the
CPU cache.
2020-02-11 16:38:31 -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 c9c5d43829 Shader:hasBlock; Shader:sendBlock errors on missing block; 2020-01-30 18:26:05 -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
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
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
bjorn 4c1917f6ce Fix some prototypes; 2020-01-23 10:55:46 -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 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 dc1c011380 Fix bug with std140 offset logic; 2020-01-09 21:57:25 -08:00
Bjorn 16b93869ee
Merge pull request #143 from bjornbytes/shadow-samplers
Shadow samplers;
2019-12-14 11:34:38 -08:00
bjorn e2d8f8c645 platform -> os;
The function names are staying the same for now.
2019-12-13 19:55:46 -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 2f9400a5f7 Adjust includes; 2019-12-10 13:01:28 -08:00
bjorn c07b9e3fec rm unnecessary include; 2019-11-28 16:04:41 -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 ac441ec15b lovrGraphicsGetCamera; 2019-10-12 12:45:11 -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 403b217781 Fix Model destructor memory issues;
- Memory leaks.
- Freeing things that weren't allocated.
2019-09-20 13:46:27 -07:00
bjorn 2c29119e44 Fix non-interpolated cubic spline keyframe evaluation; 2019-09-19 23:01:50 -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 17ae64baec Fix sphere winding; 2019-08-31 03:00:40 -07:00
bjorn f64e2064ef Adjust Canvas padding so it's 128 bytes; 2019-08-23 01:43:35 -07:00
bjorn 80eaea21f1 Adjust Buffer padding so it's 48 bytes; 2019-08-23 01:35:46 -07:00
bjorn 8d8f4eef73 Adjust Texture padding so it's 64 bytes; 2019-08-23 01:34:23 -07:00
bjorn 28344928c9 Simplify arr; 2019-08-21 23:16:58 -07:00
bjorn 13655d0df4 Simplify logging; 2019-08-21 19:02:02 -07:00
bjorn cd09e1e695 rm sds; 2019-08-21 16:30:20 -07:00
bjorn a4781c7013 Fix cylinder winding; 2019-08-12 20:03:32 -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 4d3bfea67c Model:getMaterial(name|index); rm Model:setMaterial; 2019-08-09 16:10:46 -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 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 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 239a9514ea Model: Fix animations that aren't keyed at t=0; 2019-07-19 16:42:51 -07:00
bjorn 84cdc592bc Make sure lovrBufferUnmap always unmaps; 2019-07-12 20:16:18 -07:00
bjorn 2eb4b779ab Model cleanup; 2019-07-11 20:13:47 -07:00
bjorn 4b4020d3a7 Model:pose; Model:getNodePose; 2019-07-11 20:09:46 -07:00
bjorn f81a65430b Add support for cubic spline keyframe interpolation; 2019-07-11 11:05:53 -07:00
bjorn 3c07ad6b0b Replace Animator with Model:animate; 2019-07-10 22:08:19 -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 af29e29e4d Fix lovr.graphics.setProjection;
Needed to be using new frameData stuff.
2019-07-08 14:35:54 -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 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