summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-05-05 16:46:03 +1000
committerTimothy Arceri <[email protected]>2017-05-11 13:53:39 +1000
commitd90ced445c21b412c08928f0fc0af222021685f7 (patch)
tree7403fc8ff293a376da324c305ff78a5d842c32bb /src
parent786b9ad95b7ff4b863b15627f3308e8df271fbf7 (diff)
mesa: add _mesa_get_and_validate_attachment() helper
Will be used to add KHR_no_error support. We make this available external so it can be called from meta. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/fbobject.c37
-rw-r--r--src/mesa/main/fbobject.h5
2 files changed, 30 insertions, 12 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index a1c5a6f26eb..88679215c27 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3188,25 +3188,22 @@ check_level(struct gl_context *ctx, GLenum target, GLint level,
}
-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,
@@ -3217,9 +3214,25 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
"%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);
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index a9e9beb3965..aef2755c661 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -119,6 +119,11 @@ _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,