util: move ASTCLutHolder from mesa/main to util

v2: remove extra u_formats.h header addition (Chia-I Wu)
    use stddef.h and not unistd.h (Chia-I Wu)

Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24672>
This commit is contained in:
Yogesh Mohan Marimuthu
2023-09-17 23:30:30 +05:30
committed by Marge Bot
parent 0236b7f18a
commit 8da85d2475
7 changed files with 17 additions and 15 deletions

View File

@@ -206,10 +206,6 @@ files_libmesa = files(
'main/texcompress.h',
'main/texcompress_astc.cpp',
'main/texcompress_astc.h',
'main/texcompress_astc_luts.cpp',
'main/texcompress_astc_luts.h',
'main/texcompress_astc_luts_wrap.cpp',
'main/texcompress_astc_luts_wrap.h',
'main/texcompress_bptc.c',
'main/texcompress_bptc.h',
'main/texcompress_cpal.c',

View File

@@ -33,7 +33,7 @@
#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "main/texcompress_astc.h"
#include "main/texcompress_astc_luts_wrap.h"
#include "util/texcompress_astc_luts_wrap.h"
#include "main/uniforms.h"
#include "state_tracker/st_atom_constbuf.h"
@@ -554,9 +554,12 @@ get_astc_partition_table_view(struct st_context *st,
unsigned block_w,
unsigned block_h)
{
unsigned lut_width;
unsigned lut_height;
struct pipe_box ptable_box;
void *ptable_data =
_mesa_get_astc_decoder_partition_table(block_w, block_h, &ptable_box);
_mesa_get_astc_decoder_partition_table(block_w, block_h, &lut_width, &lut_height);
u_box_origin_2d(lut_width, lut_height, &ptable_box);
struct pipe_sampler_view *view =
util_hash_table_get(st->texcompress_compute.astc_partition_tables,

View File

@@ -127,6 +127,10 @@ files_mesa_util = files(
'strndup.h',
'strtod.c',
'strtod.h',
'texcompress_astc_luts.cpp',
'texcompress_astc_luts.h',
'texcompress_astc_luts_wrap.cpp',
'texcompress_astc_luts_wrap.h',
'timespec.h',
'u_atomic.c',
'u_atomic.h',

View File

@@ -23,8 +23,6 @@
#include "texcompress_astc_luts_wrap.h"
#include "texcompress_astc_luts.h"
#include "util/u_box.h"
extern "C" void
_mesa_init_astc_decoder_luts(astc_decoder_lut_holder *holder)
{
@@ -54,12 +52,13 @@ _mesa_init_astc_decoder_luts(astc_decoder_lut_holder *holder)
extern "C" void *
_mesa_get_astc_decoder_partition_table(uint32_t block_width,
uint32_t block_height,
struct pipe_box *ptable_box)
unsigned *lut_width,
unsigned *lut_height)
{
auto &luts = Granite::get_astc_luts();
auto &table = luts.get_partition_table(block_width, block_height);
u_box_origin_2d(table.lut_width, table.lut_height, ptable_box);
*lut_width = table.lut_width;
*lut_height = table.lut_height;
return table.lut_buffer.data();
}

View File

@@ -24,7 +24,8 @@
#define TEXCOMPRESS_ASTC_LUTS_WRAP_H
#include <stdint.h>
#include "pipe/p_state.h"
#include <stddef.h>
#include "format/u_formats.h"
/* C wrapper for Granite::ASTCLutHolder. */
@@ -32,8 +33,6 @@
extern "C" {
#endif
struct pipe_box;
typedef struct
{
void *data;
@@ -53,7 +52,8 @@ typedef struct
void _mesa_init_astc_decoder_luts(astc_decoder_lut_holder *holder);
void *_mesa_get_astc_decoder_partition_table(uint32_t block_width,
uint32_t block_height,
struct pipe_box *ptable_box);
unsigned *lut_width,
unsigned *lut_height);
#ifdef __cplusplus
}