Commit Graph

221 Commits

Author SHA1 Message Date
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
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