<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 19, 2015 at 11:13 AM, Martin Peres <span dir="ltr"><<a href="mailto:martin.peres@linux.intel.com" target="_blank">martin.peres@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">v2: Review from Laura Ekstrand<br>
- get rid of a change that should not have happened in this patch<br>
- improve the error messages<br>
- fix alignments<br>
- fix a capitalization in a function name in an error message<br>
<br>
Signed-off-by: Martin Peres <<a href="mailto:martin.peres@linux.intel.com">martin.peres@linux.intel.com</a>><br>
---<br>
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  15 +++<br>
 src/mesa/main/fbobject.c                       | 161 ++++++++++++++++++-------<br>
 src/mesa/main/fbobject.h                       |  13 +-<br>
 src/mesa/main/tests/dispatch_sanity.cpp        |   2 +<br>
 4 files changed, 148 insertions(+), 43 deletions(-)<br>
<br>
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
index d4e1f7c..8a092d6 100644<br>
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
@@ -159,6 +159,21 @@<br>
<span class="">       <param name="renderbuffers" type="GLuint *" /><br>
    </function><br>
<br>
+   <function name="NamedRenderbufferStorage" offset="assign"><br>
+      <param name="renderbuffer" type="GLuint" /><br>
+      <param name="internalformat" type="GLenum" /><br>
+      <param name="width" type="GLsizei" /><br>
+      <param name="height" type="GLsizei" /><br>
+   </function><br>
+<br>
+   <function name="NamedRenderbufferStorageMultisample" offset="assign"><br>
+      <param name="renderbuffer" type="GLuint" /><br>
+      <param name="samples" type="GLsizei" /><br>
+      <param name="internalformat" type="GLenum" /><br>
+      <param name="width" type="GLsizei" /><br>
+      <param name="height" type="GLsizei" /><br>
+   </function><br>
+<br>
    <function name="GetNamedRenderbufferParameteriv" offset="assign"><br>
       <param name="renderbuffer" type="GLuint" /><br>
       <param name="pname" type="GLenum" /><br>
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c<br>
</span>index ae0dd76..fc76c4a 100644<br>
--- a/src/mesa/main/fbobject.c<br>
+++ b/src/mesa/main/fbobject.c<br>
@@ -1785,40 +1785,17 @@ invalidate_rb(GLuint key, void *data, void *userData)<br>
<div><div class="h5"><br>
<br>
 /**<br>
- * Helper function used by _mesa_RenderbufferStorage() and<br>
- * _mesa_RenderbufferStorageMultisample().<br>
- * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorage().<br>
+ * Helper function used by renderbuffer_storage_direct() and<br>
+ * renderbuffer_storage_target().<br>
+ * samples will be NO_SAMPLES if called by a non-multisample function.<br>
  */<br>
 static void<br>
-renderbuffer_storage(GLenum target, GLenum internalFormat,<br>
-                     GLsizei width, GLsizei height, GLsizei samples)<br>
+renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,<br>
+                     GLenum internalFormat, GLsizei width,<br>
+                     GLsizei height, GLsizei samples, const char *func)<br>
 {<br>
-   const char *func = samples == NO_SAMPLES ?<br>
-      "glRenderbufferStorage" : "glRenderbufferStorageMultisample";<br>
-   struct gl_renderbuffer *rb;<br>
    GLenum baseFormat;<br>
    GLenum sample_count_error;<br>
-   GET_CURRENT_CONTEXT(ctx);<br>
-<br>
-   if (MESA_VERBOSE & VERBOSE_API) {<br>
-      if (samples == NO_SAMPLES)<br>
-         _mesa_debug(ctx, "%s(%s, %s, %d, %d)\n",<br>
-                     func,<br>
-                     _mesa_lookup_enum_by_nr(target),<br>
-                     _mesa_lookup_enum_by_nr(internalFormat),<br>
-                     width, height);<br>
-      else<br>
-         _mesa_debug(ctx, "%s(%s, %s, %d, %d, %d)\n",<br>
-                     func,<br>
-                     _mesa_lookup_enum_by_nr(target),<br>
-                     _mesa_lookup_enum_by_nr(internalFormat),<br>
-                     width, height, samples);<br>
-   }<br>
-<br>
-   if (target != GL_RENDERBUFFER_EXT) {<br>
-      _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);<br>
-      return;<br>
-   }<br>
<br>
    baseFormat = _mesa_base_fbo_format(ctx, internalFormat);<br>
    if (baseFormat == 0) {<br>
</div></div>@@ -1828,12 +1805,14 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,<br>
<span class="">    }<br>
<br>
    if (width < 0 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) {<br>
-      _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func);<br>
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid width %d)", func,<br>
+                  width);<br>
       return;<br>
    }<br>
