From f52e63069a3fad23e03d42306a42bd20f0159da3 Mon Sep 17 00:00:00 2001 From: Bruce Cherniak Date: Thu, 4 May 2017 19:33:36 -0500 Subject: swr: move msaa resolve to generalized StoreTile v3: list piglit tests fixed by this patch. Fixed typo Tim pointed out. v2: Reword commit message to more closely adhere to community guidelines. This patch moves msaa resolve down into core/StoreTiles where the surface format conversion routines are available. The previous "experimental" resolve was limited to 8-bit unsigned render targets. This fixes a number of piglit msaa tests by adding resolve support for all the render target formats we support. Specifically: layered-rendering/gl-layer-render: fail->pass layered-rendering/gl-layer-render-storage: fail->pass multisample-formats *[2,4,8,16] gl_arb_texture_rg: crash->pass multisample-formats *[2,4,8,16] gl_ext_texture_snorm: crash->pass multisample-formats *[2,4,8,16] gl_arb_texture_float: fail->pass multisample-formats *[2,4,8,16] gl_arb_texture_rg-float: fail->pass MSAA is still disabled by default, but can be enabled with "export SWR_MSAA_MAX_COUNT=4" (1,2,4,8,16 are options) The default is 0, which is disabled. This patch improves the number of multisample-formats supported by swr, and fixes several crashes currently in the 17.1 branch. Therefore, it should be considered for inclusion in the 17.1 stable release. Being disabled by default, it poses no risk to most users of swr. Reviewed-by: Tim Rowley cc: mesa-stable@lists.freedesktop.org --- src/gallium/drivers/swr/swr_context.cpp | 77 +-------------------------------- 1 file changed, 2 insertions(+), 75 deletions(-) (limited to 'src/gallium/drivers/swr/swr_context.cpp') diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index e8e465196db..11ce3464d44 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -267,65 +267,6 @@ swr_resource_copy(struct pipe_context *pipe, } -/* XXX: This resolve is incomplete and suboptimal. It will be removed once the - * pipelined resolve blit works. */ -void -swr_do_msaa_resolve(struct pipe_resource *src_resource, - struct pipe_resource *dst_resource) -{ - /* This is a pretty dumb inline resolve. It only supports 8-bit formats - * (ex RGBA8/BGRA8) - which are most common display formats anyway. - */ - - /* quick check for 8-bit and number of components */ - uint8_t bits_per_component = - util_format_get_component_bits(src_resource->format, - UTIL_FORMAT_COLORSPACE_RGB, 0); - - /* Unsupported resolve format */ - assert(src_resource->format == dst_resource->format); - assert(bits_per_component == 8); - if ((src_resource->format != dst_resource->format) || - (bits_per_component != 8)) { - return; - } - - uint8_t src_num_comps = util_format_get_nr_components(src_resource->format); - - SWR_SURFACE_STATE *src_surface = &swr_resource(src_resource)->swr; - SWR_SURFACE_STATE *dst_surface = &swr_resource(dst_resource)->swr; - - uint32_t *src, *dst, offset; - uint32_t num_samples = src_surface->numSamples; - float recip_num_samples = 1.0f / num_samples; - for (uint32_t y = 0; y < src_surface->height; y++) { - for (uint32_t x = 0; x < src_surface->width; x++) { - float r = 0.0f; - float g = 0.0f; - float b = 0.0f; - float a = 0.0f; - for (uint32_t sampleNum = 0; sampleNum < num_samples; sampleNum++) { - offset = ComputeSurfaceOffset(x, y, 0, 0, sampleNum, 0, src_surface); - src = (uint32_t *) src_surface->pBaseAddress + offset/src_num_comps; - const uint32_t sample = *src; - r += (float)((sample >> 24) & 0xff) / 255.0f * recip_num_samples; - g += (float)((sample >> 16) & 0xff) / 255.0f * recip_num_samples; - b += (float)((sample >> 8) & 0xff) / 255.0f * recip_num_samples; - a += (float)((sample ) & 0xff) / 255.0f * recip_num_samples; - } - uint32_t result = 0; - result = ((uint8_t)(r * 255.0f) & 0xff) << 24; - result |= ((uint8_t)(g * 255.0f) & 0xff) << 16; - result |= ((uint8_t)(b * 255.0f) & 0xff) << 8; - result |= ((uint8_t)(a * 255.0f) & 0xff); - offset = ComputeSurfaceOffset(x, y, 0, 0, 0, 0, src_surface); - dst = (uint32_t *) dst_surface->pBaseAddress + offset/src_num_comps; - *dst = result; - } - } -} - - static void swr_blit(struct pipe_context *pipe, const struct pipe_blit_info *blit_info) { @@ -342,28 +283,14 @@ swr_blit(struct pipe_context *pipe, const struct pipe_blit_info *blit_info) debug_printf("swr_blit: color resolve : %d -> %d\n", info.src.resource->nr_samples, info.dst.resource->nr_samples); - /* Because the resolve is being done inline (not pipelined), - * resources need to be stored out of hottiles and the pipeline empty. - * - * Resources are marked unused following fence finish because all - * pipeline operations are complete. Validation of the blit will mark - * them are read/write again. - */ + /* Resolve is done as part of the surface store. */ swr_store_dirty_resource(pipe, info.src.resource, SWR_TILE_RESOLVED); - swr_store_dirty_resource(pipe, info.dst.resource, SWR_TILE_RESOLVED); - swr_fence_finish(pipe->screen, NULL, swr_screen(pipe->screen)->flush_fence, 0); - swr_resource_unused(info.src.resource); - swr_resource_unused(info.dst.resource); struct pipe_resource *src_resource = info.src.resource; struct pipe_resource *resolve_target = swr_resource(src_resource)->resolve_target; - /* Inline resolve samples into resolve target resource, then continue - * the blit. */ - swr_do_msaa_resolve(src_resource, resolve_target); - - /* The resolve target becomes the new source for the blit. */ + /* The resolve target becomes the new source for the blit. */ info.src.resource = resolve_target; } -- cgit v1.2.3