Commit Graph

235 Commits

Author SHA1 Message Date
Sasha Szpakowski 3a6833ffb5 fix compile error 2024-09-30 20:15:11 -03:00
Sasha Szpakowski 1ee89154c0 vulkan: memory barrier after compute dispatches. 2024-09-30 19:58:45 -03:00
Sasha Szpakowski 8e6efac595 vulkan: fix a crash when the window has no depth or stencil. 2024-09-28 18:30:26 -03: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 654585ccc2 vulkan: don't try to enable blending with integer canvases. 2024-08-14 21:00:24 -03:00
Sasha Szpakowski 0ca8cb4b41 vulkan: fix negative scissors not being clamped. 2024-08-05 10:21:10 -03:00
Sasha Szpakowski 6acdd5f01f vulkan: fix depth texture compare mode setting. 2024-07-11 21:29:58 -03:00
Sasha Szpakowski 9f18595559 vulkan: reduce memory use in some situations 2024-06-28 21:53:03 -03:00
Sasha Szpakowski b16e1d6e27 vulkan: don't periodically clean up render pass objects.
It's not needed.
2024-06-24 18:41:52 -03:00
Sasha Szpakowski 35f20eb053 vulkan: move cached PSO ownership to shaders.
Fixes issues with state corruption when a shader is created with the same memory address as a recently deleted shader.
2024-06-24 18:31:34 -03:00
Sasha Szpakowski 10c435cfc9 vulkan: fix a crash in setCanvas. 2024-06-22 21:05:37 -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 bfc4212f30 Remove NormalMatrix shader uniform.
It doesn't provide much value given its costs. It also didn't work properly with auto-batched draws.
2024-06-17 20:57:28 -03:00
Sasha Szpakowski e180b256b8 vulkan: fix cull mode in quad drawing code 2024-06-17 17:08:31 -03:00
Sasha Szpakowski a894c2f6a4 vulkan: fix validation errors related to scissors when drawing. 2024-05-03 20:24:25 -03:00
Sasha Szpakowski 1f0f2a0781 vulkan: fix detection of linear filter support for pixel formats 2024-04-12 18:00:09 -03:00
Sasha Szpakowski 4b3fdc2317 vulkan: fix a crash in the error screen 2024-04-11 22:44:47 -03:00
Sasha Szpakowski 111bbde32d vulkan: fix shaders with int vertex attributes when nothing using that attribute is drawn. 2024-04-11 22:35:43 -03:00
niki 15c14c69b4 vulkan: correct scissor extent calculation 2024-04-09 18:04:54 +02:00
niki 869cb23314 vulkan: fix incorrect scissor when rendering to a canvas 2024-04-09 17:31:04 +02:00
Sasha Szpakowski 8140817107 vulkan: fix a crash on minimization.
Use a fake backbuffer when the system reports 0 for swap chain dimensions.
2024-04-07 17:25:46 -03:00
Sasha Szpakowski 2bc9777c3b vulkan: limit render pass layout transitions to the active mipmap/layer. 2024-04-07 09:48:54 -03:00
Mark Jansen a689d8e450 Fix building love on Windows for SDL3-3.1.0 2024-04-01 19:26:52 +02:00
Sasha Szpakowski 44a6a81641 vulkan: improve depth/stencil texture support. 2024-03-31 17:56:36 -03:00
Sasha Szpakowski f32b6bde57 vulkan: fix validation error when clearing mid-pass. 2024-03-31 13:28:46 -03:00
Sasha Szpakowski a0ca3c148e vulkan: improve handling of vertex attribute bindings. 2024-03-31 12:55:40 -03:00
Sasha Szpakowski b33afc4371 vulkan: love.graphics.clear fixes.
- Fix love.graphics.clear(color) when multiple canvases are active.
- Fix love.graphics.clear when an integer-format canvas is active.
2024-03-28 19:00:29 -03:00
Sasha Szpakowski d82922f774 vulkan: let the system handle device rotation for us.
We'd need to inject a whole bunch of code into user shaders (for example to rotate derivates) if we wanted to reliably handle it ourselves, which isn't viable.
2024-03-27 20:00:05 -03:00
Sasha Szpakowski 7bfbd647ba Make shader clip space consistent across APIs and projection matrices.
- All shaders are expected to output clip space values that are effectively y-up, with [-1, 1] z, in NDC.
- The transform to a backend's expected clip space values from the above range now happens after user vertex shader code is run, instead of inside a projection matrix.
- Projection matrices no longer need to be flipped when rendering to a canvas versus the main screen.

