Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced perfomance in new version #32

Closed
moreginger opened this issue Nov 7, 2017 · 1 comment
Closed

Reduced perfomance in new version #32

moreginger opened this issue Nov 7, 2017 · 1 comment

Comments

@moreginger
Copy link
Contributor

Something about the new version seems to have reduced performance. I was getting 60fps with my fastgaussianblur shader, and now I'm getting ~35fps.

I think there is more buffer switching going on than used to happen, but I'm not sure that could explain it. Maybe it's applying the shader twice?

After inlining the shader code for the blur filter I got back up to 60fps, i.e. I did something like:

    local ps = love.graphics.getShader()
    local pc = love.graphics.setCanvas()
    local pbm = love.graphics.getBlendMode()

    love.graphics.setCanvas(c1)
    love.graphics.clear()
    _drawGameInternal(players, map, draw_map_end, shaders.cfg_all)

    love.graphics.setShader(shader)
    love.graphics.setBlendMode("alpha", "premultiplied")
    shader:send('direction', {1 / love.graphics.getWidth(), 0})
    love.graphics.setCanvas(c2)
    love.graphics.clear()
    love.graphics.draw(c1, 0, 0)
    shader:send('direction', {0, 1 / love.graphics.getHeight()})
    love.graphics.setCanvas(pc)
    love.graphics.draw(c2, 0, 0)

    love.graphics.setBlendMode(pbm)
    love.graphics.setShader(ps)
@vrld
Copy link
Owner

vrld commented Nov 19, 2017

Strange. The draw of a chain with a fast gaussian blur should expand to this:

    local canvas = love.graphics.getCanvas()
    local shader = love.graphics.getShader()
    local color = {love.graphics.getColor()}

    love.graphics.setCanvas(front, back) -- a bug, at the moment
    love.graphics.clear()
    _drawGameInternal(...)

    local blendmode = love.graphics.getBlendMode()

    love.graphics.setColor(color)
    love.graphics.setBlendMode("alpha", "premultiplied")
   
    -- first pass
    shader:send('direction', {1 / love.graphics.getWidth(), 0})
    front, back = back, front
    love.graphics.setCanvas(front)
    love.graphics.clear()
    if shader ~= love.graphics.getShader() then
      love.graphics.setShader(shader)
    end
    love.graphics.draw(back)

    -- second pass
    shader:send('direction', {0, 1 / love.graphics.getHeight()})
    front, back = back, front
    love.graphics.setCanvas(front)
    love.graphics.clear()
    if shader ~= love.graphics.getShader() then
      love.graphics.setShader(shader)
    end
    love.graphics.draw(back)

    love.graphics.setShader()
    love.graphics.setCanvas(canvas)
    love.graphics.draw(front,0,0)

    love.graphics.setBlendMode(blendmode)
    love.graphics.setShader(shader)

So there is one more buffer switch than in your version. Unfortunately, the switch is needed to make chaining work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants