From 7f587b57f70c9a547d0b664e20f99357b8a8ac9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 11 Jun 2018 18:48:58 -0400 Subject: [PATCH] st/mesa: add renderbuffer support for AMD_framebuffer_multisample_advanced Reviewed-by: Brian Paul --- src/mesa/state_tracker/st_cb_fbo.c | 61 +++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 8114516..0e53525 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -159,22 +159,66 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, * Find the supported number of samples >= rb->NumSamples */ if (rb->NumSamples > 0) { - unsigned start, i; + unsigned start, start_storage; if (ctx->Const.MaxSamples > 1 && rb->NumSamples == 1) { /* don't try num_samples = 1 with drivers that support real msaa */ start = 2; + start_storage = 2; } else { start = rb->NumSamples; + start_storage = rb->NumStorageSamples; } - for (i = start; i <= ctx->Const.MaxSamples; i++) { - format = st_choose_renderbuffer_format(st, internalFormat, i, i); - - if (format != PIPE_FORMAT_NONE) { - rb->NumSamples = i; - rb->NumStorageSamples = i; - break; + if (ctx->Extensions.AMD_framebuffer_multisample_advanced) { + if (rb->_BaseFormat == GL_DEPTH_COMPONENT || + rb->_BaseFormat == GL_DEPTH_STENCIL || + rb->_BaseFormat == GL_STENCIL_INDEX) { + /* Find a supported depth-stencil format. */ + for (unsigned samples = start; + samples <= ctx->Const.MaxDepthStencilFramebufferSamples; + samples++) { + format = st_choose_renderbuffer_format(st, internalFormat, + samples, samples); + + if (format != PIPE_FORMAT_NONE) { + rb->NumSamples = samples; + rb->NumStorageSamples = samples; + break; + } + } + } else { + /* Find a supported color format, samples >= storage_samples. */ + for (unsigned storage_samples = start_storage; + storage_samples <= ctx->Const.MaxColorFramebufferStorageSamples; + storage_samples++) { + for (unsigned samples = MAX2(start, storage_samples); + samples <= ctx->Const.MaxColorFramebufferSamples; + samples++) { + format = st_choose_renderbuffer_format(st, internalFormat, + samples, + storage_samples); + + if (format != PIPE_FORMAT_NONE) { + rb->NumSamples = samples; + rb->NumStorageSamples = storage_samples; + goto found; + } + } + } + found:; + } + } else { + for (unsigned samples = start; samples <= ctx->Const.MaxSamples; + samples++) { + format = st_choose_renderbuffer_format(st, internalFormat, + samples, samples); + + if (format != PIPE_FORMAT_NONE) { + rb->NumSamples = samples; + rb->NumStorageSamples = samples; + break; + } } } } else { @@ -467,6 +511,7 @@ st_update_renderbuffer_surface(struct st_context *st, if (!surf || surf->texture->nr_samples != strb->Base.NumSamples || + surf->texture->nr_storage_samples != strb->Base.NumStorageSamples || surf->format != format || surf->texture != resource || surf->width != rtt_width || -- 2.7.4