baldurk / renderdoc

RenderDoc is a stand-alone graphics debugging tool.
https://renderdoc.org
MIT License
9.05k stars 1.35k forks source link

Histogram visualization is stale for different mipmap levels after changing custom shader #2828

Closed Pokechu22 closed 1 year ago

Pokechu22 commented 1 year ago

Description

The histogram visualization seems to re-use the values from the previous custom shader once after modifying the custom shader when changing mipmap levels.

Note that the histogram itself does update when changing levels, just to the value for the previous custom shader. Furthermore, the incorrect set of values is only used once, becoming correct after switching away from the new mipmap level and back again. This only seems to happen if both the texture viewer and shader editor are visible at the same time. Also, the selected mipmap level is immediately updated; it's only the other mipmap levels that exhibit this behavior.

Steps to reproduce

  1. Load a capture that contains a texture with multiple mipmap levels.
  2. Select a texture with multiple mipmap levels.
  3. Set channels to "custom".
  4. Enter a name for the custom shader, and then click the "+". I used a GLSL shader.
  5. Drag the "editing fragment shader" tab and dock it on the side of the screen so that both it and the texture viewer are visible at the same time (this is required; the issue does not happen if you need to switch tabs to see the texture viewer).
  6. Enter the following as the shader:

    #version 420 core
    
    layout (location = 0) in vec2 uv;
    
    layout (location = 0) out vec4 color_out;
    
    uint RD_SelectedMip();
    
    void main()
    {
        color_out = vec4(0, .1 + .2 * RD_SelectedMip(), 0, 0);
    }
  7. Click "refresh". The texture viewer should immediately update.
  8. Enable the histogram in the texture viewer.
  9. Scroll through all of the mipmaps. The histogram should (probably?) look correct for them all.
  10. Change the shader to this:

    #version 420 core
    
    layout (location = 0) in vec2 uv;
    
    layout (location = 0) out vec4 color_out;
    
    uint RD_SelectedMip();
    
    void main()
    {
        color_out = vec4(.5, .15 + .2 * RD_SelectedMip(), .4, .3);
    }
  11. Click "refresh". The texture viewer and histogram should immediately update.
  12. Scroll through all of the mipmaps. Observe that the histogram is that of the original shader (a changing line and a line at 0), not that of the new shader (4 distinct lines).
  13. Scroll through all of the mipmaps again. Observe that the histogram is now correct.

Environment

baldurk commented 1 year ago

Thanks for the report. This was an order-of-operations problem, it wasn't refreshing the rendered custom shader for a new mip level before fetching the histogram data. That commit should fix the issue.