Commit Graph

52 Commits

Author SHA1 Message Date
Sasha Szpakowski 343d192f10 Compressed texture formats have explicit sRGB variants 2023-10-14 15:01:01 -03:00
Sasha Szpakowski 86eb6df05c vulkan: don't hold onto ImageData references after loading an image.
Reduces CPU memory usage.
2023-10-09 20:22:04 -03:00
Sasha Szpakowski cf26e39d1b vulkan: potential fix for compressed textures with mipmaps 2023-10-09 13:13:37 -03:00
Sasha Szpakowski f6cdbdc868 Merge branch 'main' into 12.0-development 2022-12-31 22:46:34 -04:00
slime b9da6d6ddc vulkan: always use optimal image tiling.
Linear is useful for intermediate texture copy steps between the CPU and GPU, but we use buffers instead of textures for that.
2022-09-25 22:05:18 -03:00
slime 1b89de4497 vulkan: clean up texture creation flags 2022-09-22 22:20:42 -03:00
slime 2b074fe90e vulkan: improve sRGB support for textures 2022-09-20 19:04:56 -03:00
niki eaa043c3ff vulkan: report approximate used texture memory 2022-09-20 12:36:56 +02:00
niki 58c801be58 vulkan: fix incorrect samplers 2022-09-19 19:51:48 +02:00
niki ba759f5bc0 vulkan: use SamplerState::toKey for caching 2022-09-19 14:23:46 +02:00
niki 87c9b74c8e vulkan: fix linux build attempt 5 2022-09-18 22:00:28 +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 aec9e201f5 vulkan: implement volume textures 2022-09-16 13:49:31 +02:00
niki 4e59b563a4 vulkan: implement texture msaa 2022-09-14 14:15:57 +02:00
niki 726cd147c8 vulkan: render targets with mip and slice 2022-09-14 13:48:13 +02:00
niki 1658c89f3d vulkan: add support for custom depth/stencil tex 2022-09-11 01:57:23 +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
nikeinikei 502c1e83ab vulkan: more reserved usage flags of texture 2022-09-01 16:10:10 +02:00
niki a0ee9f7b9b vulkan: implement compute shaders
A lot of stuff probably isn't implemented yet, however the
following code already works:

```lua
local shader = love.graphics.newComputeShader [[
    layout (local_size_x = 1, local_size_y = 1) in;

    layout(r32f) uniform highp image2D out_tex;

    uniform float time;

    void computemain() {
        imageStore(out_tex, ivec2(love_GlobalThreadID.xy), vec4(time, 1.0, 1.0, 1.0));
    }
]]

local tex = love.graphics.newTexture(64, 64, {computewrite = true,format = "r32f"})

function love.draw()
    shader:send("out_tex", tex)
    shader:send("time", love.timer.getTime() % 1)
    love.graphics.dispatchThreadgroups(shader, 64, 64, 1)

    love.graphics.print("compute shader test")
    love.graphics.draw(tex, 25, 25)
end
```
2022-08-31 02:07:46 +02:00
niki ec5a3a50f9 vulkan: implement graphics readback 2022-08-30 17:11:59 +02:00
niki d123021e26 vulkan: fix canvas rendering (on android)
Before this patch, sometimes rendering a texture
on an android device would result in random things
appearing in the canvas, apart from the stuff
that has been drawn properly.
With these changes this does not seem to appear anymore.
2022-08-29 17:43:54 +02:00
niki 748f2676d5 vulkan: fix mip maps 2022-08-27 22:20:33 +02:00
niki b2771dd111 vulkan: fix cube textures 2022-08-15 00:06:50 +02:00
niki fbb64a07af vulkan: partially implement mipmaps
There is no real effect yet when rendering, however debugging the
application with renderdoc reveals that the mipmap generation is
already correct. There's probably something weird going on with the
sampling. I'll have to look into that next.
2022-08-09 00:57:07 +02:00
niki 0ebb34e037 vulkan: avoid usage of general image layout 2022-08-08 22:06:01 +02:00
niki c51b12a177 vulkan: make api design more senseful 2022-08-08 21:36:43 +02:00
niki dcea056fcb vulkan: properly implement samplers 2022-08-01 18:51:09 +02:00
niki 224b9e84f0 vulkan: add support for 2d array textures 2022-08-01 15:53:31 +02:00
niki 8cf7a79657 vulkan: add missing layout transitions 2022-07-31 23:56:03 +02:00
niki 4686de8ebd vulkan: implement copy Texture <-> buffer methods 2022-07-30 02:17:58 +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 94c58e1599 vulkan: fix video rendering 2022-07-30 00:26:49 +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 524e011133 vulkan: make Texture::uploadByteData async
Before this commit we would greedily wait for the upload to be complete
before exiting the function. This is of course not correct, since
we might be changing data that is still being used in a render in
flight. Of course we also need to cleanup the resources asynchronously
after the frame has been rendered fully.
2022-07-29 22:35:35 +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 6d7bd645fc vulkan: use vkCmdClearColorImage to clear texture
using the vulkan functionality probably leads to less bugs.
Until now it was assumed that any image was in the rgba8 format,
which is of course not correct. Clearing a texture to white or black
should now work for any format.
2022-07-24 13:43:48 +02:00
niki ac9d8ec2a0 vulkan: fix canvas rendering
Sometimes canvas commands wouldn't get executed.
This was because when the window gets resized,
the command buffers would get recreated, and would thus
lose the recorded commands.
2022-07-16 15:55:48 +02:00
niki 95952c691d vulkan: implement setRenderTargetsInternal
basic usage of canvases now works.
Colors probably aren't correct yet.
2022-07-15 01:44:07 +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 c5327bfc4f vulkan: fix some more memory leaks 2022-07-11 01:47:34 +02:00
niki 0759e8d513 vulkan: fix some memory leaks 2022-07-11 01:13:50 +02:00
niki b1fb5b551e working text rendering 2022-07-10 02:25:28 +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 acf0474cc8 Implement drawing very basic textures
With this commit you can draw very simple textures.
The following code will showcase it:

```lua
function love.run()
    local data = love.image.newImageData(40, 40)
    for i = 0,39 do
        for j=0,39 do
            if i <= 20 then
                if j <= 20 then
                    data:setPixel(i, j, 1, 0, 0, 1)
                else
                    data:setPixel(i, j, 0, 1, 0, 1)
                end
            else
                if j <= 20 then
                    data:setPixel(i, j, 0, 0, 1, 1)
                else
                    data:setPixel(i, j, 1, 1, 1, 1)
                end
            end
        end
    end

    local texture
    texture = love.graphics.newTexture(data)

    return function()
        love.event.pump()
        for name, a,b,c,d,e,f in love.event.poll() do
            if name == "quit" then
                if not love.quit or not love.quit() then
                    return a or 0
                end
            end
            love.handlers[name](a,b,c,d,e,f)
        end

        love.graphics.origin()
        love.graphics.clear()

        love.graphics.draw(texture, 50, 500)

        love.graphics.present()
    end
end
```
2022-06-11 20:33:44 +02:00
niki c16c07780f use default texture when rendering primitives 2022-05-08 22:44:32 +02:00
niki 4e8304255d first draft of vulkan texture impl 2022-05-06 16:06:09 +02:00