[Mesa-dev] [Mesa-dev RESEND 19/26] mesa: add clear_bufferi() helper

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Aug 1 09:11:53 UTC 2017


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/mesa/main/clear.c | 50 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 853d445b7e..4c3400412c 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -622,33 +622,34 @@ _mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
  * New in GL 3.0
  * Clear depth/stencil buffer only.
  */
-void GLAPIENTRY
-_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
-                    GLfloat depth, GLint stencil)
+static ALWAYS_INLINE void
+clear_bufferfi(struct gl_context *ctx, GLenum buffer, GLint drawbuffer,
+               GLfloat depth, GLint stencil, bool no_error)
 {
-   GET_CURRENT_CONTEXT(ctx);
    GLbitfield mask = 0;
 
    FLUSH_VERTICES(ctx, 0);
    FLUSH_CURRENT(ctx, 0);
 
-   if (buffer != GL_DEPTH_STENCIL) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)",
-                  _mesa_enum_to_string(buffer));
-      return;
-   }
+   if (!no_error) {
+      if (buffer != GL_DEPTH_STENCIL) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)",
+                     _mesa_enum_to_string(buffer));
+         return;
+      }
 
-   /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
-    *
-    *     "ClearBuffer generates an INVALID VALUE error if buffer is
-    *     COLOR and drawbuffer is less than zero, or greater than the
-    *     value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
-    *     STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
-    */
-   if (drawbuffer != 0) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)",
-                  drawbuffer);
-      return;
+      /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
+       *
+       *     "ClearBuffer generates an INVALID VALUE error if buffer is
+       *     COLOR and drawbuffer is less than zero, or greater than the
+       *     value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
+       *     STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
+       */
+      if (drawbuffer != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)",
+                     drawbuffer);
+         return;
+      }
    }
 
    if (ctx->RasterDiscard)
@@ -682,6 +683,15 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
 }
 
 
+void GLAPIENTRY
+_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
+                    GLfloat depth, GLint stencil)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   clear_bufferfi(ctx, buffer, drawbuffer, depth, stencil, false);
+}
+
+
 /**
  * The ClearBuffer framework is so complicated and so riddled with the
  * assumption that the framebuffer is bound that, for now, we will just fake
-- 
2.13.3



More information about the mesa-dev mailing list