From: falcovorbis <fal...@us...> - 2024-08-19 04:27:20
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 9d115023ffc10996601a8e12fdb809cff2c5804f (commit) via 51b5cd64678d5c6e8446bed3f6ccf7365d06538b (commit) from 8f1db16e84dbbc968567f5bda8c6f96b012b74b1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9d115023ffc10996601a8e12fdb809cff2c5804f Author: dfchil <dan...@gm...> Date: Mon Aug 19 06:26:56 2024 +0200 Add pvrtex utility (#602) * added pvrtex source files * handled compilation warnings added install target in makefile some minor formatting cleanup * bugfix makefile * fixed install target, further cleanup in nvmath.h for arm64 compilation * Added install target in Makefile Removed some dead code in nvmath.h that prevented compilation on ARM64 targets Added targets for generating header files from selected sections in the README file Added command line option --examples/-E which outputs the "Usage Examples" section of the README file Changed -h/--help option to output the "Command Line Options:" section of the README file Added this CHANGELOG file * Fixed bug with printing of non zero terminated char arrays from info/*.h files * Updated doc/CHANGELOG * Added pvrtex folder as a dependency in utils/Makefile * removed two unused variables * fixed make depency error improved error output * Added missing symbols in file_dctex.h by including <dc/pvr.h> * fixed header compile issues after upgrading gcc to 14.1.1-dev and kos to latest stable * allowed myself the liberty of patching init.mk in this PR as well, for my own convienience * removed dependency on kos/pvr.h, added generated info/*.h files --------- Co-authored-by: drxl <da...@vm...> Co-authored-by: Daniel Fairchild <da...@vi...> commit 51b5cd64678d5c6e8446bed3f6ccf7365d06538b Author: Paul Cercueil <pa...@cr...> Date: Mon Aug 19 06:20:37 2024 +0200 Iso9660: Read CD-ROM sectors using DMA (#659) * iso9660: Reduce number of allocations Reduce the number of allocations for the cache from 32 (16 icache/dcache buffers) to just 2: one for the icache/dcache structures, and one for the data buffers. This will later allow to allocate the data arrays all at once with a specific alignment. Signed-off-by: Paul Cercueil <pa...@cr...> * iso9660: Use DMA to read sectors from CD-ROM Use the DMA to read sectors from the CD-ROM instead of reading them using PIO. This frees the CPU to work on other tasks while the data transfer is ongoing. Signed-off-by: Paul Cercueil <pa...@cr...> --------- Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + kernel/arch/dreamcast/fs/fs_iso9660.c | 26 +- utils/Makefile | 2 +- utils/pvrtex/.gitignore | 2 + utils/pvrtex/CHANGELOG | 29 + utils/pvrtex/Makefile | 59 + utils/pvrtex/avstring.c | 462 ++ utils/pvrtex/bprint.c | 332 + utils/pvrtex/compat/va_copy.h | 34 + utils/pvrtex/crc.c | 413 ++ utils/pvrtex/dither.cpp | 478 ++ utils/pvrtex/elbg.c | 530 ++ utils/pvrtex/elbg.h | 59 + utils/pvrtex/file_common.c | 74 + utils/pvrtex/file_common.h | 22 + utils/pvrtex/file_dctex.c | 88 + utils/pvrtex/file_dctex.h | 565 ++ utils/pvrtex/file_pvr.c | 82 + utils/pvrtex/file_pvr.h | 21 + utils/pvrtex/file_tex.c | 76 + utils/pvrtex/file_tex.h | 8 + addons/lib/.keepme => utils/pvrtex/info/.gitkeep | 0 utils/pvrtex/info/examples.h | 175 + utils/pvrtex/info/options.h | 1030 +++ utils/pvrtex/lfg.c | 87 + utils/pvrtex/libavcodec/elbg.h | 59 + utils/pvrtex/libavutil/attributes.h | 173 + utils/pvrtex/libavutil/attributes_internal.h | 34 + utils/pvrtex/libavutil/avassert.h | 75 + utils/pvrtex/libavutil/avconfig.h | 6 + utils/pvrtex/libavutil/avstring.h | 429 ++ utils/pvrtex/libavutil/avutil.h | 371 + utils/pvrtex/libavutil/bprint.h | 251 + utils/pvrtex/libavutil/bswap.h | 111 + utils/pvrtex/libavutil/common.h | 578 ++ utils/pvrtex/libavutil/crc.h | 102 + utils/pvrtex/libavutil/dynarray.h | 70 + utils/pvrtex/libavutil/error.h | 128 + utils/pvrtex/libavutil/internal.h | 188 + utils/pvrtex/libavutil/intfloat.h | 77 + utils/pvrtex/libavutil/intreadwrite.h | 644 ++ utils/pvrtex/libavutil/lfg.c | 87 + utils/pvrtex/libavutil/lfg.h | 81 + utils/pvrtex/libavutil/libm.h | 472 ++ utils/pvrtex/libavutil/log.h | 387 ++ utils/pvrtex/libavutil/macros.h | 80 + utils/pvrtex/libavutil/mathematics.c | 319 + utils/pvrtex/libavutil/mathematics.h | 300 + utils/pvrtex/libavutil/md5.h | 89 + utils/pvrtex/libavutil/mem.c | 568 ++ utils/pvrtex/libavutil/mem.h | 609 ++ utils/pvrtex/libavutil/pixfmt.h | 699 ++ utils/pvrtex/libavutil/rational.c | 193 + utils/pvrtex/libavutil/rational.h | 221 + utils/pvrtex/libavutil/thread.h | 202 + utils/pvrtex/libavutil/version.h | 128 + utils/pvrtex/log.c | 490 ++ utils/pvrtex/main.c | 455 ++ utils/pvrtex/md5.c | 208 + utils/pvrtex/mem.c | 566 ++ utils/pvrtex/mycommon.c | 32 + utils/pvrtex/mycommon.h | 40 + utils/pvrtex/nvmath.h | 722 ++ utils/pvrtex/optparse.h | 403 ++ utils/pvrtex/optparse_impl.c | 2 + utils/pvrtex/pixel.h | 492 ++ utils/pvrtex/pvr_texture.c | 476 ++ utils/pvrtex/pvr_texture.h | 115 + utils/pvrtex/pvr_texture_encoder.c | 932 +++ utils/pvrtex/pvr_texture_encoder.h | 226 + utils/pvrtex/readme_unformatted.txt | 309 + utils/pvrtex/stb_image.h | 7897 ++++++++++++++++++++++ utils/pvrtex/stb_image_impl.c | 3 + utils/pvrtex/stb_image_resize.h | 2634 ++++++++ utils/pvrtex/stb_image_resize_impl.c | 3 + utils/pvrtex/stb_image_write.h | 1724 +++++ utils/pvrtex/stb_image_write_impl.c | 3 + utils/pvrtex/tddither.c | 231 + utils/pvrtex/tddither.h | 13 + utils/pvrtex/vqcompress.c | 154 + utils/pvrtex/vqcompress.h | 38 + 81 files changed, 30542 insertions(+), 12 deletions(-) create mode 100644 utils/pvrtex/.gitignore create mode 100644 utils/pvrtex/CHANGELOG create mode 100644 utils/pvrtex/Makefile create mode 100644 utils/pvrtex/avstring.c create mode 100644 utils/pvrtex/bprint.c create mode 100644 utils/pvrtex/compat/va_copy.h create mode 100644 utils/pvrtex/crc.c create mode 100644 utils/pvrtex/dither.cpp create mode 100644 utils/pvrtex/elbg.c create mode 100644 utils/pvrtex/elbg.h create mode 100644 utils/pvrtex/file_common.c create mode 100644 utils/pvrtex/file_common.h create mode 100644 utils/pvrtex/file_dctex.c create mode 100644 utils/pvrtex/file_dctex.h create mode 100644 utils/pvrtex/file_pvr.c create mode 100644 utils/pvrtex/file_pvr.h create mode 100644 utils/pvrtex/file_tex.c create mode 100644 utils/pvrtex/file_tex.h copy addons/lib/.keepme => utils/pvrtex/info/.gitkeep (100%) create mode 100644 utils/pvrtex/info/examples.h create mode 100644 utils/pvrtex/info/options.h create mode 100644 utils/pvrtex/lfg.c create mode 100644 utils/pvrtex/libavcodec/elbg.h create mode 100644 utils/pvrtex/libavutil/attributes.h create mode 100644 utils/pvrtex/libavutil/attributes_internal.h create mode 100644 utils/pvrtex/libavutil/avassert.h create mode 100644 utils/pvrtex/libavutil/avconfig.h create mode 100644 utils/pvrtex/libavutil/avstring.h create mode 100644 utils/pvrtex/libavutil/avutil.h create mode 100644 utils/pvrtex/libavutil/bprint.h create mode 100644 utils/pvrtex/libavutil/bswap.h create mode 100644 utils/pvrtex/libavutil/common.h create mode 100644 utils/pvrtex/libavutil/crc.h create mode 100644 utils/pvrtex/libavutil/dynarray.h create mode 100644 utils/pvrtex/libavutil/error.h create mode 100644 utils/pvrtex/libavutil/internal.h create mode 100644 utils/pvrtex/libavutil/intfloat.h create mode 100644 utils/pvrtex/libavutil/intreadwrite.h create mode 100644 utils/pvrtex/libavutil/lfg.c create mode 100644 utils/pvrtex/libavutil/lfg.h create mode 100644 utils/pvrtex/libavutil/libm.h create mode 100644 utils/pvrtex/libavutil/log.h create mode 100644 utils/pvrtex/libavutil/macros.h create mode 100644 utils/pvrtex/libavutil/mathematics.c create mode 100644 utils/pvrtex/libavutil/mathematics.h create mode 100644 utils/pvrtex/libavutil/md5.h create mode 100644 utils/pvrtex/libavutil/mem.c create mode 100644 utils/pvrtex/libavutil/mem.h create mode 100644 utils/pvrtex/libavutil/pixfmt.h create mode 100644 utils/pvrtex/libavutil/rational.c create mode 100644 utils/pvrtex/libavutil/rational.h create mode 100644 utils/pvrtex/libavutil/thread.h create mode 100644 utils/pvrtex/libavutil/version.h create mode 100644 utils/pvrtex/log.c create mode 100644 utils/pvrtex/main.c create mode 100644 utils/pvrtex/md5.c create mode 100644 utils/pvrtex/mem.c create mode 100644 utils/pvrtex/mycommon.c create mode 100644 utils/pvrtex/mycommon.h create mode 100644 utils/pvrtex/nvmath.h create mode 100644 utils/pvrtex/optparse.h create mode 100644 utils/pvrtex/optparse_impl.c create mode 100644 utils/pvrtex/pixel.h create mode 100644 utils/pvrtex/pvr_texture.c create mode 100644 utils/pvrtex/pvr_texture.h create mode 100644 utils/pvrtex/pvr_texture_encoder.c create mode 100644 utils/pvrtex/pvr_texture_encoder.h create mode 100644 utils/pvrtex/readme_unformatted.txt create mode 100644 utils/pvrtex/stb_image.h create mode 100644 utils/pvrtex/stb_image_impl.c create mode 100644 utils/pvrtex/stb_image_resize.h create mode 100644 utils/pvrtex/stb_image_resize_impl.c create mode 100644 utils/pvrtex/stb_image_write.h create mode 100644 utils/pvrtex/stb_image_write_impl.c create mode 100644 utils/pvrtex/tddither.c create mode 100644 utils/pvrtex/tddither.h create mode 100644 utils/pvrtex/vqcompress.c create mode 100644 utils/pvrtex/vqcompress.h diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 251ed0bf..f3da1509 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -228,6 +228,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Added thread support for tracking CPU time + updated clock_gettime() [FG] - *** Added support for one-shot timers [PC] - DC Use one-shot timers for timeout and a proper polling mechanism in modem [PC] +- *** Added pvrtex utility by TapamN to utils [DF == Daniel Fairchild] - *** Added full support for <time.h> additions from C23 standard. [FG] - *** Fixes mutexes not working properly [PC] - DC fs_dcload: Set errno on error in dcload_stat() [PC] diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c index f8445cad..6f3f5273 100644 --- a/kernel/arch/dreamcast/fs/fs_iso9660.c +++ b/kernel/arch/dreamcast/fs/fs_iso9660.c @@ -197,8 +197,8 @@ static uint32 iso_733(const uint8 *from) { this cache. As the cache fills up, sectors are removed from the end of it. */ typedef struct { + uint8 *data; /* Sector data */ uint32 sector; /* CD sector */ - uint8 data[2048]; /* Sector data */ } cache_block_t; /* List of cache blocks (ordered least recently used to most recently) */ @@ -206,6 +206,9 @@ typedef struct { static cache_block_t *icache[NUM_CACHE_BLOCKS]; /* inode cache */ static cache_block_t *dcache[NUM_CACHE_BLOCKS]; /* data cache */ +static unsigned char *cache_data; +static cache_block_t *caches; + /* Cache modification mutex */ static mutex_t cache_mutex; @@ -268,7 +271,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) { } /* Load the requested block */ - j = cdrom_read_sectors(cache[i]->data, sector + 150, 1); + j = cdrom_read_sectors_ex(cache[i]->data, sector + 150, 1, CDROM_READ_DMA); if(j < 0) { //dbglog(DBG_ERROR, "fs_iso9660: can't read_sectors for %d: %d\n", @@ -1084,11 +1087,16 @@ void fs_iso9660_init(void) { mutex_init(&cache_mutex, MUTEX_TYPE_NORMAL); mutex_init(&fh_mutex, MUTEX_TYPE_NORMAL); - /* Allocate cache block space */ + /* Allocate cache block space, properly aligned for DMA access */ + cache_data = memalign(32, 2 * NUM_CACHE_BLOCKS * 2048); + caches = malloc(2 * NUM_CACHE_BLOCKS * sizeof(cache_block_t)); + for(i = 0; i < NUM_CACHE_BLOCKS; i++) { - icache[i] = malloc(sizeof(cache_block_t)); + icache[i] = &caches[i * 2]; + icache[i]->data = &cache_data[i * 2 * 2048]; icache[i]->sector = -1; - dcache[i] = malloc(sizeof(cache_block_t)); + dcache[i] = &caches[i * 2 + 1]; + dcache[i]->data = &cache_data[i * 2 * 2048 + 2048]; dcache[i]->sector = -1; } @@ -1104,16 +1112,12 @@ void fs_iso9660_init(void) { /* De-init the file system */ void fs_iso9660_shutdown(void) { - int i; - /* De-register with vblank */ vblank_handler_remove(iso_vblank_hnd); /* Dealloc cache block space */ - for(i = 0; i < NUM_CACHE_BLOCKS; i++) { - free(icache[i]); - free(dcache[i]); - } + free(cache_data); + free(caches); /* Free muteces */ mutex_destroy(&cache_mutex); diff --git a/utils/Makefile b/utils/Makefile index f3045bd7..19988ecb 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -4,7 +4,7 @@ # Copyright (C) 2001 Megan Potter # -DIRS = bin2c bincnv dcbumpgen genromfs kmgenc makeip scramble vqenc wav2adpcm +DIRS = bin2c bincnv dcbumpgen genromfs kmgenc makeip scramble vqenc wav2adpcm pvrtex ifeq ($(KOS_SUBARCH), naomi) DIRS += naomibintool naominetboot diff --git a/utils/pvrtex/.gitignore b/utils/pvrtex/.gitignore new file mode 100644 index 00000000..1d3690fa --- /dev/null +++ b/utils/pvrtex/.gitignore @@ -0,0 +1,2 @@ +pvrtex +README diff --git a/utils/pvrtex/CHANGELOG b/utils/pvrtex/CHANGELOG new file mode 100644 index 00000000..7c51f43c --- /dev/null +++ b/utils/pvrtex/CHANGELOG @@ -0,0 +1,29 @@ +Based on code by TapamN +Source released here: https://dcemulation.org/phpBB/viewtopic.php?t=106138 + + Version 1.0 + Initial release + + Version 1.01 + Program now displays error message when an error occurs loading a source image. Previously, the program would hit an assertion. + + Fixed "--resize down" option. Previously, the program would round down sizes that were already a power-of-two, now sizes that are already POT are left unchanged. + + Included a missing FFmpeg header file. + +--------------------------- + +Adaption into KOS by Daniel Fairchild, 2024 + +Version 1.0.2 + Added install target in Makefile + + Removed some dead code in nvmath.h that prevented compilation on ARM64 targets + + Added targets for generating header files from selected sections in the README file + + Added command line option --examples/-E which outputs the "Usage Examples" section of the README file + + Changed -h/--help option to output the "Command Line Options:" section of the README file + + Added this CHANGELOG file diff --git a/utils/pvrtex/Makefile b/utils/pvrtex/Makefile new file mode 100644 index 00000000..40e17a3e --- /dev/null +++ b/utils/pvrtex/Makefile @@ -0,0 +1,59 @@ +#Uncomment when debugging +#DEBUGBUILD = true + +TARGET = pvrtex +OBJS = elbg.o mem.o log.o bprint.o avstring.o lfg.o crc.o md5.o stb_image_impl.o \ + stb_image_write_impl.o stb_image_resize_impl.o optparse_impl.o pvr_texture.o \ + dither.o tddither.o vqcompress.o mycommon.o file_common.o \ + file_pvr.o file_tex.o file_dctex.o pvr_texture_encoder.o main.o + +ifdef $(DEBUGBUILD) + OPTMODE= -Og -pg -g +else + OPTMODE= -O3 -flto +endif + +MYFLAGS=-flto=auto -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Ilibavutil -I. -DCONFIG_MEMORY_POISONING=0 -DHAVE_FAST_UNALIGNED=0 -I${KOS_INC_PATHS} +MYCPPFLAGS=$(MYFLAGS) +MYCFLAGS=$(MYFLAGS) -Wno-pointer-sign + + +define textSegment2Header + awk '/$1/,/--------------------------------------------------------------------------/' README|xxd -i -n $2_$3 > $2/$3.h +endef + + +TOOLINSTALLDIR=$(KOS_BASE)/../bin + +.PHONY: all clean + + +$(TARGET): $(OBJS) + gcc $(OPTMODE) -o $(TARGET) \ + $(OBJS) $(PROGMAIN) -lm -lstdc++ + +main.o: main.c info/options.h info/examples.h + gcc $(CFLAGS) $(MYCFLAGS) $(OPTMODE) -c $< -o $@ + +%.o: %.c + gcc $(CFLAGS) $(MYCFLAGS) $(OPTMODE) -c $< -o $@ + +%.o: %.cpp + gcc $(CFLAGS) $(MYCPPFLAGS) $(CXXFLAGS) $(OPTMODE) -c $< -o $@ + +clean: + rm -f $(TARGET) $(OBJS) README + +README: readme_unformatted.txt + fmt -s readme_unformatted.txt > README + +all: $(TARGET) README + +install: all + install -m 755 $(TARGET) $(TOOLINSTALLDIR)/ + +info/options.h: README + $(call textSegment2Header,Command Line Options:,info,options) + +info/examples.h: README + $(call textSegment2Header,Usage Examples:,info,examples) diff --git a/utils/pvrtex/avstring.c b/utils/pvrtex/avstring.c new file mode 100644 index 00000000..99f06690 --- /dev/null +++ b/utils/pvrtex/avstring.c @@ -0,0 +1,462 @@ +/* + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * Copyright (c) 2007 Mans Rullgard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <limits.h> +#include <stdarg.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "mem.h" +#include "avassert.h" +#include "avstring.h" +#include "bprint.h" +#include "error.h" +#include "macros.h" +#include "version.h" + +int av_strstart(const char *str, const char *pfx, const char **ptr) +{ + while (*pfx && *pfx == *str) { + pfx++; + str++; + } + if (!*pfx && ptr) + *ptr = str; + return !*pfx; +} + +int av_stristart(const char *str, const char *pfx, const char **ptr) +{ + while (*pfx && av_toupper((unsigned)*pfx) == av_toupper((unsigned)*str)) { + pfx++; + str++; + } + if (!*pfx && ptr) + *ptr = str; + return !*pfx; +} + +char *av_stristr(const char *s1, const char *s2) +{ + if (!*s2) + return (char*)(intptr_t)s1; + + do + if (av_stristart(s1, s2, NULL)) + return (char*)(intptr_t)s1; + while (*s1++); + + return NULL; +} + +char *av_strnstr(const char *haystack, const char *needle, size_t hay_length) +{ + size_t needle_len = strlen(needle); + if (!needle_len) + return (char*)haystack; + while (hay_length >= needle_len) { + hay_length--; + if (!memcmp(haystack, needle, needle_len)) + return (char*)haystack; + haystack++; + } + return NULL; +} + +size_t av_strlcpy(char *dst, const char *src, size_t size) +{ + size_t len = 0; + while (++len < size && *src) + *dst++ = *src++; + if (len <= size) + *dst = 0; + return len + strlen(src) - 1; +} + +size_t av_strlcat(char *dst, const char *src, size_t size) +{ + size_t len = strlen(dst); + if (size <= len + 1) + return len + strlen(src); + return len + av_strlcpy(dst + len, src, size - len); +} + +size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) +{ + size_t len = strlen(dst); + va_list vl; + + va_start(vl, fmt); + len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl); + va_end(vl); + + return len; +} + +char *av_asprintf(const char *fmt, ...) +{ + char *p = NULL; + va_list va; + int len; + + va_start(va, fmt); + len = vsnprintf(NULL, 0, fmt, va); + va_end(va); + if (len < 0) + goto end; + + p = av_malloc(len + 1); + if (!p) + goto end; + + va_start(va, fmt); + len = vsnprintf(p, len + 1, fmt, va); + va_end(va); + if (len < 0) + av_freep(&p); + +end: + return p; +} + ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |