aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/fbobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/fbobject.c')
-rw-r--r--mesalib/src/mesa/main/fbobject.c67
1 files changed, 52 insertions, 15 deletions
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 4c3c157a4..305362297 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -468,6 +468,7 @@ set_renderbuffer_attachment(struct gl_context *ctx,
remove_attachment(ctx, att);
att->Type = GL_RENDERBUFFER_EXT;
att->Texture = NULL; /* just to be safe */
+ att->Layered = GL_FALSE;
att->Complete = GL_FALSE;
_mesa_reference_renderbuffer(&att->Renderbuffer, rb);
}
@@ -780,6 +781,18 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
att->Complete = GL_FALSE;
return;
}
+
+ /* OES_texture_float allows creation and use of floating point
+ * textures with GL_FLOAT, GL_HALF_FLOAT but it does not allow
+ * these textures to be used as a render target, this is done via
+ * GL_EXT_color_buffer(_half)_float with set of new sized types.
+ */
+ if (_mesa_is_gles(ctx) && (texImage->TexObject->_IsFloat ||
+ texImage->TexObject->_IsHalfFloat)) {
+ att_incomplete("bad internal format");
+ att->Complete = GL_FALSE;
+ return;
+ }
}
else if (format == GL_DEPTH) {
if (baseFormat == GL_DEPTH_COMPONENT) {
@@ -886,6 +899,8 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
GLuint max_layer_count = 0, att_layer_count;
bool is_layered = false;
GLenum layer_tex_target = 0;
+ bool has_depth_attachment = false;
+ bool has_stencil_attachment = false;
assert(_mesa_is_user_fbo(fb));
@@ -923,6 +938,8 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
fbo_incomplete(ctx, "depth attachment incomplete", -1);
return;
+ } else if (att->Type != GL_NONE) {
+ has_depth_attachment = true;
}
}
else if (i == -1) {
@@ -932,6 +949,8 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
fbo_incomplete(ctx, "stencil attachment incomplete", -1);
return;
+ } else if (att->Type != GL_NONE) {
+ has_stencil_attachment = true;
}
}
else {
@@ -960,7 +979,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
if (!is_format_color_renderable(ctx, attFormat,
texImg->InternalFormat) &&
!is_legal_depth_format(ctx, f)) {
- fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
fbo_incomplete(ctx, "texture attachment incomplete", -1);
return;
}
@@ -1128,6 +1147,20 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
}
}
+ /* The OpenGL ES3 spec, in chapter 9.4. FRAMEBUFFER COMPLETENESS, says:
+ *
+ * "Depth and stencil attachments, if present, are the same image."
+ *
+ * This restriction is not present in the OpenGL ES2 spec.
+ */
+ if (_mesa_is_gles3(ctx) &&
+ has_stencil_attachment && has_depth_attachment &&
+ !_mesa_has_depthstencil_combined(fb)) {
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED;
+ fbo_incomplete(ctx, "Depth and stencil attachments must be the same image", -1);
+ return;
+ }
+
/* Provisionally set status = COMPLETE ... */
fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
@@ -1291,6 +1324,11 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
GLint i;
GET_CURRENT_CONTEXT(ctx);
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteRenderbuffers(n < 0)");
+ return;
+ }
+
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
for (i = 0; i < n; i++) {
@@ -1430,9 +1468,6 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
case GL_RGB8:
return GL_RGB;
case GL_RGB:
- if (_mesa_is_gles3(ctx))
- return GL_RGB;
- /* fallthrough */
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
@@ -1447,9 +1482,6 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
case GL_RGBA8:
return GL_RGBA;
case GL_RGBA:
- if (_mesa_is_gles3(ctx))
- return GL_RGBA;
- /* fallthrough */
case GL_RGBA2:
case GL_RGBA12:
case GL_RGBA16:
@@ -2183,6 +2215,11 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
GLint i;
GET_CURRENT_CONTEXT(ctx);
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteFramebuffers(n < 0)");
+ return;
+ }
+
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
for (i = 0; i < n; i++) {
@@ -2323,7 +2360,7 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb,
static void
framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
GLenum attachment, GLenum textarget, GLuint texture,
- GLint level, GLint zoffset, GLboolean layered)
+ GLint level, GLuint zoffset, GLboolean layered)
{
struct gl_renderbuffer_attachment *att;
struct gl_texture_object *texObj = NULL;
@@ -2417,8 +2454,8 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
}
if (texObj->Target == GL_TEXTURE_3D) {
- const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
- if (zoffset < 0 || zoffset >= maxSize) {
+ const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
+ if (zoffset >= maxSize) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glFramebufferTexture%s(zoffset)", caller);
return;
@@ -2428,8 +2465,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
(texObj->Target == GL_TEXTURE_2D_ARRAY_EXT) ||
(texObj->Target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
(texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
- if (zoffset < 0 ||
- zoffset >= (GLint) ctx->Const.MaxArrayTextureLayers) {
+ if (zoffset >= ctx->Const.MaxArrayTextureLayers) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glFramebufferTexture%s(layer)", caller);
return;
@@ -2766,7 +2802,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
if (_mesa_is_gles3(ctx) && attachment != GL_BACK &&
attachment != GL_DEPTH && attachment != GL_STENCIL) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
+ _mesa_error(ctx, GL_INVALID_ENUM,
"glGetFramebufferAttachmentParameteriv(attachment)");
return;
}
@@ -2869,7 +2905,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
_mesa_error(ctx, err,
"glGetFramebufferAttachmentParameteriv(pname)");
} else if (att->Type == GL_TEXTURE) {
- if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) {
+ if (att->Texture && (att->Texture->Target == GL_TEXTURE_3D ||
+ att->Texture->Target == GL_TEXTURE_2D_ARRAY)) {
*params = att->Zoffset;
}
else {
@@ -2967,7 +3004,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
}
else if (att->Texture) {
const struct gl_texture_image *texImage =
- _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target,
+ _mesa_select_tex_image(att->Texture, att->Texture->Target,
att->TextureLevel);
if (texImage) {
*params = get_component_bits(pname, texImage->_BaseFormat,