Commit Graph

28 Commits

Author SHA1 Message Date
Sasha Szpakowski c70b0a0b03 Add Buffer:clear, to reset all or part of a Buffer's contents to 0. 2023-02-19 19:36:03 -04:00
Sasha Szpakowski 70a18e115f vulkan: don't set CREATE_DEDICATED_MEMORY flag for buffer memory.
It was being set all the time because of a code bug, but also documentation recommends using it very sparingly - partly because systems have a hard limit on the number of individual allocations (and they can also be a lot slower).

We might want to revisit more selective use of the flag in the future.
2023-02-14 20:18:26 -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 f6cdbdc868 Merge branch 'main' into 12.0-development 2022-12-31 22:46:34 -04:00
niki 6a3fffaee2 vulkan: Buffer:fill is now more like OpenGL impl 2022-10-14 14:58:27 +02:00
niki 087fe4c196 vulkan: improve negated bit syntax 2022-10-14 14:29:19 +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 503b17a5fc vulkan: fill buffer with initial data if supplied 2022-09-21 14:03:06 +02:00
niki 9a91cfd593 vulkan: use staging buffer for Buffer operations 2022-09-18 04:31:24 +02:00
niki cf099946a1 vulkan: fix depth stencil textures 2022-09-18 00:18:32 +02:00
niki e128f3453e vulkan: implement compressed textures 2022-09-17 20:32:34 +02:00
niki ccf8cb45c9 vulkan: implement storage and texel buffers 2022-09-16 00:30:26 +02:00
niki 816e3f01a2 vulkan: correctly order gpu commands 2022-09-10 19:21:31 +02:00
niki a93d153792 vulkan: adjust code styling 2022-09-10 17:40:46 +02:00
niki ec5a3a50f9 vulkan: implement graphics readback 2022-08-30 17:11:59 +02:00
niki c51b12a177 vulkan: make api design more senseful 2022-08-08 21:36:43 +02:00
niki ad8243f257 vulkan: implement Buffer::copyTo 2022-07-30 01:41:37 +02:00
niki 7bbc042fce vulkan: remove redundant tabs
this makes reading the source files easier
and is more in line with the rest of the löve codebase
2022-07-30 01:16:56 +02:00
niki 1096b76054 vulkan: fix clean up
We now don't do any more greedy waiting when destroying vulkan objects.
2022-07-29 22:59:15 +02:00
niki 7a3e9ed71e vulkan: fix uniform buffer descriptor
There was a bug where the count of used builtin uniform buffer objects
was not advanced. This caused another problem since vulkan requires
a certain alignment for the buffer. This commit fixes both of those
things.
2022-07-29 21:04:35 +02:00
niki 0ae81091d1 vulkan: use dynamic rendering
This vulkan 1.3 feature will make the code simpler when dealing
with off screen render targets (i.e. löve canvases)
2022-07-14 18:01:46 +02:00
niki 9d04ec0030 vulkan: fix all memory leaks
Now now errors regarding resource management appear in the debug output / validation layers.
2022-07-11 13:58:35 +02:00
niki 0759e8d513 vulkan: fix some memory leaks 2022-07-11 01:13:50 +02:00
niki 0cea07806f use different uniform buffers for each draw call 2022-06-30 18:42:49 +02:00
niki 7f894e5bf7 some work on drawQuads (not fully working yet) 2022-06-25 23:02:13 +02:00
niki 6c19e8c10a merge newest 12.0 commits 2022-06-11 01:34:17 +02:00
niki d09f834bf3 first draft of vulkan buffer implementation 2022-02-04 23:48:36 +01:00