<br>
    if (height < 0 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) {<br>
-      _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func);<br>
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid height %d)", func,<br>
+                  height);<br>
       return;<br>
    }<br>
<br>
</span>@@ -1845,7 +1824,7 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,<br>
<span class="">       /* check the sample count;<br>
        * note: driver may choose to use more samples than what's requested<br>
        */<br>
-      sample_count_error = _mesa_check_sample_count(ctx, target,<br>
+      sample_count_error = _mesa_check_sample_count(ctx, GL_RENDERBUFFER,<br>
             internalFormat, samples);<br>
       if (sample_count_error != GL_NO_ERROR) {<br>
          _mesa_error(ctx, sample_count_error, "%s(samples)", func);<br>
</span>@@ -1853,7 +1832,6 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,<br>
<span class="">       }<br>
    }<br>
<br>
-   rb = ctx->CurrentRenderbuffer;<br></span></blockquote><div>I would move this check up into renderbuffer_storage_target and renderbuffer_storage_named since you can customize it to those functions.  Also, I think it makes more sense to check this right away before passing it into another function.  (Unless order of checking matters a lot for this entry point.) <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
    if (!rb) {<br>
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);<br>
</span>       return;<br>
@@ -1900,6 +1878,75 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,<br>
    }<br>
 }<br>
<br>
+/**<br>
+ * Helper function used by _mesa_NamedRenderbufferStorage*().<br>
<div><div class="h5">+ * samples will be NO_SAMPLES if called by a non-multisample function.<br>
+ */<br>
+static void<br>
+renderbuffer_storage_named(GLuint renderbuffer, GLenum internalFormat,<br>
+                           GLsizei width, GLsizei height, GLsizei samples,<br>
+                           const char *func)<br>
+{<br>
+   GET_CURRENT_CONTEXT(ctx);<br>
+<br>
+   if (MESA_VERBOSE & VERBOSE_API) {<br>
+      if (samples == NO_SAMPLES)<br>
+         _mesa_debug(ctx, "%s(%u, %s, %d, %d)\n",<br>
+                     func, renderbuffer,<br>
+                     _mesa_lookup_enum_by_nr(internalFormat),<br>
+                     width, height);<br>
+      else<br>
+         _mesa_debug(ctx, "%s(%u, %s, %d, %d, %d)\n",<br>
+                     func, renderbuffer,<br>
+                     _mesa_lookup_enum_by_nr(internalFormat),<br>
+                     width, height, samples);<br>
+   }<br>
+<br>
+   struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);<br>
+   if (rb == &DummyRenderbuffer) {<br>
+      /* ID was reserved, but no real renderbuffer object made yet */<br>
+      rb = NULL;<br>
+   }<br>
+<br>
+   renderbuffer_storage(ctx, rb, internalFormat, width, height, samples, func);<br>
+}<br>
+<br>
+/**<br>
+ * Helper function used by _mesa_RenderbufferStorage() and<br>
+ * _mesa_RenderbufferStorageMultisample().<br>
+ * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorage().<br>
+ */<br>
+static void<br>
+renderbuffer_storage_target(GLenum target, GLenum internalFormat,<br>
+                            GLsizei width, GLsizei height, GLsizei samples,<br>
+                            const char *func)<br>
+{<br>
+   GET_CURRENT_CONTEXT(ctx);<br>
+<br>
+   if (MESA_VERBOSE & VERBOSE_API) {<br>
+      if (samples == NO_SAMPLES)<br>
+         _mesa_debug(ctx, "%s(%s, %s, %d, %d)\n",<br>
+                     func,<br>
+                     _mesa_lookup_enum_by_nr(target),<br>
+                     _mesa_lookup_enum_by_nr(internalFormat),<br>
+                     width, height);<br>
+      else<br>
+         _mesa_debug(ctx, "%s(%s, %s, %d, %d, %d)\n",<br>
+                     func,<br>
+                     _mesa_lookup_enum_by_nr(target),<br>
+                     _mesa_lookup_enum_by_nr(internalFormat),<br>
+                     width, height, samples);<br>
+   }<br>
+<br>
+   if (target != GL_RENDERBUFFER_EXT) {<br>
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);<br>
+      return;<br>
+   }<br>
+<br>
+   renderbuffer_storage(ctx, ctx->CurrentRenderbuffer, internalFormat, width,<br>
+                        height, samples, func);<br>
+}<br>
+<br>
<br>
 void GLAPIENTRY<br>
 _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)<br>
