st/mesa: only try to create 1x msaa surfaces for "fake" msaa drivers

For software drivers where we want "fake" msaa support for GL 3.x, we
treat 1 sample as being msaa.

For drivers with real msaa support, start format probing at 2x msaa.
For drivers with fake msaa support, start format probing at 1x msaa.

This also tweaks the MaxSamples code in st_init_extensions() so that
we use MaxSamples=1 for fake msaa.  This allows the format proble loops
to run at least one iteration.

This fixes a llvmpipe/VTK regression from commit 6839d33699.
And for drivers with fake msaa support, calls such as
glTexImage2DMultisample(samples=1) will now succeed.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102038
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102125
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
Brian Paul 2017-08-21 20:53:25 -06:00
parent 1c4e6d7ca8
commit 9eca7e0ddb
3 changed files with 24 additions and 14 deletions

View file

@ -155,12 +155,19 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
* to <samples> and no more than the next larger sample count supported
* by the implementation.
*
* So let's find the supported number of samples closest to NumSamples.
* Find the supported number of samples >= rb->NumSamples
*/
if (rb->NumSamples > 0) {
unsigned i;
unsigned start, i;
for (i = MAX2(2, rb->NumSamples); i <= ctx->Const.MaxSamples; i++) {
if (ctx->Const.MaxSamples > 1 && rb->NumSamples == 1) {
/* don't try num_samples = 1 with drivers that support real msaa */
start = 2;
} else {
start = rb->NumSamples;
}
for (i = start; i <= ctx->Const.MaxSamples; i++) {
format = st_choose_renderbuffer_format(st, internalFormat, i);
if (format != PIPE_FORMAT_NONE) {

View file

@ -2739,13 +2739,18 @@ st_texture_storage(struct gl_context *ctx,
bindings = default_bindings(st, fmt);
/* Raise the sample count if the requested one is unsupported. */
if (num_samples > 0) {
/* Find msaa sample count which is actually supported. For example,
* if the user requests 1x but only 4x or 8x msaa is supported, we'll
* choose 4x here.
*/
enum pipe_texture_target ptarget = gl_target_to_pipe(texObj->Target);
boolean found = FALSE;
/* start the query with at least two samples */
num_samples = MAX2(num_samples, 2);
if (ctx->Const.MaxSamples > 1 && num_samples == 1) {
/* don't try num_samples = 1 with drivers that support real msaa */
num_samples = 2;
}
for (; num_samples <= ctx->Const.MaxSamples; num_samples++) {
if (screen->is_format_supported(screen, fmt, ptarget,

View file

@ -1046,17 +1046,15 @@ void st_init_extensions(struct pipe_screen *screen,
void_formats, 32,
PIPE_BIND_RENDER_TARGET);
}
if (consts->MaxSamples == 1) {
/* one sample doesn't really make sense */
consts->MaxSamples = 0;
}
else if (consts->MaxSamples >= 2) {
if (consts->MaxSamples >= 2) {
/* Real MSAA support */
extensions->EXT_framebuffer_multisample = GL_TRUE;
extensions->EXT_framebuffer_multisample_blit_scaled = GL_TRUE;
}
if (consts->MaxSamples == 0 &&
screen->get_param(screen, PIPE_CAP_FAKE_SW_MSAA)) {
else if (consts->MaxSamples > 0 &&
screen->get_param(screen, PIPE_CAP_FAKE_SW_MSAA)) {
/* fake MSAA support */
consts->FakeSWMSAA = GL_TRUE;
extensions->EXT_framebuffer_multisample = GL_TRUE;
extensions->EXT_framebuffer_multisample_blit_scaled = GL_TRUE;