Commit Graph

3559 Commits

Author SHA1 Message Date
nikeinikei edeab5e4e8 Merge branch 'love2d:12.0-development' into 12.0-development 2023-02-06 12:19:19 +01:00
Sasha Szpakowski 6ac7c09d90 shaders: default to std430 layout for storage buffers. 2023-02-05 22:16:28 -04:00
Sasha Szpakowski 2178b634c8 Add functions for indirect draws and compute dispatches.
Resolves #1879.

- Add an 'indirectdraw' boolean field to the graphics feature support table returned by love.graphics.getSupported. This is almost always supported when compute shaders are supported, except on a few older phones.

- Add an 'indirectarguments' boolean field to the settings table in love.graphics.newBuffer.

- Add love.graphics.dispatchIndirect(shader, argumentsbuffer [, argumentsindex = 1]).
    The compute dispatch's threadgroup width, height, and depth values are fetched from the buffer (as 3 uints) instead of coming from function parameters.

- Add love.graphics.drawIndirect(mesh, argumentsbuffer, argumentsindex, x, y, ....).
    Vertex or index count, instance count, and other related parameters for drawing the mesh are fetched from the buffer (as 4 or 5 uints depending on whether the mesh has an index buffer) instead of coming from function parameters. It's usually a good idea to keep parameters other than the instance count in sync with what the mesh should be using.

- Add love.graphics.drawFromShaderIndirect(drawmode, argumentsbuffer [, argumentsindex = 1] [, maintexture = nil]) and drawFromShaderIndirect(indexbuffer, argumentsbuffer [, argumentsindex] [, maintexture = nil]).
    Vertex or index count, instance count, and other related parameters are fetched from the buffer as 4 or 5 uints, as above.

For the dispatch indirect arguments buffer, it has to have 3 uint32 elements: { uint threadgroupsX, uint threadgroupsY, uint threadgroupsZ }.

For non-indexed draws, the arguments buffer has to have 4 uint32 elements: { uint vertexCount, uint instanceCount, uint baseVertex, uint baseInstance }. Note that baseInstance should always be set to 0 as many drivers don't support non-zero values.

For draws which use an index buffer, the arguments buffer has to have 5 uint32 elements: { uint indexCount, uint instanceCount, uint firstIndex, uint baseVertex, uint baseInstance }. As above, the baseInstance value should always be 0.

A buffer can be created to have an array of those structures, which can be used with the argumentsindex parameter of the Indirect dispatch/draw functions.
2023-02-05 15:55:19 -04:00
Sasha Szpakowski d3747cebb1 Rename love.graphics.drawShaderVertices to drawFromShader. 2023-02-05 15:16:10 -04:00
Sasha Szpakowski e13b0078a2 shaders: ignore code in comments when parsing entry point functions.
Fixes #1581.
2023-02-04 10:25:13 -04:00
niki 9f452474c7 vulkan: remove unnecessary getDevice() calls 2023-01-31 01:07:02 +01:00
Sasha Szpakowski defe811f62 Allow creating a mipmapped texture with less than the full mip range.
When creating a texture with user-specified mipmaps, it no longer errors if all mipmaps down to 1x1 aren't present.

Added a 'mipmapcount' field to the settings table in newImage and friends (only used when mipmaps are enabled for the texture.) If it's set, only mipmap levels up to the specified count will be created instead of always creating the full range.

Old OpenGL ES 2 devices don't support loading a mipmapped texture without the full mipmap range, so there's a new 'mipmaprange' boolean field in the table returned by love.graphics.getSupported.
2023-01-29 16:02:39 -04:00
Sasha Szpakowski 8706f0ef6a Rename Texture:isRenderTarget to Texture:isCanvas. 2023-01-29 15:58:31 -04:00
niki 0e1f645538 vulkan: clean up glslang objects properly
By using smart pointers we don't want to worry about
explicitely deleting.
2023-01-29 01:14:06 +01:00
niki f01457a610 vulkan: remove internal Shader::attach call
Shader::attach() should not be called internally
by a graphics backend.
2023-01-27 14:10:19 +01:00
nikeinikei fdc860e6b6 Merge branch 'love2d:12.0-development' into 12.0-development 2023-01-27 13:53:32 +01:00
niki 377d269f4a vulkan: remap bindings to prevent clash
Vulkan does not differentiate between between bindings for textures
and buffers, as opposed to opengl. This can lead to situations, where
different uniforms get assigned the same binding leading to a crash,
when trying to update a descriptor set with the wrong type.
This patch solves this problem, by remapping the bindings when needed.
2023-01-27 02:36:10 +01:00
Miku AuahDark 61352b90a5 Update dr_mp3 to 0.6.34.
Closes #1898
2023-01-24 20:42:21 +08:00
niki a2466a4a1b vulkan: use temporary pipeline cache 2023-01-22 00:17:42 +01:00
Sasha Szpakowski 02d2dc9427 Fix race condition when a thread is destroyed right after thread:start 2023-01-18 17:27:06 -04:00
Sasha Szpakowski 0f4304edd1 Pump events a couple times during bootup.
Fixes unexpectedly slow first frames on macOS.
Fixes #1859
2023-01-15 12:36:15 -04:00
Sasha Szpakowski 9edae19d74 Merge branch 'main' into 12.0-development 2023-01-14 22:40:13 -04:00
Sasha Szpakowski 592c306276 Fix images with mipmaps when ANGLE is used with an AMD gpu. 2023-01-14 22:35:00 -04:00
Sasha Szpakowski 8cac37b811 Fix typo 2023-01-14 12:17:57 -04:00
Sasha Szpakowski 8ae7342875 Improve variable name readability in line rendering code. 2023-01-14 12:13:35 -04:00
Sasha Szpakowski f6b74e9ce7 WheelJoint:getMotorTorque takes a dt param instead of inverse dt.
Matches the change made to RevoluteJoint:getMotorTorque.
2023-01-13 18:10:45 -04:00
Sasha Szpakowski a85858236d error handler: increase font size slightly.
The new default font plus better kerning made the old size too small compared to 11.4.
2023-01-12 19:26:37 -04:00
Sasha Szpakowski 94d05e319b Clear auto-generated temporary depth/stencil buffers in setCanvas.
Previously it would discard them, which needed the user to call love.graphics.clear afterward to get them into a valid state.