</div></div>@@ -1959,7 +2006,8 @@ _mesa_RenderbufferStorage(GLenum target, GLenum internalFormat,<br>
<span class="">     * glRenderbufferStorageMultisample() with samples=0.  We pass in<br>
     * a token value here just for error reporting purposes.<br>
     */<br>
-   renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES);<br>
+   renderbuffer_storage_target(target, internalFormat, width, height,<br>
+                               NO_SAMPLES, "glRenderbufferStorage");<br>
 }<br>
<br>
<br>
</span>@@ -1968,10 +2016,10 @@ _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples,<br>
<span class="">                                      GLenum internalFormat,<br>
                                      GLsizei width, GLsizei height)<br>
 {<br>
-   renderbuffer_storage(target, internalFormat, width, height, samples);<br>
+   renderbuffer_storage_target(target, internalFormat, width, height,<br>
+                               samples, "glRenderbufferStorageMultisample");<br>
 }<br>
<br>
-<br>
 /**<br>
  * OpenGL ES version of glRenderBufferStorage.<br>
  */<br>
</span>@@ -1989,7 +2037,30 @@ _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,<br>
<span class="">       break;<br>
    }<br>
<br>
-   renderbuffer_storage(target, internalFormat, width, height, 0);<br>
+   renderbuffer_storage_target(target, internalFormat, width, height, 0,<br>
</span>+                               "glRenderbufferStorageEXT");<br>
<span class="">+}<br>
+<br>
+void GLAPIENTRY<br>
+_mesa_NamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat,<br>
+                               GLsizei width, GLsizei height)<br>
+{<br>
+   /* GL_ARB_fbo says calling this function is equivalent to calling<br>
+    * glRenderbufferStorageMultisample() with samples=0.  We pass in<br>
+    * a token value here just for error reporting purposes.<br>
+    */<br>
+   renderbuffer_storage_named(renderbuffer, internalformat, width, height,<br>
+                              NO_SAMPLES, "glNamedRenderbufferStorage");<br>
</span><span class="">+}<br>
+<br>
+void GLAPIENTRY<br>
+_mesa_NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples,<br>
+                                          GLenum internalformat,<br>
+                                          GLsizei width, GLsizei height)<br>
</span><span class="">+{<br>
+   renderbuffer_storage_named(renderbuffer, internalformat, width, height,<br>
+                              samples,<br>
+                              "glNamedRenderbufferStorageMultisample");<br>
 }<br>
