diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-06-18 10:43:07 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-06-20 08:22:38 -0700 |
commit | 035a07c0ae82b01b6df3315d2865aa82de915906 (patch) | |
tree | 86185e9ec25bc06c21ef1dd4b03e345b9d8ee7ca /src/gallium/drivers/panfrost | |
parent | 7b46f09f26c3f4377f46d145344f98d5b27b0b00 (diff) |
panfrost: Switch to lima tiling
Lima and Panfrost both have implementations of software tiling
(the Lima one was forked off the Panfrost one which was forked off the
original Lima one...). Switch to the most recent Lima code, since it's
more complete than ours at this point.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost')
-rw-r--r-- | src/gallium/drivers/panfrost/meson.build | 2 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_resource.c | 37 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_swizzle.c | 196 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_swizzle.h | 39 |
5 files changed, 11 insertions, 265 deletions
diff --git a/src/gallium/drivers/panfrost/meson.build b/src/gallium/drivers/panfrost/meson.build index 94b89098bc8..d6fe4fc49a6 100644 --- a/src/gallium/drivers/panfrost/meson.build +++ b/src/gallium/drivers/panfrost/meson.build @@ -53,7 +53,6 @@ files_panfrost = files( 'pan_allocate.c', 'pan_assemble.c', 'pan_format.c', - 'pan_swizzle.c', 'pan_blending.c', 'pan_blend_shaders.c', 'pan_pretty_print.c', @@ -69,6 +68,7 @@ panfrost_includes = [ inc_gallium_aux, inc_include, inc_src, + inc_panfrost, include_directories('include'), include_directories('midgard'), include_directories('bifrost'), diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 470a259419b..c359d2ddafd 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -26,7 +26,6 @@ #include <errno.h> #include "pan_context.h" -#include "pan_swizzle.h" #include "pan_format.h" #include "util/macros.h" @@ -2799,7 +2798,6 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags) panfrost_emit_tiler_payload(ctx); panfrost_invalidate_frame(ctx); panfrost_default_shader_backend(ctx); - panfrost_generate_space_filler_indices(); return gallium; } diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 4f4499aa403..5b84daf3a3f 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -43,8 +43,8 @@ #include "pan_context.h" #include "pan_screen.h" #include "pan_resource.h" -#include "pan_swizzle.h" #include "pan_util.h" +#include "pan_tiling.h" static struct pipe_resource * panfrost_resource_from_handle(struct pipe_screen *pscreen, @@ -524,32 +524,9 @@ panfrost_transfer_map(struct pipe_context *pctx, } static void -panfrost_tile_texture(struct panfrost_screen *screen, struct panfrost_resource *rsrc, struct panfrost_gtransfer *trans) -{ - struct panfrost_bo *bo = (struct panfrost_bo *)rsrc->bo; - - unsigned level = trans->base.level; - - panfrost_texture_swizzle( - trans->base.box.x, - trans->base.box.y, - trans->base.box.width, - trans->base.box.height, - util_format_get_blocksize(rsrc->base.format), - u_minify(rsrc->base.width0, level), - trans->map, - bo->cpu - + bo->slices[level].offset - + bo->cubemap_stride * trans->base.box.z - ); -} - -static void panfrost_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer) { - struct panfrost_context *ctx = pan_context(pctx); - /* Gallium expects writeback here, so we tile */ struct panfrost_gtransfer *trans = pan_transfer(transfer); @@ -563,10 +540,16 @@ panfrost_transfer_unmap(struct pipe_context *pctx, if (bo->layout == PAN_AFBC) { DBG("Unimplemented: writes to AFBC\n"); } else if (bo->layout == PAN_TILED) { - struct pipe_context *gallium = (struct pipe_context *) ctx; - struct panfrost_screen *screen = pan_screen(gallium->screen); + unsigned level = transfer->level; assert(transfer->box.depth == 1); - panfrost_tile_texture(screen, prsrc, trans); + + panfrost_store_tiled_image( + bo->cpu + bo->slices[level].offset, + trans->map, + &transfer->box, + bo->slices[level].stride, + transfer->stride, + util_format_get_blocksize(prsrc->base.format)); } } } diff --git a/src/gallium/drivers/panfrost/pan_swizzle.c b/src/gallium/drivers/panfrost/pan_swizzle.c deleted file mode 100644 index 60f6953443f..00000000000 --- a/src/gallium/drivers/panfrost/pan_swizzle.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2012-2013 Luc Verhaegen <[email protected]> - * Copyright (c) 2018 Alyssa Rosenzweig <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <stdio.h> -#include "pan_swizzle.h" -#include "pan_allocate.h" - -/* Space a group of 4-bits out. For instance, 0x7 -- that is, 0b111 -- would - * become 0b10101 */ - -static inline int -space_bits_4(int i) -{ - return ((i & 0x8) << 3) | - ((i & 0x4) << 2) | - ((i & 0x2) << 1) | - ((i & 0x1) << 0); -} - -/* Generate lookup table for the space filler curve. Note this is a 1:1 - * mapping, just with bits twiddled around. */ - -uint32_t space_filler[16][16]; -uint32_t space_filler_packed4[16][4]; - -void -panfrost_generate_space_filler_indices() -{ - for (int y = 0; y < 16; ++y) { - for (int x = 0; x < 16; ++x) { - space_filler[y][x] = - space_bits_4(y ^ x) | (space_bits_4(y) << 1); - } - - for (int q = 0; q < 4; ++q) { - space_filler_packed4[y][q] = - (space_filler[y][(q * 4) + 0] << 0) | - (space_filler[y][(q * 4) + 1] << 8) | - (space_filler[y][(q * 4) + 2] << 16) | - (space_filler[y][(q * 4) + 3] << 24); - } - } -} - -static void -swizzle_bpp1_align16(int width, int height, int source_stride, int block_pitch, - const uint8_t *pixels, - uint8_t *ldest) -{ - for (int y = 0; y < height; ++y) { - { - int block_y = y & ~(0x0f); - int rem_y = y & 0x0f; - uint8_t *block_start_s = ldest + (block_y * block_pitch); - const uint8_t *source_start = pixels + (y * source_stride); - const uint8_t *source_end = source_start + width; - - /* Operate on blocks of 16 pixels to minimise bookkeeping */ - - for (; source_start < source_end; block_start_s += 16 * 16, source_start += 16) { - const uint32_t *src_32 = (const uint32_t *) source_start; - - for (int q = 0; q < 4; ++q) { - uint32_t src = src_32[q]; - uint32_t spaced = space_filler_packed4[rem_y][q]; - uint16_t *bs = (uint16_t *) block_start_s; - - int spacedA = (spaced >> 0) & 0xFF; - int spacedB = (spaced >> 16) & 0xFF; - - bs[spacedA >> 1] = (src >> 0) & 0xFFFF; - bs[spacedB >> 1] = (src >> 16) & 0xFFFF; - } - } - } - - ++y; - - if (y >= height) - break; - - { - int block_y = y & ~(0x0f); - int rem_y = y & 0x0f; - uint8_t *block_start_s = ldest + (block_y * block_pitch); - const uint8_t *source_start = pixels + (y * source_stride); - const uint8_t *source_end = source_start + width; - - /* Operate on blocks of 16 pixels to minimise bookkeeping */ - - for (; source_start < source_end; block_start_s += 16 * 16, source_start += 16) { - const uint32_t *src_32 = (const uint32_t *) source_start; - - for (int q = 0; q < 4; ++q) { - uint32_t src = src_32[q]; - uint32_t spaced = space_filler_packed4[rem_y][q]; - - block_start_s[(spaced >> 0) & 0xFF] = (src >> 0) & 0xFF; - block_start_s[(spaced >> 8) & 0xFF] = (src >> 8) & 0xFF; - - block_start_s[(spaced >> 16) & 0xFF] = (src >> 16) & 0xFF; - block_start_s[(spaced >> 24) & 0xFF] = (src >> 24) & 0xFF; - } - } - } - - } -} - -static void -swizzle_bpp4_align16(int width, int height, int source_stride, int block_pitch, - const uint32_t *pixels, - uint32_t *ldest) -{ - for (int y = 0; y < height; ++y) { - int block_y = y & ~(0x0f); - int rem_y = y & 0x0f; - uint32_t *block_start_s = ldest + (block_y * block_pitch); - const uint32_t *source_start = pixels + (y * source_stride); - const uint32_t *source_end = source_start + width; - - /* Operate on blocks of 16 pixels to minimise bookkeeping */ - - for (; source_start < source_end; block_start_s += 16 * 16, source_start += 16) { - for (int j = 0; j < 16; ++j) - block_start_s[space_filler[rem_y][j]] = source_start[j]; - } - } -} - -void -panfrost_texture_swizzle(unsigned off_x, - unsigned off_y, - int width, int height, int bytes_per_pixel, int dest_width, - const uint8_t *pixels, - uint8_t *ldest) -{ - /* Calculate maximum size, overestimating a bit */ - int block_pitch = ALIGN(dest_width, 16) >> 4; - - /* Strides must be tight, since we're only ever called indirectly */ - int source_stride = width * bytes_per_pixel; - - /* Use fast path if available */ - if (!(off_x || off_y) && (width == dest_width)) { - if (bytes_per_pixel == 4 && (ALIGN(width, 16) == width)) { - swizzle_bpp4_align16(width, height, source_stride >> 2, (block_pitch * 256 >> 4), (const uint32_t *) pixels, (uint32_t *) ldest); - return; - } else if (bytes_per_pixel == 1 && (ALIGN(width, 16) == width)) { - swizzle_bpp1_align16(width, height, source_stride, (block_pitch * 256 >> 4), pixels, (uint8_t *) ldest); - return; - } - } - - /* Otherwise, default back on generic path */ - - for (int y = 0; y < height; ++y) { - int block_y = (y + off_y) >> 4; - int rem_y = (y + off_y) & 0x0F; - int block_start_s = block_y * block_pitch * 256; - int source_start = y * source_stride; - - for (int x = 0; x < width; ++x) { - int block_x_s = ((x + off_x) >> 4) * 256; - int rem_x = (x + off_x) & 0x0F; - - int index = space_filler[rem_y][rem_x]; - const uint8_t *source = &pixels[source_start + bytes_per_pixel * x]; - uint8_t *dest = ldest + bytes_per_pixel * (block_start_s + block_x_s + index); - - for (int b = 0; b < bytes_per_pixel; ++b) - dest[b] = source[b]; - } - } -} diff --git a/src/gallium/drivers/panfrost/pan_swizzle.h b/src/gallium/drivers/panfrost/pan_swizzle.h deleted file mode 100644 index f4188f13930..00000000000 --- a/src/gallium/drivers/panfrost/pan_swizzle.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * © Copyright 2018 Alyssa Rosenzweig - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#ifndef __TEXSWZ_H__ -#define __TEXSWZ_H__ - -#include <stdint.h> - -void -panfrost_generate_space_filler_indices(void); - -void -panfrost_texture_swizzle(unsigned off_x, unsigned off_y, - int width, int height, int bytes_per_pixel, int dest_width, - const uint8_t *pixels, - uint8_t *ldest); - -#endif |