[Mesa-dev] [PATCH 05/13] mesa: add _mesa_get_and_validate_attachment() helper
Timothy Arceri
tarceri at itsqueeze.com
Mon May 8 06:35:29 UTC 2017
Will be used to add KHR_no_error support. We make this available
external so it can be called from meta.
---
src/mesa/main/fbobject.c | 37 +++++++++++++++++++++++++------------
src/mesa/main/fbobject.h | 5 +++++
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index a1c5a6f..8867921 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3181,52 +3181,65 @@ check_level(struct gl_context *ctx, GLenum target, GLint level,
(level >= _mesa_max_texture_levels(ctx, target))) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(invalid level %d)", caller, level);
return false;
}
return true;
}
-void
-_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLenum attachment,
- struct gl_texture_object *texObj, GLenum textarget,
- GLint level, GLuint layer, GLboolean layered,
- const char *caller)
+struct gl_renderbuffer_attachment *
+_mesa_get_and_validate_attachment(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment, const char *caller)
{
- struct gl_renderbuffer_attachment *att;
- bool is_color_attachment;
-
/* The window-system framebuffer object is immutable */
if (_mesa_is_winsys_fbo(fb)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(window-system framebuffer)",
caller);
- return;
+ return NULL;
}
/* Not a hash lookup, so we can afford to get the attachment here. */
- att = get_attachment(ctx, fb, attachment, &is_color_attachment);
+ bool is_color_attachment;
+ struct gl_renderbuffer_attachment *att =
+ get_attachment(ctx, fb, attachment, &is_color_attachment);
if (att == NULL) {
if (is_color_attachment) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(invalid color attachment %s)", caller,
_mesa_enum_to_string(attachment));
} else {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(invalid attachment %s)", caller,
_mesa_enum_to_string(attachment));
}
- return;
+ return NULL;
}
+ return att;
+}
+
+
+void
+_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_texture_object *texObj, GLenum textarget,
+ GLint level, GLuint layer, GLboolean layered,
+ const char *caller)
+{
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, caller);
+ if (!att)
+ return;
+
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
mtx_lock(&fb->Mutex);
if (texObj) {
if (attachment == GL_DEPTH_ATTACHMENT &&
texObj == fb->Attachment[BUFFER_STENCIL].Texture &&
level == fb->Attachment[BUFFER_STENCIL].TextureLevel &&
_mesa_tex_target_to_face(textarget) ==
fb->Attachment[BUFFER_STENCIL].CubeMapFace &&
layer == fb->Attachment[BUFFER_STENCIL].Zoffset) {
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index a9e9beb..aef2755 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -112,20 +112,25 @@ extern GLboolean
_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat);
extern GLenum
_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat);
extern bool
_mesa_detach_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
const void *att);
+extern struct gl_renderbuffer_attachment *
+_mesa_get_and_validate_attachment(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment, const char *caller);
+
extern void
_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment,
struct gl_texture_object *texObj, GLenum textarget,
GLint level, GLuint layer, GLboolean layered,
const char *caller);
extern GLenum
_mesa_check_framebuffer_status(struct gl_context *ctx,
struct gl_framebuffer *fb);
--
2.9.3
More information about the mesa-dev
mailing list