The current code has suboptimal performance if the user still calls clear after setCanvas (a common situation), so more optimizations will probably be needed.

Fixes #1843.
2023-01-11 18:17:22 -04:00
Sasha Szpakowski 249d90067e Don't discard the backbuffer depth/stencil in setCanvas.
#1893.
2023-01-11 08:58:12 -04:00
niki 7e7d2884c8 vulkan: fix shader crash 2023-01-09 16:37:12 +01:00
Sasha Szpakowski 8572d4f935 Merge branch 'text-shaping' into 12.0-development 2023-01-08 20:48:48 -04:00
Sasha Szpakowski 52283425ca metal: fix crashes on the iOS Simulator 2023-01-08 20:37:05 -04:00
Sasha Szpakowski c2778587f7 Merge branch '12.0-development' into text-shaping 2023-01-08 20:31:37 -04:00
Sasha Szpakowski b0f79f78a5 vulkan: don't pass a SDL_Window into GetInstanceExtensions, it's unneeded. 2023-01-08 15:21:26 -04:00
Sasha Szpakowski 6a6ec2eeb6 Merge branch 'main' into 12.0-development 2023-01-06 17:15:29 -04:00
Sasha Szpakowski bb82a448be Fix another compile error with some compilers. 2023-01-03 20:35:31 -04:00
Sasha Szpakowski de2b986787 Code style fixes 2023-01-01 15:07:37 -04:00
Sasha Szpakowski 616ed0e7f8 Fix compile errors with some compilers. 2023-01-01 12:52:38 -04:00
Sasha Szpakowski 6f14a18da0 Update copyright year in TextShaper files 2023-01-01 12:20:01 -04:00
Sasha Szpakowski d085f44e6a Merge branch '12.0-development' into text-shaping 2023-01-01 12:18:54 -04:00
Sasha Szpakowski 22b6388a96 Merge pull request #1888 from steveRoll-git/main
Allow Canvas:renderTo to accept varargs
2023-01-01 10:59:42 -04:00
Sasha Szpakowski f6cdbdc868 Merge branch 'main' into 12.0-development 2022-12-31 22:46:34 -04:00
Sasha Szpakowski 0b75f6cfa5 Missed some files... 2022-12-31 22:36:48 -04:00
Sasha Szpakowski c823dbca96 Update copyright year for 2023 2022-12-31 22:25:49 -04:00
Sasha Szpakowski 4ace4bc3b6 Initial fallback font support for Harfbuzz text shaping. 2022-12-31 21:45:12 -04:00
Ron Tseytlin c5d72846c4 Allow Canvas:renderTo to accept varargs
The varargs will be forwarded to the function.
2022-12-31 02:32:54 +02:00
Sasha Szpakowski 9502942b7b font rendering: reimplement tab-as-spaces support. 2022-12-28 19:46:48 -04:00
Sasha Szpakowski bcc4a45e46 Merge pull request #1885 from nikeinikei/12.0-development
Vulkan fixes
2022-12-27 13:32:08 -04:00
niki 74027ad780 vulkan: remove unneeded Module::getInstance call 2022-12-27 13:55:35 +01:00
niki cd07a464fb vulkan: document future possibility for vsync
Right now we have to recreate the swapchain everytime vsync
/ present mode changes.
VK_EXT_swapchain_maintenance1 might remove the need for this.
However, right now there are not any drivers yet that support it.
In the future, this might be the better way to handle this situation.
2022-12-27 13:54:46 +01:00
Sasha Szpakowski 7137c3ffb7 Remove #ifdefs supporting old Visual Studio versions. 2022-12-26 22:22:14 -04:00
Matt Durgavich c441797976 Prefer snprintf over sprintf in OpenGL 2022-12-26 20:57:56 -05:00
Sasha Szpakowski 7a0f6621e7 Initial (WIP) Harfbuzz text shaping integration.
This a significant refactor / rewrite of much of the love.graphics Font code.
Text positioning is now split into TextShaper classes in the love.font module. This isn't exposed to users yet.
BMFonts and ImageFonts use the same text shaping as before (in the new TextShaper API). Fonts loaded via FreeType now use Harfbuzz for text shaping.

The new code isn't at feature-parity with the old code yet. Harfbuzz-based text shaping enables kerning support in more fonts, character combining into ligature glyphs, and directions other than left-to-right (this isn't supported in love yet).
2022-12-26 19:06:08 -04:00
niki 00c65d63fe vulkan: fix incorrect descriptor sets 2022-12-25 23:09:57 +01:00
niki 8694c44207 vulkan: fix incorrect textures in shader uniforms 2022-12-24 22:37:58 +01:00