love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
5.06k stars 401 forks source link

Storage texture reflection seemingly not working on Metal #1783

Closed shakesoda closed 2 years ago

shakesoda commented 2 years ago

I'm attempting to experiment with compute shaders having seen that they've been added for a while and the Metal backend was merged recently.

Shader compile works fine, and I think it's valid, but reflection says my storage texture uniform isn't present. Running 12.0-development on my M1 Mac Mini.

input:

local shader = love.graphics.newComputeShader([[
layout(r32f) uniform highp image2D out_tex;

layout (local_size_x = 1, local_size_y = 1) in;

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

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

function love.draw()
    shader:send("out_tex", tex)
    love.graphics.dispatchThreadgroups(shader, 512, 512, 1)
end

expected output: silently filling the storage texture with 512x512 worth of 1.0f

actual output: Shader uniform 'out_tex' does not exist.

I'm not sure if this codepath simply is unfinished or if I'm doing it wrong (no docs, hard to say from where I'm at - although I see some TODOs in the code around this I didn't dig into it), but I figured I'd report it. If there's any information about using shader storage buffers and/or if they're available yet on Metal, that would be very helpful too.

edit: I've tested this on Linux/GL now and it works there (verified by drawing the texture), so I suppose that rules out doing it wrong.

slime73 commented 2 years ago

Looks like I forgot to implement that, whoops.

slime73 commented 2 years ago

Should be fixed now in 99ad5766683b4adea54f9a3afd1fdd3afee8c29f

shakesoda commented 2 years ago

Confirmed working on my end, thank you!

On Mon, Oct 10, 2022 at 10:14 AM slime73 @.***> wrote:

Should be fixed now in 99ad576 https://github.com/love2d/love/commit/99ad5766683b4adea54f9a3afd1fdd3afee8c29f

— Reply to this email directly, view it on GitHub https://github.com/love2d/love/issues/1783#issuecomment-1273609308, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABVS5QACO3QH5TEIXAAJBTWCRFINANCNFSM5P4W63BA . You are receiving this because you authored the thread.Message ID: @.***>