mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 17:10:11 +01:00
mesa: Refactor renderbuffer_storage to make _mesa_renderbuffer_storage
Pulls the parts of renderbuffer_storage that aren't just parameter validation out into a function that can be called from other parts of Mesa (e.g., meta). Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
parent
9ae42ab1ec
commit
eb5bc62e97
2 changed files with 63 additions and 39 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
|
|||
GLenum attachment,
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue