[Mesa-dev] [PATCH 1/8] mesa: add storageSamples parameter to renderbuffer functions

Marek Olšák maraeo at gmail.com
Wed Aug 1 23:25:57 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

It's just passed to other functions but otherwise unused.
It will be used in following commits.
---
 src/mesa/drivers/common/meta.c |  2 +-
 src/mesa/main/fbobject.c       | 41 +++++++++++++++++++++-------------
 src/mesa/main/fbobject.h       |  3 ++-
 src/mesa/main/multisample.c    |  3 ++-
 src/mesa/main/multisample.h    |  3 ++-
 src/mesa/main/teximage.c       |  2 +-
 6 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 6b1713e3b1c..04752e0e875 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3072,21 +3072,21 @@ decompress_texture_image(struct gl_context *ctx,
       _mesa_framebuffer_renderbuffer(ctx, ctx->DrawBuffer, GL_COLOR_ATTACHMENT0,
                                      decompress_fbo->rb);
    }
    else {
       _mesa_bind_framebuffers(ctx, decompress_fbo->fb, decompress_fbo->fb);
    }
 
    /* alloc dest surface */
    if (width > decompress_fbo->Width || height > decompress_fbo->Height) {
       _mesa_renderbuffer_storage(ctx, decompress_fbo->rb, rbFormat,
-                                 width, height, 0);
+                                 width, height, 0, 0);
 
       /* Do the full completeness check to recompute
        * ctx->DrawBuffer->Width/Height.
        */
       ctx->DrawBuffer->_Status = GL_FRAMEBUFFER_UNDEFINED;
       status = _mesa_check_framebuffer_status(ctx, ctx->DrawBuffer);
       if (status != GL_FRAMEBUFFER_COMPLETE) {
          /* If the framebuffer isn't complete then we'll leave
           * decompress_fbo->Width as zero so that it will fail again next time
           * too */
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index cfe2174ef12..edafdd011aa 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2209,32 +2209,34 @@ invalidate_rb(GLuint key, void *data, void *userData)
    }
 }
 
 
 /** sentinal value, see below */
 #define NO_SAMPLES 1000
 
 void
 _mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
                            GLenum internalFormat, GLsizei width,
-                           GLsizei height, GLsizei samples)
+                           GLsizei height, GLsizei samples,
+                           GLsizei storageSamples)
 {
    const GLenum baseFormat = _mesa_base_fbo_format(ctx, internalFormat);
 
    assert(baseFormat != 0);
    assert(width >= 0 && width <= (GLsizei) ctx->Const.MaxRenderbufferSize);
    assert(height >= 0 && height <= (GLsizei) ctx->Const.MaxRenderbufferSize);
    assert(samples != NO_SAMPLES);
    if (samples != 0) {
       assert(samples > 0);
       assert(_mesa_check_sample_count(ctx, GL_RENDERBUFFER,
-                                      internalFormat, samples) == GL_NO_ERROR);
+                                      internalFormat, samples,
+                                      storageSamples) == GL_NO_ERROR);
    }
 
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 
    if (rb->InternalFormat == internalFormat &&
        rb->Width == (GLuint) width &&
        rb->Height == (GLuint) height &&
        rb->NumSamples == samples) {
       /* no change in allocation needed */
       return;
@@ -2272,21 +2274,22 @@ _mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
 }
 
 /**
  * Helper function used by renderbuffer_storage_direct() and
  * renderbuffer_storage_target().
  * samples will be NO_SAMPLES if called by a non-multisample function.
  */
 static void
 renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
                      GLenum internalFormat, GLsizei width,
-                     GLsizei height, GLsizei samples, const char *func)
+                     GLsizei height, GLsizei samples, GLsizei storageSamples,
+                     const char *func)
 {
    GLenum baseFormat;
    GLenum sample_count_error;
 
    baseFormat = _mesa_base_fbo_format(ctx, internalFormat);
    if (baseFormat == 0) {
       _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat=%s)",
                   func, _mesa_enum_to_string(internalFormat));
       return;
    }
@@ -2299,54 +2302,58 @@ renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
 
    if (height < 0 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) {
       _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid height %d)", func,
                   height);
       return;
    }
 
    if (samples == NO_SAMPLES) {
       /* NumSamples == 0 indicates non-multisampling */
       samples = 0;
+      storageSamples = 0;
    }
    else {
       /* check the sample count;
        * note: driver may choose to use more samples than what's requested
        */
       sample_count_error = _mesa_check_sample_count(ctx, GL_RENDERBUFFER,
-            internalFormat, samples);
+            internalFormat, samples, storageSamples);
 
       /* Section 2.5 (GL Errors) of OpenGL 3.0 specification, page 16:
        *
        * "If a negative number is provided where an argument of type sizei or
        * sizeiptr is specified, the error INVALID VALUE is generated."
        */