<br>
<br></span></blockquote><div>These changes to render buffer parameteriv don't look like they belong in this commit.  Perhaps you meant to put them in your render buffer parameteriv commit and they slipped in here? <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
</span>@@ -2000,10 +2071,6 @@ get_render_buffer_parameteriv(struct gl_context *ctx,<br>
 {<br>
    const char *func = dsa ? "glGetNamedRenderbufferParameteriv" :<br>
                             "glGetRenderbufferParameteriv";<br>
-   if (!rb) {<br>
-      _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);<br>
-      return;<br>
-   }<br>
<br>
    /* No need to flush here since we're just quering state which is<br>
     * not effected by rendering.<br>
@@ -2053,6 +2120,12 @@ _mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)<br>
       return;<br>
    }<br>
<br>
+   if (!ctx->CurrentRenderbuffer) {<br>
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetRenderbufferParameteriv"<br>
+                  "(invalid renderbuffer)");<br>
+      return;<br>
+   }<br>
+<br>
    get_render_buffer_parameteriv(ctx, ctx->CurrentRenderbuffer, pname,<br>
                                  params, false);<br>
 }<br>
@@ -2070,6 +2143,12 @@ _mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname,<br>
       rb = NULL;<br>
    }<br>
<br>
+   if (!rb) {<br>
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetNamedRenderbufferParameteriv"<br>
+                  "(invalid renderbuffer name %i)", renderbuffer);<br>
+      return;<br>
+   }<br>
+<br>
    get_render_buffer_parameteriv(ctx, rb, pname, params, true);<br>
 }<br>
<br>
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h<br>
index b92149b..2c5273f 100644<br>
--- a/src/mesa/main/fbobject.h<br>
+++ b/src/mesa/main/fbobject.h<br>
@@ -128,14 +128,23 @@ _mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples,<br>
<span class=""><br>
 extern void GLAPIENTRY<br>
 _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,<br>
</span>-                          GLsizei width, GLsizei height);<br></blockquote><div>Other people frown on changing other function prototypes in new entry point commits.  "It's not part of this commit."  I don't think it's a big deal, though, so I'll leave it up to you whether you get rid of this or not.  It's a nice cleanup. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                           GLsizei width, GLsizei height);<br>
+<br>
+extern void GLAPIENTRY<br>
<span class="">+_mesa_NamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat,<br>
+                               GLsizei width, GLsizei height);<br>
+<br>
</span><span class="">+extern void GLAPIENTRY<br>
+_mesa_NamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples,<br>
+                                          GLenum internalformat,<br>
+                                          GLsizei width, GLsizei height);<br>
<br>
</span><span class=""> extern void GLAPIENTRY<br>
 _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);<br>
<br>
</span> extern void GLAPIENTRY<br>
 _mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname,<br>
-                                    GLint *params);<br></blockquote><div>See above comment. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                                 GLint *params);<br>
<br>
 void GLAPIENTRY<br>
 _mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname,<br>
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp<br>
index bb573d4..eb83e4d 100644<br>
--- a/src/mesa/main/tests/dispatch_sanity.cpp<br>
+++ b/src/mesa/main/tests/dispatch_sanity.cpp<br>
@@ -944,6 +944,8 @@ const struct function gl_core_functions_possible[] = {<br>
    { "glGetNamedBufferPointerv", 45, -1 },<br>
    { "glGetNamedBufferSubData", 45, -1 },<br>
<span class="">    { "glCreateRenderbuffers", 45, -1 },<br>
+   { "glNamedRenderbufferStorage", 45, -1 },<br>
+   { "glNamedRenderbufferStorageMultisample", 45, -1 },<br>
    { "glGetNamedRenderbufferParameteriv", 45, -1 },<br>
    { "glCreateTextures", 45, -1 },<br>
</span>    { "glTextureStorage1D", 45, -1 },<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.3.3<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>