diff options
author | Marek Olšák <[email protected]> | 2018-06-11 18:48:58 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-08-04 02:46:55 -0400 |
commit | 7f587b57f70c9a547d0b664e20f99357b8a8ac9c (patch) | |
tree | 2c7e32d235632e12aa9621d9b5fbefca18758174 | |
parent | 8e3d0019e1b548327ac43a90256d8593f25cc129 (diff) |
st/mesa: add renderbuffer support for AMD_framebuffer_multisample_advanced
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r-- | src/mesa/state_tracker/st_cb_fbo.c | 61 |
1 files 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 811451656ca..0e535257cb4 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 || |