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

Overlay to show discarded fragments #2775

Open
JuanDiegoMontoya opened this issue Nov 15, 2022 · 5 comments
Open

Overlay to show discarded fragments #2775

JuanDiegoMontoya opened this issue Nov 15, 2022 · 5 comments
Labels
Feature An improvement or feature Unresolved Waiting for a fix or implementation

Comments

@JuanDiegoMontoya
Copy link

Description

The ability to see how many fragments were discarded per pixel in a draw or pass can be useful to debug the execution of shaders containing discard statements (or in the case of HLSL, calls to clip). For example, it can be used to ensure that stochastic alpha masked/cutout geometry is being rendered correctly. It can also help debug fullscreen passes that are intended to execute only for certain pixels on the screen (e.g., the shading pass in a deferred renderer, a screen-space reflections shader, or a subsurface scattering shader). This could also be used to debug instances where nothing is rendering because too many fragments are being discarded.

In my specific case, this feature would help debug a renderer which rasterizes proxy geometry (as a sort of acceleration structure), then traces a ray per pixel inside the volume, starting at the volume's surface. The rays discard in the event that they hit no geometry inside the volume.

As far as I can tell, none of the current overlays are affected by discarding, so they don't help with the aforementioned situations. I also could not find any

Without this feature, it is still possible, but rather cumbersome to debug discarded fragments by replacing them with a bright color. However, this fails for debugging cases with overlapping geometry.

The overlay would create a heatmap of discarded fragments (each discarded fragment adds to the heat at that pixel), much in the style of the quad overdraw overlay. There could be an option to view the heatmap for just the draw or the entire pass, as the user desires.

Environment

  • RenderDoc version: 1.22
  • Operating System: Windows 10
  • Graphics API: OpenGL
@baldurk baldurk added Feature An improvement or feature Unresolved Waiting for a fix or implementation labels Nov 15, 2022
@JuanDiegoMontoya
Copy link
Author

I imagine the main difficulty in implementing this (compared to the other overlays) is that it would require somehow patching the shader to insert an extra buffer/image write just before each discard statement.

@baldurk
Copy link
Owner

baldurk commented Nov 15, 2022

This should be implementable without any shader patching on any API. The draw can be run to an off-screen target to generate a pass/fail stencil mask (unconditional stencil pass means passing fragments would write and any discarded fragments wouldn't) which can be tested against to render the overlay.

I would not implement it as a heatmap, it would function the same as all the other 'test' overlays showing a pass or a fail - the overlays are intended for quick debugging & sanity checking, not detailed introspection.

@JuanDiegoMontoya
Copy link
Author

Yeah, the heatmap is not strictly necessary for my request. It would just be a consequence of how I thought it would be implemented. Your idea sounds good ❤️

@deccer
Copy link

deccer commented Nov 18, 2022

While looking for something complete unrelated I did stumble upon this obscure website, describing GL_INTEL_performance_queries which has counters for a metric like @JuanDiegoMontoya is asking for, or at least sounds very similar.

http://zaynar.co.uk/docs/gl-intel-performance-queries.html Not sure if its of any help or worth to be implemented to enable that kind of thing at least on intel gpus.

@Trass3r
Copy link
Contributor

Trass3r commented Jan 13, 2023

Intel HW perf counters are already supported #2034.
Of course that only gives you a number, not a nice picture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature An improvement or feature Unresolved Waiting for a fix or implementation
Projects
None yet
Development

No branches or pull requests

4 participants