diff options
author | Tapani Pälli <[email protected]> | 2018-09-19 10:16:58 +0300 |
---|---|---|
committer | Tapani Pälli <[email protected]> | 2018-10-23 14:08:05 +0300 |
commit | 91d3a5d1a86915480e9e07cf370ad0e9743ab5b5 (patch) | |
tree | 43c2aeee25a1f8a1719ae65501e133d6f1dfd3d1 /src/mesa/drivers/dri/i965 | |
parent | bc021be78d2d5a36376494fca7eaf7f0728c6a29 (diff) |
i965: expose type of memcpy instead of memcpy function itself
There is currently no use of returned memcpy functions outside
intel_tiled_memcpy. Patch changes intel_get_memcpy to return memcpy
type instead of actual function. This makes it easier later to separate
streaming load copy in to own static library.
Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_pixel_read.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tex_image.c | 14 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tiled_memcpy.c | 58 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tiled_memcpy.h | 15 |
4 files changed, 63 insertions, 30 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_pixel_read.c b/src/mesa/drivers/dri/i965/intel_pixel_read.c index 09a3c3440fa..537ac057a36 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_read.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_read.c @@ -87,7 +87,7 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx, struct brw_bo *bo; uint32_t cpp; - mem_copy_fn mem_copy = NULL; + mem_copy_fn_type copy_type; /* This fastpath is restricted to specific renderbuffer types: * a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support @@ -125,7 +125,7 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx, if (rb->_BaseFormat == GL_RGB) return false; - if (!intel_get_memcpy(rb->Format, format, type, &mem_copy, &cpp)) + if (!intel_get_memcpy_type(rb->Format, format, type, ©_type, &cpp)) return false; if (!irb->mt || @@ -206,7 +206,7 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx, dst_pitch, irb->mt->surf.row_pitch_B, brw->has_swizzling, irb->mt->surf.tiling, - mem_copy + copy_type ); brw_bo_unmap(bo); diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c index 9775f788788..bdcdb7736e6 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_image.c +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c @@ -192,7 +192,7 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx, struct brw_bo *bo; uint32_t cpp; - mem_copy_fn mem_copy = NULL; + mem_copy_fn_type copy_type; /* This fastpath is restricted to specific texture types: * a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support @@ -222,7 +222,8 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx, if (ctx->_ImageTransferState) return false; - if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp)) + if (!intel_get_memcpy_type(texImage->TexFormat, format, type, ©_type, + &cpp)) return false; /* If this is a nontrivial texture view, let another path handle it instead. */ @@ -297,7 +298,7 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx, image->mt->surf.row_pitch_B, src_pitch, brw->has_swizzling, image->mt->surf.tiling, - mem_copy + copy_type ); brw_bo_unmap(bo); @@ -694,7 +695,7 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx, struct brw_bo *bo; uint32_t cpp; - mem_copy_fn mem_copy = NULL; + mem_copy_fn_type copy_type; /* This fastpath is restricted to specific texture types: * a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support @@ -728,7 +729,8 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx, if (texImage->_BaseFormat == GL_RGB) return false; - if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp)) + if (!intel_get_memcpy_type(texImage->TexFormat, format, type, ©_type, + &cpp)) return false; /* If this is a nontrivial texture view, let another path handle it instead. */ @@ -800,7 +802,7 @@ intel_gettexsubimage_tiled_memcpy(struct gl_context *ctx, dst_pitch, image->mt->surf.row_pitch_B, brw->has_swizzling, image->mt->surf.tiling, - mem_copy + copy_type ); brw_bo_unmap(bo); diff --git a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c index 7c6bde990d6..76a92b4d41f 100644 --- a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c +++ b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.c @@ -230,7 +230,7 @@ typedef void (*tile_copy_fn)(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, char *dst, const char *src, int32_t linear_pitch, uint32_t swizzle_bit, - mem_copy_fn mem_copy); + mem_copy_fn_type copy_type); /** * Copy texture data from linear to X tile layout. @@ -566,6 +566,19 @@ ytiled_to_linear(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, } } +static mem_copy_fn +choose_copy_function(mem_copy_fn_type copy_type) +{ + switch(copy_type) { + case INTEL_COPY_MEMCPY: + return memcpy; + case INTEL_COPY_RGBA8: + return rgba8_copy; + default: + assert(!"unreachable"); + } + return NULL; +} /** * Copy texture data from linear to X tile layout, faster. @@ -582,8 +595,10 @@ linear_to_xtiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, char *dst, const char *src, int32_t src_pitch, uint32_t swizzle_bit, - mem_copy_fn mem_copy) + mem_copy_fn_type copy_type) { + mem_copy_fn mem_copy = choose_copy_function(copy_type); + if (x0 == 0 && x3 == xtile_width && y0 == 0 && y1 == xtile_height) { if (mem_copy == memcpy) return linear_to_xtiled(0, 0, xtile_width, xtile_width, 0, xtile_height, @@ -625,8 +640,10 @@ linear_to_ytiled_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, char *dst, const char *src, int32_t src_pitch, uint32_t swizzle_bit, - mem_copy_fn mem_copy) + mem_copy_fn_type copy_type) { + mem_copy_fn mem_copy = choose_copy_function(copy_type); + if (x0 == 0 && x3 == ytile_width && y0 == 0 && y1 == ytile_height) { if (mem_copy == memcpy) return linear_to_ytiled(0, 0, ytile_width, ytile_width, 0, ytile_height, @@ -667,8 +684,10 @@ xtiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, char *dst, const char *src, int32_t dst_pitch, uint32_t swizzle_bit, - mem_copy_fn mem_copy) + mem_copy_fn_type copy_type) { + mem_copy_fn mem_copy = choose_copy_function(copy_type); + if (x0 == 0 && x3 == xtile_width && y0 == 0 && y1 == xtile_height) { if (mem_copy == memcpy) return xtiled_to_linear(0, 0, xtile_width, xtile_width, 0, xtile_height, @@ -709,8 +728,10 @@ ytiled_to_linear_faster(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, char *dst, const char *src, int32_t dst_pitch, uint32_t swizzle_bit, - mem_copy_fn mem_copy) + mem_copy_fn_type copy_type) { + mem_copy_fn mem_copy = choose_copy_function(copy_type); + if (x0 == 0 && x3 == ytile_width && y0 == 0 && y1 == ytile_height) { if (mem_copy == memcpy) return ytiled_to_linear(0, 0, ytile_width, ytile_width, 0, ytile_height, @@ -754,7 +775,7 @@ linear_to_tiled(uint32_t xt1, uint32_t xt2, uint32_t dst_pitch, int32_t src_pitch, bool has_swizzling, enum isl_tiling tiling, - mem_copy_fn mem_copy) + mem_copy_fn_type copy_type) { tile_copy_fn tile_copy; uint32_t xt0, xt3; @@ -822,7 +843,7 @@ linear_to_tiled(uint32_t xt1, uint32_t xt2, src + (ptrdiff_t)xt - xt1 + ((ptrdiff_t)yt - yt1) * src_pitch, src_pitch, swizzle_bit, - mem_copy); + copy_type); } } } @@ -845,7 +866,7 @@ tiled_to_linear(uint32_t xt1, uint32_t xt2, int32_t dst_pitch, uint32_t src_pitch, bool has_swizzling, enum isl_tiling tiling, - mem_copy_fn mem_copy) + mem_copy_fn_type copy_type) { tile_copy_fn tile_copy; uint32_t xt0, xt3; @@ -913,7 +934,7 @@ tiled_to_linear(uint32_t xt1, uint32_t xt2, src + (ptrdiff_t)xt * th + (ptrdiff_t)yt * src_pitch, dst_pitch, swizzle_bit, - mem_copy); + copy_type); } } } @@ -939,9 +960,12 @@ tiled_to_linear(uint32_t xt1, uint32_t xt2, * * \return true if the format and type combination are valid */ -bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, - GLenum type, mem_copy_fn *mem_copy, uint32_t *cpp) +bool +intel_get_memcpy_type(mesa_format tiledFormat, GLenum format, GLenum type, + mem_copy_fn_type *copy_type, uint32_t *cpp) { + *copy_type = INTEL_COPY_INVALID; + if (type == GL_UNSIGNED_INT_8_8_8_8_REV && !(format == GL_RGBA || format == GL_BGRA)) return false; /* Invalid type/format combination */ @@ -949,16 +973,16 @@ bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, if ((tiledFormat == MESA_FORMAT_L_UNORM8 && format == GL_LUMINANCE) || (tiledFormat == MESA_FORMAT_A_UNORM8 && format == GL_ALPHA)) { *cpp = 1; - *mem_copy = memcpy; + *copy_type = INTEL_COPY_MEMCPY; } else if ((tiledFormat == MESA_FORMAT_B8G8R8A8_UNORM) || (tiledFormat == MESA_FORMAT_B8G8R8X8_UNORM) || (tiledFormat == MESA_FORMAT_B8G8R8A8_SRGB) || (tiledFormat == MESA_FORMAT_B8G8R8X8_SRGB)) { *cpp = 4; if (format == GL_BGRA) { - *mem_copy = memcpy; + *copy_type = INTEL_COPY_MEMCPY; } else if (format == GL_RGBA) { - *mem_copy = rgba8_copy; + *copy_type = INTEL_COPY_RGBA8; } } else if ((tiledFormat == MESA_FORMAT_R8G8B8A8_UNORM) || (tiledFormat == MESA_FORMAT_R8G8B8X8_UNORM) || @@ -969,13 +993,13 @@ bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, /* Copying from RGBA to BGRA is the same as BGRA to RGBA so we can * use the same function. */ - *mem_copy = rgba8_copy; + *copy_type = INTEL_COPY_RGBA8; } else if (format == GL_RGBA) { - *mem_copy = memcpy; + *copy_type = INTEL_COPY_MEMCPY; } } - if (!(*mem_copy)) + if (*copy_type == INTEL_COPY_INVALID) return false; return true; diff --git a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h index 62ec8847fbc..70934410298 100644 --- a/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h +++ b/src/mesa/drivers/dri/i965/intel_tiled_memcpy.h @@ -35,6 +35,12 @@ #include <stdint.h> #include "main/mtypes.h" +typedef enum { + INTEL_COPY_MEMCPY = 0, + INTEL_COPY_RGBA8, + INTEL_COPY_INVALID, +} mem_copy_fn_type; + typedef void *(*mem_copy_fn)(void *dest, const void *src, size_t n); void @@ -44,7 +50,7 @@ linear_to_tiled(uint32_t xt1, uint32_t xt2, uint32_t dst_pitch, int32_t src_pitch, bool has_swizzling, enum isl_tiling tiling, - mem_copy_fn mem_copy); + mem_copy_fn_type copy_type); void tiled_to_linear(uint32_t xt1, uint32_t xt2, @@ -53,9 +59,10 @@ tiled_to_linear(uint32_t xt1, uint32_t xt2, int32_t dst_pitch, uint32_t src_pitch, bool has_swizzling, enum isl_tiling tiling, - mem_copy_fn mem_copy); + mem_copy_fn_type copy_type); -bool intel_get_memcpy(mesa_format tiledFormat, GLenum format, - GLenum type, mem_copy_fn *mem_copy, uint32_t *cpp); +bool intel_get_memcpy_type(mesa_format tiledFormat, GLenum format, + GLenum type, mem_copy_fn_type *copy_type, + uint32_t *cpp); #endif /* INTEL_TILED_MEMCPY */ |