cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

__ian__
Adept I

Catastrophic performance loss

I am the developer of the supermodel emulator (sega model 3 arcade emulator). I've stumbled on an issue that seems to effect all AMD cards, making the project completely unusable on them, even on the highest top of the range cards. Currently I am testing with a WX 7100 pro card. For comparison sake the code works flawlessly on Intel integrated GPUs ... I've checked the opengl code itself with AMD codexl and it doesn't find any issues (api violations).

I am creating an FBO with 3 texture attachments (RGBA8), and 1 depth/stencil. I am drawing the base texture (first texture like this)

    void main()
    {
        vec4 colBase = texture2D( tex1, fsTexCoord);
        if(colBase.a < 1.0) discard;
        gl_FragColor = colBase;
    }

Anyway doing this causes some kind of slow path inside the driver.

Comparison screenshots so you can see the issue

Look at the GPU usage and frame rate .. 40fps at 80% GPU usage

https://i.imgur.com/RTySusy.png 

If i simply blit the FBO to the back buffer like so

    glBindFramebuffer(GL_READ_FRAMEBUFFER, m_frameBufferID);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
    glBlitFramebuffer(0, 0, m_width, m_height, 0, 0, m_width, m_height, GL_COLOR_BUFFER_BIT, GL_LINEAR);

Performance looks like this 20% GPU usage at 60fps

https://i.imgur.com/xBQPsPP.png 

I can't use the second (blitting) path because it is missing critical effects that we need for correct emulation.

This is the full source code for the frame buffer emulation

Supermodel / Code / [r775] /trunk/Src/Graphics/New3D/R3DFrameBuffers.cpp 

Basically I am drawing opaque pixels to one buffer, and alpha pixels to 2 different layers, which are then composited together at the end of the frame.

6 Replies
dorisyan
Staff

Hi @__ian__, thanks for your report, I will investigate it as soon as possible.

0 Likes

Thanks, if you need anything else for testing such as compiled binaries etc, let me know.

0 Likes

Hi dorisyan,

You can find the project here. I am building with visual studio 2017. It should have all the dependencies you need so no need to go looking for stuff.

https://gofile.io/?c=3g1I6b

Just build it (in release mode). Hit F5 to run it, then when the emulator is running, hit F7 to go to the particular save state. Hit alt+p if you want to pause a particular frame. It'll keep redrawing (and issuing) opengl commands in paused mode.

In new3d.cpp

If you swap around

            m_r3dFrameBuffers.CompositeBaseLayer();                // copy opaque pixels to back buffer
            //m_r3dFrameBuffers.BlitFrameBuffer();

You'll see the dramatic performance difference.

I tried making a bare bones project to replicate this issue but the performance problem didn't show up in my bare bones project. So perhaps it's something else in the API causing it.

One of our users in the forum reported this

Hi all

i've an old ati radeon 7970 that is equivalent to a modern Radeon R9 280X.

for me the problems depend from drivers.
if i Use the last version named adrenalin supermodel run very slow.
if i Use the old crimson version of the drivers supermodel runs very well.

So it seems it works fine with older drivers. Hope this helps!

- Ian

0 Likes

Thanks for the info!

0 Likes
dorisyan
Staff

Hi @__ian__, I just found if I enable "compositeAlphaLayer", the FPS will drop to 45, I will continue investigating it, maybe you can disable it for the time being.

0 Likes

In the version I uploaded for you that method was commented out, and it was still dropping frames like crazy. Simply drawing the frame buffer seemed to cause the performance hit. Blitting seemed unaffected, which makes no sense to me because the shader for drawing was super simple.

0 Likes