Rather than testing the fbo's name against zero.
Reviewed-by: José Fonseca <jfonseca@vmware.com>
#include "colormac.h"
#include "context.h"
#include "enums.h"
+#include "fbobject.h"
#include "mtypes.h"
{
GLbitfield mask = 0x0;
- if (fb->Name > 0) {
+ if (_mesa_is_user_fbo(fb)) {
/* A user-created renderbuffer */
GLuint i;
ASSERT(ctx->Extensions.EXT_framebuffer_object);
struct gl_framebuffer *fb = ctx->DrawBuffer;
/* Flag the FBO as requiring validation. */
- if (fb->Name != 0) {
+ if (_mesa_is_user_fbo(fb)) {
fb->_Status = 0;
}
}
fb->ColorDrawBuffer[buf] = GL_NONE;
}
- if (fb->Name == 0) {
+ if (_mesa_is_winsys_fbo(fb)) {
/* also set context drawbuffer state */
for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) {
GLuint i;
/* should be a window system FBO */
- assert(ctx->DrawBuffer->Name == 0);
+ assert(_mesa_is_winsys_fbo(ctx->DrawBuffer));
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++)
buffers[i] = ctx->Color.DrawBuffer[i];
{
struct gl_framebuffer *fb = ctx->ReadBuffer;
- if (fb->Name == 0) {
+ if (_mesa_is_winsys_fbo(fb)) {
/* Only update the per-context READ_BUFFER state if we're bound to
* a window-system framebuffer.
*/
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
- if (fb->Name > 0 && buffer == GL_NONE) {
+ if (_mesa_is_user_fbo(fb) && buffer == GL_NONE) {
/* This is legal for user-created framebuffer objects */
srcBuffer = -1;
}
static struct gl_framebuffer IncompleteFramebuffer;
-/**
- * Is the given FBO a user-created FBO?
- */
-static inline GLboolean
-is_user_fbo(const struct gl_framebuffer *fb)
-{
- return fb->Name != 0;
-}
-
-
-/**
- * Is the given FBO a window system FBO (like an X window)?
- */
-static inline GLboolean
-is_winsys_fbo(const struct gl_framebuffer *fb)
-{
- return fb->Name == 0;
-}
-
-
static void
delete_dummy_renderbuffer(struct gl_renderbuffer *rb)
{
{
GLuint i;
- assert(is_user_fbo(fb));
+ assert(_mesa_is_user_fbo(fb));
switch (attachment) {
case GL_COLOR_ATTACHMENT0_EXT:
_mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment)
{
- assert(is_winsys_fbo(fb));
+ assert(_mesa_is_winsys_fbo(fb));
switch (attachment) {
case GL_FRONT_LEFT:
GLint i;
GLuint j;
- assert(is_user_fbo(fb));
+ assert(_mesa_is_user_fbo(fb));
numImages = 0;
fb->Width = 0;
_mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
}
- if (is_user_fbo(ctx->DrawBuffer)) {
+ if (_mesa_is_user_fbo(ctx->DrawBuffer)) {
detach_renderbuffer(ctx, ctx->DrawBuffer, rb);
}
- if (is_user_fbo(ctx->ReadBuffer)
+ if (_mesa_is_user_fbo(ctx->ReadBuffer)
&& ctx->ReadBuffer != ctx->DrawBuffer) {
detach_renderbuffer(ctx, ctx->ReadBuffer, rb);
}
struct gl_renderbuffer *rb = (struct gl_renderbuffer *) userData;
/* If this is a user-created FBO */
- if (is_user_fbo(fb)) {
+ if (_mesa_is_user_fbo(fb)) {
GLuint i;
for (i = 0; i < BUFFER_COUNT; i++) {
struct gl_renderbuffer_attachment *att = fb->Attachment + i;
GLuint i;
ASSERT(ctx->Driver.RenderTexture);
- if (is_winsys_fbo(fb))
+ if (_mesa_is_winsys_fbo(fb))
return; /* can't render to texture with winsys framebuffers */
for (i = 0; i < BUFFER_COUNT; i++) {
static void
check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
{
- if (is_winsys_fbo(fb))
+ if (_mesa_is_winsys_fbo(fb))
return; /* can't render to texture with winsys framebuffers */
if (ctx->Driver.FinishRenderTexture) {
return 0;
}
- if (is_winsys_fbo(buffer)) {
+ if (_mesa_is_winsys_fbo(buffer)) {
/* The window system / default framebuffer is always complete */
return GL_FRAMEBUFFER_COMPLETE_EXT;
}
}
/* check framebuffer binding */
- if (is_winsys_fbo(fb)) {
+ if (_mesa_is_winsys_fbo(fb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferTexture%sEXT", caller);
return;
return;
}
- if (is_winsys_fbo(fb)) {
+ if (_mesa_is_winsys_fbo(fb)) {
/* Can't attach new renderbuffers to a window system framebuffer */
_mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT");
return;
return;
}
- if (is_winsys_fbo(buffer)) {
+ if (_mesa_is_winsys_fbo(buffer)) {
/* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec
* says:
*
switch (pname) {
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
- *params = is_winsys_fbo(buffer) ? GL_FRAMEBUFFER_DEFAULT : att->Type;
+ *params = _mesa_is_winsys_fbo(buffer)
+ ? GL_FRAMEBUFFER_DEFAULT : att->Type;
return;
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
if (att->Type == GL_RENDERBUFFER_EXT) {
struct gl_context;
struct gl_texture_object;
+
+/**
+ * Is the given FBO a user-created FBO?
+ */
+static inline GLboolean
+_mesa_is_user_fbo(const struct gl_framebuffer *fb)
+{
+ return fb->Name != 0;
+}
+
+
+/**
+ * Is the given FBO a window system FBO (like an X window)?
+ */
+static inline GLboolean
+_mesa_is_winsys_fbo(const struct gl_framebuffer *fb)
+{
+ return fb->Name == 0;
+}
+
+
+
extern void
_mesa_init_fbobjects(struct gl_context *ctx);
* and return early.
*/
- /* For window system framebuffers, Name is zero */
- assert(fb->Name == 0);
+ /* Can only resize win-sys framebuffer objects */
+ assert(_mesa_is_winsys_fbo(fb));
for (i = 0; i < BUFFER_COUNT; i++) {
struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
GLuint i;
/* user-created framebuffers only */
- assert(fb->Name);
+ assert(_mesa_is_user_fbo(fb));
for (i = 0; i < BUFFER_COUNT; i++) {
struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
static void
update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
{
- if (fb->Name == 0) {
+ if (_mesa_is_winsys_fbo(fb)) {
/* This is a window-system framebuffer */
/* Need to update the FB's GL_DRAW_BUFFER state to match the
* context state (GL_READ_BUFFER too).
fb->Attachment[bufferName].Renderbuffer == NULL);
/* winsys vs. user-created buffer cross check */
- if (fb->Name) {
+ if (_mesa_is_user_fbo(fb)) {
assert(rb->Name);
}
else {
}
/* Check that the source buffer is complete */
- if (ctx->ReadBuffer->Name) {
+ if (_mesa_is_user_fbo(ctx->ReadBuffer)) {
if (ctx->ReadBuffer->_Status == 0) {
_mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer);
}
GLenum target, GLint level)
{
/* Check that the source buffer is complete */
- if (ctx->ReadBuffer->Name) {
+ if (_mesa_is_user_fbo(ctx->ReadBuffer)) {
if (ctx->ReadBuffer->_Status == 0) {
_mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer);
}
const GLuint level = info->level, face = info->face;
/* If this is a user-created FBO */
- if (fb->Name) {
+ if (_mesa_is_user_fbo(fb)) {
GLuint i;
/* check if any of the FBO's attachments point to 'texObj' */
for (i = 0; i < BUFFER_COUNT; i++) {
for (i = 0; i < n; i++) {
struct gl_framebuffer *fb = (i == 0) ? ctx->DrawBuffer : ctx->ReadBuffer;
- if (fb->Name) {
+ if (_mesa_is_user_fbo(fb)) {
GLuint j;
for (j = 0; j < BUFFER_COUNT; j++) {
if (fb->Attachment[j].Type == GL_TEXTURE &&