diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c index 89646441bec..4f6ec00d266 100644 --- a/src/mesa/main/blit.c +++ b/src/mesa/main/blit.c @@ -247,6 +247,20 @@ validate_color_buffer(struct gl_context *ctx, struct gl_framebuffer *readFb, } + /** + * OVR_multiview + + INVALID_FRAMEBUFFER_OPERATION is generated by commands that read from the + framebuffer such as BlitFramebuffer, ReadPixels, CopyTexImage*, and + CopyTexSubImage*, if the number of views in the current read framebuffer + is greater than 1. + */ + if (colorReadRb->rtt_numviews > 1) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION, + "%s(NumViews > 1 on read framebuffer)", func); + return false; + } + if (filter != GL_NEAREST) { /* From EXT_framebuffer_multisample_blit_scaled specification: * "Calling BlitFramebuffer will result in an INVALID_OPERATION error if diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index 9e77284c3f9..e3a377c7aed 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -160,6 +160,26 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx) } } + /** + * OVR_multiview + + INVALID_OPERATION is generated if a rendering command is issued and the the + number of views in the current draw framebuffer is not equal to the number + of views declared in the currently bound program. + */ + struct gl_program *vp = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; + if (vp) { + unsigned num_views = util_bitcount(vp->info.view_mask); + for (int i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { + gl_buffer_index buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; + if (buf != BUFFER_NONE) { + struct gl_renderbuffer *rb = ctx->DrawBuffer->Attachment[buf].Renderbuffer; + if (rb && rb->rtt_numviews != num_views) + return; + } + } + } + /* DrawPixels/CopyPixels/Bitmap is valid after this point. */ ctx->DrawPixValid = true; diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 2d2df176c45..ad127c808ca 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -4401,7 +4401,7 @@ _mesa_FramebufferTextureMultiviewOVR_no_error(GLenum target, GLenum attachment, GLint baseViewIndex, GLsizei numViews) { frame_buffer_texture(0, target, attachment, texture, level, 0, baseViewIndex, - "glFramebufferTexture", false, true, false, true, numViews); + "glFramebufferTextureMultiviewOVR", false, true, false, true, numViews); } @@ -4411,7 +4411,7 @@ _mesa_FramebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLint baseViewIndex, GLsizei numViews) { frame_buffer_texture(0, target, attachment, texture, level, 0, baseViewIndex, - "glFramebufferTexture", false, false, false, true, numViews); + "glFramebufferTextureMultiviewOVR", false, false, false, true, numViews); } diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 1ae2784fb20..32a70e4264a 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -1164,6 +1164,20 @@ read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, return; } } + + /** + * OVR_multiview + + INVALID_FRAMEBUFFER_OPERATION is generated by commands that read from the + framebuffer such as BlitFramebuffer, ReadPixels, CopyTexImage*, and + CopyTexSubImage*, if the number of views in the current read framebuffer + is greater than 1. + */ + if (rb->rtt_numviews > 1) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION, + "glReadPixels(NumViews > 1 on read framebuffer)"); + return; + } } /* Do all needed clipping here, so that we can forget about it later */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 0a728a13c63..66a25565760 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2669,6 +2669,20 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, } } + /** + * OVR_multiview + + INVALID_FRAMEBUFFER_OPERATION is generated by commands that read from the + framebuffer such as BlitFramebuffer, ReadPixels, CopyTexImage*, and + CopyTexSubImage*, if the number of views in the current read framebuffer + is greater than 1. + */ + if (rb->rtt_numviews > 1) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION, + "glCopyTexImage%dD(NumViews > 1 on read framebuffer)", dimensions); + return GL_TRUE; + } + if (!mutable_tex_object(texObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexImage%dD(immutable texture)", dimensions); @@ -2820,6 +2834,21 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } + /** + * OVR_multiview + + INVALID_FRAMEBUFFER_OPERATION is generated by commands that read from the + framebuffer such as BlitFramebuffer, ReadPixels, CopyTexImage*, and + CopyTexSubImage*, if the number of views in the current read framebuffer + is greater than 1. + */ + if (_mesa_is_color_format(texImage->InternalFormat) && + ctx->ReadBuffer->_ColorReadBuffer->rtt_numviews > 1) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION, + "%s(NumViews > 1 on read framebuffer)", caller); + return GL_TRUE; + } + /* if we get here, the parameters are OK */ return GL_FALSE; }