summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2017-08-21 20:53:25 -0600
committerBrian Paul <[email protected]>2017-08-31 22:09:57 -0600
commit9eca7e0ddb58808af77c6f251f5d368ea328c894 (patch)
tree7f644449ad846af8bd1ddacd54e23998738ce7e7 /src/mesa/state_tracker
parent1c4e6d7ca83578caf5212f7a484538cb1b4ae2a3 (diff)
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 6839d3369905eb02151. 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 <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c13
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c11
-rw-r--r--src/mesa/state_tracker/st_extensions.c14
3 files changed, 24 insertions, 14 deletions
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index afc7700306e..a7c286bcc52 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -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) {
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index af2052db243..b5006b05a7b 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -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,
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 87859032512..bc206df3bf1 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -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;