From d9eae63792a011535d246c74d2dcb7296c2d9b3d Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 29 Mar 2010 19:52:29 +0200 Subject: gallium: add new texture formats These are needed for DX10 and/or OGL3.3. This just adds the formats nothing handles them yet. PIPE_FORMAT_R1_UNORM can't be used currently as it requires special filter. Need to reclassify compressed formats at some point. --- src/gallium/auxiliary/util/u_format.csv | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index d2a925141b..4494f26f0f 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -80,6 +80,7 @@ PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, r PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb +PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb @@ -92,6 +93,7 @@ PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, r PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb # Depth-stencil formats +# UNORM isn't really fitting. Only applies to depth, not stencil component PIPE_FORMAT_S8_UNORM , plain, 1, 1, un8 , , , , _x__, zs PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs @@ -100,6 +102,7 @@ PIPE_FORMAT_Z24S8_UNORM , plain, 1, 1, un24, un8 , , , xy__, z PIPE_FORMAT_S8Z24_UNORM , plain, 1, 1, un8 , un24, , , yx__, zs PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, un8 , , , x___, zs PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un8 , un24, , , y___, zs +PIPE_FORMAT_Z32_FLOAT_S8X24_UNORM , plain, 1, 1, f32, un8 , un24, , xy__, zs # YUV formats # http://www.fourcc.org/yuv.php#UYVY @@ -108,6 +111,15 @@ PIPE_FORMAT_UYVY , subsampled, 2, 1, x32 , , , , xyz # XXX: u_tile.c's ycbcr_get_tile_rgba actually interprets it as VYUY but the # intent should be to match D3DFMT_YUY2 PIPE_FORMAT_YUYV , subsampled, 2, 1, x32 , , , , xyz1, yuv +# same subsampling but with rgb channels +PIPE_FORMAT_R8G8_B8G8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb +PIPE_FORMAT_G8R8_G8B8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb + +# some special formats not fitting anywhere else +PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb +PIPE_FORMAT_R11G11B10_FLOAT , plain, 1, 1, f11 , f11 , f10 , , xyz1, rgb +PIPE_FORMAT_R9G9B9E5_FLOAT , compressed, 1, 1, x32 , , , , xyz1, rgb +PIPE_FORMAT_R1_UNORM , compressed, 8, 1, x8 , , , , x001, rgb # Compressed formats PIPE_FORMAT_DXT1_RGB , compressed, 4, 4, x64 , , , , xyz1, rgb @@ -118,6 +130,10 @@ PIPE_FORMAT_DXT1_SRGB , compressed, 4, 4, x64 , , , , xy PIPE_FORMAT_DXT1_SRGBA , compressed, 4, 4, x64 , , , , xyzw, srgb PIPE_FORMAT_DXT3_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb PIPE_FORMAT_DXT5_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_RGTC1_UNORM , compressed, 4, 4, x64, , , , x001, rgb +PIPE_FORMAT_RGTC1_SNORM , compressed, 4, 4, x64, , , , x001, rgb +PIPE_FORMAT_RGTC2_UNORM , compressed, 4, 4, x128, , , , xy01, rgb +PIPE_FORMAT_RGTC2_SNORM , compressed, 4, 4, x128, , , , xy01, rgb # Straightforward D3D10-like formats (also used for # vertex buffer element description) @@ -153,6 +169,10 @@ PIPE_FORMAT_R32_FIXED , plain, 1, 1, h32 , , , , x001, r PIPE_FORMAT_R32G32_FIXED , plain, 1, 1, h32 , h32 , , , xy01, rgb PIPE_FORMAT_R32G32B32_FIXED , plain, 1, 1, h32 , h32 , h32 , , xyz1, rgb PIPE_FORMAT_R32G32B32A32_FIXED , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb +PIPE_FORMAT_R16_FLOAT , plain, 1, 1, f16 , , , , x001, rgb +PIPE_FORMAT_R16G16_FLOAT , plain, 1, 1, f16 , f16 , , , xy01, rgb +PIPE_FORMAT_R16G16B16_FLOAT , plain, 1, 1, f16 , f16 , f16 , , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_FLOAT , plain, 1, 1, f16 , f16 , f16 , f16 , xyzw, rgb PIPE_FORMAT_R16_UNORM , plain, 1, 1, un16, , , , x001, rgb PIPE_FORMAT_R16G16_UNORM , plain, 1, 1, un16, un16, , , xy01, rgb PIPE_FORMAT_R16G16B16_UNORM , plain, 1, 1, un16, un16, un16, , xyz1, rgb -- cgit v1.2.3 From 9de2ee646ad09676817c558a6d02f5b2bb7bb173 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 29 Mar 2010 20:00:41 +0200 Subject: gallium: fix bogus depth/stencil format names (and channel descriptions) only the depth part is normalized, stencil part isn't. --- src/gallium/auxiliary/util/u_format.csv | 19 +++++++++---------- src/gallium/include/pipe/p_format.h | 8 ++++---- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 4494f26f0f..2b2230f308 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -93,16 +93,15 @@ PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, r PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb # Depth-stencil formats -# UNORM isn't really fitting. Only applies to depth, not stencil component -PIPE_FORMAT_S8_UNORM , plain, 1, 1, un8 , , , , _x__, zs -PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs -PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs -PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs -PIPE_FORMAT_Z24S8_UNORM , plain, 1, 1, un24, un8 , , , xy__, zs -PIPE_FORMAT_S8Z24_UNORM , plain, 1, 1, un8 , un24, , , yx__, zs -PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, un8 , , , x___, zs -PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un8 , un24, , , y___, zs -PIPE_FORMAT_Z32_FLOAT_S8X24_UNORM , plain, 1, 1, f32, un8 , un24, , xy__, zs +PIPE_FORMAT_S8_USCALED , plain, 1, 1, u8 , , , , _x__, zs +PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs +PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs +PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs +PIPE_FORMAT_Z24_UNORM_S8_USCALED , plain, 1, 1, un24, u8 , , , xy__, zs +PIPE_FORMAT_S8_USCALED_Z24_UNORM , plain, 1, 1, u8 , un24, , , yx__, zs +PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, u8 , , , x___, zs +PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, u8 , un24, , , y___, zs +PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , u24 , , xy__, zs # YUV formats # http://www.fourcc.org/yuv.php#UYVY diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index d825d3daa3..c7a90a09a1 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -63,11 +63,11 @@ enum pipe_format { PIPE_FORMAT_Z16_UNORM = 16, PIPE_FORMAT_Z32_UNORM = 17, PIPE_FORMAT_Z32_FLOAT = 18, - PIPE_FORMAT_Z24S8_UNORM = 19, - PIPE_FORMAT_S8Z24_UNORM = 20, + PIPE_FORMAT_Z24_UNORM_S8_USCALED = 19, + PIPE_FORMAT_S8_USCALED_Z24_UNORM = 20, PIPE_FORMAT_Z24X8_UNORM = 21, PIPE_FORMAT_X8Z24_UNORM = 22, - PIPE_FORMAT_S8_UNORM = 23, /**< ubyte stencil */ + PIPE_FORMAT_S8_USCALED = 23, /**< ubyte stencil */ PIPE_FORMAT_R64_FLOAT = 24, PIPE_FORMAT_R64G64_FLOAT = 25, PIPE_FORMAT_R64G64B64_FLOAT = 26, @@ -176,7 +176,7 @@ enum pipe_format { PIPE_FORMAT_R10G10B10A2_USCALED = 123, PIPE_FORMAT_R11G11B10_FLOAT = 124, PIPE_FORMAT_R9G9B9E5_FLOAT = 125, - PIPE_FORMAT_Z32_FLOAT_S8X24_UNORM = 126, + PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED = 126, PIPE_FORMAT_R1_UNORM = 127, PIPE_FORMAT_COUNT -- cgit v1.2.3 From 4e9690f00ca67e42e31367c50f9c216ad10ef553 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 30 Mar 2010 01:33:28 +0200 Subject: gallium: make the python scripts for format parsing not fail on new formats they won't generate any useful conversion code for some of the new formats but at least don't assert. Also needed some more hacks so they don't generate code for some of the new formats, as gcc was not impressed. Also declare unused channels as void, and change the scripts to not fail if the first channel happened to be unused. Needs serious fixing. --- src/gallium/auxiliary/util/u_format.csv | 20 ++++++++++---------- src/gallium/auxiliary/util/u_format_access.py | 5 +++++ src/gallium/auxiliary/util/u_format_pack.py | 14 ++++++++++++-- src/gallium/auxiliary/util/u_format_parse.py | 2 ++ 4 files changed, 29 insertions(+), 12 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 2b2230f308..f55bc3d805 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -58,12 +58,12 @@ # Typical rendertarget formats PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb -PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb +PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb -PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb -PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb +PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb @@ -82,11 +82,11 @@ PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, s PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb -PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb +PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb # Mixed-sign formats (typically used for bump map textures) PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb @@ -99,9 +99,9 @@ PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs PIPE_FORMAT_Z24_UNORM_S8_USCALED , plain, 1, 1, un24, u8 , , , xy__, zs PIPE_FORMAT_S8_USCALED_Z24_UNORM , plain, 1, 1, u8 , un24, , , yx__, zs -PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, u8 , , , x___, zs -PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, u8 , un24, , , y___, zs -PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , u24 , , xy__, zs +PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs +PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs +PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , x24 , , xy__, zs # YUV formats # http://www.fourcc.org/yuv.php#UYVY diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 00424779d2..42a37badca 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -60,6 +60,9 @@ def is_format_supported(format): channel = format.channels[i] if channel.type not in (VOID, UNSIGNED, FLOAT): return False + if channel.type == FLOAT: + if channel.size not in (32, 64) or format.is_mixed(): + return False # We can only read a color from a depth/stencil format if the depth channel is present if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: @@ -78,6 +81,8 @@ def native_type(format): else: # For array pixel formats return the integer type that matches the color channel channel = format.channels[0] + if channel.type == VOID: + channel = format.channels[1] if channel.type == UNSIGNED: return 'uint%u_t' % channel.size elif channel.type == SIGNED: diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 409d024c63..47def90317 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -46,11 +46,11 @@ def generate_format_type(format): '''Generate a structure that describes the format.''' print 'union util_format_%s {' % format.short_name() - if format.is_bitmask(): + if format.is_bitmask() or format.short_name() == "r11g11b10_float": print ' uint%u_t value;' % (format.block_size(),) print ' struct {' for channel in format.channels: - if format.is_bitmask() and not format.is_array(): + if (format.is_bitmask() or format.is_mixed()) and not format.is_array() or format.short_name() == "r11g11b10_float": if channel.type == VOID: if channel.size: print ' unsigned %s:%u;' % (channel.name, channel.size) @@ -58,6 +58,11 @@ def generate_format_type(format): print ' unsigned %s:%u;' % (channel.name, channel.size) elif channel.type == SIGNED: print ' int %s:%u;' % (channel.name, channel.size) + elif channel.type == FLOAT: + if channel.size == 32: + print ' float %s;' % (channel.name) + else: + print ' unsigned %s:%u;' % (channel.name, channel.size) else: assert 0 else: @@ -107,6 +112,9 @@ def is_format_supported(format): channel = format.channels[i] if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT): return False + if channel.type == FLOAT: + if channel.size not in (32, 64): + return False # We can only read a color from a depth/stencil format if the depth channel is present if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: @@ -125,6 +133,8 @@ def native_type(format): else: # For array pixel formats return the integer type that matches the color channel type = format.channels[0] + if type.type == VOID: + type = format.channels[1] if type.type == UNSIGNED: return 'uint%u_t' % type.size elif type.type == SIGNED: diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index f74dc5e88a..03dc62d329 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -142,6 +142,8 @@ class Format: def is_mixed(self): ref_channel = self.channels[0] + if ref_channel.type == VOID: + ref_channel = self.channels[1] for channel in self.channels[1:]: if channel.type != VOID: if channel.type != ref_channel.type: -- cgit v1.2.3 From 6fb364a1717858d8201b2caf234076ce5d4832ac Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 30 Mar 2010 01:35:49 +0200 Subject: gallium: adapt all code to the renamed depth/stencil formats --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 4 +- src/gallium/auxiliary/util/u_pack_color.h | 12 +++--- src/gallium/auxiliary/util/u_tile.c | 20 +++++----- src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 12 +++--- src/gallium/drivers/cell/ppu/cell_screen.c | 2 +- src/gallium/drivers/cell/spu/spu_command.c | 4 +- src/gallium/drivers/cell/spu/spu_per_fragment_op.c | 4 +- src/gallium/drivers/i915/i915_screen.c | 4 +- src/gallium/drivers/i915/i915_state_emit.c | 2 +- src/gallium/drivers/i915/i915_state_sampler.c | 2 +- src/gallium/drivers/i965/brw_misc_state.c | 2 +- src/gallium/drivers/i965/brw_pipe_clear.c | 4 +- src/gallium/drivers/i965/brw_screen.c | 4 +- src/gallium/drivers/i965/brw_screen_texture.c | 2 +- src/gallium/drivers/nv50/nv50_miptree.c | 4 +- src/gallium/drivers/nv50/nv50_screen.c | 8 ++-- src/gallium/drivers/nv50/nv50_state_validate.c | 4 +- src/gallium/drivers/nv50/nv50_surface.c | 4 +- src/gallium/drivers/nv50/nv50_tex.c | 4 +- src/gallium/drivers/nvfx/nv04_surface_2d.c | 4 +- src/gallium/drivers/nvfx/nv30_fragtex.c | 2 +- src/gallium/drivers/nvfx/nv40_fragtex.c | 2 +- src/gallium/drivers/nvfx/nvfx_screen.c | 4 +- src/gallium/drivers/nvfx/nvfx_state_fb.c | 2 +- src/gallium/drivers/r300/r300_screen.c | 2 +- src/gallium/drivers/r300/r300_texture.c | 4 +- src/gallium/drivers/softpipe/sp_quad_depth_test.c | 12 +++--- src/gallium/drivers/softpipe/sp_tile_cache.c | 6 +-- src/gallium/drivers/svga/svga_pipe_clear.c | 2 +- src/gallium/drivers/svga/svga_pipe_misc.c | 4 +- src/gallium/drivers/svga/svga_screen.c | 2 +- src/gallium/drivers/svga/svga_screen_texture.c | 4 +- src/gallium/drivers/svga/svga_state_framebuffer.c | 2 +- src/gallium/state_trackers/dri/common/dri_screen.c | 8 ++-- src/gallium/state_trackers/egl/kms/native_kms.c | 4 +- src/gallium/state_trackers/egl/x11/native_dri2.c | 4 +- src/gallium/state_trackers/egl/x11/native_ximage.c | 4 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 4 +- src/gallium/state_trackers/vega/vg_tracker.c | 2 +- src/gallium/state_trackers/wgl/stw_pixelformat.c | 4 +- src/gallium/state_trackers/xorg/xorg_dri2.c | 4 +- src/mesa/state_tracker/st_cb_drawpixels.c | 12 +++--- src/mesa/state_tracker/st_cb_fbo.c | 6 +-- src/mesa/state_tracker/st_cb_readpixels.c | 10 ++--- src/mesa/state_tracker/st_extensions.c | 8 ++-- src/mesa/state_tracker/st_format.c | 46 +++++++++++----------- 46 files changed, 135 insertions(+), 135 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index 4ce1a27a06..c6d0e4bc04 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -495,8 +495,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, assert(format_desc->block.height == 1); if (stencil[0].enabled) { - assert(format_desc->format == PIPE_FORMAT_Z24S8_UNORM || - format_desc->format == PIPE_FORMAT_S8Z24_UNORM); + assert(format_desc->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || + format_desc->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM); } assert(z_swizzle < 4); diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index c5fd7a6783..ad4a06dc77 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -446,17 +446,17 @@ util_pack_z(enum pipe_format format, double z) return (uint) (z * 0xffffffff); case PIPE_FORMAT_Z32_FLOAT: return (uint)z; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z24X8_UNORM: if (z == 1.0) return 0xffffff; return (uint) (z * 0xffffff); - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: if (z == 1.0) return 0xffffff00; return ((uint) (z * 0xffffff)) << 8; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: /* this case can get it via util_pack_z_stencil() */ return 0; default: @@ -477,13 +477,13 @@ util_pack_z_stencil(enum pipe_format format, double z, uint s) unsigned packed = util_pack_z(format, z); switch (format) { - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: packed |= s << 24; break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: packed |= s; break; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: packed |= s; break; default: diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 09b2382733..e03ee9b8bd 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1036,7 +1036,7 @@ z32_get_tile_rgba(const unsigned *src, } -/*** PIPE_FORMAT_Z24S8_UNORM ***/ +/*** PIPE_FORMAT_Z24_UNORM_S8_USCALED ***/ /** * Return Z component as four float in [0,1]. Stencil part ignored. @@ -1063,7 +1063,7 @@ s8z24_get_tile_rgba(const unsigned *src, } -/*** PIPE_FORMAT_S8Z24_UNORM ***/ +/*** PIPE_FORMAT_S8_USCALED_Z24_UNORM ***/ /** * Return Z component as four float in [0,1]. Stencil part ignored. @@ -1271,11 +1271,11 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_Z32_UNORM: z32_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z24X8_UNORM: s8z24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: z24s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; @@ -1468,11 +1468,11 @@ pipe_put_tile_rgba(struct pipe_context *pipe, case PIPE_FORMAT_Z32_UNORM: /*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z24X8_UNORM: /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; @@ -1525,7 +1525,7 @@ pipe_get_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z24X8_UNORM: { const uint *ptrc @@ -1540,7 +1540,7 @@ pipe_get_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: { const uint *ptrc @@ -1609,7 +1609,7 @@ pipe_put_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: { uint *pDest = (uint *) (map + y * pt->stride + x*4); assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); @@ -1636,7 +1636,7 @@ pipe_put_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c index c54576b3c3..628bc1c694 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c @@ -1859,7 +1859,7 @@ gen_depth_stencil(struct cell_context *cell, spe_comment(f, 0, "Fetch Z/stencil quad from tile"); switch(zs_format) { - case PIPE_FORMAT_Z24S8_UNORM: /* fall through */ + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: /* fall through */ case PIPE_FORMAT_Z24X8_UNORM: /* prepare mask to extract Z vals from ZS vals */ spe_load_uint(f, zmask_reg, 0x00ffffff); @@ -1880,7 +1880,7 @@ gen_depth_stencil(struct cell_context *cell, spe_rotmi(f, fbS_reg, fbZS_reg, -24); break; - case PIPE_FORMAT_S8Z24_UNORM: /* fall through */ + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: /* fall through */ case PIPE_FORMAT_X8Z24_UNORM: /* convert fragment Z from [0,1] to 32-bit ints */ spe_cfltu(f, fragZ_reg, fragZ_reg, 32); @@ -1969,12 +1969,12 @@ gen_depth_stencil(struct cell_context *cell, * fbS_reg has four 8-bit Z values in bits [7..0]. */ spe_comment(f, 0, "Store quad's depth/stencil values in tile"); - if (zs_format == PIPE_FORMAT_Z24S8_UNORM || + if (zs_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || zs_format == PIPE_FORMAT_Z24X8_UNORM) { spe_shli(f, fbS_reg, fbS_reg, 24); /* fbS = fbS << 24 */ spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */ } - else if (zs_format == PIPE_FORMAT_S8Z24_UNORM || + else if (zs_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || zs_format == PIPE_FORMAT_X8Z24_UNORM) { spe_shli(f, fbZ_reg, fbZ_reg, 8); /* fbZ = fbZ << 8 */ spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */ @@ -1985,7 +1985,7 @@ gen_depth_stencil(struct cell_context *cell, else if (zs_format == PIPE_FORMAT_Z16_UNORM) { spe_move(f, fbZS_reg, fbZ_reg); /* fbZS = fbZ */ } - else if (zs_format == PIPE_FORMAT_S8_UNORM) { + else if (zs_format == PIPE_FORMAT_S8_USCALED) { ASSERT(0); /* XXX to do */ } else { @@ -2015,7 +2015,7 @@ gen_depth_stencil(struct cell_context *cell, * code before the fragment shader to cull fragments/quads that are * totally occluded/discarded. * - * XXX we only support PIPE_FORMAT_S8Z24_UNORM z/stencil buffer right now. + * XXX we only support PIPE_FORMAT_S8_USCALED_Z24_UNORM z/stencil buffer right now. * * See the spu_default_fragment_ops() function to see how the per-fragment * operations would be done with ordinary C code. diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 4204574406..363d1e65e7 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -147,7 +147,7 @@ cell_is_format_supported( struct pipe_screen *screen, /* only a few formats are known to work at this time */ switch (format) { - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_B8G8R8A8_UNORM: case PIPE_FORMAT_I8_UNORM: diff --git a/src/gallium/drivers/cell/spu/spu_command.c b/src/gallium/drivers/cell/spu/spu_command.c index 79f1fb7fb2..f16cabc027 100644 --- a/src/gallium/drivers/cell/spu/spu_command.c +++ b/src/gallium/drivers/cell/spu/spu_command.c @@ -337,8 +337,8 @@ cmd_state_framebuffer(const struct cell_command_framebuffer *cmd) spu.fb.zsize = 4; spu.fb.zscale = (float) 0xffffffffu; break; - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_Z24X8_UNORM: spu.fb.zsize = 4; diff --git a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c index 2c9e7458af..3b9566042a 100644 --- a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c +++ b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c @@ -138,13 +138,13 @@ spu_fallback_fragment_ops(uint x, uint y, if (spu.depth_stencil_alpha.stencil[0].enabled) { /* do stencil test */ - ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24S8_UNORM); + ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED); } else if (spu.depth_stencil_alpha.depth.enabled) { /* do depth test */ - ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24S8_UNORM || + ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || spu.fb.depth_format == PIPE_FORMAT_Z24X8_UNORM); vector unsigned int ifragZ; diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 53ef6e50f6..4ccc66b037 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -178,13 +178,13 @@ i915_is_format_supported(struct pipe_screen *screen, PIPE_FORMAT_L8A8_UNORM, PIPE_FORMAT_UYVY, PIPE_FORMAT_YUYV, - PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_NONE /* list terminator */ }; static const enum pipe_format surface_supported[] = { PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_B5G6R5_UNORM, - PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_NONE /* list terminator */ }; const enum pipe_format *list; diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c index 04a3924aaf..2d212abfb9 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -50,7 +50,7 @@ static unsigned translate_format( enum pipe_format format ) static unsigned translate_depth_format( enum pipe_format zformat ) { switch (zformat) { - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: return DEPTH_FRMT_24_FIXED_8_OTHER; case PIPE_FORMAT_Z16_UNORM: return DEPTH_FRMT_16_FIXED; diff --git a/src/gallium/drivers/i915/i915_state_sampler.c b/src/gallium/drivers/i915/i915_state_sampler.c index 4c326561cb..270d4f21e1 100644 --- a/src/gallium/drivers/i915/i915_state_sampler.c +++ b/src/gallium/drivers/i915/i915_state_sampler.c @@ -220,7 +220,7 @@ translate_texture_format(enum pipe_format pipeFormat) case PIPE_FORMAT_RGBA_DXT5: return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5); #endif - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: return (MAPSURF_32BIT | MT_32BIT_xI824); default: debug_printf("i915: translate_texture_format() bad image format %x\n", diff --git a/src/gallium/drivers/i965/brw_misc_state.c b/src/gallium/drivers/i965/brw_misc_state.c index e3f25bdf62..b5029ceb69 100644 --- a/src/gallium/drivers/i965/brw_misc_state.c +++ b/src/gallium/drivers/i965/brw_misc_state.c @@ -266,7 +266,7 @@ static int emit_depthbuffer(struct brw_context *brw) cpp = 2; break; case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT; cpp = 4; break; diff --git a/src/gallium/drivers/i965/brw_pipe_clear.c b/src/gallium/drivers/i965/brw_pipe_clear.c index d7048f769b..abf507991e 100644 --- a/src/gallium/drivers/i965/brw_pipe_clear.c +++ b/src/gallium/drivers/i965/brw_pipe_clear.c @@ -140,7 +140,7 @@ static void zstencil_clear(struct brw_context *brw, switch (bsurface->base.format) { case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: value = ((unsigned)(depth * MASK24) & MASK24); break; case PIPE_FORMAT_Z16_UNORM: @@ -153,7 +153,7 @@ static void zstencil_clear(struct brw_context *brw, switch (bsurface->base.format) { case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: value = value | (stencil << 24); break; diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index cef83ffea8..ba30e63f20 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -252,7 +252,7 @@ brw_is_format_supported(struct pipe_screen *screen, /* depth */ PIPE_FORMAT_Z32_FLOAT, PIPE_FORMAT_Z24X8_UNORM, - PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_Z16_UNORM, /* signed */ PIPE_FORMAT_R8G8_SNORM, @@ -268,7 +268,7 @@ brw_is_format_supported(struct pipe_screen *screen, static const enum pipe_format depth_supported[] = { PIPE_FORMAT_Z32_FLOAT, PIPE_FORMAT_Z24X8_UNORM, - PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_NONE /* list terminator */ }; diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index cadcb7cee2..613ac78420 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -158,7 +158,7 @@ static GLuint translate_tex_format( enum pipe_format pf ) case PIPE_FORMAT_Z16_UNORM: return BRW_SURFACEFORMAT_I16_UNORM; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z24X8_UNORM: return BRW_SURFACEFORMAT_I24X8_UNORM; diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index e091cae602..85b0aef20c 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -89,14 +89,14 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) case PIPE_FORMAT_Z32_FLOAT: tile_flags = 0x4800; break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: tile_flags = 0x1800; break; case PIPE_FORMAT_Z16_UNORM: tile_flags = 0x6c00; break; case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: tile_flags = 0x2800; break; case PIPE_FORMAT_R32G32B32A32_FLOAT: diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 1a4606d9e2..801548d8a1 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -51,9 +51,9 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { switch (format) { case PIPE_FORMAT_Z32_FLOAT: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: return TRUE; default: break; @@ -75,8 +75,8 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: case PIPE_FORMAT_DXT5_RGBA: - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z32_FLOAT: case PIPE_FORMAT_R16G16B16A16_SNORM: case PIPE_FORMAT_R16G16B16A16_UNORM: diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index b7e355283c..402045416c 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -122,13 +122,13 @@ validate_fb(struct nv50_context *nv50) so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0); switch (fb->zsbuf->format) { - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: so_data(so, NV50TCL_ZETA_FORMAT_S8Z24_UNORM); break; case PIPE_FORMAT_Z24X8_UNORM: so_data(so, NV50TCL_ZETA_FORMAT_X8Z24_UNORM); break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: so_data(so, NV50TCL_ZETA_FORMAT_Z24S8_UNORM); break; case PIPE_FORMAT_Z32_FLOAT: diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 6467c48a32..7a9dada531 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -60,8 +60,8 @@ nv50_format(enum pipe_format format) /* only because we require src format == dst format: */ case PIPE_FORMAT_R16G16_SNORM: case PIPE_FORMAT_R16G16_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM; case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_B4G4R4A4_UNORM: diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 85ab947c00..d094b490ed 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -62,8 +62,8 @@ static const uint32_t nv50_texture_formats[PIPE_FORMAT_COUNT] = _(DXT3_RGBA, UNORM, C0, C1, C2, C3, DXT3), _(DXT5_RGBA, UNORM, C0, C1, C2, C3, DXT5), - _MIXED(S8Z24_UNORM, UINT, UNORM, UINT, UINT, C1, C1, C1, ONE, 24_8), - _MIXED(Z24S8_UNORM, UNORM, UINT, UINT, UINT, C0, C0, C0, ONE, 8_24), + _MIXED(S8_USCALED_Z24_UNORM, UINT, UNORM, UINT, UINT, C1, C1, C1, ONE, 24_8), + _MIXED(Z24_UNORM_S8_USCALED, UNORM, UINT, UINT, UINT, C0, C0, C0, ONE, 8_24), _(R16G16B16A16_SNORM, UNORM, C0, C1, C2, C3, 16_16_16_16), _(R16G16B16A16_UNORM, SNORM, C0, C1, C2, C3, 16_16_16_16), diff --git a/src/gallium/drivers/nvfx/nv04_surface_2d.c b/src/gallium/drivers/nvfx/nv04_surface_2d.c index ed18c9f24d..6784170c00 100644 --- a/src/gallium/drivers/nvfx/nv04_surface_2d.c +++ b/src/gallium/drivers/nvfx/nv04_surface_2d.c @@ -25,7 +25,7 @@ nv04_surface_format(enum pipe_format format) case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_B8G8R8A8_UNORM: return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32; default: @@ -45,7 +45,7 @@ nv04_rect_format(enum pipe_format format) return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5; case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_B8G8R8A8_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8; default: diff --git a/src/gallium/drivers/nvfx/nv30_fragtex.c b/src/gallium/drivers/nvfx/nv30_fragtex.c index 54e47574c4..d3f3edb327 100644 --- a/src/gallium/drivers/nvfx/nv30_fragtex.c +++ b/src/gallium/drivers/nvfx/nv30_fragtex.c @@ -63,7 +63,7 @@ nv30_texture_formats[] = { _(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X), _(L8A8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y), _(Z16_UNORM , R5G6B5 , S1, S1, S1, ONE, X, X, X, X), - _(S8Z24_UNORM , A8R8G8B8, S1, S1, S1, ONE, X, X, X, X), + _(S8_USCALED_Z24_UNORM , A8R8G8B8, S1, S1, S1, ONE, X, X, X, X), _(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W), _(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W), _(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W), diff --git a/src/gallium/drivers/nvfx/nv40_fragtex.c b/src/gallium/drivers/nvfx/nv40_fragtex.c index 05506e2809..fe87cebbb6 100644 --- a/src/gallium/drivers/nvfx/nv40_fragtex.c +++ b/src/gallium/drivers/nvfx/nv40_fragtex.c @@ -81,7 +81,7 @@ nv40_texture_formats[] = { _(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X, 0, 0, 0, 0), _(L8A8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y, 0, 0, 0, 0), _(Z16_UNORM , Z16 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0), - _(S8Z24_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0), + _(S8_USCALED_Z24_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0), _(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W, 0, 0, 0, 0), _(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), _(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index f7f3921894..1a103520a3 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -133,7 +133,7 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen, } else if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { switch (format) { - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: return TRUE; case PIPE_FORMAT_Z16_UNORM: @@ -155,7 +155,7 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen, case PIPE_FORMAT_I8_UNORM: case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_Z16_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: diff --git a/src/gallium/drivers/nvfx/nvfx_state_fb.c b/src/gallium/drivers/nvfx/nvfx_state_fb.c index dd64ba4193..1923184163 100644 --- a/src/gallium/drivers/nvfx/nvfx_state_fb.c +++ b/src/gallium/drivers/nvfx/nvfx_state_fb.c @@ -102,7 +102,7 @@ nvfx_state_framebuffer_validate(struct nvfx_context *nvfx) rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16; zeta_bits = 16; break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: case 0: rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8; diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index e46f836dd2..090964b025 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -208,7 +208,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, uint32_t retval = 0; boolean is_r500 = r300_screen(screen)->caps->is_r500; boolean is_z24 = format == PIPE_FORMAT_X8Z24_UNORM || - format == PIPE_FORMAT_S8Z24_UNORM; + format == PIPE_FORMAT_S8_USCALED_Z24_UNORM; boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM; if (target >= PIPE_MAX_TEXTURE_TYPES) { diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7c86bdb4bd..bc7e606063 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -104,7 +104,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format) case PIPE_FORMAT_Z16_UNORM: return R300_EASY_TX_FORMAT(X, X, X, X, X16); case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP); default: return ~0; /* Unsupported. */ @@ -372,7 +372,7 @@ static uint32_t r300_translate_zsformat(enum pipe_format format) /* 24-bit depth, ignored stencil */ case PIPE_FORMAT_X8Z24_UNORM: /* 24-bit depth, 8-bit stencil */ - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL; default: return ~0; /* Unsupported. */ diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 17cd5b8207..4ee31969e6 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -75,7 +75,7 @@ get_depth_stencil_values( struct depth_data *data, } break; case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); @@ -84,7 +84,7 @@ get_depth_stencil_values( struct depth_data *data, } break; case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); @@ -153,7 +153,7 @@ convert_quad_depth( struct depth_data *data, } break; case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: { float scale = (float) ((1 << 24) - 1); @@ -163,7 +163,7 @@ convert_quad_depth( struct depth_data *data, } break; case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: { float scale = (float) ((1 << 24) - 1); @@ -206,14 +206,14 @@ write_depth_stencil_values( struct depth_data *data, tile->data.depth32[y][x] = data->bzzzz[j]; } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); tile->data.depth32[y][x] = (data->stencilVals[j] << 24) | data->bzzzz[j]; } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 1c3c2667d7..7551b923fb 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -158,13 +158,13 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, PIPE_TRANSFER_READ_WRITE, 0, 0, ps->width, ps->height); - tc->depth_stencil = (ps->format == PIPE_FORMAT_Z24S8_UNORM || + tc->depth_stencil = (ps->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || ps->format == PIPE_FORMAT_Z24X8_UNORM || - ps->format == PIPE_FORMAT_S8Z24_UNORM || + ps->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || ps->format == PIPE_FORMAT_X8Z24_UNORM || ps->format == PIPE_FORMAT_Z16_UNORM || ps->format == PIPE_FORMAT_Z32_UNORM || - ps->format == PIPE_FORMAT_S8_UNORM); + ps->format == PIPE_FORMAT_S8_USCALED); } } diff --git a/src/gallium/drivers/svga/svga_pipe_clear.c b/src/gallium/drivers/svga/svga_pipe_clear.c index 8483a3fad7..bb1664fbed 100644 --- a/src/gallium/drivers/svga/svga_pipe_clear.c +++ b/src/gallium/drivers/svga/svga_pipe_clear.c @@ -63,7 +63,7 @@ try_clear(struct svga_context *svga, if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && fb->zsbuf) { flags |= SVGA3D_CLEAR_DEPTH; - if (svga->curr.framebuffer.zsbuf->format == PIPE_FORMAT_S8Z24_UNORM) + if (svga->curr.framebuffer.zsbuf->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM) flags |= SVGA3D_CLEAR_STENCIL; rect.w = MAX2(rect.w, fb->zsbuf->width); diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c index 95bf0e6f91..2c43f9a24f 100644 --- a/src/gallium/drivers/svga/svga_pipe_misc.c +++ b/src/gallium/drivers/svga/svga_pipe_misc.c @@ -118,9 +118,9 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe, case PIPE_FORMAT_Z16_UNORM: svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D16; break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D24S8; break; diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 6022c38cfc..9a2e7c6f5b 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -210,7 +210,7 @@ svga_translate_format_cap(enum pipe_format format) case PIPE_FORMAT_Z16_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_Z_D16; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8; case PIPE_FORMAT_X8Z24_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8; diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 4a058eda88..41f88eed72 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -81,7 +81,7 @@ svga_translate_format(enum pipe_format format) */ case PIPE_FORMAT_Z16_UNORM: return SVGA3D_Z_D16; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: return SVGA3D_Z_D24S8; case PIPE_FORMAT_X8Z24_UNORM: return SVGA3D_Z_D24X8; @@ -114,7 +114,7 @@ svga_translate_format_render(enum pipe_format format) case PIPE_FORMAT_B5G5R5A1_UNORM: case PIPE_FORMAT_B4G4R4A4_UNORM: case PIPE_FORMAT_B5G6R5_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_Z32_UNORM: case PIPE_FORMAT_Z16_UNORM: diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index b710914acd..bd92f00343 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -70,7 +70,7 @@ static int emit_framebuffer( struct svga_context *svga, return ret; if (curr->zsbuf && - curr->zsbuf->format == PIPE_FORMAT_S8Z24_UNORM) { + curr->zsbuf->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM) { ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_STENCIL, curr->zsbuf); if (ret != PIPE_OK) return ret; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 821c1dea62..6fc7487071 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -97,10 +97,10 @@ dri_fill_in_modes(struct dri_screen *screen, pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM, + pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM, + pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM, @@ -241,8 +241,8 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen, PIPE_FORMAT_X8Z24_UNORM; } else { stvis->depth_stencil_format = (screen->sd_depth_bits_last) ? - PIPE_FORMAT_Z24S8_UNORM: - PIPE_FORMAT_S8Z24_UNORM; + PIPE_FORMAT_Z24_UNORM_S8_USCALED: + PIPE_FORMAT_S8_USCALED_Z24_UNORM; } break; case 32: diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index 7322240856..3174774490 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -631,9 +631,9 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs) nconf->mode.alphaBits = 8; nconf->mode.rgbBits = 32; - format = PIPE_FORMAT_Z24S8_UNORM; + format = PIPE_FORMAT_Z24_UNORM_S8_USCALED; if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { - format = PIPE_FORMAT_S8Z24_UNORM; + format = PIPE_FORMAT_S8_USCALED_Z24_UNORM; if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) format = PIPE_FORMAT_NONE; } diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 9839979231..8c0553ce0d 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -558,8 +558,8 @@ choose_depth_stencil_format(const __GLcontextModes *mode, break; case 24: if (mode->stencilBits) { - formats[count++] = PIPE_FORMAT_Z24S8_UNORM; - formats[count++] = PIPE_FORMAT_S8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24_UNORM_S8_USCALED; + formats[count++] = PIPE_FORMAT_S8_USCALED_Z24_UNORM; } else { formats[count++] = PIPE_FORMAT_Z24X8_UNORM; diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index c6b16354f9..d69011ac5e 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -526,8 +526,8 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs) xconf->base.stencil_format = PIPE_FORMAT_NONE; /* create the second config with depth/stencil buffer */ if (j == 1) { - xconf->base.depth_format = PIPE_FORMAT_Z24S8_UNORM; - xconf->base.stencil_format = PIPE_FORMAT_Z24S8_UNORM; + xconf->base.depth_format = PIPE_FORMAT_Z24_UNORM_S8_USCALED; + xconf->base.stencil_format = PIPE_FORMAT_Z24_UNORM_S8_USCALED; mode->depthBits = 24; mode->stencilBits = 8; mode->haveDepthBuffer = TRUE; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 3022d45157..919497be5f 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -356,8 +356,8 @@ choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil) formats[count++] = PIPE_FORMAT_Z24X8_UNORM; } if (depth <= 24 && stencil <= 8) { - formats[count++] = PIPE_FORMAT_S8Z24_UNORM; - formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + formats[count++] = PIPE_FORMAT_S8_USCALED_Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24_UNORM_S8_USCALED; } if (depth <= 32 && stencil == 0) { formats[count++] = PIPE_FORMAT_Z32_UNORM; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index f438e34087..108dd6a975 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -208,7 +208,7 @@ struct st_framebuffer * st_create_framebuffer(const void *visual, if (stencilFormat == depthFormat) stfb->dsrb = st_new_renderbuffer_fb(stencilFormat); else - stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_Z24S8_UNORM); + stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_Z24_UNORM_S8_USCALED); /*### currently we always allocate it but it's possible it's not necessary if EGL_ALPHA_MASK_SIZE was 0 diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index bc28f31ed1..02ff89a388 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -96,8 +96,8 @@ stw_pf_depth_stencil[] = { { PIPE_FORMAT_Z24X8_UNORM, {24, 0} }, { PIPE_FORMAT_Z16_UNORM, {16, 0} }, /* combined depth-stencil */ - { PIPE_FORMAT_Z24S8_UNORM, {24, 8} }, - { PIPE_FORMAT_S8Z24_UNORM, {24, 8} } + { PIPE_FORMAT_Z24_UNORM_S8_USCALED, {24, 8} }, + { PIPE_FORMAT_S8_USCALED_Z24_UNORM, {24, 8} } }; diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index f23e4c6cc7..91c251bb4f 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -122,7 +122,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form } } else { template.format = ms->ds_depth_bits_last ? - PIPE_FORMAT_Z24S8_UNORM : PIPE_FORMAT_S8Z24_UNORM; + PIPE_FORMAT_Z24_UNORM_S8_USCALED : PIPE_FORMAT_S8_USCALED_Z24_UNORM; } template.width0 = pDraw->width; template.height0 = pDraw->height; @@ -439,7 +439,7 @@ xorg_dri2_init(ScreenPtr pScreen) PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); ms->ds_depth_bits_last = - ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24S8_UNORM, + ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index c9d1e9c6c4..85570541ef 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -735,14 +735,14 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* now pack the stencil (and Z) values in the dest format */ switch (pt->texture->format) { - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: { ubyte *dest = stmap + spanY * pt->stride + spanX; assert(usage == PIPE_TRANSFER_WRITE); memcpy(dest, sValues, spanWidth); } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -760,7 +760,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -913,7 +913,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, src = buffer + i * width; switch (ptDraw->texture->format) { - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: { uint *dst4 = (uint *) dst; int j; @@ -924,7 +924,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: { uint *dst4 = (uint *) dst; int j; @@ -935,7 +935,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } break; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: assert(usage == PIPE_TRANSFER_WRITE); memcpy(dst, src, width); break; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 84c2474038..542ab38a50 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -255,13 +255,13 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) case PIPE_FORMAT_Z32_UNORM: strb->Base.InternalFormat = GL_DEPTH_COMPONENT32; break; - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_X8Z24_UNORM: strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT; break; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT; break; case PIPE_FORMAT_R16G16B16A16_SNORM: diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 7afb275fe2..10795ee9e4 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -103,13 +103,13 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* get stencil (and Z) values */ switch (pt->texture->format) { - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: { const ubyte *src = stmap + srcY * pt->stride; memcpy(sValues, src, width); } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -127,7 +127,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -437,7 +437,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width, format, type); - if (trans->texture->format == PIPE_FORMAT_Z24S8_UNORM || + if (trans->texture->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { @@ -469,7 +469,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } - else if (trans->texture->format == PIPE_FORMAT_S8Z24_UNORM || + else if (trans->texture->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 290ee36b0f..0118c600f0 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -281,18 +281,18 @@ void st_init_extensions(struct st_context *st) /* GL_EXT_packed_depth_stencil requires both the ability to render to * a depth/stencil buffer and texture from depth/stencil source. */ - if (screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, + if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, + screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } - else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, + else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, + screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 9ae0c9f9ba..ecc08762bb 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -76,8 +76,8 @@ st_format_datatype(enum pipe_format format) format == PIPE_FORMAT_B5G6R5_UNORM) { return GL_UNSIGNED_SHORT; } - else if (format == PIPE_FORMAT_Z24S8_UNORM || - format == PIPE_FORMAT_S8Z24_UNORM) { + else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || + format == PIPE_FORMAT_S8_USCALED_Z24_UNORM) { return GL_UNSIGNED_INT_24_8; } else { @@ -151,9 +151,9 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_Z32: return PIPE_FORMAT_Z32_UNORM; case MESA_FORMAT_Z24_S8: - return PIPE_FORMAT_S8Z24_UNORM; + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; case MESA_FORMAT_S8_Z24: - return PIPE_FORMAT_Z24S8_UNORM; + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; case MESA_FORMAT_YCBCR: return PIPE_FORMAT_UYVY; #if FEATURE_texture_s3tc @@ -224,7 +224,7 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_L8; case PIPE_FORMAT_I8_UNORM: return MESA_FORMAT_I8; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: return MESA_FORMAT_S8; case PIPE_FORMAT_R16G16B16A16_SNORM: @@ -234,13 +234,13 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_Z16; case PIPE_FORMAT_Z32_UNORM: return MESA_FORMAT_Z32; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: return MESA_FORMAT_Z24_S8; case PIPE_FORMAT_X8Z24_UNORM: return MESA_FORMAT_Z24_X8; case PIPE_FORMAT_Z24X8_UNORM: return MESA_FORMAT_X8_Z24; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: return MESA_FORMAT_S8_Z24; case PIPE_FORMAT_UYVY: @@ -393,8 +393,8 @@ default_depth_format(struct pipe_screen *screen, static const enum pipe_format zFormats[] = { PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_S8Z24_UNORM + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM }; uint i; for (i = 0; i < Elements(zFormats); i++) { @@ -546,10 +546,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_Z16_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT24: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT32: if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags )) @@ -563,20 +563,20 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX8_EXT: case GL_STENCIL_INDEX16_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; return PIPE_FORMAT_NONE; case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; return PIPE_FORMAT_NONE; case GL_SRGB_EXT: -- cgit v1.2.3 From 56b34e54f29cdd0a479219695c6559c44a41a76c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 30 Mar 2010 02:01:11 +0200 Subject: gallium/util: use other layout instead of the old compressed --- src/gallium/auxiliary/util/u_format.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 57e995c03b..ee91788d71 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -117,8 +117,8 @@ PIPE_FORMAT_G8R8_G8B8_UNORM , subsampled, 2, 1, x32 , , , , xyz # some special formats not fitting anywhere else PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb PIPE_FORMAT_R11G11B10_FLOAT , plain, 1, 1, f11 , f11 , f10 , , xyz1, rgb -PIPE_FORMAT_R9G9B9E5_FLOAT , compressed, 1, 1, x32 , , , , xyz1, rgb -PIPE_FORMAT_R1_UNORM , compressed, 8, 1, x8 , , , , x001, rgb +PIPE_FORMAT_R9G9B9E5_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb +PIPE_FORMAT_R1_UNORM , other, 8, 1, x8 , , , , x001, rgb # Compressed formats # - http://en.wikipedia.org/wiki/S3_Texture_Compression -- cgit v1.2.3 From 7a26c875a9195587c408188ddc7d02a42dfde2bb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 13:55:12 +0100 Subject: util: Generalize lp_format_is_rgba8 into util_format_is_rgba8_variant. --- src/gallium/auxiliary/Makefile | 1 - src/gallium/auxiliary/SConscript | 1 - .../auxiliary/gallivm/lp_bld_format_query.c | 72 ---------------------- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 2 +- src/gallium/auxiliary/util/u_format.h | 28 +++++++++ 5 files changed, 29 insertions(+), 75 deletions(-) delete mode 100644 src/gallium/auxiliary/gallivm/lp_bld_format_query.c (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 452eceb7f4..a0b3f8abc7 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -149,7 +149,6 @@ GALLIVM_SOURCES = \ gallivm/lp_bld_depth.c \ gallivm/lp_bld_flow.c \ gallivm/lp_bld_format_aos.c \ - gallivm/lp_bld_format_query.c \ gallivm/lp_bld_format_soa.c \ gallivm/lp_bld_interp.c \ gallivm/lp_bld_intr.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 0a23da47b2..2c0cd8ea23 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -193,7 +193,6 @@ if drawllvm: 'gallivm/lp_bld_depth.c', 'gallivm/lp_bld_flow.c', 'gallivm/lp_bld_format_aos.c', - 'gallivm/lp_bld_format_query.c', 'gallivm/lp_bld_format_soa.c', 'gallivm/lp_bld_interp.c', 'gallivm/lp_bld_intr.c', diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_query.c b/src/gallium/auxiliary/gallivm/lp_bld_format_query.c deleted file mode 100644 index f3832d07ff..0000000000 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_query.c +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * 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 VMWARE AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * @file - * Utility functions to make assertions about formats. - * - * This module centralizes most of logic used when determining what algorithm - * is most suitable (i.e., most efficient yet correct) for a given format. - * - * It might be possible to move some of these functions to u_format module, - * but since tiny differences in the format my render it more/less - * appropriate to a given algorithm it is impossible to make any long term - * guarantee about the semantics of these functions. - * - * @author Jose Fonseca - */ - - -#include "util/u_format.h" - -#include "lp_bld_format.h" - - -/** - * Whether this format is a 4 rgba8 variant - */ -boolean -lp_format_is_rgba8(const struct util_format_description *desc) -{ - unsigned chan; - - if(desc->block.width != 1 || - desc->block.height != 1 || - desc->block.bits != 32) - return FALSE; - - for(chan = 0; chan < 4; ++chan) { - if(desc->channel[chan].type != UTIL_FORMAT_TYPE_UNSIGNED && - desc->channel[chan].type != UTIL_FORMAT_TYPE_SIGNED && - desc->channel[chan].type != UTIL_FORMAT_TYPE_VOID) - return FALSE; - if(desc->channel[chan].size != 8) - return FALSE; - } - - return TRUE; -} diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 995c016b9d..5b56f2cf3b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2037,7 +2037,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, depth); - if (lp_format_is_rgba8(bld.format_desc) && + if (util_format_is_rgba8_variant(bld.format_desc) && static_state->target == PIPE_TEXTURE_2D && static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR && static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR && diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 98d4b98ebb..4d59b9927d 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -261,6 +261,34 @@ util_format_is_depth_and_stencil(enum pipe_format format) desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE; } +/** + * Whether this format is a rgab8 variant. + * + * That is, any format that matches the + * + * PIPE_FORMAT_?8?8?8?8_UNORM + */ +static INLINE boolean +util_format_is_rgba8_variant(const struct util_format_description *desc) +{ + unsigned chan; + + if(desc->block.width != 1 || + desc->block.height != 1 || + desc->block.bits != 32) + return FALSE; + + for(chan = 0; chan < 4; ++chan) { + if(desc->channel[chan].type != UTIL_FORMAT_TYPE_UNSIGNED && + desc->channel[chan].type != UTIL_FORMAT_TYPE_VOID) + return FALSE; + if(desc->channel[chan].size != 8) + return FALSE; + } + + return TRUE; +} + /** * Return total bits needed for the pixel format per block. -- cgit v1.2.3 From 338b9d71dfd93cfe516b16db1be4038725c5bc7b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 14:28:34 +0100 Subject: util: Use VOID type for X channels in format descriptions. --- src/gallium/auxiliary/util/u_format.csv | 18 +++++++++--------- src/gallium/auxiliary/util/u_format_access.py | 2 +- src/gallium/auxiliary/util/u_format_pack.py | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index d819bbbde1..25a661eb45 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -58,12 +58,12 @@ # Typical rendertarget formats PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb -PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb +PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb -PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb -PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb +PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb @@ -81,11 +81,11 @@ PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, s PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb -PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb +PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb # Mixed-sign formats (typically used for bump map textures) PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb @@ -98,8 +98,8 @@ PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, z PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs PIPE_FORMAT_Z24S8_UNORM , plain, 1, 1, un24, un8 , , , xy__, zs PIPE_FORMAT_S8Z24_UNORM , plain, 1, 1, un8 , un24, , , yx__, zs -PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, un8 , , , x___, zs -PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un8 , un24, , , y___, zs +PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs +PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs # YUV formats # http://www.fourcc.org/yuv.php#UYVY diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 00424779d2..a5cb67f7e4 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -78,7 +78,7 @@ def native_type(format): else: # For array pixel formats return the integer type that matches the color channel channel = format.channels[0] - if channel.type == UNSIGNED: + if channel.type in (UNSIGNED, VOID): return 'uint%u_t' % channel.size elif channel.type == SIGNED: return 'int%u_t' % channel.size diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 409d024c63..e9d2573667 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -124,15 +124,15 @@ def native_type(format): return 'uint%u_t' % format.block_size() else: # For array pixel formats return the integer type that matches the color channel - type = format.channels[0] - if type.type == UNSIGNED: - return 'uint%u_t' % type.size - elif type.type == SIGNED: - return 'int%u_t' % type.size - elif type.type == FLOAT: - if type.size == 32: + channel = format.channels[0] + if channel.type in (UNSIGNED, VOID): + return 'uint%u_t' % channel.size + elif channel.type == SIGNED: + return 'int%u_t' % channel.size + elif channel.type == FLOAT: + if channel.size == 32: return 'float' - elif type.size == 64: + elif channel.size == 64: return 'double' else: assert False -- cgit v1.2.3 From bce109c944c45d763497cea3aeaa6cf0d8163149 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 14:28:54 +0100 Subject: util: Fix PIPE_FORMAT_B5G5R5X1_UNORM test case. --- src/gallium/auxiliary/util/u_format_tests.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format_tests.c b/src/gallium/auxiliary/util/u_format_tests.c index 9d6debcd8c..4c4cc067a5 100644 --- a/src/gallium/auxiliary/util/u_format_tests.c +++ b/src/gallium/auxiliary/util/u_format_tests.c @@ -120,12 +120,11 @@ util_format_test_cases[] = * 16-bit rendertarget formats */ - {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}}, - {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}}, - {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x8000), {0.0, 0.0, 0.0, 1.0}}, - {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7fff), {1.0, 1.0, 1.0, 1.0}}, {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}}, {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}}, -- cgit v1.2.3 From 325d55303d5920c137c0047e673a3940a99e4629 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 14:31:29 +0100 Subject: util: Make util_format_xxx_pack_xxx take pointer as arguments. --- progs/gallium/unit/u_format_test.c | 8 ++++++-- src/gallium/auxiliary/util/u_format_pack.py | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index 5274311e03..1aef416a7e 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -60,13 +60,17 @@ test_format_unpack_4f(const struct util_format_test_case *test) static boolean test_format_pack_4f(const struct util_format_test_case *test) { + float unpacked[4]; uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; unsigned i; boolean success; memset(packed, 0, sizeof packed); - util_format_pack_4f(test->format, packed, test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]); + for (i = 0; i < 4; ++i) + unpacked[i] = (float) test->unpacked[i]; + + util_format_pack_4f(test->format, packed, unpacked); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) @@ -158,7 +162,7 @@ test_format_pack_4ub(const struct util_format_test_case *test) memset(packed, 0, sizeof packed); - util_format_pack_4ub(test->format, packed, unpacked[0], unpacked[1], unpacked[2], unpacked[3]); + util_format_pack_4ub(test->format, packed, unpacked); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index e9d2573667..43468ecf56 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -423,7 +423,7 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): inv_swizzle = format.inv_swizzles() print 'static INLINE void' - print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type) + print 'util_format_%s_pack_%s(void *dst, const %s *src)' % (name, src_suffix, src_native_type) print '{' if format.is_bitmask(): @@ -434,7 +434,7 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): for i in range(4): dst_channel = format.channels[i] if inv_swizzle[i] is not None: - value = 'rgba'[inv_swizzle[i]] + value ='src[%u]' % inv_swizzle[i] value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if format.colorspace == ZS: if i == 3: @@ -470,7 +470,7 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): width = dst_channel.size if inv_swizzle[i] is None: continue - value = 'rgba'[inv_swizzle[i]] + value ='src[%u]' % inv_swizzle[i] value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if format.colorspace == ZS: if i == 3: @@ -520,9 +520,9 @@ def generate_pack(formats, src_channel, src_native_type, src_suffix): generate_format_pack(format, src_channel, src_native_type, src_suffix) print 'static INLINE void' - print 'util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type) + print 'util_format_pack_%s(enum pipe_format format, void *dst, %s *src)' % (src_suffix, src_native_type) print '{' - print ' void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type) + print ' void (*func)(void *dst, const %s *src);' % (src_native_type,) print ' switch(format) {' for format in formats: if is_format_supported(format): @@ -533,7 +533,7 @@ def generate_pack(formats, src_channel, src_native_type, src_suffix): print ' debug_printf("%s: unsupported format\\n", __FUNCTION__);' print ' return;' print ' }' - print ' func(dst, r, g, b, a);' + print ' func(dst, src);' print '}' print -- cgit v1.2.3 From e245ca74e11869750cafb1ab3fbb6957100c554b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 14:43:09 +0100 Subject: util: Make pack/unpack operate on spans. --- progs/gallium/unit/u_format_test.c | 8 ++-- src/gallium/auxiliary/util/u_format_pack.py | 64 +++++++++++++++++------------ 2 files changed, 42 insertions(+), 30 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index 1aef416a7e..303f4fa499 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -41,7 +41,7 @@ test_format_unpack_4f(const struct util_format_test_case *test) unsigned i; boolean success; - util_format_unpack_4f(test->format, unpacked, test->packed); + util_format_unpack_4f(test->format, unpacked, test->packed, 1); success = TRUE; for (i = 0; i < 4; ++i) @@ -70,7 +70,7 @@ test_format_pack_4f(const struct util_format_test_case *test) for (i = 0; i < 4; ++i) unpacked[i] = (float) test->unpacked[i]; - util_format_pack_4f(test->format, packed, unpacked); + util_format_pack_4f(test->format, packed, unpacked, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) @@ -127,7 +127,7 @@ test_format_unpack_4ub(const struct util_format_test_case *test) unsigned i; boolean success; - util_format_unpack_4ub(test->format, unpacked, test->packed); + util_format_unpack_4ub(test->format, unpacked, test->packed, 1); convert_4f_to_4ub(expected, test->unpacked); @@ -162,7 +162,7 @@ test_format_pack_4ub(const struct util_format_test_case *test) memset(packed, 0, sizeof packed); - util_format_pack_4ub(test->format, packed, unpacked); + util_format_pack_4ub(test->format, packed, unpacked, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 43468ecf56..e156b30203 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -311,24 +311,26 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): src_native_type = native_type(format) print 'static INLINE void' - print 'util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type) + print 'util_format_%s_unpack_%s(%s *dst, const uint8_t *src, unsigned length)' % (name, dst_suffix, dst_native_type) print '{' + print ' while(length--) {' + if format.is_bitmask(): depth = format.block_size() - print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) + print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) # Declare the intermediate variables for i in range(format.nr_channels()): src_channel = format.channels[i] if src_channel.type == UNSIGNED: - print ' uint%u_t %s;' % (depth, src_channel.name) + print ' uint%u_t %s;' % (depth, src_channel.name) elif src_channel.type == SIGNED: - print ' int%u_t %s;' % (depth, src_channel.name) + print ' int%u_t %s;' % (depth, src_channel.name) - print '#ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print '#endif' + print ' #ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print ' #endif' # Compute the intermediate unshifted values shift = 0 @@ -355,7 +357,7 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): value = None if value is not None: - print ' %s = %s;' % (src_channel.name, value) + print ' %s = %s;' % (src_channel.name, value) shift += src_channel.size @@ -379,11 +381,11 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): value = get_one(dst_channel) elif i >= 1: value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) else: - print ' union util_format_%s pixel;' % format.short_name() - print ' memcpy(&pixel, src, sizeof pixel);' + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' bswap_format(format) for i in range(4): @@ -405,7 +407,11 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): value = get_one(dst_channel) elif i >= 1: value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + print ' src += %u;' % (format.block_size() / 8,) + print ' dst += 4;' + print ' }' print '}' print @@ -423,12 +429,14 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): inv_swizzle = format.inv_swizzles() print 'static INLINE void' - print 'util_format_%s_pack_%s(void *dst, const %s *src)' % (name, src_suffix, src_native_type) + print 'util_format_%s_pack_%s(uint8_t *dst, const %s *src, unsigned length)' % (name, src_suffix, src_native_type) print '{' + print ' while(length--) {' + if format.is_bitmask(): depth = format.block_size() - print ' uint%u_t value = 0;' % depth + print ' uint%u_t value = 0;' % depth shift = 0 for i in range(4): @@ -452,18 +460,18 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): else: value = None if value is not None: - print ' value |= %s;' % (value) + print ' value |= %s;' % (value) shift += dst_channel.size print '#ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth + print ' value = util_bswap%u(value);' % depth print '#endif' - print ' *(uint%u_t *)dst = value;' % depth + print ' *(uint%u_t *)dst = value;' % depth else: - print ' union util_format_%s pixel;' % format.short_name() + print ' union util_format_%s pixel;' % format.short_name() for i in range(4): dst_channel = format.channels[i] @@ -477,11 +485,15 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): value = get_one(dst_channel) elif i >= 1: value = '0' - print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) bswap_format(format) - print ' memcpy(dst, &pixel, sizeof pixel);' + print ' memcpy(dst, &pixel, sizeof pixel);' + print ' src += 4;' + print ' dst += %u;' % (format.block_size() / 8,) + print ' }' + print '}' print @@ -494,9 +506,9 @@ def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix): generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) print 'static INLINE void' - print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type) + print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const uint8_t *src, unsigned length)' % (dst_suffix, dst_native_type) print '{' - print ' void (*func)(%s *dst, const void *src);' % dst_native_type + print ' void (*func)(%s *dst, const uint8_t *src, unsigned length);' % dst_native_type print ' switch(format) {' for format in formats: if is_format_supported(format): @@ -507,7 +519,7 @@ def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix): print ' debug_printf("unsupported format\\n");' print ' return;' print ' }' - print ' func(dst, src);' + print ' func(dst, src, length);' print '}' print @@ -520,9 +532,9 @@ def generate_pack(formats, src_channel, src_native_type, src_suffix): generate_format_pack(format, src_channel, src_native_type, src_suffix) print 'static INLINE void' - print 'util_format_pack_%s(enum pipe_format format, void *dst, %s *src)' % (src_suffix, src_native_type) + print 'util_format_pack_%s(enum pipe_format format, uint8_t *dst, const %s *src, unsigned length)' % (src_suffix, src_native_type) print '{' - print ' void (*func)(void *dst, const %s *src);' % (src_native_type,) + print ' void (*func)(uint8_t *dst, const %s *src, unsigned length);' % (src_native_type,) print ' switch(format) {' for format in formats: if is_format_supported(format): @@ -533,7 +545,7 @@ def generate_pack(formats, src_channel, src_native_type, src_suffix): print ' debug_printf("%s: unsupported format\\n", __FUNCTION__);' print ' return;' print ' }' - print ' func(dst, src);' + print ' func(dst, src, length);' print '}' print -- cgit v1.2.3 From 96bf4aff5bd674bba5d83ab32c46024a686c1a1d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 15:30:14 +0100 Subject: util: Put the format pack/unpack functions in the description table. --- progs/gallium/unit/u_format_test.c | 45 +-- src/gallium/auxiliary/Makefile | 6 +- src/gallium/auxiliary/SConscript | 7 - src/gallium/auxiliary/util/.gitignore | 1 - src/gallium/auxiliary/util/u_format.h | 17 ++ src/gallium/auxiliary/util/u_format_access.py | 2 +- src/gallium/auxiliary/util/u_format_pack.py | 389 +++++++++++--------------- src/gallium/auxiliary/util/u_format_table.py | 36 ++- 8 files changed, 245 insertions(+), 258 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index 303f4fa499..e96f0a9d12 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -31,17 +31,17 @@ #include "util/u_format.h" #include "util/u_format_tests.h" -#include "util/u_format_pack.h" static boolean -test_format_unpack_4f(const struct util_format_test_case *test) +test_format_unpack_float(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { float unpacked[4]; unsigned i; boolean success; - util_format_unpack_4f(test->format, unpacked, test->packed, 1); + format_desc->unpack_float(unpacked, test->packed, 1); success = TRUE; for (i = 0; i < 4; ++i) @@ -58,7 +58,8 @@ test_format_unpack_4f(const struct util_format_test_case *test) static boolean -test_format_pack_4f(const struct util_format_test_case *test) +test_format_pack_float(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { float unpacked[4]; uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; @@ -70,7 +71,7 @@ test_format_pack_4f(const struct util_format_test_case *test) for (i = 0; i < 4; ++i) unpacked[i] = (float) test->unpacked[i]; - util_format_pack_4f(test->format, packed, unpacked, 1); + format_desc->pack_float(packed, unpacked, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) @@ -96,7 +97,7 @@ test_format_pack_4f(const struct util_format_test_case *test) static boolean -convert_4f_to_4ub(uint8_t *dst, const double *src) +convert_float_to_8unorm(uint8_t *dst, const double *src) { unsigned i; boolean accurate = TRUE; @@ -120,16 +121,17 @@ convert_4f_to_4ub(uint8_t *dst, const double *src) static boolean -test_format_unpack_4ub(const struct util_format_test_case *test) +test_format_unpack_8unorm(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { uint8_t unpacked[4]; uint8_t expected[4]; unsigned i; boolean success; - util_format_unpack_4ub(test->format, unpacked, test->packed, 1); + format_desc->unpack_8unorm(unpacked, test->packed, 1); - convert_4f_to_4ub(expected, test->unpacked); + convert_float_to_8unorm(expected, test->unpacked); success = TRUE; for (i = 0; i < 4; ++i) @@ -146,14 +148,15 @@ test_format_unpack_4ub(const struct util_format_test_case *test) static boolean -test_format_pack_4ub(const struct util_format_test_case *test) +test_format_pack_8unorm(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { uint8_t unpacked[4]; uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; unsigned i; boolean success; - if (!convert_4f_to_4ub(unpacked, test->unpacked)) { + if (!convert_float_to_8unorm(unpacked, test->unpacked)) { /* * Skip test cases which cannot be represented by four unorm bytes. */ @@ -162,7 +165,7 @@ test_format_pack_4ub(const struct util_format_test_case *test) memset(packed, 0, sizeof packed); - util_format_pack_4ub(test->format, packed, unpacked, 1); + format_desc->pack_8unorm(packed, unpacked, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) @@ -188,7 +191,8 @@ test_format_pack_4ub(const struct util_format_test_case *test) typedef boolean -(*test_func_t)(const struct util_format_test_case *test); +(*test_func_t)(const struct util_format_description *format_desc, + const struct util_format_test_case *test); static boolean @@ -200,14 +204,15 @@ test_one(test_func_t func, const char *suffix) for (i = 0; i < util_format_nr_test_cases; ++i) { const struct util_format_test_case *test = &util_format_test_cases[i]; + const struct util_format_description *format_desc; + format_desc = util_format_description(test->format); + if (test->format != last_format) { - const struct util_format_description *format_desc; - format_desc = util_format_description(test->format); printf("Testing util_format_%s_%s ...\n", format_desc->short_name, suffix); last_format = test->format; } - if (!func(&util_format_test_cases[i])) + if (!func(format_desc, &util_format_test_cases[i])) success = FALSE; } @@ -220,16 +225,16 @@ test_all(void) { bool success = TRUE; - if (!test_one(&test_format_pack_4f, "pack_4f")) + if (!test_one(&test_format_pack_float, "pack_float")) success = FALSE; - if (!test_one(&test_format_unpack_4f, "unpack_4f")) + if (!test_one(&test_format_unpack_float, "unpack_float")) success = FALSE; - if (!test_one(&test_format_pack_4ub, "pack_4ub")) + if (!test_one(&test_format_pack_8unorm, "pack_8unorm")) success = FALSE; - if (!test_one(&test_format_unpack_4ub, "unpack_4ub")) + if (!test_one(&test_format_unpack_8unorm, "unpack_8unorm")) success = FALSE; return success; diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 1b75915ff2..903c5a331c 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -168,7 +168,6 @@ GENERATED_SOURCES = \ indices/u_indices_gen.c \ indices/u_unfilled_gen.c \ util/u_format_access.c \ - util/u_format_pack.h \ util/u_format_table.c @@ -192,12 +191,9 @@ indices/u_indices_gen.c: indices/u_indices_gen.py indices/u_unfilled_gen.c: indices/u_unfilled_gen.py python $< > $@ -util/u_format_table.c: util/u_format_table.py util/u_format_parse.py util/u_format.csv +util/u_format_table.c: util/u_format_table.py util/u_format_pack.py util/u_format_parse.py util/u_format.csv python util/u_format_table.py util/u_format.csv > $@ -util/u_format_pack.h: util/u_format_pack.py util/u_format_parse.py util/u_format.csv - python util/u_format_pack.py util/u_format.csv > $@ - util/u_format_access.c: util/u_format_access.py util/u_format_parse.py util/u_format.csv python util/u_format_access.py util/u_format.csv > $@ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 8cf13fc293..772ab41523 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -30,13 +30,6 @@ env.CodeGenerate( command = 'python $SCRIPT $SOURCE > $TARGET' ) -env.CodeGenerate( - target = File('util/u_format_pack.h').srcnode(), - script = 'util/u_format_pack.py', - source = ['util/u_format.csv'], - command = 'python $SCRIPT $SOURCE > $TARGET' -) - env.CodeGenerate( target = 'util/u_format_access.c', script = 'util/u_format_access.py', diff --git a/src/gallium/auxiliary/util/.gitignore b/src/gallium/auxiliary/util/.gitignore index 448d2f304f..29c586c9b5 100644 --- a/src/gallium/auxiliary/util/.gitignore +++ b/src/gallium/auxiliary/util/.gitignore @@ -1,3 +1,2 @@ u_format_access.c u_format_table.c -u_format_pack.h diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 4d59b9927d..609d398ebf 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -189,6 +189,23 @@ struct util_format_description * Colorspace transformation. */ enum util_format_colorspace colorspace; + + /** + * Accessor functions. + */ + + void + (*unpack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + + void + (*pack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + + void + (*unpack_float)(float *dst, const uint8_t *src, unsigned nr_blocks); + + void + (*pack_float)(uint8_t *dst, const float *src, unsigned nr_blocks); + }; diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index a5cb67f7e4..c85f538626 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -317,7 +317,7 @@ def main(): print print '#include "pipe/p_compiler.h"' print '#include "u_math.h"' - print '#include "u_format_pack.h"' + print '#include "u_format.h"' print generate_srgb_tables() diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index e156b30203..28a9dad60e 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -304,114 +304,116 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to unpack pixels from a particular format''' - assert format.layout == PLAIN - name = format.short_name() - src_native_type = native_type(format) - print 'static INLINE void' print 'util_format_%s_unpack_%s(%s *dst, const uint8_t *src, unsigned length)' % (name, dst_suffix, dst_native_type) print '{' + + if is_format_supported(format): + + assert format.layout == PLAIN - print ' while(length--) {' + src_native_type = native_type(format) - if format.is_bitmask(): - depth = format.block_size() - print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) - - # Declare the intermediate variables - for i in range(format.nr_channels()): - src_channel = format.channels[i] - if src_channel.type == UNSIGNED: - print ' uint%u_t %s;' % (depth, src_channel.name) - elif src_channel.type == SIGNED: - print ' int%u_t %s;' % (depth, src_channel.name) - - print ' #ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print ' #endif' - - # Compute the intermediate unshifted values - shift = 0 - for i in range(format.nr_channels()): - src_channel = format.channels[i] - value = 'value' - if src_channel.type == UNSIGNED: - if shift: - value = '%s >> %u' % (value, shift) - if shift + src_channel.size < depth: - value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) - elif src_channel.type == SIGNED: - if shift + src_channel.size < depth: - # Align the sign bit - lshift = depth - (shift + src_channel.size) - value = '%s << %u' % (value, lshift) - # Cast to signed - value = '(int%u_t)(%s) ' % (depth, value) - if src_channel.size < depth: - # Align the LSB bit - rshift = depth - src_channel.size - value = '(%s) >> %u' % (value, rshift) - else: - value = None - - if value is not None: - print ' %s = %s;' % (src_channel.name, value) - - shift += src_channel.size - - # Convert, swizzle, and store final values - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - src_channel = format.channels[swizzle] - value = src_channel.name - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: - value = get_one(dst_channel) - elif swizzle == SWIZZLE_NONE: - value = '0' - else: - assert False - if format.colorspace == ZS: - if i == 3: + print ' while(length--) {' + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) + + # Declare the intermediate variables + for i in range(format.nr_channels()): + src_channel = format.channels[i] + if src_channel.type == UNSIGNED: + print ' uint%u_t %s;' % (depth, src_channel.name) + elif src_channel.type == SIGNED: + print ' int%u_t %s;' % (depth, src_channel.name) + + print ' #ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print ' #endif' + + # Compute the intermediate unshifted values + shift = 0 + for i in range(format.nr_channels()): + src_channel = format.channels[i] + value = 'value' + if src_channel.type == UNSIGNED: + if shift: + value = '%s >> %u' % (value, shift) + if shift + src_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) + elif src_channel.type == SIGNED: + if shift + src_channel.size < depth: + # Align the sign bit + lshift = depth - (shift + src_channel.size) + value = '%s << %u' % (value, lshift) + # Cast to signed + value = '(int%u_t)(%s) ' % (depth, value) + if src_channel.size < depth: + # Align the LSB bit + rshift = depth - src_channel.size + value = '(%s) >> %u' % (value, rshift) + else: + value = None + + if value is not None: + print ' %s = %s;' % (src_channel.name, value) + + shift += src_channel.size + + # Convert, swizzle, and store final values + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: value = get_one(dst_channel) - elif i >= 1: - value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + else: + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' + bswap_format(format) - else: - print ' union util_format_%s pixel;' % format.short_name() - print ' memcpy(&pixel, src, sizeof pixel);' - bswap_format(format) - - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - src_channel = format.channels[swizzle] - value = 'pixel.chan.%s' % src_channel.name - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: - value = get_one(dst_channel) - elif swizzle == SWIZZLE_NONE: - value = '0' - else: - assert False - if format.colorspace == ZS: - if i == 3: + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = 'pixel.chan.%s' % src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: value = get_one(dst_channel) - elif i >= 1: - value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) - - print ' src += %u;' % (format.block_size() / 8,) - print ' dst += 4;' - print ' }' + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + print ' src += %u;' % (format.block_size() / 8,) + print ' dst += 4;' + print ' }' print '}' print @@ -422,26 +424,63 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): name = format.short_name() - dst_native_type = native_type(format) - - assert format.layout == PLAIN - - inv_swizzle = format.inv_swizzles() - print 'static INLINE void' print 'util_format_%s_pack_%s(uint8_t *dst, const %s *src, unsigned length)' % (name, src_suffix, src_native_type) print '{' - print ' while(length--) {' - - if format.is_bitmask(): - depth = format.block_size() - print ' uint%u_t value = 0;' % depth - - shift = 0 - for i in range(4): - dst_channel = format.channels[i] - if inv_swizzle[i] is not None: + if is_format_supported(format): + dst_native_type = native_type(format) + + assert format.layout == PLAIN + + inv_swizzle = format.inv_swizzles() + + print ' while(length--) {' + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = 0;' % depth + + shift = 0 + for i in range(4): + dst_channel = format.channels[i] + if inv_swizzle[i] is not None: + value ='src[%u]' % inv_swizzle[i] + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = '0' + if dst_channel.type in (UNSIGNED, SIGNED): + if shift + dst_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) + if shift: + value = '(%s) << %u' % (value, shift) + if dst_channel.type == SIGNED: + # Cast to unsigned + value = '(uint%u_t)(%s) ' % (depth, value) + else: + value = None + if value is not None: + print ' value |= %s;' % (value) + + shift += dst_channel.size + + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print '#endif' + + print ' *(uint%u_t *)dst = value;' % depth + + else: + print ' union util_format_%s pixel;' % format.short_name() + + for i in range(4): + dst_channel = format.channels[i] + width = dst_channel.size + if inv_swizzle[i] is None: + continue value ='src[%u]' % inv_swizzle[i] value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if format.colorspace == ZS: @@ -449,50 +488,14 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): value = get_one(dst_channel) elif i >= 1: value = '0' - if dst_channel.type in (UNSIGNED, SIGNED): - if shift + dst_channel.size < depth: - value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) - if shift: - value = '(%s) << %u' % (value, shift) - if dst_channel.type == SIGNED: - # Cast to unsigned - value = '(uint%u_t)(%s) ' % (depth, value) - else: - value = None - if value is not None: - print ' value |= %s;' % (value) - - shift += dst_channel.size - - print '#ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print '#endif' - - print ' *(uint%u_t *)dst = value;' % depth - - else: - print ' union util_format_%s pixel;' % format.short_name() - - for i in range(4): - dst_channel = format.channels[i] - width = dst_channel.size - if inv_swizzle[i] is None: - continue - value ='src[%u]' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - if format.colorspace == ZS: - if i == 3: - value = get_one(dst_channel) - elif i >= 1: - value = '0' - print ' pixel.chan.%s = %s;' % (dst_channel.name, value) - - bswap_format(format) - print ' memcpy(dst, &pixel, sizeof pixel);' + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) - print ' src += 4;' - print ' dst += %u;' % (format.block_size() / 8,) - print ' }' + bswap_format(format) + print ' memcpy(dst, &pixel, sizeof pixel);' + + print ' src += 4;' + print ' dst += %u;' % (format.block_size() / 8,) + print ' }' print '}' print @@ -502,67 +505,17 @@ def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix): '''Generate the dispatch function to unpack pixels from any format''' for format in formats: - if is_format_supported(format): - generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) - - print 'static INLINE void' - print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const uint8_t *src, unsigned length)' % (dst_suffix, dst_native_type) - print '{' - print ' void (*func)(%s *dst, const uint8_t *src, unsigned length);' % dst_native_type - print ' switch(format) {' - for format in formats: - if is_format_supported(format): - print ' case %s:' % format.name - print ' func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix) - print ' break;' - print ' default:' - print ' debug_printf("unsupported format\\n");' - print ' return;' - print ' }' - print ' func(dst, src, length);' - print '}' - print + generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) def generate_pack(formats, src_channel, src_native_type, src_suffix): '''Generate the dispatch function to pack pixels to any format''' for format in formats: - if is_format_supported(format): - generate_format_pack(format, src_channel, src_native_type, src_suffix) - - print 'static INLINE void' - print 'util_format_pack_%s(enum pipe_format format, uint8_t *dst, const %s *src, unsigned length)' % (src_suffix, src_native_type) - print '{' - print ' void (*func)(uint8_t *dst, const %s *src, unsigned length);' % (src_native_type,) - print ' switch(format) {' - for format in formats: - if is_format_supported(format): - print ' case %s:' % format.name - print ' func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix) - print ' break;' - print ' default:' - print ' debug_printf("%s: unsupported format\\n", __FUNCTION__);' - print ' return;' - print ' }' - print ' func(dst, src, length);' - print '}' - print - + generate_format_pack(format, src_channel, src_native_type, src_suffix) -def main(): - formats = [] - for arg in sys.argv[1:]: - formats.extend(parse(arg)) - print '/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */' - print - # This will print the copyright message on the top of this file - print __doc__.strip() - - print - print '#ifndef U_FORMAT_PACK_H' - print '#define U_FORMAT_PACK_H' +def generate(formats): print print '#include "pipe/p_compiler.h"' print '#include "u_math.h"' @@ -572,30 +525,20 @@ def main(): generate_clamp() for format in formats: - if format.layout == PLAIN: + if is_format_supported(format): generate_format_type(format) channel = Channel(FLOAT, False, 32) native_type = 'float' - suffix = '4f' + suffix = 'float' generate_unpack(formats, channel, native_type, suffix) generate_pack(formats, channel, native_type, suffix) channel = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' - suffix = '4ub' + suffix = '8unorm' generate_unpack(formats, channel, native_type, suffix) generate_pack(formats, channel, native_type, suffix) - print - print '#ifdef __cplusplus' - print '}' - print '#endif' - print - print '#endif /* ! U_FORMAT_PACK_H */' - - -if __name__ == '__main__': - main() diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index fb68852a53..fe910d9a77 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -33,6 +33,7 @@ import sys from u_format_parse import * +import u_format_pack def layout_map(layout): @@ -86,6 +87,27 @@ def write_format_table(formats): print print '#include "u_format.h"' print + print ''' +static void +util_format_none_unpack_8unorm(uint8_t *dst, const uint8_t *src, unsigned length) +{ +} + +static void +util_format_none_pack_8unorm(uint8_t *dst, const uint8_t *src, unsigned length) +{ +} + +static void +util_format_none_unpack_float(float *dst, const uint8_t *src, unsigned length) +{ +} + +static void +util_format_none_pack_float(uint8_t *dst, const float *src, unsigned length) +{ +} + ''' print 'const struct util_format_description' print 'util_format_none_description = {' print " PIPE_FORMAT_NONE," @@ -99,9 +121,16 @@ def write_format_table(formats): print " 0," print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," print " {0, 0, 0, 0}," - print " 0" + print " 0," + print " &util_format_none_unpack_8unorm," + print " &util_format_none_pack_8unorm," + print " &util_format_none_unpack_float," + print " &util_format_none_pack_float" print "};" print + + u_format_pack.generate(formats) + for format in formats: print 'const struct util_format_description' print 'util_format_%s_description = {' % (format.short_name(),) @@ -140,8 +169,13 @@ def write_format_table(formats): print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) print " }," print " %s," % (colorspace_map(format.colorspace),) + print " &util_format_%s_unpack_8unorm," % format.short_name() + print " &util_format_%s_pack_8unorm," % format.short_name() + print " &util_format_%s_unpack_float," % format.short_name() + print " &util_format_%s_pack_float" % format.short_name() print "};" print + print "const struct util_format_description *" print "util_format_description(enum pipe_format format)" print "{" -- cgit v1.2.3 From c5d4a44f449a8203a8b1da9b18806a718d80f131 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 17:26:31 +0100 Subject: util: Use u_format_pack.py's code instead of u_format_access.py. --- src/gallium/auxiliary/Makefile | 3 +- src/gallium/auxiliary/SConscript | 9 +- src/gallium/auxiliary/util/.gitignore | 1 - src/gallium/auxiliary/util/u_format.c | 146 +++++++++++ src/gallium/auxiliary/util/u_format_access.py | 344 -------------------------- src/gallium/auxiliary/util/u_format_pack.py | 15 ++ 6 files changed, 163 insertions(+), 355 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_format.c delete mode 100644 src/gallium/auxiliary/util/u_format_access.py (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 903c5a331c..4df3fbd132 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -105,7 +105,7 @@ C_SOURCES = \ util/u_cpu_detect.c \ util/u_dl.c \ util/u_draw_quad.c \ - util/u_format_access.c \ + util/u_format.c \ util/u_format_table.c \ util/u_format_tests.c \ util/u_gen_mipmap.c \ @@ -167,7 +167,6 @@ GALLIVM_CPP_SOURCES = \ GENERATED_SOURCES = \ indices/u_indices_gen.c \ indices/u_unfilled_gen.c \ - util/u_format_access.c \ util/u_format_table.c diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 772ab41523..db2c13ce5b 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -30,13 +30,6 @@ env.CodeGenerate( command = 'python $SCRIPT $SOURCE > $TARGET' ) -env.CodeGenerate( - target = 'util/u_format_access.c', - script = 'util/u_format_access.py', - source = ['util/u_format.csv'], - command = 'python $SCRIPT $SOURCE > $TARGET' -) - source = [ 'cso_cache/cso_context.c', 'cso_cache/cso_cache.c', @@ -142,7 +135,7 @@ source = [ 'util/u_dump_state.c', 'util/u_dl.c', 'util/u_draw_quad.c', - 'util/u_format_access.c', + 'util/u_format.c', 'util/u_format_table.c', 'util/u_format_tests.c', 'util/u_gen_mipmap.c', diff --git a/src/gallium/auxiliary/util/.gitignore b/src/gallium/auxiliary/util/.gitignore index 29c586c9b5..53fe9b8a65 100644 --- a/src/gallium/auxiliary/util/.gitignore +++ b/src/gallium/auxiliary/util/.gitignore @@ -1,2 +1 @@ -u_format_access.c u_format_table.c diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c new file mode 100644 index 0000000000..11ef839ec1 --- /dev/null +++ b/src/gallium/auxiliary/util/u_format.c @@ -0,0 +1,146 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * 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 VMWARE AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +/** + * @file + * Pixel format accessor functions. + * + * @author Jose Fonseca + */ + +#include "u_format.h" + + +void +util_format_read_4f(enum pipe_format format, + float *dst, unsigned dst_stride, + const void *src, unsigned src_stride, + unsigned x, unsigned y, unsigned w, unsigned h) +{ + const struct util_format_description *format_desc; + const uint8_t *src_row; + float *dst_row; + unsigned row_blocks; + unsigned i; + + format_desc = util_format_description(format); + + assert(x % format_desc->block.width == 0); + assert(y % format_desc->block.height == 0); + + src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); + dst_row = dst; + row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; + + for (i = 0; i < h; i += format_desc->block.height) { + format_desc->unpack_float(dst_row, src_row, row_blocks); + src_row += src_stride; + dst_row += dst_stride/sizeof(*dst_row); + } +} + + +void +util_format_write_4f(enum pipe_format format, + const float *src, unsigned src_stride, + void *dst, unsigned dst_stride, + unsigned x, unsigned y, unsigned w, unsigned h) +{ + const struct util_format_description *format_desc; + uint8_t *dst_row; + const float *src_row; + unsigned row_blocks; + unsigned i; + + format_desc = util_format_description(format); + + assert(x % format_desc->block.width == 0); + assert(y % format_desc->block.height == 0); + + dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); + src_row = src; + row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; + + for (i = 0; i < h; i += format_desc->block.height) { + format_desc->pack_float(dst_row, src_row, row_blocks); + dst_row += dst_stride; + src_row += src_stride/sizeof(*src_row); + } +} + + +void +util_format_read_4ub(enum pipe_format format, uint8_t *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h) +{ + const struct util_format_description *format_desc; + const uint8_t *src_row; + uint8_t *dst_row; + unsigned row_blocks; + unsigned i; + + format_desc = util_format_description(format); + + assert(x % format_desc->block.width == 0); + assert(y % format_desc->block.height == 0); + + src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); + dst_row = dst; + row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; + + for (i = 0; i < h; i += format_desc->block.height) { + format_desc->unpack_8unorm(dst_row, src_row, row_blocks); + src_row += src_stride; + dst_row += dst_stride/sizeof(*dst_row); + } +} + + +void +util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h) +{ + const struct util_format_description *format_desc; + uint8_t *dst_row; + const uint8_t *src_row; + unsigned row_blocks; + unsigned i; + + format_desc = util_format_description(format); + + assert(x % format_desc->block.width == 0); + assert(y % format_desc->block.height == 0); + + dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); + src_row = src; + row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; + + for (i = 0; i < h; i += format_desc->block.height) { + format_desc->pack_8unorm(dst_row, src_row, row_blocks); + dst_row += dst_stride; + src_row += src_stride/sizeof(*src_row); + } +} + diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py deleted file mode 100644 index 1c76d9a79d..0000000000 --- a/src/gallium/auxiliary/util/u_format_access.py +++ /dev/null @@ -1,344 +0,0 @@ -#!/usr/bin/env python - -''' -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * 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 VMWARE AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * @file - * Pixel format accessor functions. - * - * @author Jose Fonseca - */ -''' - - -import math -import sys - -from u_format_pack import * - - -def is_format_supported(format): - '''Determines whether we actually have the plumbing necessary to generate the - to read/write to/from this format.''' - - # FIXME: Ideally we would support any format combination here. - - # XXX: It should be straightforward to support srgb - if format.colorspace not in ('rgb', 'zs'): - return False - - if format.layout != PLAIN: - return False - - for i in range(4): - channel = format.channels[i] - if channel.type not in (VOID, UNSIGNED, FLOAT): - return False - if channel.type == FLOAT: - if channel.size not in (32, 64) or format.is_mixed(): - return False - - # We can only read a color from a depth/stencil format if the depth channel is present - if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: - return False - - return True - - -def native_type(format): - '''Get the native appropriate for a format.''' - - if format.layout == PLAIN: - if not format.is_array(): - # For arithmetic pixel formats return the integer type that matches the whole pixel - return 'uint%u_t' % format.block_size() - else: - # For array pixel formats return the integer type that matches the color channel - channel = format.channels[0] - if channel.type in (UNSIGNED, VOID): - return 'uint%u_t' % channel.size - elif channel.type == SIGNED: - return 'int%u_t' % channel.size - elif channel.type == FLOAT: - if channel.size == 32: - return 'float' - elif channel.size == 64: - return 'double' - else: - assert False - else: - assert False - else: - assert False - - -def generate_srgb_tables(): - print 'static ubyte srgb_to_linear[256] = {' - for i in range(256): - print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255)) - print '};' - print - print 'static ubyte linear_to_srgb[256] = {' - print ' 0,' - for i in range(1, 256): - print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255)) - print '};' - print - - -def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): - '''Generate the function to read pixels from a particular format''' - - name = format.short_name() - - src_native_type = native_type(format) - - print 'static void' - print 'util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type) - print '{' - print ' unsigned x, y;' - print ' const uint8_t *src_row = src + y0*src_stride;' - print ' %s *dst_row = dst;' % dst_native_type - print ' for (y = 0; y < h; ++y) {' - print ' const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride()) - print ' %s *dst_pixel = dst_row;' %dst_native_type - print ' for (x = 0; x < w; ++x) {' - - names = ['']*4 - if format.colorspace == 'rgb': - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - names[swizzle] += 'rgba'[i] - elif format.colorspace == 'zs': - swizzle = format.swizzles[0] - if swizzle < 4: - names[swizzle] = 'z' - else: - assert False - else: - assert False - - if format.layout == PLAIN: - if not format.is_array(): - print ' %s pixel = *src_pixel++;' % src_native_type - shift = 0; - for i in range(4): - src_channel = format.channels[i] - width = src_channel.size - if names[i]: - value = 'pixel' - mask = (1 << width) - 1 - if shift: - value = '(%s >> %u)' % (value, shift) - if shift + width < format.block_size(): - value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - print ' %s %s = %s;' % (dst_native_type, names[i], value) - shift += width - else: - for i in range(4): - src_channel = format.channels[i] - if names[i]: - value = 'src_pixel[%u]' % i - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - print ' %s %s = %s;' % (dst_native_type, names[i], value) - print ' src_pixel += %u;' % (format.nr_channels()) - else: - assert False - - for i in range(4): - if format.colorspace == 'rgb': - swizzle = format.swizzles[i] - if swizzle < 4: - value = names[swizzle] - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: - value = get_one(dst_channel) - else: - assert False - elif format.colorspace == 'zs': - if i < 3: - value = 'z' - else: - value = get_one(dst_channel) - else: - assert False - print ' *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i]) - - print ' }' - print ' src_row += src_stride;' - print ' dst_row += dst_stride/sizeof(*dst_row);' - print ' }' - print '}' - print - - -def generate_format_write(format, src_channel, src_native_type, src_suffix): - '''Generate the function to write pixels to a particular format''' - - name = format.short_name() - - dst_native_type = native_type(format) - - print 'static void' - print 'util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type) - print '{' - print ' unsigned x, y;' - print ' uint8_t *dst_row = dst + y0*dst_stride;' - print ' const %s *src_row = src;' % src_native_type - print ' for (y = 0; y < h; ++y) {' - print ' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride()) - print ' const %s *src_pixel = src_row;' %src_native_type - print ' for (x = 0; x < w; ++x) {' - - inv_swizzle = format.inv_swizzles() - - if format.layout == PLAIN: - if not format.is_array(): - print ' %s pixel = 0;' % dst_native_type - shift = 0; - for i in range(4): - dst_channel = format.channels[i] - width = dst_channel.size - if inv_swizzle[i] is not None: - value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - if shift: - value = '(%s << %u)' % (value, shift) - print ' pixel |= %s;' % value - shift += width - print ' *dst_pixel++ = pixel;' - else: - for i in range(4): - dst_channel = format.channels[i] - if inv_swizzle[i] is not None: - value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - print ' *dst_pixel++ = %s;' % value - else: - assert False - print ' src_pixel += 4;' - - print ' }' - print ' dst_row += dst_stride;' - print ' src_row += src_stride/sizeof(*src_row);' - print ' }' - print '}' - print - - -def generate_read(formats, dst_channel, dst_native_type, dst_suffix): - '''Generate the dispatch function to read pixels from any format''' - - for format in formats: - if is_format_supported(format): - generate_format_read(format, dst_channel, dst_native_type, dst_suffix) - - print 'void' - print 'util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type) - print '{' - print ' void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type - print ' switch(format) {' - for format in formats: - if is_format_supported(format): - print ' case %s:' % format.name - print ' func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix) - print ' break;' - print ' default:' - print ' debug_printf("unsupported format\\n");' - print ' return;' - print ' }' - print ' func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);' - print '}' - print - - -def generate_write(formats, src_channel, src_native_type, src_suffix): - '''Generate the dispatch function to write pixels to any format''' - - for format in formats: - if is_format_supported(format): - generate_format_write(format, src_channel, src_native_type, src_suffix) - - print 'void' - print 'util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type) - - print '{' - print ' void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type - print ' switch(format) {' - for format in formats: - if is_format_supported(format): - print ' case %s:' % format.name - print ' func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix) - print ' break;' - print ' default:' - print ' debug_printf("unsupported format\\n");' - print ' return;' - print ' }' - print ' func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);' - print '}' - print - - -def main(): - formats = [] - for arg in sys.argv[1:]: - formats.extend(parse(arg)) - - print '/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */' - print - # This will print the copyright message on the top of this file - print __doc__.strip() - print - print '#include "pipe/p_compiler.h"' - print '#include "u_math.h"' - print '#include "u_format.h"' - print - - generate_srgb_tables() - - type = Channel(FLOAT, False, 32) - native_type = 'float' - suffix = '4f' - - generate_read(formats, type, native_type, suffix) - generate_write(formats, type, native_type, suffix) - - type = Channel(UNSIGNED, True, 8) - native_type = 'uint8_t' - suffix = '4ub' - - generate_read(formats, type, native_type, suffix) - generate_write(formats, type, native_type, suffix) - - -if __name__ == '__main__': - main() diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index f40b3bdf2e..4831912f02 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -38,6 +38,7 @@ import sys +import math from u_format_parse import * @@ -90,6 +91,20 @@ def generate_format_type(format): print +def generate_srgb_tables(): + print 'static ubyte srgb_to_linear[256] = {' + for i in range(256): + print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255)) + print '};' + print + print 'static ubyte linear_to_srgb[256] = {' + print ' 0,' + for i in range(1, 256): + print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255)) + print '};' + print + + def bswap_format(format): '''Generate a structure that describes the format.''' -- cgit v1.2.3 From f1f6370eb41dc83c65c415c7cfd6699a36559172 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 17:29:51 +0100 Subject: util: Remove the hand written u_tile.c functions for the ones that are code generated correctly. Not that the code generated are any better, but to quickly detect any regression in the code generated ones from now on. --- src/gallium/auxiliary/util/u_tile.c | 783 ------------------------------------ 1 file changed, 783 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index e03ee9b8bd..43b45eb926 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -108,436 +108,6 @@ pipe_put_tile_raw(struct pipe_context *pipe, -/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/ - -static void -a8r8g8b8_get_tile_rgba(const unsigned *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const unsigned pixel = *src++; - pRow[0] = ubyte_to_float((pixel >> 16) & 0xff); - pRow[1] = ubyte_to_float((pixel >> 8) & 0xff); - pRow[2] = ubyte_to_float((pixel >> 0) & 0xff); - pRow[3] = ubyte_to_float((pixel >> 24) & 0xff); - } - p += dst_stride; - } -} - - -static void -a8r8g8b8_put_tile_rgba(unsigned *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, g, b, a; - r = float_to_ubyte(pRow[0]); - g = float_to_ubyte(pRow[1]); - b = float_to_ubyte(pRow[2]); - a = float_to_ubyte(pRow[3]); - *dst++ = (a << 24) | (r << 16) | (g << 8) | b; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_B8G8R8X8_UNORM ***/ - -static void -x8r8g8b8_get_tile_rgba(const unsigned *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const unsigned pixel = *src++; - pRow[0] = ubyte_to_float((pixel >> 16) & 0xff); - pRow[1] = ubyte_to_float((pixel >> 8) & 0xff); - pRow[2] = ubyte_to_float((pixel >> 0) & 0xff); - pRow[3] = 1.0F; - } - p += dst_stride; - } -} - - -static void -x8r8g8b8_put_tile_rgba(unsigned *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, g, b; - r = float_to_ubyte(pRow[0]); - g = float_to_ubyte(pRow[1]); - b = float_to_ubyte(pRow[2]); - *dst++ = (0xff << 24) | (r << 16) | (g << 8) | b; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/ - -static void -b8g8r8a8_get_tile_rgba(const unsigned *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const unsigned pixel = *src++; - pRow[0] = ubyte_to_float((pixel >> 8) & 0xff); - pRow[1] = ubyte_to_float((pixel >> 16) & 0xff); - pRow[2] = ubyte_to_float((pixel >> 24) & 0xff); - pRow[3] = ubyte_to_float((pixel >> 0) & 0xff); - } - p += dst_stride; - } -} - - -static void -b8g8r8a8_put_tile_rgba(unsigned *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, g, b, a; - r = float_to_ubyte(pRow[0]); - g = float_to_ubyte(pRow[1]); - b = float_to_ubyte(pRow[2]); - a = float_to_ubyte(pRow[3]); - *dst++ = (b << 24) | (g << 16) | (r << 8) | a; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_A8B8G8R8_UNORM ***/ - -static void -r8g8b8a8_get_tile_rgba(const unsigned *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const unsigned pixel = *src++; - pRow[0] = ubyte_to_float((pixel >> 24) & 0xff); - pRow[1] = ubyte_to_float((pixel >> 16) & 0xff); - pRow[2] = ubyte_to_float((pixel >> 8) & 0xff); - pRow[3] = ubyte_to_float((pixel >> 0) & 0xff); - } - p += dst_stride; - } -} - - -static void -r8g8b8a8_put_tile_rgba(unsigned *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, g, b, a; - r = float_to_ubyte(pRow[0]); - g = float_to_ubyte(pRow[1]); - b = float_to_ubyte(pRow[2]); - a = float_to_ubyte(pRow[3]); - *dst++ = (r << 24) | (g << 16) | (b << 8) | a; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_B5G5R5X1_UNORM ***/ - -static void -x1r5g5b5_get_tile_rgba(const ushort *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const ushort pixel = *src++; - pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f); - pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f); - pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); - pRow[3] = 1.0f; - } - p += dst_stride; - } -} - - -static void -x1r5g5b5_put_tile_rgba(ushort *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, g, b; - r = float_to_ubyte(pRow[0]); - g = float_to_ubyte(pRow[1]); - b = float_to_ubyte(pRow[2]); - r = r >> 3; /* 5 bits */ - g = g >> 3; /* 5 bits */ - b = b >> 3; /* 5 bits */ - *dst++ = (1 << 15) | (r << 10) | (g << 5) | b; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_B5G5R5A1_UNORM ***/ - -static void -a1r5g5b5_get_tile_rgba(const ushort *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const ushort pixel = *src++; - pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f); - pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f); - pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); - pRow[3] = ((pixel >> 15) ) * 1.0f; - } - p += dst_stride; - } -} - - -static void -a1r5g5b5_put_tile_rgba(ushort *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, g, b, a; - r = float_to_ubyte(pRow[0]); - g = float_to_ubyte(pRow[1]); - b = float_to_ubyte(pRow[2]); - a = float_to_ubyte(pRow[3]); - r = r >> 3; /* 5 bits */ - g = g >> 3; /* 5 bits */ - b = b >> 3; /* 5 bits */ - a = a >> 7; /* 1 bit */ - *dst++ = (a << 15) | (r << 10) | (g << 5) | b; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_B4G4R4A4_UNORM ***/ - -static void -a4r4g4b4_get_tile_rgba(const ushort *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const ushort pixel = *src++; - pRow[0] = ((pixel >> 8) & 0xf) * (1.0f / 15.0f); - pRow[1] = ((pixel >> 4) & 0xf) * (1.0f / 15.0f); - pRow[2] = ((pixel ) & 0xf) * (1.0f / 15.0f); - pRow[3] = ((pixel >> 12) ) * (1.0f / 15.0f); - } - p += dst_stride; - } -} - - -static void -a4r4g4b4_put_tile_rgba(ushort *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, g, b, a; - r = float_to_ubyte(pRow[0]); - g = float_to_ubyte(pRow[1]); - b = float_to_ubyte(pRow[2]); - a = float_to_ubyte(pRow[3]); - r >>= 4; - g >>= 4; - b >>= 4; - a >>= 4; - *dst++ = (a << 12) | (r << 8) | (g << 4) | b; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_B5G6R5_UNORM ***/ - -static void -r5g6b5_get_tile_rgba(const ushort *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - const ushort pixel = *src++; - pRow[0] = ((pixel >> 11) & 0x1f) * (1.0f / 31.0f); - pRow[1] = ((pixel >> 5) & 0x3f) * (1.0f / 63.0f); - pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); - pRow[3] = 1.0f; - } - p += dst_stride; - } -} - - -static void -r5g6b5_put_tile_rgba(ushort *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - uint r = (uint) (CLAMP(pRow[0], 0.0, 1.0) * 31.0); - uint g = (uint) (CLAMP(pRow[1], 0.0, 1.0) * 63.0); - uint b = (uint) (CLAMP(pRow[2], 0.0, 1.0) * 31.0); - *dst++ = (r << 11) | (g << 5) | (b); - } - p += src_stride; - } -} - - - -/*** PIPE_FORMAT_R8G8B8_UNORM ***/ - -static void -r8g8b8_get_tile_rgba(const ubyte *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - pRow[0] = ubyte_to_float(src[0]); - pRow[1] = ubyte_to_float(src[1]); - pRow[2] = ubyte_to_float(src[2]); - pRow[3] = 1.0f; - src += 3; - } - p += dst_stride; - } -} - - -static void -r8g8b8_put_tile_rgba(ubyte *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - dst[0] = float_to_ubyte(pRow[0]); - dst[1] = float_to_ubyte(pRow[1]); - dst[2] = float_to_ubyte(pRow[2]); - dst += 3; - } - p += src_stride; - } -} - - - /*** PIPE_FORMAT_Z16_UNORM ***/ /** @@ -567,179 +137,6 @@ z16_get_tile_rgba(const ushort *src, -/*** PIPE_FORMAT_L8_UNORM ***/ - -static void -l8_get_tile_rgba(const ubyte *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, src++, pRow += 4) { - pRow[0] = - pRow[1] = - pRow[2] = ubyte_to_float(*src); - pRow[3] = 1.0; - } - p += dst_stride; - } -} - - -static void -l8_put_tile_rgba(ubyte *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r; - r = float_to_ubyte(pRow[0]); - *dst++ = (ubyte) r; - } - p += src_stride; - } -} - - - -/*** PIPE_FORMAT_A8_UNORM ***/ - -static void -a8_get_tile_rgba(const ubyte *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, src++, pRow += 4) { - pRow[0] = - pRow[1] = - pRow[2] = 0.0; - pRow[3] = ubyte_to_float(*src); - } - p += dst_stride; - } -} - - -static void -a8_put_tile_rgba(ubyte *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned a; - a = float_to_ubyte(pRow[3]); - *dst++ = (ubyte) a; - } - p += src_stride; - } -} - - - -/*** PIPE_FORMAT_R16_SNORM ***/ - -static void -r16_get_tile_rgba(const short *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, src++, pRow += 4) { - pRow[0] = SHORT_TO_FLOAT(src[0]); - pRow[1] = - pRow[2] = 0.0; - pRow[3] = 1.0; - } - p += dst_stride; - } -} - - -static void -r16_put_tile_rgba(short *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, dst++, pRow += 4) { - UNCLAMPED_FLOAT_TO_SHORT(dst[0], pRow[0]); - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_R16G16B16A16_SNORM ***/ - -static void -r16g16b16a16_get_tile_rgba(const short *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, src += 4, pRow += 4) { - pRow[0] = SHORT_TO_FLOAT(src[0]); - pRow[1] = SHORT_TO_FLOAT(src[1]); - pRow[2] = SHORT_TO_FLOAT(src[2]); - pRow[3] = SHORT_TO_FLOAT(src[3]); - } - p += dst_stride; - } -} - - -static void -r16g16b16a16_put_tile_rgba(short *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, dst += 4, pRow += 4) { - UNCLAMPED_FLOAT_TO_SHORT(dst[0], pRow[0]); - UNCLAMPED_FLOAT_TO_SHORT(dst[1], pRow[1]); - UNCLAMPED_FLOAT_TO_SHORT(dst[2], pRow[2]); - UNCLAMPED_FLOAT_TO_SHORT(dst[3], pRow[3]); - } - p += src_stride; - } -} - - /*** PIPE_FORMAT_A8B8G8R8_SRGB ***/ /** @@ -919,96 +316,6 @@ l8_srgb_put_tile_rgba(ubyte *dst, } -/*** PIPE_FORMAT_I8_UNORM ***/ - -static void -i8_get_tile_rgba(const ubyte *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, src++, pRow += 4) { - pRow[0] = - pRow[1] = - pRow[2] = - pRow[3] = ubyte_to_float(*src); - } - p += dst_stride; - } -} - - -static void -i8_put_tile_rgba(ubyte *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r; - r = float_to_ubyte(pRow[0]); - *dst++ = (ubyte) r; - } - p += src_stride; - } -} - - -/*** PIPE_FORMAT_L8A8_UNORM ***/ - -static void -a8l8_get_tile_rgba(const ushort *src, - unsigned w, unsigned h, - float *p, - unsigned dst_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - ushort p = *src++; - pRow[0] = - pRow[1] = - pRow[2] = ubyte_to_float(p & 0xff); - pRow[3] = ubyte_to_float(p >> 8); - } - p += dst_stride; - } -} - - -static void -a8l8_put_tile_rgba(ushort *dst, - unsigned w, unsigned h, - const float *p, - unsigned src_stride) -{ - unsigned i, j; - - for (i = 0; i < h; i++) { - const float *pRow = p; - for (j = 0; j < w; j++, pRow += 4) { - unsigned r, a; - r = float_to_ubyte(pRow[0]); - a = float_to_ubyte(pRow[3]); - *dst++ = (a << 8) | r; - } - p += src_stride; - } -} - - - - /*** PIPE_FORMAT_Z32_UNORM ***/ /** @@ -1211,51 +518,6 @@ pipe_tile_raw_to_rgba(enum pipe_format format, float *dst, unsigned dst_stride) { switch (format) { - case PIPE_FORMAT_B8G8R8A8_UNORM: - a8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_B8G8R8X8_UNORM: - x8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_A8R8G8B8_UNORM: - b8g8r8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_A8B8G8R8_UNORM: - r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_B5G5R5X1_UNORM: - x1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_B5G5R5A1_UNORM: - a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_B4G4R4A4_UNORM: - a4r4g4b4_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_B5G6R5_UNORM: - r5g6b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_R8G8B8_UNORM: - r8g8b8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_L8_UNORM: - l8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_A8_UNORM: - a8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_I8_UNORM: - i8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_L8A8_UNORM: - a8l8_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_R16_SNORM: - r16_get_tile_rgba((short *) src, w, h, dst, dst_stride); - break; - case PIPE_FORMAT_R16G16B16A16_SNORM: - r16g16b16a16_get_tile_rgba((short *) src, w, h, dst, dst_stride); - break; case PIPE_FORMAT_B8G8R8A8_SRGB: a8r8g8b8_srgb_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; @@ -1408,51 +670,6 @@ pipe_put_tile_rgba(struct pipe_context *pipe, return; switch (format) { - case PIPE_FORMAT_B8G8R8A8_UNORM: - a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_B8G8R8X8_UNORM: - x8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_A8R8G8B8_UNORM: - b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_A8B8G8R8_UNORM: - r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_B5G5R5X1_UNORM: - x1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_B5G5R5A1_UNORM: - a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_B5G6R5_UNORM: - r5g6b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_R8G8B8_UNORM: - r8g8b8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_B4G4R4A4_UNORM: - a4r4g4b4_put_tile_rgba((ushort *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_L8_UNORM: - l8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_A8_UNORM: - a8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_I8_UNORM: - i8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_L8A8_UNORM: - a8l8_put_tile_rgba((ushort *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_R16_SNORM: - r16_put_tile_rgba((short *) packed, w, h, p, src_stride); - break; - case PIPE_FORMAT_R16G16B16A16_SNORM: - r16g16b16a16_put_tile_rgba((short *) packed, w, h, p, src_stride); - break; case PIPE_FORMAT_B8G8R8A8_SRGB: a8r8g8b8_srgb_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; -- cgit v1.2.3 From 69895725cfe9d4dc917ff6e643af9e6e3a6e093f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 20:15:17 +0100 Subject: util: Add callback to fetch a single pixel. --- progs/gallium/unit/u_format_test.c | 34 +++ src/gallium/auxiliary/util/u_format.h | 17 +- src/gallium/auxiliary/util/u_format_pack.py | 360 ++++++++++++++------------- src/gallium/auxiliary/util/u_format_table.py | 11 +- 4 files changed, 248 insertions(+), 174 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index e96f0a9d12..ba4e9fab66 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -33,6 +33,37 @@ #include "util/u_format_tests.h" +static boolean +test_format_fetch_float(const struct util_format_description *format_desc, + const struct util_format_test_case *test) +{ + float unpacked[4]; + unsigned i; + boolean success; + + /* + * TODO: test block formats too. + */ + if (format_desc->block.width != 1 && format_desc->block.height != 1) { + return TRUE; + } + + format_desc->fetch_float(unpacked, test->packed, 0, 0); + + success = TRUE; + for (i = 0; i < 4; ++i) + if (test->unpacked[i] != unpacked[i]) + success = FALSE; + + if (!success) { + printf("FAILED: (%f %f %f %f) obtained\n", unpacked[0], unpacked[1], unpacked[2], unpacked[3]); + printf(" (%f %f %f %f) expected\n", test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]); + } + + return success; +} + + static boolean test_format_unpack_float(const struct util_format_description *format_desc, const struct util_format_test_case *test) @@ -225,6 +256,9 @@ test_all(void) { bool success = TRUE; + if (!test_one(&test_format_fetch_float, "fetch_float")) + success = FALSE; + if (!test_one(&test_format_pack_float, "pack_float")) success = FALSE; diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 609d398ebf..8e76e13b66 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -191,21 +191,34 @@ struct util_format_description enum util_format_colorspace colorspace; /** - * Accessor functions. + * Unpack a span of pixel blocks to R8G8B8A8_UNORM. */ - void (*unpack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + /** + * Pack a span of pixel blocks from R8G8B8A8_UNORM. + */ void (*pack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + /** + * Unpack a span of pixel blocks to R32G32B32A32_FLOAT. + */ void (*unpack_float)(float *dst, const uint8_t *src, unsigned nr_blocks); + /** + * Pack a span of pixel blocks from R32G32B32A32_FLOAT. + */ void (*pack_float)(uint8_t *dst, const float *src, unsigned nr_blocks); + /** + * Fetch a single pixel (i, j) from a block. + */ + void + (*fetch_float)(float *dst, const uint8_t *src, unsigned i, unsigned j); }; diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 4831912f02..c74900ce63 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -324,115 +324,190 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True assert False -def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): - '''Generate the function to unpack pixels from a particular format''' - - name = format.short_name() - - print 'static INLINE void' - print 'util_format_%s_unpack_%s(%s *dst, const uint8_t *src, unsigned length)' % (name, dst_suffix, dst_native_type) - print '{' +def generate_unpack_kernel(format, dst_channel, dst_native_type): - if is_format_supported(format): - - assert format.layout == PLAIN - - src_native_type = native_type(format) - - print ' while(length--) {' - - if format.is_bitmask(): - depth = format.block_size() - print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) + if not is_format_supported(format): + return - # Declare the intermediate variables - for i in range(format.nr_channels()): - src_channel = format.channels[i] - if src_channel.type == UNSIGNED: - print ' uint%u_t %s;' % (depth, src_channel.name) - elif src_channel.type == SIGNED: - print ' int%u_t %s;' % (depth, src_channel.name) + assert format.layout == PLAIN + + src_native_type = native_type(format) + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) + + # Declare the intermediate variables + for i in range(format.nr_channels()): + src_channel = format.channels[i] + if src_channel.type == UNSIGNED: + print ' uint%u_t %s;' % (depth, src_channel.name) + elif src_channel.type == SIGNED: + print ' int%u_t %s;' % (depth, src_channel.name) + + print ' #ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print ' #endif' + + # Compute the intermediate unshifted values + shift = 0 + for i in range(format.nr_channels()): + src_channel = format.channels[i] + value = 'value' + if src_channel.type == UNSIGNED: + if shift: + value = '%s >> %u' % (value, shift) + if shift + src_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) + elif src_channel.type == SIGNED: + if shift + src_channel.size < depth: + # Align the sign bit + lshift = depth - (shift + src_channel.size) + value = '%s << %u' % (value, lshift) + # Cast to signed + value = '(int%u_t)(%s) ' % (depth, value) + if src_channel.size < depth: + # Align the LSB bit + rshift = depth - src_channel.size + value = '(%s) >> %u' % (value, rshift) + else: + value = None + + if value is not None: + print ' %s = %s;' % (src_channel.name, value) + + shift += src_channel.size + + # Convert, swizzle, and store final values + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: + value = get_one(dst_channel) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + else: + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' + bswap_format(format) - print ' #ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print ' #endif' + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = 'pixel.chan.%s' % src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: + value = get_one(dst_channel) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) - # Compute the intermediate unshifted values - shift = 0 - for i in range(format.nr_channels()): - src_channel = format.channels[i] - value = 'value' - if src_channel.type == UNSIGNED: - if shift: - value = '%s >> %u' % (value, shift) - if shift + src_channel.size < depth: - value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) - elif src_channel.type == SIGNED: - if shift + src_channel.size < depth: - # Align the sign bit - lshift = depth - (shift + src_channel.size) - value = '%s << %u' % (value, lshift) - # Cast to signed - value = '(int%u_t)(%s) ' % (depth, value) - if src_channel.size < depth: - # Align the LSB bit - rshift = depth - src_channel.size - value = '(%s) >> %u' % (value, rshift) - else: - value = None - - if value is not None: - print ' %s = %s;' % (src_channel.name, value) - - shift += src_channel.size + +def generate_pack_kernel(format, src_channel, src_native_type): + + if not is_format_supported(format): + return - # Convert, swizzle, and store final values - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - src_channel = format.channels[swizzle] - value = src_channel.name - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: - value = get_one(dst_channel) - elif swizzle == SWIZZLE_NONE: - value = '0' - else: - assert False + dst_native_type = native_type(format) + + assert format.layout == PLAIN + + inv_swizzle = format.inv_swizzles() + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = 0;' % depth + + shift = 0 + for i in range(4): + dst_channel = format.channels[i] + if inv_swizzle[i] is not None: + value ='src[%u]' % inv_swizzle[i] + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if format.colorspace == ZS: if i == 3: value = get_one(dst_channel) elif i >= 1: - value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) - - else: - print ' union util_format_%s pixel;' % format.short_name() - print ' memcpy(&pixel, src, sizeof pixel);' - bswap_format(format) + value = '0' + if dst_channel.type in (UNSIGNED, SIGNED): + if shift + dst_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) + if shift: + value = '(%s) << %u' % (value, shift) + if dst_channel.type == SIGNED: + # Cast to unsigned + value = '(uint%u_t)(%s) ' % (depth, value) + else: + value = None + if value is not None: + print ' value |= %s;' % (value) + + shift += dst_channel.size + + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print '#endif' - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - src_channel = format.channels[swizzle] - value = 'pixel.chan.%s' % src_channel.name - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: + print ' *(uint%u_t *)dst = value;' % depth + + else: + print ' union util_format_%s pixel;' % format.short_name() + + for i in range(4): + dst_channel = format.channels[i] + width = dst_channel.size + if inv_swizzle[i] is None: + continue + value ='src[%u]' % inv_swizzle[i] + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + if format.colorspace == ZS: + if i == 3: value = get_one(dst_channel) - elif swizzle == SWIZZLE_NONE: + elif i >= 1: value = '0' - else: - assert False - if format.colorspace == ZS: - if i == 3: - value = get_one(dst_channel) - elif i >= 1: - value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + + bswap_format(format) + print ' memcpy(dst, &pixel, sizeof pixel);' + + +def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): + '''Generate the function to unpack pixels from a particular format''' + + name = format.short_name() + + print 'static INLINE void' + print 'util_format_%s_unpack_%s(%s *dst, const uint8_t *src, unsigned length)' % (name, dst_suffix, dst_native_type) + print '{' + + if is_format_supported(format): + print ' while(length--) {' + + generate_unpack_kernel(format, dst_channel, dst_native_type) print ' src += %u;' % (format.block_size() / 8,) print ' dst += 4;' @@ -452,69 +527,9 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): print '{' if is_format_supported(format): - dst_native_type = native_type(format) - - assert format.layout == PLAIN - - inv_swizzle = format.inv_swizzles() - print ' while(length--) {' - if format.is_bitmask(): - depth = format.block_size() - print ' uint%u_t value = 0;' % depth - - shift = 0 - for i in range(4): - dst_channel = format.channels[i] - if inv_swizzle[i] is not None: - value ='src[%u]' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - if format.colorspace == ZS: - if i == 3: - value = get_one(dst_channel) - elif i >= 1: - value = '0' - if dst_channel.type in (UNSIGNED, SIGNED): - if shift + dst_channel.size < depth: - value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) - if shift: - value = '(%s) << %u' % (value, shift) - if dst_channel.type == SIGNED: - # Cast to unsigned - value = '(uint%u_t)(%s) ' % (depth, value) - else: - value = None - if value is not None: - print ' value |= %s;' % (value) - - shift += dst_channel.size - - print '#ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print '#endif' - - print ' *(uint%u_t *)dst = value;' % depth - - else: - print ' union util_format_%s pixel;' % format.short_name() - - for i in range(4): - dst_channel = format.channels[i] - width = dst_channel.size - if inv_swizzle[i] is None: - continue - value ='src[%u]' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - if format.colorspace == ZS: - if i == 3: - value = get_one(dst_channel) - elif i >= 1: - value = '0' - print ' pixel.chan.%s = %s;' % (dst_channel.name, value) - - bswap_format(format) - print ' memcpy(dst, &pixel, sizeof pixel);' + generate_pack_kernel(format, src_channel, src_native_type) print ' src += 4;' print ' dst += %u;' % (format.block_size() / 8,) @@ -524,18 +539,20 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): print -def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix): - '''Generate the dispatch function to unpack pixels from any format''' +def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix): + '''Generate the function to unpack pixels from a particular format''' - for format in formats: - generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) + name = format.short_name() + print 'static INLINE void' + print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, unsigned i, unsigned j)' % (name, dst_suffix, dst_native_type) + print '{' -def generate_pack(formats, src_channel, src_native_type, src_suffix): - '''Generate the dispatch function to pack pixels to any format''' + if is_format_supported(format): + generate_unpack_kernel(format, dst_channel, dst_native_type) - for format in formats: - generate_format_pack(format, src_channel, src_native_type, src_suffix) + print '}' + print def generate(formats): @@ -555,13 +572,16 @@ def generate(formats): native_type = 'float' suffix = 'float' - generate_unpack(formats, channel, native_type, suffix) - generate_pack(formats, channel, native_type, suffix) + for format in formats: + generate_format_unpack(format, channel, native_type, suffix) + generate_format_pack(format, channel, native_type, suffix) + generate_format_fetch(format, channel, native_type, suffix) channel = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' suffix = '8unorm' - generate_unpack(formats, channel, native_type, suffix) - generate_pack(formats, channel, native_type, suffix) + for format in formats: + generate_format_unpack(format, channel, native_type, suffix) + generate_format_pack(format, channel, native_type, suffix) diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index fe910d9a77..6877bd6844 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -106,6 +106,11 @@ util_format_none_unpack_float(float *dst, const uint8_t *src, unsigned length) static void util_format_none_pack_float(uint8_t *dst, const float *src, unsigned length) { +} + +static void +util_format_none_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ } ''' print 'const struct util_format_description' @@ -125,7 +130,8 @@ util_format_none_pack_float(uint8_t *dst, const float *src, unsigned length) print " &util_format_none_unpack_8unorm," print " &util_format_none_pack_8unorm," print " &util_format_none_unpack_float," - print " &util_format_none_pack_float" + print " &util_format_none_pack_float," + print " &util_format_none_fetch_float" print "};" print @@ -172,7 +178,8 @@ util_format_none_pack_float(uint8_t *dst, const float *src, unsigned length) print " &util_format_%s_unpack_8unorm," % format.short_name() print " &util_format_%s_pack_8unorm," % format.short_name() print " &util_format_%s_unpack_float," % format.short_name() - print " &util_format_%s_pack_float" % format.short_name() + print " &util_format_%s_pack_float," % format.short_name() + print " &util_format_%s_fetch_float" % format.short_name() print "};" print -- cgit v1.2.3 From 9fcf2b87b35240efe8dd8ebe7d2f40268e647902 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 17 Mar 2010 19:50:33 +0000 Subject: util: Silence pointer to integer size mismatch errors. --- src/gallium/auxiliary/util/u_memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h index a2fc597356..53d56599fe 100644 --- a/src/gallium/auxiliary/util/u_memory.h +++ b/src/gallium/auxiliary/util/u_memory.h @@ -88,7 +88,7 @@ mem_dup(const void *src, uint size) /** * Offset of a field in a struct, in bytes. */ -#define Offset(TYPE, MEMBER) ((unsigned)&(((TYPE *)NULL)->MEMBER)) +#define Offset(TYPE, MEMBER) ((uintptr_t)&(((TYPE *)NULL)->MEMBER)) -- cgit v1.2.3 From 329814c6ee8a87d67a55ecf197af9d6e6fb7ade0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Mar 2010 11:27:29 +0000 Subject: util: Describe PIPE_FORMAT_NONE as PIPE_FORMAT_R8_USCALED. Avoids the need to special case PIPE_FORMAT_NONE so often. Conflicts: src/gallium/auxiliary/util/u_format_table.py --- src/gallium/auxiliary/util/u_format.csv | 4 +++ src/gallium/auxiliary/util/u_format.h | 28 +++++++-------- src/gallium/auxiliary/util/u_format_table.py | 51 +--------------------------- 3 files changed, 19 insertions(+), 64 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index ee91788d71..0cf539247e 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -56,6 +56,10 @@ # internal formats to base in- ternal formats, and desired component # resolutions for each sized internal format." +# None +# Described as regular uint_8 bytes, i.e. PIPE_FORMAT_R8_USCALED +PIPE_FORMAT_NONE , plain, 1, 1, u8 , , , , x001, rgb + # Typical rendertarget formats PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 8e76e13b66..0fad81fe40 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -239,8 +239,8 @@ util_format_name(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - assert(format); - if (!format) { + assert(desc); + if (!desc) { return "???"; } @@ -252,8 +252,8 @@ util_format_is_s3tc(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - assert(format); - if (!format) { + assert(desc); + if (!desc) { return FALSE; } @@ -265,8 +265,8 @@ util_format_is_depth_or_stencil(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - assert(format); - if (!format) { + assert(desc); + if (!desc) { return FALSE; } @@ -278,8 +278,8 @@ util_format_is_depth_and_stencil(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - assert(format); - if (!format) { + assert(desc); + if (!desc) { return FALSE; } @@ -328,8 +328,8 @@ util_format_get_blocksizebits(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - assert(format); - if (!format) { + assert(desc); + if (!desc) { return 0; } @@ -354,8 +354,8 @@ util_format_get_blockwidth(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - assert(format); - if (!format) { + assert(desc); + if (!desc) { return 1; } @@ -367,8 +367,8 @@ util_format_get_blockheight(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - assert(format); - if (!format) { + assert(desc); + if (!desc) { return 1; } diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 6877bd6844..1309044097 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -3,7 +3,7 @@ ''' /************************************************************************** * - * Copyright 2009 VMware, Inc. + * Copyright 2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -87,53 +87,6 @@ def write_format_table(formats): print print '#include "u_format.h"' print - print ''' -static void -util_format_none_unpack_8unorm(uint8_t *dst, const uint8_t *src, unsigned length) -{ -} - -static void -util_format_none_pack_8unorm(uint8_t *dst, const uint8_t *src, unsigned length) -{ -} - -static void -util_format_none_unpack_float(float *dst, const uint8_t *src, unsigned length) -{ -} - -static void -util_format_none_pack_float(uint8_t *dst, const float *src, unsigned length) -{ -} - -static void -util_format_none_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ -} - ''' - print 'const struct util_format_description' - print 'util_format_none_description = {' - print " PIPE_FORMAT_NONE," - print " \"PIPE_FORMAT_NONE\"," - print " \"none\"," - print " {0, 0, 0}," - print " 0," - print " 0," - print " 0," - print " 0," - print " 0," - print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," - print " {0, 0, 0, 0}," - print " 0," - print " &util_format_none_unpack_8unorm," - print " &util_format_none_pack_8unorm," - print " &util_format_none_unpack_float," - print " &util_format_none_pack_float," - print " &util_format_none_fetch_float" - print "};" - print u_format_pack.generate(formats) @@ -191,8 +144,6 @@ util_format_none_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigne print " }" print print " switch (format) {" - print " case PIPE_FORMAT_NONE:" - print " return &util_format_none_description;" for format in formats: print " case %s:" % format.name print " return &util_format_%s_description;" % (format.short_name(),) -- cgit v1.2.3 From b8012643e1f5f6e49593ec8f04d3721df53e6afb Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 31 Mar 2010 21:54:54 +0200 Subject: util: First stab at half-float conversion. --- src/gallium/auxiliary/util/u_format_pack.py | 101 +++++++++++++++------------- 1 file changed, 55 insertions(+), 46 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index c74900ce63..26f8748604 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -43,6 +43,45 @@ import math from u_format_parse import * +def generate_f16_to_f32(): + '''Naive implementation, need something faster that operates on bits''' + + print ''' +static float +f16_to_f32(uint16_t h) +{ + unsigned mantissa = h & 0x3ff; + unsigned exponent = (h >> 10) & 0x1f; + float sign = (h & 0x8000) ? -1.0f : 1.0f; + + if (exponent == 0) { + if (mantissa == 0) { + return sign * 0.0f; + } + return sign * powf(2.0f, -14.0f) * (float)mantissa / 1024.0f; + } + if (exponent == 31) { + if (mantissa == 0) { + /* XXX: infinity */ + return sign * 100000.0f; + } + /* XXX: NaN */ + return 1000.0f; + } + return sign * powf(2.0f, (float)exponent - 15.0f) * (1.0f + (float)mantissa / 1024.0f); +} +''' + +def generate_f32_to_f16(): + print ''' +static uint16_t +f32_to_f16(float f) +{ + /* TODO */ + return 0; +} +''' + def generate_format_type(format): '''Generate a structure that describes the format.''' @@ -127,9 +166,6 @@ def is_format_supported(format): channel = format.channels[i] if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT): return False - if channel.type == FLOAT: - if channel.size not in (32, 64): - return False # We can only read a color from a depth/stencil format if the depth channel is present if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: @@ -153,7 +189,9 @@ def native_type(format): elif channel.type == SIGNED: return 'int%u_t' % channel.size elif channel.type == FLOAT: - if channel.size == 32: + if channel.size == 16: + return 'uint16_t' + elif channel.size == 32: return 'float' elif channel.size == 64: return 'double' @@ -202,31 +240,6 @@ def get_one(type): return (1 << get_one_shift(type)) - 1 -def generate_clamp(): - '''Code generate the clamping functions for each type. - - We don't use a macro so that arguments with side effects, - like *src_pixel++ are correctly handled. - ''' - - for suffix, native_type in [ - ('', 'double'), - ('f', 'float'), - ('ui', 'unsigned int'), - ('si', 'int'), - ]: - print 'static INLINE %s' % native_type - print 'clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type) - print '{' - print ' if(value < lbound)' - print ' return lbound;' - print ' if(value > ubound)' - print ' return ubound;' - print ' return value;' - print '}' - print - - def clamp_expr(src_channel, dst_channel, dst_native_type, value): '''Generate the expression to clamp the value in the source type to the destination type range.''' @@ -234,21 +247,6 @@ def clamp_expr(src_channel, dst_channel, dst_native_type, value): if src_channel == dst_channel: return value - # Pick the approriate clamp function - if src_channel.type == FLOAT: - if src_channel.size == 32: - func = 'clampf' - elif src_channel.size == 64: - func = 'clamp' - else: - assert False - elif src_channel.type == UNSIGNED: - func = 'clampui' - elif src_channel.type == SIGNED: - func = 'clampsi' - else: - assert False - src_min = src_channel.min() src_max = src_channel.max() dst_min = dst_channel.min() @@ -273,7 +271,17 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True return value if src_channel.type == FLOAT and dst_channel.type == FLOAT: - return '(%s)%s' % (dst_native_type, value) + if src_channel.size == dst_channel.size: + return value + if src_channel.size == 64: + value = '(float)%s' % (value) + elif src_channel.size == 16: + value = 'f16_to_f32(%s)' % (value) + if dst_channel.size == 16: + value = 'f32_to_f16(%s)' % (value) + elif dst_channel.size == 64: + value = '(double)%s' % (value) + return value if clamp: value = clamp_expr(src_channel, dst_channel, dst_native_type, value) @@ -562,7 +570,8 @@ def generate(formats): print '#include "u_format.h"' print - generate_clamp() + generate_f16_to_f32() + generate_f32_to_f16() for format in formats: if is_format_supported(format): -- cgit v1.2.3 From 018aae950df449a18d7d69de54d51af587be94c6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 21:16:16 +0100 Subject: util: Make the accessors bidimensional again. Otherwise there's no way to unpack blocks with height >1 --- progs/gallium/unit/u_format_test.c | 8 ++-- src/gallium/auxiliary/util/u_format.c | 36 ++------------- src/gallium/auxiliary/util/u_format.h | 28 ++++++++---- src/gallium/auxiliary/util/u_format_pack.py | 70 +++++++++++++++++------------ 4 files changed, 69 insertions(+), 73 deletions(-) (limited to 'src/gallium/auxiliary/util') diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index ba4e9fab66..54cb6b879e 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -72,7 +72,7 @@ test_format_unpack_float(const struct util_format_description *format_desc, unsigned i; boolean success; - format_desc->unpack_float(unpacked, test->packed, 1); + format_desc->unpack_float(unpacked, 0, test->packed, 0, 1, 1); success = TRUE; for (i = 0; i < 4; ++i) @@ -102,7 +102,7 @@ test_format_pack_float(const struct util_format_description *format_desc, for (i = 0; i < 4; ++i) unpacked[i] = (float) test->unpacked[i]; - format_desc->pack_float(packed, unpacked, 1); + format_desc->pack_float(packed, 0, unpacked, 0, 1, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) @@ -160,7 +160,7 @@ test_format_unpack_8unorm(const struct util_format_description *format_desc, unsigned i; boolean success; - format_desc->unpack_8unorm(unpacked, test->packed, 1); + format_desc->unpack_8unorm(unpacked, 0, test->packed, 0, 1, 1); convert_float_to_8unorm(expected, test->unpacked); @@ -196,7 +196,7 @@ test_format_pack_8unorm(const struct util_format_description *format_desc, memset(packed, 0, sizeof packed); - format_desc->pack_8unorm(packed, unpacked, 1); + format_desc->pack_8unorm(packed, 0, unpacked, 0, 1, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index 11ef839ec1..7f16cf7d01 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -44,8 +44,6 @@ util_format_read_4f(enum pipe_format format, const struct util_format_description *format_desc; const uint8_t *src_row; float *dst_row; - unsigned row_blocks; - unsigned i; format_desc = util_format_description(format); @@ -54,13 +52,8 @@ util_format_read_4f(enum pipe_format format, src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); dst_row = dst; - row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; - for (i = 0; i < h; i += format_desc->block.height) { - format_desc->unpack_float(dst_row, src_row, row_blocks); - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } + format_desc->unpack_float(dst_row, dst_stride, src_row, src_stride, w, h); } @@ -73,8 +66,6 @@ util_format_write_4f(enum pipe_format format, const struct util_format_description *format_desc; uint8_t *dst_row; const float *src_row; - unsigned row_blocks; - unsigned i; format_desc = util_format_description(format); @@ -83,13 +74,8 @@ util_format_write_4f(enum pipe_format format, dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); src_row = src; - row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; - for (i = 0; i < h; i += format_desc->block.height) { - format_desc->pack_float(dst_row, src_row, row_blocks); - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } + format_desc->pack_float(dst_row, dst_stride, src_row, src_stride, w, h); } @@ -99,8 +85,6 @@ util_format_read_4ub(enum pipe_format format, uint8_t *dst, unsigned dst_stride, const struct util_format_description *format_desc; const uint8_t *src_row; uint8_t *dst_row; - unsigned row_blocks; - unsigned i; format_desc = util_format_description(format); @@ -109,13 +93,8 @@ util_format_read_4ub(enum pipe_format format, uint8_t *dst, unsigned dst_stride, src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); dst_row = dst; - row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; - for (i = 0; i < h; i += format_desc->block.height) { - format_desc->unpack_8unorm(dst_row, src_row, row_blocks); - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } + format_desc->unpack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h); } @@ -125,8 +104,6 @@ util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_ const struct util_format_description *format_desc; uint8_t *dst_row; const uint8_t *src_row; - unsigned row_blocks; - unsigned i; format_desc = util_format_description(format); @@ -135,12 +112,7 @@ util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_ dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); src_row = src; - row_blocks = (w + format_desc->block.width - 1) / format_desc->block.width; - for (i = 0; i < h; i += format_desc->block.height) { - format_desc->pack_8unorm(dst_row, src_row, row_blocks); - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } + format_desc->pack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h); } diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 0fad81fe40..93818a3161 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -191,34 +191,44 @@ struct util_format_description enum util_format_colorspace colorspace; /** - * Unpack a span of pixel blocks to R8G8B8A8_UNORM. + * Unpack pixel blocks to R8G8B8A8_UNORM. */ void - (*unpack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + (*unpack_8unorm)(uint8_t *dst, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height); /** - * Pack a span of pixel blocks from R8G8B8A8_UNORM. + * Pack pixel blocks from R8G8B8A8_UNORM. */ void - (*pack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + (*pack_8unorm)(uint8_t *dst, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height); /** - * Unpack a span of pixel blocks to R32G32B32A32_FLOAT. + * Unpack pixel blocks to R32G32B32A32_FLOAT. */ void - (*unpack_float)(float *dst, const uint8_t *src, unsigned nr_blocks); + (*unpack_float)(float *dst, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height); /** - * Pack a span of pixel blocks from R32G32B32A32_FLOAT. + * Pack pixel blocks from R32G32B32A32_FLOAT. */ void - (*pack_float)(uint8_t *dst, const float *src, unsigned nr_blocks); + (*pack_float)(uint8_t *dst, unsigned dst_stride, + const float *src, unsigned src_stride, + unsigned width, unsigned height); /** * Fetch a single pixel (i, j) from a block. */ void - (*fetch_float)(float *dst, const uint8_t *src, unsigned i, unsigned j); + (*fetch_float)(float *dst, + const uint8_t *src, + unsigned i, unsigned j); }; diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 26f8748604..73309cca5c 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -343,19 +343,19 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): if format.is_bitmask(): depth = format.block_size() - print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) + print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) # Declare the intermediate variables for i in range(format.nr_channels()): src_channel = format.channels[i] if src_channel.type == UNSIGNED: - print ' uint%u_t %s;' % (depth, src_channel.name) + print ' uint%u_t %s;' % (depth, src_channel.name) elif src_channel.type == SIGNED: - print ' int%u_t %s;' % (depth, src_channel.name) + print ' int%u_t %s;' % (depth, src_channel.name) - print ' #ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print ' #endif' + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print '#endif' # Compute the intermediate unshifted values shift = 0 @@ -382,7 +382,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): value = None if value is not None: - print ' %s = %s;' % (src_channel.name, value) + print ' %s = %s;' % (src_channel.name, value) shift += src_channel.size @@ -406,11 +406,11 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): value = get_one(dst_channel) elif i >= 1: value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) else: - print ' union util_format_%s pixel;' % format.short_name() - print ' memcpy(&pixel, src, sizeof pixel);' + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' bswap_format(format) for i in range(4): @@ -432,7 +432,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): value = get_one(dst_channel) elif i >= 1: value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) def generate_pack_kernel(format, src_channel, src_native_type): @@ -448,7 +448,7 @@ def generate_pack_kernel(format, src_channel, src_native_type): if format.is_bitmask(): depth = format.block_size() - print ' uint%u_t value = 0;' % depth + print ' uint%u_t value = 0;' % depth shift = 0 for i in range(4): @@ -472,18 +472,18 @@ def generate_pack_kernel(format, src_channel, src_native_type): else: value = None if value is not None: - print ' value |= %s;' % (value) + print ' value |= %s;' % (value) shift += dst_channel.size print '#ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth + print ' value = util_bswap%u(value);' % depth print '#endif' - print ' *(uint%u_t *)dst = value;' % depth + print ' *(uint%u_t *)dst = value;' % depth else: - print ' union util_format_%s pixel;' % format.short_name() + print ' union util_format_%s pixel;' % format.short_name() for i in range(4): dst_channel = format.channels[i] @@ -497,10 +497,10 @@ def generate_pack_kernel(format, src_channel, src_native_type): value = get_one(dst_channel) elif i >= 1: value = '0' - print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) bswap_format(format) - print ' memcpy(dst, &pixel, sizeof pixel);' + print ' memcpy(dst, &pixel, sizeof pixel);' def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): @@ -509,16 +509,23 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): name = format.short_name() print 'static INLINE void' - print 'util_format_%s_unpack_%s(%s *dst, const uint8_t *src, unsigned length)' % (name, dst_suffix, dst_native_type) + print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type) print '{' if is_format_supported(format): - print ' while(length--) {' - + print ' unsigned x, y;' + print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) + print ' %s *dst = dst_row;' % (dst_native_type) + print ' const uint8_t *src = src_row;' + print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) + generate_unpack_kernel(format, dst_channel, dst_native_type) - print ' src += %u;' % (format.block_size() / 8,) - print ' dst += 4;' + print ' src += %u;' % (format.block_size() / 8,) + print ' dst += 4;' + print ' }' + print ' src_row += src_stride;' + print ' dst_row += dst_stride/sizeof(*dst_row);' print ' }' print '}' @@ -531,18 +538,25 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): name = format.short_name() print 'static INLINE void' - print 'util_format_%s_pack_%s(uint8_t *dst, const %s *src, unsigned length)' % (name, src_suffix, src_native_type) + print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type) print '{' if is_format_supported(format): - print ' while(length--) {' + print ' unsigned x, y;' + print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) + print ' const %s *src = src_row;' % (src_native_type) + print ' uint8_t *dst = dst_row;' + print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) generate_pack_kernel(format, src_channel, src_native_type) - print ' src += 4;' - print ' dst += %u;' % (format.block_size() / 8,) + print ' src += 4;' + print ' dst += %u;' % (format.block_size() / 8,) + print ' }' + print ' dst_row += dst_stride;' + print ' src_row += src_stride/sizeof(*src_row);' print ' }' - + print '}' print -- cgit v1.2.3 From 9388ce41917fa4c706c5e284d960e1ca648ee935 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 31 Mar 2010 22:46:42 +0100 Subject: util: Hook into libtxc_dxtn.so (WIP). --- src/gallium/auxiliary/Makefile | 1 + src/gallium/auxiliary/SConscript | 1 + src/gallium/auxiliary/util/u_format_pack.py | 12 +- src/gallium/auxiliary/util/u_format_s3tc.c | 510 +++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_format_s3tc.h | 218 ++++++++++++ src/gallium/auxiliary/util/u_format_table.py | 1 + 6 files changed, 738 insertions(+), 5 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_format_s3tc.c create mode 100644 src/gallium/auxiliary/util/u_format_s3tc.h (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 4df3fbd132..4c629924b9 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -106,6 +106,7 @@ C_SOURCES = \ util/u_dl.c \ util/u_draw_quad.c \ util/u_format.c \ + util/u_format_s3tc.c \ util/u_format_table.c \ util/u_format_tests.c \ util/u_gen_mipmap.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 0f1cc374c1..ed719f9f1a 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -140,6 +140,7 @@ source = [ 'util/u_dl.c', 'util/u_draw_quad.c', 'util/u_format.c', + 'util/u_format_s3tc.c', 'util/u_format_table.c', 'util/u_format_tests.c', 'util/u_gen_mipmap.c', diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 73309cca5c..95c0c79be9 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -596,15 +596,17 @@ def generate(formats): suffix = 'float' for format in formats: - generate_format_unpack(format, channel, native_type, suffix) - generate_format_pack(format, channel, native_type, suffix) - generate_format_fetch(format, channel, native_type, suffix) + if format.layout != 's3tc': + generate_format_unpack(format, channel, native_type, suffix) + generate_format_pack(format, channel, native_type, suffix) + generate_format_fetch(format, channel, native_type, suffix) channel = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' suffix = '8unorm' for format in formats: - generate_format_unpack(format, channel, native_type, suffix) - generate_format_pack(format, channel, native_type, suffix) + if format.layout != 's3tc': + generate_format_unpack(format, channel, native_type, suffix) + generate_format_pack(format, channel, native_type, suffix) diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c new file mode 100644 index 0000000000..4fe00b0e43 --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_s3tc.c @@ -0,0 +1,510 @@ +/************************************************************************** + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * 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 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 + * BRIAN PAUL 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 "u_dl.h" +#include "u_math.h" +#include "u_format.h" +#include "u_format_s3tc.h" + + +#if defined(_WIN32) || defined(WIN32) +#define DXTN_LIBNAME "dxtn.dll" +#else +#define DXTN_LIBNAME "libtxc_dxtn.so" +#endif + + +boolean util_format_s3tc_enabled = FALSE; + +util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = NULL; +util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = NULL; +util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = NULL; +util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = NULL; + +util_format_dxtn_pack_t util_format_dxtn_pack = NULL; + + +void +util_format_s3tc_init(void) +{ + static struct util_dl_library * + library = NULL; + + if (util_format_s3tc_enabled) + return; + + if (!library) { + library = util_dl_open(DXTN_LIBNAME); + if (!library) { + debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn " + "compression/decompression unavailable"); + } + else { + util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t) + util_dl_get_proc_address(library, "fetch_2d_texel_rgb_dxt1"); + util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t) + util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt1"); + util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t) + util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt3"); + util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t) + util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt5"); + util_format_dxtn_pack = (util_format_dxtn_pack_t) + util_dl_get_proc_address(library, "tx_compress_dxtn"); + + if (util_format_dxt1_rgb_fetch || + util_format_dxt1_rgba_fetch || + util_format_dxt3_rgba_fetch || + util_format_dxt5_rgba_fetch || + util_format_dxtn_pack) { + util_format_s3tc_enabled = TRUE; + debug_printf("software DXTn compression/decompression available"); + + } else { + debug_printf("couldn't reference all symbols in " + DXTN_LIBNAME ", software DXTn compression/decompression " + "unavailable"); + } + } + } +} + + +/* + * Pixel fetch. + */ + +void +util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt1_rgb_fetch) { + util_format_dxt1_rgb_fetch(0, src, i, j, dst); + } +} + +void +util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt1_rgba_fetch) { + util_format_dxt1_rgba_fetch(0, src, i, j, dst); + } +} + +void +util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt3_rgba_fetch) { + util_format_dxt3_rgba_fetch(0, src, i, j, dst); + } +} + +void +util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt5_rgba_fetch) { + util_format_dxt5_rgba_fetch(0, src, i, j, dst); + } +} + +void +util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt1_rgb_fetch) { + uint8_t tmp[4]; + util_format_dxt1_rgb_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = 1.0; + } +} + +void +util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt1_rgba_fetch) { + uint8_t tmp[4]; + util_format_dxt1_rgba_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); + } +} + +void +util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt3_rgba_fetch) { + uint8_t tmp[4]; + util_format_dxt3_rgba_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); + } +} + +void +util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + if (util_format_dxt5_rgba_fetch) { + uint8_t tmp[4]; + util_format_dxt5_rgba_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); + } +} + + +/* + * Block decompression. + * + * FIXME + */ + +void +util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + +} + +void +util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + if (util_format_dxt1_rgb_fetch) { + unsigned x, y, i, j; + for(y = 0; y < height; y += 4) { + const uint8_t *src = src_row; + for(x = 0; x < width; x += 4) { + for(j = 0; j < 4; ++j) { + for(i = 0; i < 4; ++i) { + float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + uint8_t tmp[4]; + util_format_dxt1_rgb_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = 1.0; + } + } + src += 8; + } + src_row += src_stride; + } + } +} + +void +util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + if (util_format_dxt1_rgba_fetch) { + unsigned x, y, i, j; + for(y = 0; y < height; y += 4) { + const uint8_t *src = src_row; + for(x = 0; x < width; x += 4) { + for(j = 0; j < 4; ++j) { + for(i = 0; i < 4; ++i) { + float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + uint8_t tmp[4]; + util_format_dxt1_rgba_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); + } + } + src += 8; + } + src_row += src_stride; + } + } +} + +void +util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + if (util_format_dxt3_rgba_fetch) { + unsigned x, y, i, j; + for(y = 0; y < height; y += 4) { + const uint8_t *src = src_row; + for(x = 0; x < width; x += 4) { + for(j = 0; j < 4; ++j) { + for(i = 0; i < 4; ++i) { + float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + uint8_t tmp[4]; + util_format_dxt3_rgba_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); + } + } + src += 16; + } + src_row += src_stride; + } + } +} + +void +util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + if (util_format_dxt5_rgba_fetch) { + unsigned x, y, i, j; + for(y = 0; y < height; y += 4) { + const uint8_t *src = src_row; + for(x = 0; x < width; x += 4) { + for(j = 0; j < 4; ++j) { + for(i = 0; i < 4; ++i) { + float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; + uint8_t tmp[4]; + util_format_dxt5_rgba_fetch(0, src, i, j, tmp); + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); + } + } + src += 16; + } + src_row += src_stride; + } + } +} + + +/* + * Block compression. + * + * FIXME + */ + +void +util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + +void +util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ +} + + +/* + * SRGB variants. + * + * FIXME: shunts to RGB for now + */ + +void +util_format_dxt1_srgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgb_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgb_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt1_rgb_fetch_8unorm(dst, src, i, j); +} + +void +util_format_dxt1_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt1_rgba_fetch_8unorm(dst, src, i, j); +} + +void +util_format_dxt3_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt3_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt3_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt3_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt3_rgba_fetch_8unorm(dst, src, i, j); +} + +void +util_format_dxt5_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt5_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt5_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt5_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt5_rgba_fetch_8unorm(dst, src, i, j); +} + +void +util_format_dxt1_srgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgb_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgb_pack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt1_rgb_fetch_float(dst, src, i, j); +} + +void +util_format_dxt1_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt1_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt1_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt1_rgba_fetch_float(dst, src, i, j); +} + +void +util_format_dxt3_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt3_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt3_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt3_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt3_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt3_rgba_fetch_float(dst, src, i, j); +} + +void +util_format_dxt5_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt5_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt5_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_dxt5_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height); +} + +void +util_format_dxt5_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ + util_format_dxt5_rgba_fetch_float(dst, src, i, j); +} + diff --git a/src/gallium/auxiliary/util/u_format_s3tc.h b/src/gallium/auxiliary/util/u_format_s3tc.h new file mode 100644 index 0000000000..5c3a9dd22c --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_s3tc.h @@ -0,0 +1,218 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * 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 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 COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef U_FORMAT_S3TC_H_ +#define U_FORMAT_S3TC_H_ + + +#include "pipe/p_compiler.h" + + +enum util_format_dxtn { + UTIL_FORMAT_DXT1_RGB = 0x83F0, + UTIL_FORMAT_DXT1_RGBA = 0x83F1, + UTIL_FORMAT_DXT3_RGBA = 0x83F2, + UTIL_FORMAT_DXT5_RGBA = 0x83F3 +}; + + +typedef void +(*util_format_dxtn_fetch_t)( int src_stride, + const uint8_t *src, + int col, int row, + uint8_t *dst ); + +typedef void +(*util_format_dxtn_pack_t)( int src_comps, + int width, int height, + const uint8_t *src, + enum util_format_dxtn dst_format, + uint8_t *dst, + int dst_stride); + +extern boolean util_format_s3tc_enabled; + +extern util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch; +extern util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch; +extern util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch; +extern util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch; + +extern util_format_dxtn_pack_t util_format_dxtn_pack; + + +void +util_format_s3tc_init(void); + + +void +util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt1_srgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt1_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt3_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt5_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); + + +void +util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt1_srgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt1_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt1_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt3_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt3_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +void +util_format_dxt5_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_dxt5_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + + +#endif /* U_FORMAT_S3TC_H_ */ diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 1309044097..94a4331b15 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -86,6 +86,7 @@ def write_format_table(formats): print __doc__.strip() print print '#include "u_format.h"' + print '#include "u_format_s3tc.h"' print u_format_pack.generate(formats) -- cgit v1.2.3