[Mesa-dev] [PATCH 06/13] mesa: pass rb attachment to _mesa_framebuffer_texture()
Timothy Arceri
tarceri at itsqueeze.com
Mon May 8 06:35:30 UTC 2017
This change will help us add KHR_no_error support to the caller.
---
src/mesa/drivers/common/meta.c | 8 +++++--
src/mesa/main/fbobject.c | 54 +++++++++++++++++++++++++++++-------------
src/mesa/main/fbobject.h | 4 ++--
3 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index f4c91ac..47ef16b 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -111,22 +111,26 @@ _mesa_meta_framebuffer_texture_image(struct gl_context *ctx,
GLenum attachment,
struct gl_texture_image *texImage,
GLuint layer)
{
struct gl_texture_object *texObj = texImage->TexObject;
int level = texImage->Level;
const GLenum texTarget = texObj->Target == GL_TEXTURE_CUBE_MAP
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage->Face
: texObj->Target;
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, texTarget,
- level, layer, false, __func__);
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, __func__);
+ assert(att);
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj, texTarget,
+ level, layer, false);
}
static struct gl_shader *
meta_compile_shader_with_debug(struct gl_context *ctx, gl_shader_stage stage,
const GLcharARB *source)
{
const GLuint name = ~0;
struct gl_shader *sh;
sh = _mesa_new_shader(name, stage);
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8867921..fb8fbe9 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3217,29 +3217,24 @@ _mesa_get_and_validate_attachment(struct gl_context *ctx,
return NULL;
}
return att;
}
void
_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment,
+ struct gl_renderbuffer_attachment *att,
struct gl_texture_object *texObj, GLenum textarget,
- GLint level, GLuint layer, GLboolean layered,
- const char *caller)
+ GLint level, GLuint layer, GLboolean layered)
{
- 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) {
@@ -3324,22 +3319,27 @@ framebuffer_texture_with_dims(int dims, GLenum target,
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))
return;
}
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
- layer, GL_FALSE, caller);
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, caller);
+ if (!att)
+ return;
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj, textarget,
+ level, layer, GL_FALSE);
}
void GLAPIENTRY
_mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
framebuffer_texture_with_dims(1, target, attachment, textarget, texture,
level, 0, "glFramebufferTexture1D");
}
@@ -3398,22 +3398,27 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
if (!check_level(ctx, texObj->Target, level, func))
return;
if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
assert(layer >= 0 && layer < 6);
textarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
layer = 0;
}
}
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
- layer, GL_FALSE, func);
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, func);
+ if (!att)
+ return;
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj, textarget,
+ level, layer, GL_FALSE);
}
void GLAPIENTRY
_mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
GLuint texture, GLint level, GLint layer)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
@@ -3440,22 +3445,27 @@ _mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
if (!check_level(ctx, texObj->Target, level, func))
return;
if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
assert(layer >= 0 && layer < 6);
textarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
layer = 0;
}
}
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
- layer, GL_FALSE, func);
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, func);
+ if (!att)
+ return;
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj, textarget,
+ level, layer, GL_FALSE);
}
void GLAPIENTRY
_mesa_FramebufferTexture(GLenum target, GLenum attachment,
GLuint texture, GLint level)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
@@ -3483,22 +3493,27 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
return;
if (texObj) {
if (!check_layered_texture_target(ctx, texObj->Target, func, &layered))
return;
if (!check_level(ctx, texObj->Target, level, func))
return;
}
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
- 0, layered, func);
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, func);
+ if (!att)
+ return;
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj, 0, level,
+ 0, layered);
}
void GLAPIENTRY
_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
GLuint texture, GLint level)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
@@ -3523,22 +3538,27 @@ _mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
if (texObj) {
if (!check_layered_texture_target(ctx, texObj->Target, func,
&layered))
return;
if (!check_level(ctx, texObj->Target, level, func))
return;
}
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
- 0, layered, func);
+ struct gl_renderbuffer_attachment *att =
+ _mesa_get_and_validate_attachment(ctx, fb, attachment, func);
+ if (!att)
+ return;
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, att, texObj, 0, level,
+ 0, layered);
}
void
_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLenum attachment,
struct gl_renderbuffer *rb)
{
assert(!_mesa_is_winsys_fbo(fb));
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index aef2755..d0f905e 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -120,23 +120,23 @@ _mesa_detach_renderbuffer(struct gl_context *ctx,
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_renderbuffer_attachment *att,
struct gl_texture_object *texObj, GLenum textarget,
- GLint level, GLuint layer, GLboolean layered,
- const char *caller);
+ GLint level, GLuint layer, GLboolean layered);
extern GLenum
_mesa_check_framebuffer_status(struct gl_context *ctx,
struct gl_framebuffer *fb);
extern void
_mesa_bind_framebuffers(struct gl_context *ctx,
struct gl_framebuffer *newDrawFb,
struct gl_framebuffer *newReadFb);
--
2.9.3
More information about the mesa-dev
mailing list