Commit Graph

52 Commits

Author SHA1 Message Date
Serena Postelnek 284d0a2e3c Buffer: update XYf_STPf_RGBAub DataFormat
This seems to be a simple typo, but since the texcoords are labeled as `STPf` the `DataFormat` should be `DATAFORMAT_FLOAT_VEC3`. Format `XYf_STPf` reflects this properly.
2025-10-19 12:35:40 -04:00
John Doe 6f08eb94c6 Update copyright notice with correct year 2025-07-12 23:19:22 +01:00
Sasha Szpakowski fe23e1920b Fix some compile warnings 2024-12-29 14:09:13 -04:00
Sasha Szpakowski 50ff1e4d2b use location numbers for vertex input attributes, instead of name-based binding.
- add 'location' named field to buffer and mesh vertex format tables, replaces 'name' field.
- location numbers are expected to match 'layout (location = #)' qualifiers in vertex inputs in shader code.
- deprecate vertex inputs in shader code that don't have layout location qualifiers.
- love's default vertex attributes use location 0 for position, 1 for texcoord, and 2 for color.
- add new variants of Mesh:attachAttribute, setAttributeEnabled, and isAttributeEnabled which take location numbers instead of names.

Improves draw performance in vulkan and metal backends.
2024-09-07 18:06:03 -03:00
Sasha Szpakowski 66a1197053 Remove a couple internal support checks that aren't needed anymore. 2024-06-20 17:50:36 -03:00
Sasha Szpakowski 54a31ec615 Minimum required opengl version is now OpenGL 3.3 / OpenGL ES 3.0. 2024-06-19 18:08:09 -03:00
Sasha Szpakowski 64a30f177f Merge branch 'main' into 12.0-development 2024-02-10 12:24:48 -04:00
Sasha Szpakowski 94d5864144 update year for copyright notice 2024-02-10 12:13:22 -04:00
Sasha Szpakowski 77c5ea1d6b graphics: move buffer:clear error checking to high level code 2024-01-02 11:13:31 -04:00
Sasha Szpakowski e42019c59e Add buffer stats to love.graphics.getStats.
- Add 'buffers' field, to count the total number of graphics buffer objects.
- Add 'buffermemory' field, to estimate the total number of bytes of graphics memory used by all buffers.
2023-12-25 23:25:46 +01:00
Sasha Szpakowski eb552dfcb6 Fix compile warning 2023-12-23 16:54:00 +01:00
niki 7a25dfa7fc add texture:getDebugName and buffer:getDebugName 2023-12-14 00:09:08 +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 f6cdbdc868 Merge branch 'main' into 12.0-development 2022-12-31 22:46:34 -04:00
Sasha Szpakowski c823dbca96 Update copyright year for 2023 2022-12-31 22:25:49 -04:00
Alex Szpakowski a533982cb4 Replace internal 'staging' buffer data type with new 'readback' type. 2022-05-30 21:43:25 -03:00
Alex Szpakowski 7f3538d2ba Merge branch 'main' into 12.0-development 2022-01-05 21:10:27 -04:00
Alex Szpakowski ecbc5ca7f6 Add love.graphics.getQuadIndexBuffer.
love's pre-generated quad index buffer is useful when combined with drawShaderVertices. Note that it uses 16 bit indices so it can only draw up to 16k quads in a single call.
2022-01-03 16:22:08 -04:00
Alex Szpakowski 42e8df1489 Add a GraphicsFeature support enum for 32 bit index buffers.
Some old OpenGL ES 2 systems don't support them.
2022-01-03 16:09:38 -04:00
Alex Szpakowski 8e7fd10b6f Update copyright year for 2022 2021-12-31 18:33:40 -04:00
Alex Szpakowski bfcf025ef7 Add 'staging' buffer data usage enum. 2021-12-28 12:49:33 -04:00
Alex Szpakowski 5b3a5e7721 Remove the need for copysource and copydest buffer usage flags. 2021-12-27 21:17:04 -04:00
Alex Szpakowski a3ff9999d1 Disallow mat3 formats in shader storage buffers.
GLSL's std430 layout rules make it really unintuitive for users to deal with.
2021-11-06 18:30:08 -03:00
Alex Szpakowski 68977ec311 Fix alignment of storage buffers with vec3 or mat3 components. 2021-11-06 11:17:23 -03:00
Alex Szpakowski 21f5ba86d3 Merge branch 'master' into 12.0-development 2021-04-07 20:33:44 -03:00
Alex Szpakowski f89aabb0bb Update copyright year for 2021 2021-04-04 16:14:45 -03:00
Alex Szpakowski deff795908 Rename some internal buffer enums to better match what they do 2021-01-17 20:59:16 -04:00
Alex Szpakowski e2838131f2 Add love.graphics.copyBuffer. 2021-01-17 14:02:00 -04:00
Alex Szpakowski 50ff86bd92 Graphics Buffers can be used as Shader Storage Buffers. 2021-01-10 17:53:12 -04:00
Alex Szpakowski 1f9d98263d Refactor Buffer internals.
Allows buffers created with love.graphics.newBuffer to only allocate VRAM data. Previously they had a copy of their contents in RAM.
Also makes it easier to implement Buffers in other graphics APIs and to implement more types of Buffers in the future.
2020-12-22 19:23:02 -04:00
Alex Szpakowski b011487a3e Add new texel buffer type.
GLSL 3+ shaders can read from texel buffers by declaring a uniform samplerBuffer variable and calling texelFetch with a 0-based index, in the shader code. All attributes in a texel buffer's format array must have the same data format (e.g. all 'floatvec4' formats).

