#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/fbobject.h"
-#include "main/mfeatures.h"
static GLboolean
set_renderbuffer_format(struct gl_renderbuffer *rb, GLenum internalFormat)
case GL_RGB:
case GL_RGB8:
rb->_BaseFormat = GL_RGB;
- rb->Format = MESA_FORMAT_XRGB8888;
+ rb->Format = MESA_FORMAT_B8G8R8X8_UNORM;
s->cpp = 4;
break;
case GL_RGBA:
case GL_RGBA8:
rb->_BaseFormat = GL_RGBA;
- rb->Format = MESA_FORMAT_ARGB8888;
+ rb->Format = MESA_FORMAT_B8G8R8A8_UNORM;
s->cpp = 4;
break;
case GL_RGB5:
rb->_BaseFormat = GL_RGB;
- rb->Format = MESA_FORMAT_RGB565;
+ rb->Format = MESA_FORMAT_B5G6R5_UNORM;
s->cpp = 2;
break;
case GL_DEPTH_COMPONENT16:
rb->_BaseFormat = GL_DEPTH_COMPONENT;
- rb->Format = MESA_FORMAT_Z16;
+ rb->Format = MESA_FORMAT_Z_UNORM16;
s->cpp = 2;
break;
case GL_DEPTH_COMPONENT:
case GL_STENCIL_INDEX8_EXT:
case GL_DEPTH24_STENCIL8_EXT:
rb->_BaseFormat = GL_DEPTH_STENCIL;
- rb->Format = MESA_FORMAT_Z24_S8;
+ rb->Format = MESA_FORMAT_S8_UINT_Z24_UNORM;
s->cpp = 4;
break;
default:
nouveau_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment, struct gl_renderbuffer *rb)
{
- _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ _mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
context_dirty(ctx, FRAMEBUFFER);
}
-static GLenum
-get_tex_format(struct gl_texture_image *ti)
-{
- switch (ti->TexFormat) {
- case MESA_FORMAT_ARGB8888:
- return GL_RGBA8;
- case MESA_FORMAT_XRGB8888:
- return GL_RGB8;
- case MESA_FORMAT_RGB565:
- return GL_RGB5;
- default:
- return GL_NONE;
- }
-}
-
static void
nouveau_render_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
struct gl_renderbuffer *rb = att->Renderbuffer;
- struct gl_texture_image *ti =
- att->Texture->Image[att->CubeMapFace][att->TextureLevel];
-
- /* Allocate a renderbuffer object for the texture if we
- * haven't already done so. */
- if (!rb) {
- rb = nouveau_renderbuffer_new(ctx, ~0);
- assert(rb);
-
- rb->AllocStorage = NULL;
- _mesa_reference_renderbuffer(&att->Renderbuffer, rb);
- }
+ struct gl_texture_image *ti = rb->TexImage;
/* Update the renderbuffer fields from the texture. */
- set_renderbuffer_format(rb, get_tex_format(ti));
- rb->Width = ti->Width;
- rb->Height = ti->Height;
nouveau_surface_ref(&to_nouveau_teximage(ti)->surface,
&to_nouveau_renderbuffer(rb)->surface);
static void
nouveau_finish_render_texture(struct gl_context *ctx,
- struct gl_renderbuffer_attachment *att)
+ struct gl_renderbuffer *rb)
+{
+ if (rb && rb->TexImage)
+ texture_dirty(rb->TexImage->TexObject);
+}
+
+static int
+validate_format_bpp(mesa_format format)
{
- texture_dirty(att->Texture);
+ switch (format) {
+ case MESA_FORMAT_B8G8R8X8_UNORM:
+ case MESA_FORMAT_B8G8R8A8_UNORM:
+ case MESA_FORMAT_S8_UINT_Z24_UNORM:
+ return 32;
+ case MESA_FORMAT_B5G6R5_UNORM:
+ case MESA_FORMAT_Z_UNORM16:
+ return 16;
+ default:
+ return 0;
+ }
+}
+
+static void
+nouveau_check_framebuffer_complete(struct gl_context *ctx,
+ struct gl_framebuffer *fb)
+{
+ struct gl_renderbuffer_attachment *color =
+ &fb->Attachment[BUFFER_COLOR0];
+ struct gl_renderbuffer_attachment *depth =
+ &fb->Attachment[BUFFER_DEPTH];
+ int color_bpp = 0, zeta_bpp;
+
+ if (color->Type == GL_TEXTURE) {
+ color_bpp = validate_format_bpp(
+ color->Renderbuffer->TexImage->TexFormat);
+ if (!color_bpp)
+ goto err;
+ }
+
+ if (depth->Type == GL_TEXTURE) {
+ zeta_bpp = validate_format_bpp(
+ depth->Renderbuffer->TexImage->TexFormat);
+ if (!zeta_bpp)
+ goto err;
+ /* NV04/NV05 requires same bpp-ness for color/zeta */
+ if (context_chipset(ctx) < 0x10 &&
+ color_bpp && color_bpp != zeta_bpp)
+ goto err;
+ }
+
+ return;
+err:
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ return;
}
void
functions->FramebufferRenderbuffer = nouveau_framebuffer_renderbuffer;
functions->RenderTexture = nouveau_render_texture;
functions->FinishRenderTexture = nouveau_finish_render_texture;
+ functions->ValidateFramebuffer = nouveau_check_framebuffer_complete;
}