Mesa (main): i915g: Add support for blitting compressed textures.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 02:41:34 UTC 2021


Module: Mesa
Branch: main
Commit: f46850d3b30ae4f99b807f6ef1e1982184d14e76
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f46850d3b30ae4f99b807f6ef1e1982184d14e76

Author: Emma Anholt <emma at anholt.net>
Date:   Fri Aug 13 16:57:15 2021 -0700

i915g: Add support for blitting compressed textures.

Previously we would assertion fail on s3tc uploads.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12367>

---

 .../drivers/i915/ci/piglit-i915-g33-fails.txt      |  7 -----
 src/gallium/drivers/i915/i915_surface.c            | 36 ++++++++++++++--------
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
index 284fbab5045..d0994dded64 100644
--- a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
+++ b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
@@ -258,7 +258,6 @@ spec at arb_point_parameters@arb_point_parameters-point-attenuation at Aliased combina
 spec at arb_provoking_vertex@arb-provoking-vertex-render,Fail
 spec at arb_sampler_objects@gl_ext_texture_srgb_decode,Fail
 spec at arb_shader_texture_lod@execution at glsl-fs-texturelod-01,Fail
-spec at arb_texture_compression@fbo-generatemipmap-formats,Crash
 spec at arb_texture_compression@texwrap formats bordercolor,Fail
 spec at arb_texture_compression@texwrap formats bordercolor at GL_COMPRESSED_ALPHA- border color only,Fail
 spec at arb_texture_compression@texwrap formats bordercolor at GL_COMPRESSED_INTENSITY- border color only,Fail
@@ -429,15 +428,9 @@ spec at ext_packed_depth_stencil@fbo-depthstencil-gl_depth24_stencil8-clear,Fail
 spec at ext_packed_depth_stencil@fbo-stencil-gl_depth24_stencil8-blit,Fail
 spec at ext_packed_depth_stencil@texwrap formats bordercolor,Fail
 spec at ext_packed_depth_stencil@texwrap formats bordercolor at GL_DEPTH24_STENCIL8- border color only,Fail
-spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_rgb_s3tc_dxt1_ext,Crash
-spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_rgba_s3tc_dxt1_ext,Crash
-spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_rgba_s3tc_dxt3_ext,Crash
-spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_rgba_s3tc_dxt5_ext,Crash
-spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_alpha_s3tc_dxt1_ext,Crash
 spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_alpha_s3tc_dxt3_ext,Fail
 spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_alpha_s3tc_dxt5_ext,Crash
 spec at ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_s3tc_dxt1_ext,Fail
-spec at ext_texture_compression_s3tc@fbo-generatemipmap-formats,Crash
 spec at ext_texture_compression_s3tc@s3tc-targeted,Fail
 spec at ext_texture_compression_s3tc@texwrap formats bordercolor,Fail
 spec at ext_texture_compression_s3tc@texwrap formats bordercolor at GL_COMPRESSED_RGBA_S3TC_DXT1_EXT- border color only,Fail
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index 8e446a8d0c2..79e2d657e61 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -221,20 +221,32 @@ i915_surface_copy_blitter(struct pipe_context *pipe, struct pipe_resource *dst,
       assert(src_box->z == 0);
    src_offset = i915_texture_offset(src_tex, src_level, src_box->z);
 
-   assert(util_format_get_blocksize(dpt->format) ==
-          util_format_get_blocksize(spt->format));
-   assert(util_format_get_blockwidth(dpt->format) ==
-          util_format_get_blockwidth(spt->format));
-   assert(util_format_get_blockheight(dpt->format) ==
-          util_format_get_blockheight(spt->format));
-   assert(util_format_get_blockwidth(dpt->format) == 1);
-   assert(util_format_get_blockheight(dpt->format) == 1);
-
-   i915_copy_blit(i915_context(pipe), util_format_get_blocksize(dpt->format),
+   int block_width = util_format_get_blockwidth(dpt->format);
+   int block_height = util_format_get_blockheight(dpt->format);
+   int block_size = util_format_get_blocksize(dpt->format);
+   assert(util_format_get_blocksize(spt->format) == block_size);
+   assert(util_format_get_blockwidth(spt->format) == block_width);
+   assert(util_format_get_blockheight(spt->format) == block_height);
+
+   dstx /= block_width;
+   dsty /= block_height;
+   int srcx = src_box->x / block_width;
+   int srcy = src_box->y / block_height;
+   int width = DIV_ROUND_UP(src_box->width, block_width);
+   int height = DIV_ROUND_UP(src_box->height, block_height);
+
+   if (block_size > 4) {
+      srcx *= (block_size / 4);
+      dstx *= (block_size / 4);
+      width *= (block_size / 4);
+      block_size = 4;
+   }
+
+   i915_copy_blit(i915_context(pipe), block_size,
                   (unsigned short)src_tex->stride, src_tex->buffer, src_offset,
                   (unsigned short)dst_tex->stride, dst_tex->buffer, dst_offset,
-                  (short)src_box->x, (short)src_box->y, (short)dstx,
-                  (short)dsty, (short)src_box->width, (short)src_box->height);
+                  (short)srcx, (short)srcy, (short)dstx, (short)dsty,
+                  (short)width, (short)height);
 }
 
 static void



More information about the mesa-commit mailing list