st/mesa: pass storage_sample_count parameter into st_choose_format
authorMarek Olšák <marek.olsak@amd.com>
Mon, 11 Jun 2018 19:04:11 +0000 (15:04 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 4 Aug 2018 06:46:55 +0000 (02:46 -0400)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_format.h
src/mesa/state_tracker/st_texture.c

index 5a331f841de7fe428b85097ba8a454bd70349388..b8895684bc26dc0952b0ce5faac458b8a3576c80 100644 (file)
@@ -535,7 +535,7 @@ make_texture(struct st_context *st,
       GLenum intFormat = internal_format(ctx, format, type);
 
       pipeFormat = st_choose_format(st, intFormat, format, type,
-                                    st->internal_target, 0,
+                                    st->internal_target, 0, 0,
                                     PIPE_BIND_SAMPLER_VIEW, FALSE);
       assert(pipeFormat != PIPE_FORMAT_NONE);
    }
@@ -1584,7 +1584,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       /* srcFormat is non-renderable. Find a compatible renderable format. */
       if (type == GL_DEPTH) {
          srcFormat = st_choose_format(st, GL_DEPTH_COMPONENT, GL_NONE,
-                                      GL_NONE, st->internal_target, 0,
+                                      GL_NONE, st->internal_target, 0, 0,
                                       srcBind, FALSE);
       }
       else {
@@ -1592,27 +1592,27 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
 
          if (util_format_is_float(srcFormat)) {
             srcFormat = st_choose_format(st, GL_RGBA32F, GL_NONE,
-                                         GL_NONE, st->internal_target, 0,
+                                         GL_NONE, st->internal_target, 0, 0,
                                          srcBind, FALSE);
          }
          else if (util_format_is_pure_sint(srcFormat)) {
             srcFormat = st_choose_format(st, GL_RGBA32I, GL_NONE,
-                                         GL_NONE, st->internal_target, 0,
+                                         GL_NONE, st->internal_target, 0, 0,
                                          srcBind, FALSE);
          }
          else if (util_format_is_pure_uint(srcFormat)) {
             srcFormat = st_choose_format(st, GL_RGBA32UI, GL_NONE,
-                                         GL_NONE, st->internal_target, 0,
+                                         GL_NONE, st->internal_target, 0, 0,
                                          srcBind, FALSE);
          }
          else if (util_format_is_snorm(srcFormat)) {
             srcFormat = st_choose_format(st, GL_RGBA16_SNORM, GL_NONE,
-                                         GL_NONE, st->internal_target, 0,
+                                         GL_NONE, st->internal_target, 0, 0,
                                          srcBind, FALSE);
          }
          else {
             srcFormat = st_choose_format(st, GL_RGBA, GL_NONE,
-                                         GL_NONE, st->internal_target, 0,
+                                         GL_NONE, st->internal_target, 0, 0,
                                          srcBind, FALSE);
          }
       }
index 2bb910fcecdaaa99927b89dedb826c1ce86aa8e6..811451656ca72a01f889531954d7c24ad1022aa2 100644 (file)
@@ -83,7 +83,7 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx,
       format = PIPE_FORMAT_R16G16B16A16_SNORM;
    }
    else {
-      format = st_choose_renderbuffer_format(st, internalFormat, 0);
+      format = st_choose_renderbuffer_format(st, internalFormat, 0, 0);
 
       /* Not setting gl_renderbuffer::Format here will cause
        * FRAMEBUFFER_UNSUPPORTED and ValidateFramebuffer will not be called.
@@ -169,7 +169,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
       }
 
       for (i = start; i <= ctx->Const.MaxSamples; i++) {
-         format = st_choose_renderbuffer_format(st, internalFormat, i);
+         format = st_choose_renderbuffer_format(st, internalFormat, i, i);
 
          if (format != PIPE_FORMAT_NONE) {
             rb->NumSamples = i;
@@ -178,7 +178,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
          }
       }
    } else {
-      format = st_choose_renderbuffer_format(st, internalFormat, 0);
+      format = st_choose_renderbuffer_format(st, internalFormat, 0, 0);
    }
 
    /* Not setting gl_renderbuffer::Format here will cause
index 93b6b32b7e27ed1654b786c21fccdbef710ae244..5406d0247c5319864a7d9eeb5f3c51cd91d6a3d1 100644 (file)
@@ -2043,7 +2043,7 @@ st_GetTexSubImage(struct gl_context * ctx,
       }
 
       dst_format = st_choose_format(st, dst_glformat, format, type,
-                                    pipe_target, 0, bind, FALSE);
+                                    pipe_target, 0, 0, bind, FALSE);
 
       if (dst_format == PIPE_FORMAT_NONE) {
          /* unable to get an rgba format!?! */
index c2535e85324fe4f97cfe15cbfd38de9e16315264..16a18c272dc5ec9e9c709199d34441ee28380c28 100644 (file)
@@ -2053,13 +2053,15 @@ find_supported_format(struct pipe_screen *screen,
                       const enum pipe_format formats[],
                       enum pipe_texture_target target,
                       unsigned sample_count,
+                      unsigned storage_sample_count,
                       unsigned bindings,
                       boolean allow_dxt)
 {
    uint i;
    for (i = 0; formats[i]; i++) {
       if (screen->is_format_supported(screen, formats[i], target,
-                                      sample_count, sample_count, bindings)) {
+                                      sample_count, storage_sample_count,
+                                      bindings)) {
          if (!allow_dxt && util_format_is_s3tc(formats[i])) {
             /* we can't return a dxt format, continue searching */
             continue;
@@ -2164,6 +2166,7 @@ enum pipe_format
 st_choose_format(struct st_context *st, GLenum internalFormat,
                  GLenum format, GLenum type,
                  enum pipe_texture_target target, unsigned sample_count,
+                 unsigned storage_sample_count,
                  unsigned bindings, boolean allow_dxt)
 {
    struct pipe_screen *screen = st->pipe->screen;
@@ -2193,7 +2196,7 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
    pf = find_exact_format(internalFormat, format, type);
    if (pf != PIPE_FORMAT_NONE &&
        screen->is_format_supported(screen, pf, target, sample_count,
-                                   sample_count, bindings)) {
+                                   storage_sample_count, bindings)) {
       goto success;
    }
 
@@ -2219,7 +2222,8 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
              * which is supported by the driver.
              */
             pf = find_supported_format(screen, mapping->pipeFormats,
-                                       target, sample_count, bindings,
+                                       target, sample_count,
+                                       storage_sample_count, bindings,
                                        allow_dxt);
             goto success;
          }
@@ -2247,7 +2251,8 @@ success:
  */
 enum pipe_format
 st_choose_renderbuffer_format(struct st_context *st,
-                              GLenum internalFormat, unsigned sample_count)
+                              GLenum internalFormat, unsigned sample_count,
+                              unsigned storage_sample_count)
 {
    unsigned bindings;
    if (_mesa_is_depth_or_stencil_format(internalFormat))
@@ -2255,7 +2260,8 @@ st_choose_renderbuffer_format(struct st_context *st,
    else
       bindings = PIPE_BIND_RENDER_TARGET;
    return st_choose_format(st, internalFormat, GL_NONE, GL_NONE,
-                           PIPE_TEXTURE_2D, sample_count, bindings, FALSE);
+                           PIPE_TEXTURE_2D, sample_count,
+                           storage_sample_count, bindings, FALSE);
 }
 
 
@@ -2387,12 +2393,12 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
    }
 
    pFormat = st_choose_format(st, internalFormat, format, type,
-                              pTarget, 0, bindings, GL_TRUE);
+                              pTarget, 0, 0, bindings, GL_TRUE);
 
    if (pFormat == PIPE_FORMAT_NONE && !is_renderbuffer) {
       /* try choosing format again, this time without render target bindings */
       pFormat = st_choose_format(st, internalFormat, format, type,
-                                 pTarget, 0, PIPE_BIND_SAMPLER_VIEW,
+                                 pTarget, 0, 0, PIPE_BIND_SAMPLER_VIEW,
                                  GL_TRUE);
    }
 
