From f46850d3b30ae4f99b807f6ef1e1982184d14e76 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Fri, 13 Aug 2021 16:57:15 -0700 Subject: [PATCH] i915g: Add support for blitting compressed textures. Previously we would assertion fail on s3tc uploads. Part-of: --- .../drivers/i915/ci/piglit-i915-g33-fails.txt | 7 ---- src/gallium/drivers/i915/i915_surface.c | 34 +++++++++++++------ 2 files changed, 23 insertions(+), 18 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@arb_point_parameters@arb_point_parameters-point-attenuation@Aliased combina spec@arb_provoking_vertex@arb-provoking-vertex-render,Fail spec@arb_sampler_objects@gl_ext_texture_srgb_decode,Fail spec@arb_shader_texture_lod@execution@glsl-fs-texturelod-01,Fail -spec@arb_texture_compression@fbo-generatemipmap-formats,Crash spec@arb_texture_compression@texwrap formats bordercolor,Fail spec@arb_texture_compression@texwrap formats bordercolor@GL_COMPRESSED_ALPHA- border color only,Fail spec@arb_texture_compression@texwrap formats bordercolor@GL_COMPRESSED_INTENSITY- border color only,Fail @@ -429,15 +428,9 @@ spec@ext_packed_depth_stencil@fbo-depthstencil-gl_depth24_stencil8-clear,Fail spec@ext_packed_depth_stencil@fbo-stencil-gl_depth24_stencil8-blit,Fail spec@ext_packed_depth_stencil@texwrap formats bordercolor,Fail spec@ext_packed_depth_stencil@texwrap formats bordercolor@GL_DEPTH24_STENCIL8- border color only,Fail -spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_rgb_s3tc_dxt1_ext,Crash -spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_rgba_s3tc_dxt1_ext,Crash -spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_rgba_s3tc_dxt3_ext,Crash -spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_rgba_s3tc_dxt5_ext,Crash -spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_alpha_s3tc_dxt1_ext,Crash spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_alpha_s3tc_dxt3_ext,Fail spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_alpha_s3tc_dxt5_ext,Crash spec@ext_texture_compression_s3tc@compressedteximage gl_compressed_srgb_s3tc_dxt1_ext,Fail -spec@ext_texture_compression_s3tc@fbo-generatemipmap-formats,Crash spec@ext_texture_compression_s3tc@s3tc-targeted,Fail spec@ext_texture_compression_s3tc@texwrap formats bordercolor,Fail spec@ext_texture_compression_s3tc@texwrap formats bordercolor@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); + 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); - i915_copy_blit(i915_context(pipe), util_format_get_blocksize(dpt->format), + 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