Shader:send accepts a texel Buffer for samplerBuffer uniforms.

Added 'texelbuffer' to love.graphics.getSupported (requires GLSL 3+ and desktop OpenGL).
Added 'texelbuffersize' to love.graphics.getSystemLimits. Returns the max number of values in a texel buffer (array length multiplied by the number of attributes declared in the buffer's format array).
2020-07-28 20:44:36 -03:00
Alex Szpakowski 36b0394afc Add love.graphics.newVertexBuffer and love.graphics.newBuffer. 2020-07-26 16:32:18 -03:00
Alex Szpakowski d75f5df80d Add Buffer methods
flush, setArrayData, setElement, getElement, getElementCount, getElementStride, getSize, getFormat
2020-07-25 19:48:54 -03:00
Alex Szpakowski c2be89f130 Fix crashes when creating a Buffer. 2020-07-21 20:50:49 -03:00
Alex Szpakowski 3b67db4672 Add love.graphics.newIndexBuffer 2020-07-21 18:57:50 -03:00
Alex Szpakowski 2c90ccabb3 Avoid some hardcoded strings 2020-02-23 16:49:38 -04:00
Alex Szpakowski 1ddfcd4cc8 Always use explicitly typed buffers, even in internal code 2020-02-23 16:30:55 -04:00
Alex Szpakowski 2828761060 Move some code from Mesh wrapper to Buffer wrapper 2020-02-22 18:58:41 -04:00
Alex Szpakowski 2572f0c7a1 Meshes expose GraphicsBuffers, part 2 2020-02-01 15:39:59 -04:00
Alex Szpakowski 25d9ae2ba0 Meshes expose vertex buffers, part 1
(compiles, but is currently half-implemented and broken)
2020-01-19 15:03:19 -04:00
Alex Szpakowski d5d50d2e0d Move DataFormat enum to vertex.h 2020-01-13 23:20:49 -04:00
Alex Szpakowski ee5304ba53 Remove vertex namespace 2020-01-13 20:41:05 -04:00
Alex Szpakowski b0232a4a6b Initial work on unified graphics buffers representing different types of data. 2020-01-12 16:41:23 -04:00
Alex Szpakowski fc4847c69d Update copyright for the new year 2020-01-03 22:40:36 -04:00
Alex Szpakowski 0752f27bdf Update copyright year for 2019 2019-01-03 21:09:05 -04:00
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Alex Szpakowski a31b500b03 Simplify quad drawing code, and use glDrawElementsBaseVertex when available. 2017-12-24 22:05:10 -04:00
Alex Szpakowski 785902d8bd Fix windows build 2017-12-24 16:05:52 -04:00
Alex Szpakowski 3fb621af95 Always use a 16 bit index array for quad indices, with multiple draws when necessary. See issue #1356. 2017-12-24 15:54:03 -04:00
Alex Szpakowski 864147c38c love.graphics: move more platform-independent code out of the opengl backend
--HG--
branch : minor
2017-07-22 23:34:39 -03:00