#include "buffers.h"
#include "context.h"
#include "depthstencil.h"
+#include "enums.h"
#include "formats.h"
#include "macros.h"
#include "mtypes.h"
fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF;
}
-
/**
* Create and initialize a gl_framebuffer object.
* This is intended for creating _window_system_ framebuffers, not generic
* \sa _mesa_new_framebuffer
*/
struct gl_framebuffer *
-_mesa_create_framebuffer(const GLvisual *visual)
+_mesa_create_framebuffer(const struct gl_config *visual)
{
struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
assert(visual);
* \sa _mesa_create_framebuffer
*/
struct gl_framebuffer *
-_mesa_new_framebuffer(GLcontext *ctx, GLuint name)
+_mesa_new_framebuffer(struct gl_context *ctx, GLuint name)
{
struct gl_framebuffer *fb;
(void) ctx;
*/
void
_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb,
- const GLvisual *visual)
+ const struct gl_config *visual)
{
assert(fb);
assert(visual);
* without a currently bound rendering context.
*/
void
-_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
GLuint width, GLuint height)
{
GLuint i;
* from device drivers (as was done in the past).
*/
void
-_mesa_resizebuffers( GLcontext *ctx )
+_mesa_resizebuffers( struct gl_context *ctx )
{
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
if (ctx->WinSysDrawBuffer) {
GLuint newWidth, newHeight;
- GLframebuffer *buffer = ctx->WinSysDrawBuffer;
+ struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer;
assert(buffer->Name == 0);
if (ctx->WinSysReadBuffer
&& ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) {
GLuint newWidth, newHeight;
- GLframebuffer *buffer = ctx->WinSysReadBuffer;
+ struct gl_framebuffer *buffer = ctx->WinSysReadBuffer;
assert(buffer->Name == 0);
* window-system framebuffes.
*/
static void
-update_framebuffer_size(GLcontext *ctx, struct gl_framebuffer *fb)
+update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb)
{
GLuint minWidth = ~0, minHeight = ~0;
GLuint i;
* \param ctx the GL context.
*/
void
-_mesa_update_draw_buffer_bounds(GLcontext *ctx)
+_mesa_update_draw_buffer_bounds(struct gl_context *ctx)
{
struct gl_framebuffer *buffer = ctx->DrawBuffer;
const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
const gl_format fmt = rb->Format;
- if (baseFormat == GL_RGBA || baseFormat == GL_RGB) {
+ if (baseFormat == GL_RGBA || baseFormat == GL_RGB ||
+ baseFormat == GL_ALPHA) {
fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS);
fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS);
fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS);
* \param attIndex indicates the renderbuffer to possibly wrap
*/
void
-_mesa_update_depth_buffer(GLcontext *ctx,
+_mesa_update_depth_buffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLuint attIndex)
{
depthRb = fb->Attachment[attIndex].Renderbuffer;
- if (depthRb && depthRb->_BaseFormat == GL_DEPTH_STENCIL) {
+ if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) {
/* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
if (!fb->_DepthBuffer
|| fb->_DepthBuffer->Wrapped != depthRb
* \param attIndex indicates the renderbuffer to possibly wrap
*/
void
-_mesa_update_stencil_buffer(GLcontext *ctx,
+_mesa_update_stencil_buffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLuint attIndex)
{
stencilRb = fb->Attachment[attIndex].Renderbuffer;
- if (stencilRb && stencilRb->_BaseFormat == GL_DEPTH_STENCIL) {
+ if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) {
/* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
if (!fb->_StencilBuffer
|| fb->_StencilBuffer->Wrapped != stencilRb
* writing colors.
*/
static void
-update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb)
+update_color_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb)
{
GLuint output;
* Unlike the DrawBuffer, we can only read from one (or zero) color buffers.
*/
static void
-update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
+update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
{
(void) ctx;
if (fb->_ColorReadBufferIndex == -1 ||
* glRenderbufferStorageEXT.
*/
static void
-update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
+update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
{
if (fb->Name == 0) {
/* This is a window-system framebuffer */
* Update state related to the current draw/read framebuffers.
*/
void
-_mesa_update_framebuffer(GLcontext *ctx)
+_mesa_update_framebuffer(struct gl_context *ctx)
{
struct gl_framebuffer *drawFb;
struct gl_framebuffer *readFb;
* \return GL_TRUE if buffer exists, GL_FALSE otherwise
*/
GLboolean
-_mesa_source_buffer_exists(GLcontext *ctx, GLenum format)
+_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format)
{
const struct gl_renderbuffer_attachment *att = ctx->ReadBuffer->Attachment;
return GL_FALSE;
}
ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 ||
+ _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_ALPHA_BITS) > 0 ||
_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0);
break;
case GL_DEPTH:
* XXX could do some code merging w/ above function.
*/
GLboolean
-_mesa_dest_buffer_exists(GLcontext *ctx, GLenum format)
+_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format)
{
const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment;
* Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query.
*/
GLenum
-_mesa_get_color_read_format(GLcontext *ctx)
+_mesa_get_color_read_format(struct gl_context *ctx)
{
switch (ctx->ReadBuffer->_ColorReadBuffer->Format) {
case MESA_FORMAT_ARGB8888:
* Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query.
*/
GLenum
-_mesa_get_color_read_type(GLcontext *ctx)
+_mesa_get_color_read_type(struct gl_context *ctx)
{
switch (ctx->ReadBuffer->_ColorReadBuffer->Format) {
case MESA_FORMAT_ARGB8888:
return GL_UNSIGNED_BYTE;
}
}
+
+
+/**
+ * Print framebuffer info to stderr, for debugging.
+ */
+void
+_mesa_print_framebuffer(const struct gl_framebuffer *fb)
+{
+ GLuint i;
+
+ fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb);
+ fprintf(stderr, " Size: %u x %u Status: %s\n", fb->Width, fb->Height,
+ _mesa_lookup_enum_by_nr(fb->_Status));
+ fprintf(stderr, " Attachments:\n");
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ const struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ if (att->Type == GL_TEXTURE) {
+ const struct gl_texture_image *texImage;
+ fprintf(stderr,
+ " %2d: Texture %u, level %u, face %u, slice %u, complete %d\n",
+ i, att->Texture->Name, att->TextureLevel, att->CubeMapFace,
+ att->Zoffset, att->Complete);
+ texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ fprintf(stderr, " Size: %u x %u x %u Format %s\n",
+ texImage->Width, texImage->Height, texImage->Depth,
+ _mesa_get_format_name(texImage->TexFormat));
+ }
+ else if (att->Type == GL_RENDERBUFFER) {
+ fprintf(stderr, " %2d: Renderbuffer %u, complete %d\n",
+ i, att->Renderbuffer->Name, att->Complete);
+ fprintf(stderr, " Size: %u x %u Format %s\n",
+ att->Renderbuffer->Width, att->Renderbuffer->Height,
+ _mesa_get_format_name(att->Renderbuffer->Format));
+ }
+ else {
+ fprintf(stderr, " %2d: none\n", i);
+ }
+ }
+}