[Mesa-dev] [PATCH] mesa: Inherit texture view multi-sample information from the original texture images.
Henri Verbeet
hverbeet at gmail.com
Tue Mar 27 13:52:02 UTC 2018
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.
Signed-off-by: Henri Verbeet <hverbeet at gmail.com>
---
src/mesa/main/teximage.c | 20 ++++++++++----------
src/mesa/main/teximage.h | 8 ++++++++
src/mesa/main/textureview.c | 12 ++++++++----
3 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 9e139d746f..8f5351085c 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -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) {
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 2e950bf42b..bf790af276 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -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
diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
index 89af068fae..9a064ffd71 100644
--- a/src/mesa/main/textureview.c
+++ b/src/mesa/main/textureview.c
@@ -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 */
}
--
2.11.0
More information about the mesa-dev
mailing list