Commit Graph

187 Commits

Author SHA1 Message Date
niki a5d7ba1589 implement #1992
add debugname to settings table for texture and buffer,
which can be used for debugging in e.g. RenderDoc.
2023-12-13 14:28:34 +01:00
Sasha Szpakowski 343d192f10 Compressed texture formats have explicit sRGB variants 2023-10-14 15:01:01 -03:00
Sasha Szpakowski 983ea6c0e6 Remove explicit support for systems that don't support rgba8 canvases.
This is just a very small number of really old OpenGL ES 2 drivers.
2023-10-13 21:53:45 -03:00
niki 21182d1428 vulkan: fix memory leak 2023-10-09 16:04:25 +02:00
niki 51d5b48515 vulkan: fix incorrect device extension 2023-10-09 15:32:17 +02:00
niki 8f8afe3de5 vulkan: fix crash when using love.window.close() 2023-10-09 15:31:23 +02:00
niki 3b9476b5dd vulkan: fix validation warnings
Sometimes no buffer for tex coords are given, however the shader
still expects some. We can fix this by using a default buffer, which
contains the constant tex coords (0, 0), which is then bound instead.
2023-07-18 14:56:42 +02:00
niki ba15a2ab05 vulkan: correct usage of pNext chain for device
For systems where VK_EXT_extended_dynamic_state is not supported
it is not valid to extend VkDeviceCreateInfo with an unknown struct.
Todo: if more extensions are supported in the future this code probably
needs adjustments to correctly build a pNext chain.
2023-07-18 14:01:05 +02:00
niki 04de1ade9e vulkan: correctly deal with custom input attribs 2023-07-18 13:54:48 +02:00
niki 5254417c63 vulkan: remove unnecessary vkDeviceWaitIdle
Since we are only cleaning up objects that haven't been used in the
last 5000 frames, we do not need to wait to delete them.
2023-07-18 13:54:27 +02:00
niki 332b456131 vulkan: remove getDefaultTexture 2023-07-18 13:54:06 +02:00
niki 284a385062 support more swapchain image formats 2023-07-18 13:52:13 +02:00
niki 5eae82ab33 vulkan: fix gammacorrect in Graphics::clear 2023-02-15 01:22:38 +01:00
niki 4f321d69e7 vulkan: cache depthStencilFormat 2023-02-12 14:52:30 +01:00
niki dc6e080d18 vulkan: code styling 2023-02-12 14:18:26 +01:00
niki 6183f67598 vulkan: fix wrong attachment load op 2023-02-12 00:54:03 +01:00
niki 2fc5a8afe0 vulkan: removed unused optional extension 2023-02-12 00:22:51 +01:00
niki 14e08a2b03 vulkan: remove default renderpasses & framebuffers
There is little to no performance gain, with a lot of burden
to maintenance of the extra path. It's better to unify the code
with the other render pass logic.
2023-02-11 22:36:39 +01:00
niki b698c0f11a vulkan: rename to OptionalDeviceExtensions
The previous name was misleading.
2023-02-11 22:21:07 +01:00
niki b04ba7ecb4 vulkan: fix incorrect loadOp 2023-02-11 20:20:49 +01:00
niki d06926eae9 Merge branch '12.0-development' of https://github.com/nikeinikei/love into 12.0-development 2023-02-11 20:06:22 +01:00
niki 094d6e39d1 vulkan: improve render pass performance
Before this patch some common patterns would lead to very suboptimal
render passes.
Consider the following code:
```lua
local canvas = love.graphics.newCanvas(...)

function love.draw()
    love.graphics.setCanvas(canvas)
    love.graphics.clear(...)
    love.graphics.draw(...)
    love.graphics.setCanvas()

    love.graphics.draw(canvas)
end
```
This would lead to the following rendering:
1) render pass on main window with loadOp=load, followed by an immediate
    call to vkCmdClearAttachments
2) render pass on canvas with loadOp=load, followed by an immediate call
    to vkCmdClearAttachments
3) render pass on main window with loadOp=load

This patch changes the behaviour to the more performant
(and equivalent) version:
1) render pass on canvas with loadOp=clear
2) render pass on main window with loadOp=clear

This is especially helpful on mobile devices, where creating render
passes is an expensive operation.
2023-02-11 20:06:19 +01:00
nikeinikei edeab5e4e8 Merge branch 'love2d:12.0-development' into 12.0-development 2023-02-06 12:19:19 +01: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 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
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
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
niki a2466a4a1b vulkan: use temporary pipeline cache 2023-01-22 00:17:42 +01:00
niki 7e7d2884c8 vulkan: fix shader crash 2023-01-09 16:37:12 +01: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 f6cdbdc868 Merge branch 'main' into 12.0-development 2022-12-31 22:46:34 -04: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
niki 8694c44207 vulkan: fix incorrect textures in shader uniforms 2022-12-24 22:37:58 +01:00
niki ccca355664 vulkan: fix love.window.setVsync 2022-12-22 01:27:05 +01:00
nikeinikei eec94ccc99 Merge branch 'love2d:12.0-development' into 12.0-development 2022-12-21 17:20:43 +01:00
niki 30bdb03f3b vulkan: code styling 2022-12-21 17:20:13 +01:00
niki 2d5b4966d3 vulkan: add missing vulkan errors 2022-12-11 23:21:47 +01:00
Sasha Szpakowski c89192990b vulkan: potentially improved highdpi support.
Mostly untested.
2022-12-06 20:36:36 -04:00
Sasha Szpakowski d70514b2d1 vulkan: when vsync is off prefer immediate instead of mailbox mode, for now.
Fixes #1852. This might be reevaluated in the future.
2022-12-04 17:51:11 -04:00
niki 12bc2b4545 vulkan: fix code formatting
now indenting only uses tabs and not spaces
2022-11-12 03:36:58 +01:00
niki 97a7042143 vulkan: remove instanceVersion class member
This is not actually needed. The api version specified when creating
the vulkan instance should be the highest api version that might
be used by the application, which can be higher than the supported
instance version. VMA can make use of vulkan 1.3 features so this
can be hardcoded to VK_API_VERSION_1_3.
2022-11-12 03:24:07 +01:00
niki 3b3bd63c93 vulkan: improve loop in createVulkanVertexFormat 2022-10-27 14:22:43 +02:00
niki f4bdc57fb3 vulkan: keep track of device/instance api version 2022-10-16 03:33:09 +02:00
niki 940ac05137 vulkan: call invalidate if mapping is incoherent 2022-10-13 23:58:31 +02:00
niki ecc272e0ca vulkan: flush allocations if needed
There is no guarantee that the created buffer is actually host coherent.
If it is not we have to manually flush it.
2022-10-06 02:12:36 +02:00
niki a95ff597d5 vulkan: remove unnecessary code
Since we supply the vulkan headers ourselves
we can be sure that all the definitions used are there.
2022-10-06 01:18:27 +02:00
slime 752a386640 vulkan: stencils use the same reversed compare mode convention as other backends 2022-09-26 21:20:09 -03:00
slime e3ba7a0bff vulkan: fix missing stencil compare mask dynamic state setup 2022-09-26 21:18:51 -03:00
slime b9da6d6ddc vulkan: always use optimal image tiling.
Linear is useful for intermediate texture copy steps between the CPU and GPU, but we use buffers instead of textures for that.
2022-09-25 22:05:18 -03:00
slime 1eb4f1f172 vulkan: flush batched draws before clear(). minor code cleanup. 2022-09-25 17:41:47 -03:00