This means custom projection matrices might need to be altered to account for the more consistent range.
2024-03-23 22:00:02 -03:00
Sasha Szpakowski 9aaeabd6a5 vulkan: fix love_ScreenSize shader variable when a canvas is active. 2024-03-22 23:08:34 -03:00
Sasha Szpakowski 17cb64c45f vulkan: fix validation errors in love.graphics.getTextureFormats. 2024-03-21 21:43:45 -03:00
Sasha Szpakowski bbaa55f8b8 vulkan: fix validation errors in layout transitions for depth-only and stencil-only images. 2024-03-21 21:32:03 -03:00
Sasha Szpakowski 48aefd91fa vulkan: captureScreenshot improvements.
- Don't create several persistent screen-sized images and buffers for screenshots, only create one temporary buffer during a frame that requests a screenshot.
- Attempt to handle more out-of-memory situations.
- Make sure the final screenshot is opaque.
- Swap R and B channels in the screenshot ImageData when the backbuffer is BGRA.
2024-03-16 23:51:40 -03:00
Sasha Szpakowski f3887361e5 Merge pull request #2037 from nikeinikei/main
vk: unify local uniform buffer
2024-03-13 18:33:56 -03:00
niki 07c5c44ea3 vulkan: simplify code with alignUp 2024-03-13 22:16:33 +01:00
niki 295fb214d5 vulkan: remove unused constant and use correct sizes for mapping
the local uniform stream buffer
2024-03-11 13:47:43 +01:00
Sasha Szpakowski ec9fb6eb28 Improve Windows vulkan draw performance by reducing the size of a struct. 2024-03-10 14:33:29 -03:00
niki 54f27a8277 vulkan: unify local uniform buffer 2024-03-10 14:41:37 +01:00
Sasha Szpakowski 51d5773b93 vulkan: optimize vertex buffer binding code 2024-03-09 00:15:13 -04:00
Sasha Szpakowski 42812ad521 Add texture views. Fixes #2022.
Add love.graphics.newTextureView(basetexture, viewsettings). Requires GLSL4 support.
Add 'viewformats' boolean setting to texture setting tables.
Add Texture:hasViewFormats.

The viewsettings table has the following fields:
  format = nil, -- set this to a pixel format to override the base format. It must have the same number of bytes per pixel as the original, and the 'viewformats' setting on the original texture must be true for this to work. Cannot be used for compressed or depth/stencil textures.
  type = nil, -- set this to a texture type to override the base texture type. 2d base textures can make [2d, array] views. [array, cube] base textures can make [2d, array, cube] views.
  mipmapstart = nil, -- set to a number to use a less detailed mipmap level as a base.
  mipmapcount = nil, -- set to a number to override the number of mipmaps in the texture view.
  layerstart = nil, -- set to a number to use a specific layer or cube face as a base.
  layers = nil, -- set to a number to override the number of layers in an array texture view.
2024-02-24 15:45:43 -04:00
Sasha Szpakowski 1e97e09b28 Rework internal module registration to happen in constructors. 2024-02-24 15:21:38 -04:00
Sasha Szpakowski 64a30f177f Merge branch 'main' into 12.0-development 2024-02-10 12:24:48 -04:00
Sasha Szpakowski aaab9791d5 Improve backbuffer depth buffer.
- Setting the depth buffer for the backbuffer is now done as a boolean instead of a bit depth integer, in love.conf or love.window.setMode.
- Error if depth writes are enabled when the active canvas setup or backbuffer does not have a depth buffer (now it matches stencil behaviour).
- Don't allocate a backbuffer depth-stencil buffer if they're not requested. Metal also determines the format for that buffer based on which combination of depth and stencil is requested. OpenGL still has to allocate the depth-stencil buffer for the backbuffer all the time, because changing it requires the context to be recreated.
2024-01-06 15:21:06 -04:00
Sasha Szpakowski 04462ece30 graphics: clean up some stencil code 2024-01-04 21:35:52 -04:00
Sasha Szpakowski 9b5851e039 Move current love.graphics.setStencilMode functionality to setStencilState.
Add new higher level love.graphics.setStencilMode function.
- Add love.graphics.setStencilMode(mode [, value = 1])
- Add love.graphics.setStencilMode().
- Add mode, value = love.graphics.getStencilMode().

The possible modes are "off" (same as no parameters), "draw", and "test".
The "draw" mode disables color writes and sets the stencil state to ("replace", "always") using the given value.
The "test" mode enables color writes and sets the stencil state to ("keep", "equal") using the given value to compare to.
2024-01-04 16:23:49 -04:00
Sasha Szpakowski dbcdbc47d5 Add debugname field to shader options table. 2023-12-29 16:51:24 +01:00
Sasha Szpakowski 8872497561 graphics: handle default textures in high level code.
Previously each backend had to set up default textures with its own code, which needs some care for it to be robust.
2023-12-27 21:28:02 +01:00
niki 364b5c3b7b adjust code styling 2023-12-14 00:16:38 +01:00
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