1

I find myself needing to clear the depth buffer many times per frame for the purpose of layered rendering.

In the early 2000s, clearing Z was actually pretty costly with the limited bandwidth in the day. So AMD came up with techniques like HyperZ that included a fast Z-clear operation for the depth buffer.

In this day and age, can I assume that all manufacturers have implemented fast clearing of depth values, and have it enabled by default?

Or is there an OpenGL extension I should be aware of, or a setting I need to toggle somewhere?

My target is OpenGL Core Profile 3.2 by the way.

Bram
  • 7,440
  • 3
  • 52
  • 94

1 Answers1

0

Without knowing more about what you're trying to do, I can't be sure of the best solution for your problem. However, there's a core profile function that might provide what you want: glClearBuffer.

float far_value = 1.0f;
glClearBufferfv(GL_DEPTH, 0, & far_value);

This effectively clears the depth buffer by setting the depth to the maximum value. Now, it's possible that you may want to draw over fragments that also have the the maximum depth. glDepthFunc(GL_LEQUAL) will be useful in this case. GL_LESS is the initial default value.

Brett Hale
  • 21,653
  • 2
  • 61
  • 90