mesa: Inherit texture view multi-sample information from the original texture images.
authorHenri Verbeet <hverbeet@gmail.com>
Mon, 26 Mar 2018 14:36:08 +0000 (19:06 +0430)
committerHenri Verbeet <hverbeet@gmail.com>
Thu, 29 Mar 2018 10:08:25 +0000 (14:38 +0430)
Found running "The Witness" in Wine. Without this patch, texture views created
on multi-sample textures would have a GL_TEXTURE_SAMPLES of 0. All things
considered such views actually work surprisingly well, but when combined with
(plain) multi-sample textures in a framebuffer object, the resulting FBO is
incomplete because the sample counts don't match.

CC: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/teximage.c
src/mesa/main/teximage.h
src/mesa/main/textureview.c

index 9e139d746f10816a26a5e94918f45c008ed46a0e..8f5351085c55cb04aa7e1a756b6494b2c4c1dafe 100644 (file)
@@ -837,8 +837,8 @@ clear_teximage_fields(struct gl_texture_image *img)
  * Fills in the fields of \p img with the given information.
  * Note: width, height and depth include the border.
  */
-static void
-init_teximage_fields_ms(struct gl_context *ctx,
+void
+_mesa_init_teximage_fields_ms(struct gl_context *ctx,
                         struct gl_texture_image *img,
                         GLsizei width, GLsizei height, GLsizei depth,
                         GLint border, GLenum internalFormat,
@@ -950,8 +950,8 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
                            GLint border, GLenum internalFormat,
                            mesa_format format)
 {
-   init_teximage_fields_ms(ctx, img, width, height, depth, border,
-                           internalFormat, format, 0, GL_TRUE);
+   _mesa_init_teximage_fields_ms(ctx, img, width, height, depth, border,
+                                 internalFormat, format, 0, GL_TRUE);
 }
 
 
@@ -5891,9 +5891,9 @@ texture_image_multisample(struct gl_context *ctx, GLuint dims,
 
    if (_mesa_is_proxy_texture(target)) {
       if (samplesOK && dimensionsOK && sizeOK) {
-         init_teximage_fields_ms(ctx, texImage, width, height, depth, 0,
-                                 internalformat, texFormat,
-                                 samples, fixedsamplelocations);
+         _mesa_init_teximage_fields_ms(ctx, texImage, width, height, depth, 0,
+                                       internalformat, texFormat,
+                                       samples, fixedsamplelocations);
       }
       else {
          /* clear all image fields */
@@ -5920,9 +5920,9 @@ texture_image_multisample(struct gl_context *ctx, GLuint dims,
 
       ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
 
-      init_teximage_fields_ms(ctx, texImage, width, height, depth, 0,
-                              internalformat, texFormat,
-                              samples, fixedsamplelocations);
+      _mesa_init_teximage_fields_ms(ctx, texImage, width, height, depth, 0,
+                                    internalformat, texFormat,
+                                    samples, fixedsamplelocations);
 
       if (width > 0 && height > 0 && depth > 0) {
          if (memObj) {
index 2e950bf42bb3f17825dfbc40de13a484115527e6..bf790af2766d76ecfa6d69594660a9a6a7c02c9b 100644 (file)
@@ -130,6 +130,14 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
                            GLsizei width, GLsizei height, GLsizei depth,
                            GLint border, GLenum internalFormat,
                            mesa_format format);
+extern void
+_mesa_init_teximage_fields_ms(struct gl_context *ctx,
+                              struct gl_texture_image *img,
+                              GLsizei width, GLsizei height, GLsizei depth,
+                              GLint border, GLenum internalFormat,
+                              mesa_format format,
+                              GLuint numSamples,
+                              GLboolean fixedSampleLocations);
 
 
 extern mesa_format
index 89af068fae84d7722f8d666c07a91851041fe04a..9a064ffd7184e522896a70b09c6bc44faff0af26 100644 (file)
@@ -304,7 +304,8 @@ initialize_texture_fields(struct gl_context *ctx,
                           struct gl_texture_object *texObj,
                           GLint levels,
                           GLsizei width, GLsizei height, GLsizei depth,
-                          GLenum internalFormat, mesa_format texFormat)
+                          GLenum internalFormat, mesa_format texFormat,
+                          GLuint numSamples, GLboolean fixedSampleLocations)
 {
    const GLuint numFaces = _mesa_num_tex_faces(target);
    GLint level, levelWidth = width, levelHeight = height, levelDepth = depth;
@@ -326,9 +327,10 @@ initialize_texture_fields(struct gl_context *ctx,
             return GL_FALSE;
          }
 
-         _mesa_init_teximage_fields(ctx, texImage,
+         _mesa_init_teximage_fields_ms(ctx, texImage,
                                     levelWidth, levelHeight, levelDepth,
-                                    0, internalFormat, texFormat);
+                                    0, internalFormat, texFormat,
+                                    numSamples, fixedSampleLocations);
       }
 
       _mesa_next_mipmap_level_size(target, 0,
@@ -676,7 +678,9 @@ texture_view(struct gl_context *ctx, struct gl_texture_object *origTexObj,
 
    if (!initialize_texture_fields(ctx, target, texObj, newViewNumLevels,
                                   width, height, depth,
-                                  internalformat, texFormat)) {
+                                  internalformat, texFormat,
+                                  origTexImage->NumSamples,
+                                  origTexImage->FixedSampleLocations)) {
       return; /* Already recorded error */
    }