summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/dlist.c2
-rw-r--r--src/mesa/main/fbobject.c139
-rw-r--r--src/mesa/main/fbobject.h8
3 files changed, 91 insertions, 58 deletions
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index fb31d2f2706..0e25efbae72 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -607,7 +607,7 @@ void mesa_print_display_list(GLuint list);
/**
* Allocate a gl_display_list object with an initial block of storage.
- * \param count how many display list nodes/tokes to allocate
+ * \param count how many display list nodes/tokens to allocate
*/
static struct gl_display_list *
make_list(GLuint name, GLuint count)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 2d4acb35bd6..1b9b692f001 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2008,6 +2008,63 @@ invalidate_rb(GLuint key, void *data, void *userData)
/** sentinal value, see below */
#define NO_SAMPLES 1000
+void
+_mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLsizei width,
+ GLsizei height, GLsizei samples)
+{
+ const GLenum baseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+
+ assert(baseFormat != 0);
+ assert(width >= 0 && width <= (GLsizei) ctx->Const.MaxRenderbufferSize);
+ assert(height >= 0 && height <= (GLsizei) ctx->Const.MaxRenderbufferSize);
+ assert(samples != NO_SAMPLES);
+ if (samples != 0) {
+ assert(samples > 0);
+ assert(_mesa_check_sample_count(ctx, GL_RENDERBUFFER,
+ internalFormat, samples) == GL_NO_ERROR);
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ if (rb->InternalFormat == internalFormat &&
+ rb->Width == (GLuint) width &&
+ rb->Height == (GLuint) height &&
+ rb->NumSamples == samples) {
+ /* no change in allocation needed */
+ return;
+ }
+
+ /* These MUST get set by the AllocStorage func */
+ rb->Format = MESA_FORMAT_NONE;
+ rb->NumSamples = samples;
+
+ /* Now allocate the storage */
+ assert(rb->AllocStorage);
+ if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
+ /* No error - check/set fields now */
+ /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */
+ assert(rb->Width == (GLuint) width);
+ assert(rb->Height == (GLuint) height);
+ rb->InternalFormat = internalFormat;
+ rb->_BaseFormat = baseFormat;
+ assert(rb->_BaseFormat != 0);
+ }
+ else {
+ /* Probably ran out of memory - clear the fields */
+ rb->Width = 0;
+ rb->Height = 0;
+ rb->Format = MESA_FORMAT_NONE;
+ rb->InternalFormat = GL_NONE;
+ rb->_BaseFormat = GL_NONE;
+ rb->NumSamples = 0;
+ }
+
+ /* Invalidate the framebuffers the renderbuffer is attached in. */
+ if (rb->AttachedAnytime) {
+ _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb);
+ }
+}
/**
* Helper function used by renderbuffer_storage_direct() and
@@ -2067,45 +2124,7 @@ renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
}
}
- FLUSH_VERTICES(ctx, _NEW_BUFFERS);
-
- if (rb->InternalFormat == internalFormat &&
- rb->Width == (GLuint) width &&
- rb->Height == (GLuint) height &&
- rb->NumSamples == samples) {
- /* no change in allocation needed */
- return;
- }
-
- /* These MUST get set by the AllocStorage func */
- rb->Format = MESA_FORMAT_NONE;
- rb->NumSamples = samples;
-
- /* Now allocate the storage */
- assert(rb->AllocStorage);
- if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
- /* No error - check/set fields now */
- /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */
- assert(rb->Width == (GLuint) width);
- assert(rb->Height == (GLuint) height);
- rb->InternalFormat = internalFormat;
- rb->_BaseFormat = baseFormat;
- assert(rb->_BaseFormat != 0);
- }
- else {
- /* Probably ran out of memory - clear the fields */
- rb->Width = 0;
- rb->Height = 0;
- rb->Format = MESA_FORMAT_NONE;
- rb->InternalFormat = GL_NONE;
- rb->_BaseFormat = GL_NONE;
- rb->NumSamples = 0;
- }
-
- /* Invalidate the framebuffers the renderbuffer is attached in. */
- if (rb->AttachedAnytime) {
- _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb);
- }
+ _mesa_renderbuffer_storage(ctx, rb, internalFormat, width, height, samples);
}
/**
@@ -3413,8 +3432,27 @@ void
_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLenum attachment,
- struct gl_renderbuffer *rb,
- const char *func)
+ struct gl_renderbuffer *rb)
+{
+ assert(!_mesa_is_winsys_fbo(fb));
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ assert(ctx->Driver.FramebufferRenderbuffer);
+ ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
+
+ /* Some subsequent GL commands may depend on the framebuffer's visual
+ * after the binding is updated. Update visual info now.
+ */
+ _mesa_update_framebuffer_visual(ctx, fb);
+}
+
+static void
+framebuffer_renderbuffer(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb,
+ const char *func)
{
struct gl_renderbuffer_attachment *att;
@@ -3444,18 +3482,9 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
}
}
- FLUSH_VERTICES(ctx, _NEW_BUFFERS);
-
- assert(ctx->Driver.FramebufferRenderbuffer);
- ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
-
- /* Some subsequent GL commands may depend on the framebuffer's visual
- * after the binding is updated. Update visual info now.
- */
- _mesa_update_framebuffer_visual(ctx, fb);
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
}
-
void GLAPIENTRY
_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
@@ -3491,8 +3520,8 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
rb = NULL;
}
- _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
- "glFramebufferRenderbuffer");
+ framebuffer_renderbuffer(ctx, fb, attachment, rb,
+ "glFramebufferRenderbuffer");
}
@@ -3528,8 +3557,8 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
rb = NULL;
}
- _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
- "glNamedFramebufferRenderbuffer");
+ framebuffer_renderbuffer(ctx, fb, attachment, rb,
+ "glNamedFramebufferRenderbuffer");
}
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 8dad0ff34e7..f9a60605ea5 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -91,8 +91,12 @@ extern void
_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLenum attachment,
- struct gl_renderbuffer *rb,
- const char *func);
+ struct gl_renderbuffer *rb);
+
+extern void
+_mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLsizei width,
+ GLsizei height, GLsizei samples);
extern void
_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);