-      if (samples < 0) {
+      if (samples < 0 || storageSamples < 0) {
          sample_count_error = GL_INVALID_VALUE;
       }
 
       if (sample_count_error != GL_NO_ERROR) {
-         _mesa_error(ctx, sample_count_error, "%s(samples=%d)", func, samples);
+         _mesa_error(ctx, sample_count_error,
+                     "%s(samples=%d, storageSamples=%d)", func, samples,
+                     storageSamples);
          return;
       }
    }
 
-   _mesa_renderbuffer_storage(ctx, rb, internalFormat, width, height, samples);
+   _mesa_renderbuffer_storage(ctx, rb, internalFormat, width, height, samples,
+                              storageSamples);
 }
 
 /**
  * Helper function used by _mesa_NamedRenderbufferStorage*().
  * samples will be NO_SAMPLES if called by a non-multisample function.
  */
 static void
 renderbuffer_storage_named(GLuint renderbuffer, GLenum internalFormat,
                            GLsizei width, GLsizei height, GLsizei samples,
-                           const char *func)
+                           GLsizei storageSamples, const char *func)
 {
    GET_CURRENT_CONTEXT(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API) {
       if (samples == NO_SAMPLES)
          _mesa_debug(ctx, "%s(%u, %s, %d, %d)\n",
                      func, renderbuffer,
                      _mesa_enum_to_string(internalFormat),
                      width, height);
       else
@@ -2357,32 +2364,33 @@ renderbuffer_storage_named(GLuint renderbuffer, GLenum internalFormat,
    }
 
    struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
    if (!rb || rb == &DummyRenderbuffer) {
       /* ID was reserved, but no real renderbuffer object made yet */
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid renderbuffer %u)",
                   func, renderbuffer);
       return;
    }
 
