Re: [Mesa-dev] [PATCH 1/2] st/mesa: only try to create 1x msaa surfaces for "fake" msaa drivers

2017-08-29 Thread Cherniak, Bruce
Gentle bump.  This fixes mesa master for Kitware's VTK testing.

> On Aug 25, 2017, at 2:59 PM, Bruce Cherniak  wrote:
> 
> From: Brian Paul 
> 
> 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
> ---
> src/mesa/state_tracker/st_cb_fbo.c | 13 ++---
> src/mesa/state_tracker/st_cb_texture.c | 11 ---
> src/mesa/state_tracker/st_extensions.c | 14 ++
> 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 afc7700306..a7c286bcc5 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  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 af2052db24..b5006b05a7 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 904d9cd834..2008e28250 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;
> -- 
> 2.11.0
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] st/mesa: only try to create 1x msaa surfaces for "fake" msaa drivers

2017-08-25 Thread Bruce Cherniak
From: Brian Paul 

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
---
 src/mesa/state_tracker/st_cb_fbo.c | 13 ++---
 src/mesa/state_tracker/st_cb_texture.c | 11 ---
 src/mesa/state_tracker/st_extensions.c | 14 ++
 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 afc7700306..a7c286bcc5 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  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 af2052db24..b5006b05a7 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 904d9cd834..2008e28250 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;
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev