<div dir="auto"><div>This time, send it to the list too.<div dir="auto">Gustaw</div><br><div class="gmail_extra"><br><div class="gmail_quote">1 cze 2017 15:45 "Gustaw Smolarczyk" <<a href="mailto:wielkiegie@gmail.com">wielkiegie@gmail.com</a>> napisał(a):<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div class="quoted-text"><div>1 cze 2017 15:07 "Samuel Pitoiset" <<a href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>> napisał(a):<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_447762454156480365quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>><br>
---<br>
src/mesa/main/blit.c | 111 +++++++++++++++++++++++++++---<wbr>---------------------<br>
1 file changed, 58 insertions(+), 53 deletions(-)<br>
<br>
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c<br>
index 2c0300eab3..207ce7d501 100644<br>
--- a/src/mesa/main/blit.c<br>
+++ b/src/mesa/main/blit.c<br>
@@ -178,6 +178,62 @@ is_valid_blit_filter(const struct gl_context *ctx, GLenum filter)<br>
<br>
<br>
static void<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_447762454156480365quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div></div></div><div dir="auto">Shouldn't it return a bool so that the caller will know whether the validation passed or not?</div><div class="elided-text"><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_447762454156480365quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+validate_stencil_buffer(struc<wbr>t gl_context *ctx, struct gl_framebuffer *readFb,<br>
+ struct gl_framebuffer *drawFb, GLbitfield *mask,<br>
+ bool no_error, const char *func)<br>
+{<br>
+ struct gl_renderbuffer *readRb =<br>
+ readFb->Attachment[BUFFER_STEN<wbr>CIL].Renderbuffer;<br>
+ struct gl_renderbuffer *drawRb =<br>
+ drawFb->Attachment[BUFFER_STEN<wbr>CIL].Renderbuffer;<br>
+<br>
+ /* From the EXT_framebuffer_object spec:<br>
+ *<br>
+ * "If a buffer is specified in <mask> and does not exist in both<br>
+ * the read and draw framebuffers, the corresponding bit is silently<br>
+ * ignored."<br>
+ */<br>
+ if (readRb == NULL || drawRb == NULL) {<br>
+ *mask &= ~GL_STENCIL_BUFFER_BIT;<br>
+ } else if (!no_error) {<br>
+ int read_z_bits, draw_z_bits;<br>
+<br>
+ if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {<br>
+ _mesa_error(ctx, GL_INVALID_OPERATION,<br>
+ "%s(source and destination stencil buffer cannot be the "<br>
+ "same)", func);<br>
+ return;<br>
+ }<br>
+<br>
+ if (_mesa_get_format_bits(readRb-<wbr>>Format, GL_STENCIL_BITS) !=<br>
+ _mesa_get_format_bits(drawRb-><wbr>Format, GL_STENCIL_BITS)) {<br>
+ /* There is no need to check the stencil datatype here, because<br>
+ * there is only one: GL_UNSIGNED_INT.<br>
+ */<br>
+ _mesa_error(ctx, GL_INVALID_OPERATION,<br>
+ "%s(stencil attachment format mismatch)", func);<br>
+ return;<br>
+ }<br>
+<br>
+ read_z_bits = _mesa_get_format_bits(readRb-><wbr>Format, GL_DEPTH_BITS);<br>
+ draw_z_bits = _mesa_get_format_bits(drawRb-><wbr>Format, GL_DEPTH_BITS);<br>
+<br>
+ /* If both buffers also have depth data, the depth formats must match<br>
+ * as well. If one doesn't have depth, it's not blitted, so we should<br>
+ * ignore the depth format check.<br>
+ */<br>
+ if (read_z_bits > 0 && draw_z_bits > 0 &&<br>
+ (read_z_bits != draw_z_bits ||<br>
+ _mesa_get_format_datatype(rea<wbr>dRb->Format) !=<br>
+ _mesa_get_format_datatype(dra<wbr>wRb->Format))) {<br>
+ _mesa_error(ctx, GL_INVALID_OPERATION,<br>
+ "%s(stencil attachment depth format mismatch)", func);<br>
+ return;<br>
+ }<br>
+ }<br>
+}<br>
+<br>
+static void<br>
blit_framebuffer(struct gl_context *ctx,<br>
struct gl_framebuffer *readFb, struct gl_framebuffer *drawFb,<br>
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,<br>
@@ -317,59 +373,8 @@ blit_framebuffer(struct gl_context *ctx,<br>
}<br>
}<br>
<br>
- if (mask & GL_STENCIL_BUFFER_BIT) {<br>
- struct gl_renderbuffer *readRb =<br>
- readFb->Attachment[BUFFER_STE<wbr>NCIL].Renderbuffer;<br>
- struct gl_renderbuffer *drawRb =<br>
- drawFb->Attachment[BUFFER_STE<wbr>NCIL].Renderbuffer;<br>
-<br>
- /* From the EXT_framebuffer_object spec:<br>
- *<br>
- * "If a buffer is specified in <mask> and does not exist in both<br>
- * the read and draw framebuffers, the corresponding bit is silently<br>
- * ignored."<br>
- */<br>
- if ((readRb == NULL) || (drawRb == NULL)) {<br>
- mask &= ~GL_STENCIL_BUFFER_BIT;<br>
- }<br>
- else {<br>
- int read_z_bits, draw_z_bits;<br>
-<br>
- if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {<br>
- _mesa_error(ctx, GL_INVALID_OPERATION,<br>
- "%s(source and destination stencil "<br>
- "buffer cannot be the same)", func);<br>
- return;<br>
- }<br>
-<br>
- if (_mesa_get_format_bits(readRb-<wbr>>Format, GL_STENCIL_BITS) !=<br>
- _mesa_get_format_bits(drawRb-<wbr>>Format, GL_STENCIL_BITS)) {<br>
- /* There is no need to check the stencil datatype here, because<br>
- * there is only one: GL_UNSIGNED_INT.<br>
- */<br>
- _mesa_error(ctx, GL_INVALID_OPERATION,<br>
- "%s(stencil attachment format mismatch)", func);<br>
- return;<br>
- }<br>
-<br>
- read_z_bits = _mesa_get_format_bits(readRb-><wbr>Format, GL_DEPTH_BITS);<br>
- draw_z_bits = _mesa_get_format_bits(drawRb-><wbr>Format, GL_DEPTH_BITS);<br>
-<br>
- /* If both buffers also have depth data, the depth formats must match<br>
- * as well. If one doesn't have depth, it's not blitted, so we should<br>
- * ignore the depth format check.<br>
- */<br>
- if (read_z_bits > 0 && draw_z_bits > 0 &&<br>
- (read_z_bits != draw_z_bits ||<br>
- _mesa_get_format_datatype(read<wbr>Rb->Format) !=<br>
- _mesa_get_format_datatype(draw<wbr>Rb->Format))) {<br>
-<br>
- _mesa_error(ctx, GL_INVALID_OPERATION,<br>
- "%s(stencil attachment depth format mismatch)", func);<br>
- return;<br>
- }<br>
- }<br>
- }<br>
+ if (mask & GL_STENCIL_BUFFER_BIT)<br>
+ validate_stencil_buffer(ctx, readFb, drawFb, &mask, false, func);<br></blockquote></div></div></div><div dir="auto"><br></div></div><div dir="auto">We should return here in case the validation failed.</div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto">Gustaw</div></div>
</blockquote></div><br></div></div></div>