mesa: add gl_renderbuffer::NumStorageSamples

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Marek Olšák 2018-06-11 17:24:16 -04:00
parent a96e946d25
commit 328c1c8d99
4 changed files with 23 additions and 9 deletions

View File

@ -290,6 +290,7 @@ intel_alloc_private_renderbuffer_storage(struct gl_context * ctx, struct gl_rend
assert(rb->Format != MESA_FORMAT_NONE);
rb->NumSamples = intel_quantize_num_samples(screen, rb->NumSamples);
rb->NumStorageSamples = rb->NumSamples;
rb->Width = width;
rb->Height = height;
rb->_BaseFormat = _mesa_get_format_base_format(rb->Format);
@ -433,6 +434,7 @@ intel_create_winsys_renderbuffer(struct intel_screen *screen,
_mesa_init_renderbuffer(rb, 0);
rb->ClassID = INTEL_RB_CLASS;
rb->NumSamples = num_samples;
rb->NumStorageSamples = num_samples;
/* The base format and internal format must be derived from the user-visible
* format (that is, the gl_config's format), even if we internally use

View File

@ -481,6 +481,7 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
rb->Height = texImage->Height2;
rb->Depth = texImage->Depth2;
rb->NumSamples = texImage->NumSamples;
rb->NumStorageSamples = texImage->NumSamples;
rb->TexImage = texImage;
if (driver_RenderTexture_is_safe(att))
@ -2237,7 +2238,8 @@ _mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
if (rb->InternalFormat == internalFormat &&
rb->Width == (GLuint) width &&
rb->Height == (GLuint) height &&
rb->NumSamples == samples) {
rb->NumSamples == samples &&
rb->NumStorageSamples == storageSamples) {
/* no change in allocation needed */
return;
}
@ -2245,6 +2247,7 @@ _mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
/* These MUST get set by the AllocStorage func */
rb->Format = MESA_FORMAT_NONE;
rb->NumSamples = samples;
rb->NumStorageSamples = storageSamples;
/* Now allocate the storage */
assert(rb->AllocStorage);
@ -2265,6 +2268,7 @@ _mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
rb->InternalFormat = GL_NONE;
rb->_BaseFormat = GL_NONE;
rb->NumSamples = 0;
rb->NumStorageSamples = 0;
}
/* Invalidate the framebuffers the renderbuffer is attached in. */
@ -2584,19 +2588,24 @@ get_render_buffer_parameteriv(struct gl_context *ctx,
case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
*params = get_component_bits(pname, rb->_BaseFormat, rb->Format);
break;
return;
case GL_RENDERBUFFER_SAMPLES:
if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_framebuffer_object)
|| _mesa_is_gles3(ctx)) {
*params = rb->NumSamples;
break;
return;
}
/* fallthrough */
default:
_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname=%s)", func,
_mesa_enum_to_string(pname));
return;
break;
case GL_RENDERBUFFER_STORAGE_SAMPLES_AMD:
if (ctx->Extensions.AMD_framebuffer_multisample_advanced) {
*params = rb->NumStorageSamples;
return;
}
break;
}
_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname=%s)", func,
_mesa_enum_to_string(pname));
}

View File

@ -3336,6 +3336,7 @@ struct gl_renderbuffer
*/
GLboolean NeedsFinishRenderTexture;
GLubyte NumSamples; /**< zero means not multisampled */
GLubyte NumStorageSamples; /**< for AMD_framebuffer_multisample_advanced */
GLenum16 InternalFormat; /**< The user-specified format */
GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
GL_STENCIL_INDEX. */

View File

@ -173,6 +173,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
if (format != PIPE_FORMAT_NONE) {
rb->NumSamples = i;
rb->NumStorageSamples = i;
break;
}
}
@ -204,7 +205,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
templ.depth0 = 1;
templ.array_size = 1;
templ.nr_samples = rb->NumSamples;
templ.nr_storage_samples = rb->NumSamples;
templ.nr_storage_samples = rb->NumStorageSamples;
if (util_format_is_depth_or_stencil(format)) {
templ.bind = PIPE_BIND_DEPTH_STENCIL;
@ -284,6 +285,7 @@ st_new_renderbuffer_fb(enum pipe_format format, unsigned samples, boolean sw)
_mesa_init_renderbuffer(&strb->Base, 0);
strb->Base.ClassID = 0x4242; /* just a unique value */
strb->Base.NumSamples = samples;
strb->Base.NumStorageSamples = samples;
strb->Base.Format = st_pipe_format_to_mesa_format(format);
strb->Base._BaseFormat = _mesa_get_format_base_format(strb->Base.Format);
strb->software = sw;