-   renderbuffer_storage(ctx, rb, internalFormat, width, height, samples, func);
+   renderbuffer_storage(ctx, rb, internalFormat, width, height, samples,
+                        storageSamples, func);
 }
 
 /**
  * Helper function used by _mesa_RenderbufferStorage() and
  * _mesa_RenderbufferStorageMultisample().
  * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorage().
  */
 static void
 renderbuffer_storage_target(GLenum target, GLenum internalFormat,
                             GLsizei width, GLsizei height, GLsizei samples,
-                            const char *func)
+                            GLsizei storageSamples, const char *func)
 {
    GET_CURRENT_CONTEXT(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API) {
       if (samples == NO_SAMPLES)
          _mesa_debug(ctx, "%s(%s, %s, %d, %d)\n",
                      func,
                      _mesa_enum_to_string(target),
                      _mesa_enum_to_string(internalFormat),
                      width, height);
@@ -2399,21 +2407,21 @@ renderbuffer_storage_target(GLenum target, GLenum internalFormat,
       return;
    }
 
    if (!ctx->CurrentRenderbuffer) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no renderbuffer bound)",
                   func);
       return;
    }
 
    renderbuffer_storage(ctx, ctx->CurrentRenderbuffer, internalFormat, width,
-                        height, samples, func);
+                        height, samples, storageSamples, func);
 }
 
 
 void GLAPIENTRY
 _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
 {
    struct gl_renderbuffer *rb;
    GET_CURRENT_CONTEXT(ctx);
 
    if (!ctx->Extensions.OES_EGL_image) {
@@ -2462,74 +2470,75 @@ get_component_bits(GLenum pname, GLenum baseFormat, mesa_format format)
 
 void GLAPIENTRY
 _mesa_RenderbufferStorage(GLenum target, GLenum internalFormat,
                              GLsizei width, GLsizei height)
 {
    /* GL_ARB_fbo says calling this function is equivalent to calling
     * glRenderbufferStorageMultisample() with samples=0.  We pass in
     * a token value here just for error reporting purposes.
     */
    renderbuffer_storage_target(target, internalFormat, width, height,
-                               NO_SAMPLES, "glRenderbufferStorage");
+                               NO_SAMPLES, 0, "glRenderbufferStorage");
 }
 
 
 void GLAPIENTRY
 _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples,
                                      GLenum internalFormat,
                                      GLsizei width, GLsizei height)
 {
    renderbuffer_storage_target(target, internalFormat, width, height,
-                               samples, "glRenderbufferStorageMultisample");
+                               samples, samples,
+                               "glRenderbufferStorageMultisample");
 }
 
 
 /**
  * OpenGL ES version of glRenderBufferStorage.
  */
 void GLAPIENTRY
 _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
                            GLsizei width, GLsizei height)
 {
    switch (internalFormat) {
    case GL_RGB565:
       /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */
       /* choose a closest format */
       internalFormat = GL_RGB5;
       break;
    default:
       break;
    }
 
-   renderbuffer_storage_target(target, internalFormat, width, height, 0,
+   renderbuffer_storage_target(target, internalFormat, width, height, 0, 0,
                                "glRenderbufferStorageEXT");
 }
 
 void GLAPIENTRY
 _mesa_NamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat,
                                GLsizei width, GLsizei height)
 {
    /* GL_ARB_fbo says calling this function is equivalent to calling
     * glRenderbufferStorageMultisample() with samples=0.  We pass in
     * a token value here just for error reporting purposes.
     */
    renderbuffer_storage_named(renderbuffer, internalformat, width, height,
-                              NO_SAMPLES, "glNamedRenderbufferStorage");
+                              NO_SAMPLES, 0, "glNamedRenderbufferStorage");
 }
 
 void GLAPIENTRY
 _mesa_NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples,
                                           GLenum internalformat,
                                           GLsizei width, GLsizei height)
 {
    renderbuffer_storage_named(renderbuffer, internalformat, width, height,
-                              samples,
+                              samples, samples,
                               "glNamedRenderbufferStorageMultisample");
 }
 
 
 static void
 get_render_buffer_parameteriv(struct gl_context *ctx,
                               struct gl_renderbuffer *rb, GLenum pname,
                               GLint *params, const char *func)
 {
    /* No need to flush here since we're just quering state which is
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 5ba62d6cb1a..0299781b1e5 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -88,21 +88,22 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
 
 extern void
 _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
                                struct gl_framebuffer *fb,
                                GLenum attachment,
                                struct gl_renderbuffer *rb);
 
 extern void
 _mesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
                            GLenum internalFormat, GLsizei width,
-                           GLsizei height, GLsizei samples);
+                           GLsizei height, GLsizei samples,
+                           GLsizei storageSamples);
 
 extern void
 _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
 
 extern GLboolean
 _mesa_has_depthstencil_combined(const struct gl_framebuffer *fb);
 
 extern void
 _mesa_test_framebuffer_completeness(struct gl_context *ctx,
                                     struct gl_framebuffer *fb);
diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c
index f93a18832da..4341a5918e4 100644
--- a/src/mesa/main/multisample.c
+++ b/src/mesa/main/multisample.c
@@ -202,21 +202,22 @@ _mesa_MinSampleShading(GLclampf value)
 /**
  * Helper for checking a requested sample count against the limit
  * for a particular (target, internalFormat) pair. The limit imposed,
  * and the error generated, both depend on which extensions are supported.
  *
  * Returns a GL error enum, or GL_NO_ERROR if the requested sample count is
  * acceptable.
  */
 GLenum
 _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
-                         GLenum internalFormat, GLsizei samples)
+                         GLenum internalFormat, GLsizei samples,
+                         GLsizei storageSamples)
 {
    /* Section 4.4 (Framebuffer objects), page 198 of the OpenGL ES 3.0.0
     * specification says:
     *
     *     "If internalformat is a signed or unsigned integer format and samples
     *     is greater than zero, then the error INVALID_OPERATION is generated."
     *
     * This restriction is relaxed for OpenGL ES 3.1.
     */
    if ((ctx->API == API_OPENGLES2 && ctx->Version == 30) &&
diff --git a/src/mesa/main/multisample.h b/src/mesa/main/multisample.h
index a7cd2918d7a..49683cacdc9 100644
--- a/src/mesa/main/multisample.h
+++ b/src/mesa/main/multisample.h
@@ -48,13 +48,14 @@ extern void GLAPIENTRY
 _mesa_SampleMaski(GLuint index, GLbitfield mask);
 
 void GLAPIENTRY
 _mesa_MinSampleShading_no_error(GLclampf value);
 
 extern void GLAPIENTRY
 _mesa_MinSampleShading(GLclampf value);
 
 extern GLenum
 _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
-                   GLenum internalFormat, GLsizei samples);
+                         GLenum internalFormat, GLsizei samples,
+                         GLsizei storageSamples);
 
 #endif
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 948c7df0511..730ec888431 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -5843,21 +5843,21 @@ texture_image_multisample(struct gl_context *ctx, GLuint dims,
        *
        *  (Same error is also defined for desktop OpenGL for multisample
        *  teximage/texstorage functions.)
        */
       _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalformat=%s)", func,
                   _mesa_enum_to_string(internalformat));
       return;
    }
 
    sample_count_error = _mesa_check_sample_count(ctx, target,
-         internalformat, samples);
+         internalformat, samples, samples);
    samplesOK = sample_count_error == GL_NO_ERROR;
 
    /* Page 254 of OpenGL 4.4 spec says:
     *   "Proxy arrays for two-dimensional multisample and two-dimensional
     *    multisample array textures are operated on in the same way when
     *    TexImage2DMultisample is called with target specified as
     *    PROXY_TEXTURE_2D_MULTISAMPLE, or TexImage3DMultisample is called
     *    with target specified as PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY.
     *    However, if samples is not supported, then no error is generated.
     */
-- 
2.17.1



More information about the mesa-dev mailing list