[Mesa-dev] [PATCH 07/13] mesa: add error version of get_texture_for_framebuffer()
Timothy Arceri
tarceri at itsqueeze.com
Mon May 8 06:35:31 UTC 2017
This is a step towards KHR_no_error support.
---
src/mesa/main/fbobject.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index fb8fbe9..85744e3 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2903,33 +2903,43 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb,
_mesa_reference_renderbuffer(&dst_att->Renderbuffer, src_att->Renderbuffer);
dst_att->Type = src_att->Type;
dst_att->Complete = src_att->Complete;
dst_att->TextureLevel = src_att->TextureLevel;
dst_att->CubeMapFace = src_att->CubeMapFace;
dst_att->Zoffset = src_att->Zoffset;
dst_att->Layered = src_att->Layered;
}
+static struct gl_texture_object *
+get_texture_for_framebuffer(struct gl_context *ctx, GLuint texture)
+{
+ if (!texture)
+ return NULL;
+
+ return _mesa_lookup_texture(ctx, texture);;
+}
+
+
/**
* Common code called by gl*FramebufferTexture*() to retrieve the correct
* texture object pointer.
*
* \param texObj where the pointer to the texture object is returned. Note
* that a successful call may return texObj = NULL.
*
* \return true if no errors, false if errors
*/
static bool
-get_texture_for_framebuffer(struct gl_context *ctx, GLuint texture,
- bool layered, const char *caller,
- struct gl_texture_object **texObj)
+get_texture_for_framebuffer_err(struct gl_context *ctx, GLuint texture,
+ bool layered, const char *caller,
+ struct gl_texture_object **texObj)
{
*texObj = NULL; /* This will get returned if texture = 0. */
if (!texture)
return true;
*texObj = _mesa_lookup_texture(ctx, texture);
if (*texObj == NULL || (*texObj)->Target == 0) {
/* Can't render to a non-existent texture object.
*
@@ -3305,21 +3315,21 @@ framebuffer_texture_with_dims(int dims, GLenum target,
/* Get the framebuffer object */
fb = get_framebuffer_target(ctx, target);
if (!fb) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller,
_mesa_enum_to_string(target));
return;
}
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, false, caller, &texObj))
+ if (!get_texture_for_framebuffer_err(ctx, texture, false, caller, &texObj))
return;
if (texObj) {
if (!check_textarget(ctx, dims, texObj->Target, textarget, caller))
return;
if ((dims == 3) && !check_layer(ctx, texObj->Target, layer, caller))
return;
if (!check_level(ctx, textarget, level, caller))
@@ -3378,21 +3388,21 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
/* Get the framebuffer object */
fb = get_framebuffer_target(ctx, target);
if (!fb) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTextureLayer(invalid target %s)",
_mesa_enum_to_string(target));
return;
}
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, false, func, &texObj))
+ if (!get_texture_for_framebuffer_err(ctx, texture, false, func, &texObj))
return;
if (texObj) {
if (!check_texture_target(ctx, texObj->Target, func))
return;
if (!check_layer(ctx, texObj->Target, layer, func))
return;
if (!check_level(ctx, texObj->Target, level, func))
@@ -3425,21 +3435,21 @@ _mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
GLenum textarget = 0;
const char *func = "glNamedFramebufferTextureLayer";
/* Get the framebuffer object */
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
if (!fb)
return;
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, false, func, &texObj))
+ if (!get_texture_for_framebuffer_err(ctx, texture, false, func, &texObj))
return;
if (texObj) {
if (!check_texture_target(ctx, texObj->Target, func))
return;
if (!check_layer(ctx, texObj->Target, layer, func))
return;
if (!check_level(ctx, texObj->Target, level, func))
@@ -3482,21 +3492,21 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
/* Get the framebuffer object */
fb = get_framebuffer_target(ctx, target);
if (!fb) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture(invalid target %s)",
_mesa_enum_to_string(target));
return;
}
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, true, func, &texObj))
+ if (!get_texture_for_framebuffer_err(ctx, texture, true, func, &texObj))
return;
if (texObj) {
if (!check_layered_texture_target(ctx, texObj->Target, func, &layered))
return;
if (!check_level(ctx, texObj->Target, level, func))
return;
}
@@ -3526,21 +3536,21 @@ _mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
"unsupported function (glNamedFramebufferTexture) called");
return;
}
/* Get the framebuffer object */
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
if (!fb)
return;
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, true, func, &texObj))
+ if (!get_texture_for_framebuffer_err(ctx, texture, true, func, &texObj))
return;
if (texObj) {
if (!check_layered_texture_target(ctx, texObj->Target, func,
&layered))
return;
if (!check_level(ctx, texObj->Target, level, func))
return;
}
--
2.9.3
More information about the mesa-dev
mailing list