@@ -2450,7 +2456,7 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
    /* Set sample counts in descending order. */
    for (i = 16; i > 1; i--) {
       format = st_choose_format(st, internalFormat, GL_NONE, GL_NONE,
-                                PIPE_TEXTURE_2D, i, bind, FALSE);
+                                PIPE_TEXTURE_2D, i, i, bind, FALSE);
 
       if (format != PIPE_FORMAT_NONE) {
          samples[num_sample_counts++] = i;
@@ -2509,7 +2515,7 @@ st_QueryInternalFormat(struct gl_context *ctx, GLenum target,
                                                   internalFormat,
                                                   GL_NONE,
                                                   GL_NONE,
-                                                  PIPE_TEXTURE_2D, 1,
+                                                  PIPE_TEXTURE_2D, 0, 0,
                                                   bindings, FALSE);
       if (pformat)
          params[0] = internalFormat;
index 466b5d073fc48e73cd9a083b4f33f648e0c9448f..036d3378286e1efdd17a1f3a152acf8ae9f60ca9 100644 (file)
@@ -54,11 +54,13 @@ extern enum pipe_format
 st_choose_format(struct st_context *st, GLenum internalFormat,
                  GLenum format, GLenum type,
                  enum pipe_texture_target target, unsigned sample_count,
+                 unsigned storage_sample_count,
                  unsigned bindings, boolean allow_dxt);
 
 extern enum pipe_format
 st_choose_renderbuffer_format(struct st_context *st,
-                              GLenum internalFormat, unsigned sample_count);
+                              GLenum internalFormat, unsigned sample_count,
+                              unsigned storage_sample_count);
 
 extern enum pipe_format
 st_choose_matching_format(struct st_context *st, unsigned bind,
index 5da98bd338f47e73db3e3ec725e87ccecd691640..9655eede5fed039ea39c19bfa9deff95ae134ec1 100644 (file)
@@ -415,7 +415,7 @@ st_create_color_map_texture(struct gl_context *ctx)
 
    /* find an RGBA texture format */
    format = st_choose_format(st, GL_RGBA, GL_NONE, GL_NONE,
-                             PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
+                             PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW,
                              FALSE);
 
    /* create texture for color map/table */