mesa: add error handling for OVR_multiview

there's a lot that were missed

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33632>
This commit is contained in:
Mike Blumenkrantz 2025-02-20 11:06:23 -05:00 committed by Marge Bot
parent 2b37f23314
commit 89c2639227
5 changed files with 79 additions and 2 deletions

View file

@ -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

View file

@ -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;

View file

@ -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);
}

View file

@ -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 */

View file

@ -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;
}