Commit Graph

110 Commits

Author SHA1 Message Date
Sasha Szpakowski 3509e651fd Fix Texture:getWidth for texture views. 2024-03-06 14:23:18 -04:00
Sasha Szpakowski e20f018272 Change the 'viewformats' texture setting field to be a list of pixel formats.
Replace Texture:hasViewFormats with Texture:getViewFormats.
2024-02-24 23:42:28 -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 007090af14 ImageData: remove automatic mutex locks. 2024-02-18 17:06:40 -04:00
Sasha Szpakowski d880c48502 Clean up some internal texture data upload parameters. 2024-02-17 14:10:38 -04:00
Sasha Szpakowski 81d0c720a2 Fix compressed texture uploads using the wrong pixel format. 2024-02-17 14:00:31 -04: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
niki 7a25dfa7fc add texture:getDebugName and buffer:getDebugName 2023-12-14 00:09:08 +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 8c13943f64 ImageData can track whether they're meant to be loaded into a Texture with a non-sRGB format when gamma correct rendering is enabled.
Fixes #1556.

* Add ImageData/CompressedImageData:setLinear and ImageData/CompressedImageData:isLinear.
  The flag is used as a hint when loading a texture from the data to determine if the format should not be treated as sRGB-encoded. The 'linear' flag in newImage overrides this.

* love.graphics.readbackTexture automatically sets the linear flag on ImageData it returns when the texture's format is linear.
  This allows an ImageData generated via readback to be fed back into a new Texture and the format will match the original Canvas.

* Also clean up some image decoding code.
2023-10-14 20:48:21 -03: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
Sasha Szpakowski 3865868358 Fix creating a linear rgba8 canvas when gamma correct rendering is on.
Fixes #1973
2023-10-13 21:41:32 -03: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
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
slime 919ffc08f0 remove some dead code 2022-10-10 14:35:12 -03:00
slime 2466e49fd1 Change behaviour of love.graphics.newImage when image size is too big.
Previously it would load a placeholder error texture, now it causes a Lua error - which is the same behaviour as love.graphics.newCanvas.
2022-10-01 21:55:59 -03:00
nikeinikei 60036d5dfe fix keying of samplerstate (#1853) 2022-09-26 23:57:53 -03:00
Alex Szpakowski 3a5c3df02f Add sync and async texture and buffer readback APIs.
- Add imagedata = love.graphics.readbackTexture(texture, [slice, mipmap, x, y, w, h, [dest, destx, desty]]).
- Add readback = love.graphics.readbackTextureAsync(texture, [slice, mipmap, x, y, w, h, [dest, destx, desty]]).
- Add bytedata = love.graphics.readbackBuffer(buffer, [offset, size, [dest, destoffset]]).
- Add readback = ove.graphics.readbackBufferAsync(buffer, [offset, size, [dest, destoffset]]).
- Deprecate Texture:newImageData.

The async variants return a new GraphicsReadback object. It has the following methods:
- isComplete()
- hasError()
- wait()
- getBufferData()
- getImageData()
- update() (called automatically every frame by love, not normally needed).

Support notes:
- readbackBuffer and readbackBufferAsync require buffer copying support.
- readbackTexture with a render target (canvas) is always supported. readbackTexture with a non-render-target requires copy-texture-to-buffer support.
- readbackTextureAsync with a render target requires copy-render-target-to-buffer support. readbackTextureAsync with a non-render-target requires copy-texture-to-buffer support.
2022-05-30 21:53:55 -03:00
Alex Szpakowski bc1c38d361 improve logic for detecting when Texture:generateMipmaps is supported 2022-02-19 16:34:52 -04:00
Alex Szpakowski d96e1636b1 Improve setCanvas validation of volume texture layer + mipmap values. 2022-01-16 13:00:12 -04:00
Alex Szpakowski d51e012812 Merge branch '12.0-development' into metal 2022-01-05 21:12:22 -04:00
Alex Szpakowski 7f3538d2ba Merge branch 'main' into 12.0-development 2022-01-05 21:10:27 -04:00
Alex Szpakowski 40aa50662a Merge branch '12.0-development' into metal 2022-01-01 15:36:57 -04:00
Alex Szpakowski 8e7fd10b6f Update copyright year for 2022 2021-12-31 18:33:40 -04:00
Alex Szpakowski 4195911680 Relax Texture:replacePixels sub-rect restriction for compressed textures. 2021-12-27 12:10:37 -04:00
Alex Szpakowski e63025b74f Merge branch '12.0-development' into metal 2021-12-24 15:34:05 -04:00
Alex Szpakowski a551fcd492 Initial support for writing to textures in compute shaders. 2021-08-13 14:43:03 -03:00
Alex Szpakowski 48b3a4e860 Initial support for integer format textures.
They can't be rendered to and ImageData can't use the formats, for now.
2021-08-12 16:38:54 -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 2d2918a254 Merge branch '12.0-development' into metal 2021-03-26 21:42:08 -03:00
Alex Szpakowski 2e2ebe95cd Clean up some obsolete internal graphics code 2021-01-17 16:50:44 -04:00
Alex Szpakowski 5e77944dc0 refactor texture format support internals 2021-01-16 13:09:01 -04:00
Alex Szpakowski 20a92a4106 Merge branch '12.0-development' into metal 2020-12-22 22:37:17 -04:00
Alex Szpakowski a1861a8ff4 Don't allow calling Texture:generateMipmaps on depth/stencil textures 2020-12-21 13:36:29 -04:00
Alex Szpakowski 7e0c7e3a67 Fix the default mipmap filter for textures. 2020-10-26 18:25:40 -03:00
Alex Szpakowski 99875d83b3 Fix explicit texture MSAA of 1 or 0 not being treated the same as the default 2020-10-26 17:11:50 -03:00
Alex Szpakowski e10444c21f Move Texture:generateMipmaps error handling out of backend code 2020-10-25 23:13:50 -03:00
Alex Szpakowski 7a50f32585 Merge branch '12.0-development' into metal 2020-07-29 18:21:19 -03:00
Alex Szpakowski 9d2dca5740 metal: nogame and error screens work.
- implement love.graphics.setColor
- implement default textures
- hacky implementation of default uniform data
- use texture swizzles to set up LA8 (text) texture data
- shader reflection work
2020-06-13 20:29:23 -03:00
Alex Szpakowski 2c4bfab1de Merge branch '12.0-development' into GraphicsBuffer 2020-05-23 20:29:38 -03:00
Alex Szpakowski 9765485222 metal: partial implementation of pipeline states.
Add BGRA8 pixel format.
2020-05-03 12:48:43 -03:00
Alex Szpakowski e0ff593d09 Fix love.graphics.newTexture(imagedata, {canvas=true}) not using an sRGB format when it should 2020-03-04 20:37:41 -04:00
Alex Szpakowski 7fbb68e90e Merge branch '12.0-development' into GraphicsBuffer 2020-02-28 23:10:21 -04:00
Alex Szpakowski 9425c9224b Rename internal batched draw code to be more clear 2020-02-27 20:08:50 -04:00
Alex Szpakowski b1c028a4d3 Merge branch '12.0' into GraphicsBuffer 2020-02-17 16:31:02 -04:00
Alex Szpakowski 7c34345fa6 Rename new/set/getRenderTarget back to new/set/getCanvas, for now.
The setRenderTarget/setCanvas API will likely change before 12.0 is released, so there's no reason to rename things unnecessarily before then.
2020-02-16 19:42:11 -04:00