util: move ASTCLutHolder from mesa/main to util
authorYogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
Sun, 17 Sep 2023 18:00:30 +0000 (23:30 +0530)
committerMarge Bot <emma+marge@anholt.net>
Wed, 11 Oct 2023 19:28:40 +0000 (19:28 +0000)
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>

src/mesa/meson.build
src/mesa/state_tracker/st_texcompress_compute.c
src/util/meson.build
src/util/texcompress_astc_luts.cpp [moved from src/mesa/main/texcompress_astc_luts.cpp with 100% similarity]
src/util/texcompress_astc_luts.h [moved from src/mesa/main/texcompress_astc_luts.h with 100% similarity]
src/util/texcompress_astc_luts_wrap.cpp [moved from src/mesa/main/texcompress_astc_luts_wrap.cpp with 93% similarity]
src/util/texcompress_astc_luts_wrap.h [moved from src/mesa/main/texcompress_astc_luts_wrap.h with 91% similarity]

index 12a0e74..d07b8fb 100644 (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',
index 4611f51..118efc5 100644 (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,
index c151388..2dec026 100644 (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',
similarity index 93%
rename from src/mesa/main/texcompress_astc_luts_wrap.cpp
rename to src/util/texcompress_astc_luts_wrap.cpp
index a02dad7..6020a34 100644 (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();
 }
similarity index 91%
rename from src/mesa/main/texcompress_astc_luts_wrap.h
rename to src/util/texcompress_astc_luts_wrap.h
index e78f810..e77ffba 100644 (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
 }