util: Move ASTC unpack routines to common util
Move ASTC decompression code from mesa/main to src/util to make it available for use by Vulkan drivers. This allows the Intel ANV driver to use CPU-based ASTC decompression for host image copy operations on hardware that doesn't natively support ASTC formats. The _mesa_unpack_astc_2d_ldr() function signature is updated to use pipe_format instead of mesa_format for better integration with the util format system. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37691>
This commit is contained in:
@@ -112,7 +112,6 @@
|
||||
#include <mesa/main/stencil.h>
|
||||
#include <mesa/main/syncobj.h>
|
||||
#include <mesa/main/texcompress.h>
|
||||
#include <mesa/main/texcompress_astc.h>
|
||||
#include <mesa/main/texcompress_bptc.h>
|
||||
#include <mesa/main/texcompress_cpal.h>
|
||||
#include <mesa/main/texcompress_etc.h>
|
||||
@@ -257,6 +256,7 @@
|
||||
#include <util/string_buffer.h>
|
||||
#include <util/strndup.h>
|
||||
#include <util/strtod.h>
|
||||
#include <util/texcompress_astc.h>
|
||||
#include <util/timespec.h>
|
||||
#include <util/u_atomic.h>
|
||||
#include <util/u_call_once.h>
|
||||
|
||||
@@ -200,8 +200,6 @@ files_libmesa = files(
|
||||
'main/syncobj.h',
|
||||
'main/texcompress.c',
|
||||
'main/texcompress.h',
|
||||
'main/texcompress_astc.cpp',
|
||||
'main/texcompress_astc.h',
|
||||
'main/texcompress_bptc.c',
|
||||
'main/texcompress_bptc.h',
|
||||
'main/texcompress_cpal.c',
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "main/pixeltransfer.h"
|
||||
#include "main/renderbuffer.h"
|
||||
#include "main/texcompress.h"
|
||||
#include "main/texcompress_astc.h"
|
||||
#include "util/texcompress_astc.h"
|
||||
#include "main/texcompress_bptc.h"
|
||||
#include "main/texcompress_etc.h"
|
||||
#include "main/texcompress_rgtc.h"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "main/context.h"
|
||||
#include "main/shaderapi.h"
|
||||
#include "main/shaderobj.h"
|
||||
#include "main/texcompress_astc.h"
|
||||
#include "util/texcompress_astc.h"
|
||||
#include "util/texcompress_astc_luts_wrap.h"
|
||||
#include "main/uniforms.h"
|
||||
|
||||
|
||||
@@ -130,6 +130,8 @@ files_mesa_util = files(
|
||||
'texcompress_astc_luts.h',
|
||||
'texcompress_astc_luts_wrap.cpp',
|
||||
'texcompress_astc_luts_wrap.h',
|
||||
'texcompress_astc.cpp',
|
||||
'texcompress_astc.h',
|
||||
'timespec.h',
|
||||
'u_atomic.c',
|
||||
'u_atomic.h',
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "util/half_float.h"
|
||||
#include <stdio.h>
|
||||
#include <cstdlib> // for abort() on windows
|
||||
#include <stdarg.h>
|
||||
|
||||
static bool VERBOSE_DECODE = false;
|
||||
static bool VERBOSE_WRITE = false;
|
||||
@@ -1810,13 +1811,15 @@ _mesa_unpack_astc_2d_ldr(uint8_t *dst_row,
|
||||
unsigned src_stride,
|
||||
unsigned src_width,
|
||||
unsigned src_height,
|
||||
mesa_format format)
|
||||
enum pipe_format format)
|
||||
{
|
||||
assert(_mesa_is_format_astc_2d(format));
|
||||
bool srgb = _mesa_is_format_srgb(format);
|
||||
const struct util_format_description *desc =
|
||||
util_format_description(format);
|
||||
assert(desc && desc->layout == UTIL_FORMAT_LAYOUT_ASTC &&
|
||||
desc->block.depth == 1);
|
||||
bool srgb = util_format_is_srgb(format);
|
||||
|
||||
unsigned blk_w, blk_h;
|
||||
_mesa_get_format_block_size(format, &blk_w, &blk_h);
|
||||
unsigned blk_w = desc->block.width, blk_h = desc->block.height;
|
||||
|
||||
const unsigned block_size = 16;
|
||||
unsigned x_blocks = (src_width + blk_w - 1) / blk_w;
|
||||
@@ -25,7 +25,7 @@
|
||||
#define TEXCOMPRESS_ASTC_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "texcompress.h"
|
||||
#include "util/format/u_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -38,7 +38,7 @@ _mesa_unpack_astc_2d_ldr(uint8_t *dst_row,
|
||||
unsigned src_stride,
|
||||
unsigned src_width,
|
||||
unsigned src_height,
|
||||
mesa_format format);
|
||||
enum pipe_format format);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
Reference in New Issue
Block a user