mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-05-25 12:46:34 +00:00
Rescale save-loaded textures to runtime texture dimensions (#805)
Some checks are pending
CI / clang-format (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain $GITHUB_WORKSPACE/CMake/i586-pc-msdosdjgpp.cmake, false, true, false, Ninja, DOS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain /usr/local/vitasdk/share/vita.toolchain.cmake, false, false, Ninja, Vita, ubuntu-latest, true, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0, false, false, Visual Studio 18 2026, true, Xbox One, windows-latest, amd64, false, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake, false, devkitpro/devkitarm:latest, false, Ninja, true, Nintendo 3DS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake, false, devkitpro/devkita64:latest, false, Ninja, Nintendo Switch, true, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, emcmake, false, false, true, Ninja, Emscripten, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, false, Ninja, true, MSVC (arm64), windows-latest, amd64_arm64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, true, Ninja, true, MSVC (x86), windows-latest, amd64_x86, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, false, Ninja, true, MSVC (x64), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, true, false, Ninja, true, MSVC (x64 Debug), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, -DCMAKE_SYSTEM_NAME=iOS, false, false, Xcode, true, iOS, macos-15, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, false, Ninja, Android, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, true, false, Ninja, macOS, macos-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, false, Ninja, true, mingw-w64-x86_64, mingw64, msys2 mingw64, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux (Debug), ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux, ubuntu-latest, true) (push) Waiting to run
CI / FreeBSD (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (aarch64, ubuntu-22.04-arm) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (x86_64, ubuntu-latest) (push) Waiting to run
CI / C++ (push) Waiting to run
CI / Release (push) Blocked by required conditions
Docker / Publish web port (push) Waiting to run
Some checks are pending
CI / clang-format (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain $GITHUB_WORKSPACE/CMake/i586-pc-msdosdjgpp.cmake, false, true, false, Ninja, DOS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain /usr/local/vitasdk/share/vita.toolchain.cmake, false, false, Ninja, Vita, ubuntu-latest, true, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0, false, false, Visual Studio 18 2026, true, Xbox One, windows-latest, amd64, false, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake, false, devkitpro/devkitarm:latest, false, Ninja, true, Nintendo 3DS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake, false, devkitpro/devkita64:latest, false, Ninja, Nintendo Switch, true, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, emcmake, false, false, true, Ninja, Emscripten, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, false, Ninja, true, MSVC (arm64), windows-latest, amd64_arm64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, true, Ninja, true, MSVC (x86), windows-latest, amd64_x86, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, false, Ninja, true, MSVC (x64), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, true, false, Ninja, true, MSVC (x64 Debug), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, -DCMAKE_SYSTEM_NAME=iOS, false, false, Xcode, true, iOS, macos-15, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, false, Ninja, Android, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, true, false, Ninja, macOS, macos-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, false, Ninja, true, mingw-w64-x86_64, mingw64, msys2 mingw64, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux (Debug), ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux, ubuntu-latest, true) (push) Waiting to run
CI / FreeBSD (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (aarch64, ubuntu-22.04-arm) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (x86_64, ubuntu-latest) (push) Waiting to run
CI / C++ (push) Waiting to run
CI / Release (push) Blocked by required conditions
Docker / Publish web port (push) Waiting to run
* Rescale save-loaded textures to runtime texture dimensions `LegoTextureInfo::LoadBits` sized its memcpy from the destination DirectDraw surface and assumed the source bits matched. They don't when the save was made under a different renderer than the current one: HW mode squares non-square assets in `LegoImage::Read` (e.g. 128x32 -> 128x128 via row duplication), SW mode keeps the original dimensions, and `ReadNamedTexture` always loads with `p_square=0`, so saved bits keep whatever size they had at save time. SW save loaded under HW caused an OOB read in `LoadBits`; HW save loaded under SW silently truncated the source and rendered a distorted texture. Add `LegoImage::Resize(width, height)` (nearest-neighbor, handles both up- and down-scale) and call it in `LoadFromNamedTexture` to match the runtime `LegoTextureInfo` surface dimensions before binding. Save format unchanged; `LoadBits` signature unchanged. Square textures and matching-mode loads short-circuit on the fast-path. * ci: bump Android SDL3 download + Xbox One generator for VS 18 - Android: SDL3's `build-release.py` started requiring `download` before `android` so it can fetch the new gameinput dependency. (build-release.py is technically internal SDL tooling; longer-term we may want to invoke a different SDL3 build entry point.) - Xbox One: windows-latest now ships VS 18, so the `Visual Studio 17 2022` generator can no longer find a VS install. Bump to `Visual Studio 18 2026`.
This commit is contained in:
parent
8c8559452d
commit
fdbe9a8705
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -49,7 +49,7 @@ jobs:
|
|||||||
- { name: 'Emscripten', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' }
|
- { name: 'Emscripten', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' }
|
||||||
- { name: 'Nintendo 3DS', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, n3ds: true, werror: true, clang-tidy: false, container: 'devkitpro/devkitarm:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake' }
|
- { name: 'Nintendo 3DS', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, n3ds: true, werror: true, clang-tidy: false, container: 'devkitpro/devkitarm:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake' }
|
||||||
- { name: 'Nintendo Switch', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, nx: true, werror: true, clang-tidy: false, container: 'devkitpro/devkita64:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake' }
|
- { name: 'Nintendo Switch', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, nx: true, werror: true, clang-tidy: false, container: 'devkitpro/devkita64:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake' }
|
||||||
- { name: 'Xbox One', os: 'windows-latest', generator: 'Visual Studio 17 2022', dx5: false, config: false, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64', cmake-args: '-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0', xbox-one: true}
|
- { name: 'Xbox One', os: 'windows-latest', generator: 'Visual Studio 18 2026', dx5: false, config: false, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64', cmake-args: '-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0', xbox-one: true}
|
||||||
- { name: 'Android', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, android: true, werror: true, clang-tidy: false,}
|
- { name: 'Android', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, android: true, werror: true, clang-tidy: false,}
|
||||||
- { name: 'Vita', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, vita: true, werror: true, clang-tidy: false, cmake-args: '--toolchain /usr/local/vitasdk/share/vita.toolchain.cmake'}
|
- { name: 'Vita', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, vita: true, werror: true, clang-tidy: false, cmake-args: '--toolchain /usr/local/vitasdk/share/vita.toolchain.cmake'}
|
||||||
- { name: 'DOS', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, dos: true, werror: true, clang-tidy: false, cmake-args: '--toolchain $GITHUB_WORKSPACE/CMake/i586-pc-msdosdjgpp.cmake'}
|
- { name: 'DOS', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, dos: true, werror: true, clang-tidy: false, cmake-args: '--toolchain $GITHUB_WORKSPACE/CMake/i586-pc-msdosdjgpp.cmake'}
|
||||||
|
|||||||
@ -803,6 +803,17 @@ void LoadFromNamedTexture(LegoNamedTexture* p_namedTexture)
|
|||||||
LegoTextureInfo* textureInfo = TextureContainer()->Get(p_namedTexture->GetName()->GetData());
|
LegoTextureInfo* textureInfo = TextureContainer()->Get(p_namedTexture->GetName()->GetData());
|
||||||
|
|
||||||
if (textureInfo != NULL) {
|
if (textureInfo != NULL) {
|
||||||
|
DDSURFACEDESC desc;
|
||||||
|
memset(&desc, 0, sizeof(desc));
|
||||||
|
desc.dwSize = sizeof(desc);
|
||||||
|
|
||||||
|
if (textureInfo->m_surface->GetSurfaceDesc(&desc) == DD_OK) {
|
||||||
|
LegoImage* image = p_namedTexture->GetTexture()->GetImage();
|
||||||
|
if (image->GetWidth() != desc.dwWidth || image->GetHeight() != desc.dwHeight) {
|
||||||
|
image->Resize(desc.dwWidth, desc.dwHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
textureInfo->LoadBits(p_namedTexture->GetTexture()->GetImage()->GetBits());
|
textureInfo->LoadBits(p_namedTexture->GetTexture()->GetImage()->GetBits());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,3 +179,37 @@ LegoResult LegoImage::Write(LegoStorage* p_storage)
|
|||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LegoResult LegoImage::Resize(LegoU32 p_width, LegoU32 p_height)
|
||||||
|
{
|
||||||
|
if (m_surface == NULL) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
if (m_surface->w == (int) p_width && m_surface->h == (int) p_height) {
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Surface* newSurface = SDL_CreateSurface(p_width, p_height, SDL_PIXELFORMAT_INDEX8);
|
||||||
|
if (newSurface == NULL) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LegoU32 srcW = m_surface->w;
|
||||||
|
LegoU32 srcH = m_surface->h;
|
||||||
|
const LegoU8* src = (const LegoU8*) m_surface->pixels;
|
||||||
|
LegoU8* dst = (LegoU8*) newSurface->pixels;
|
||||||
|
|
||||||
|
for (LegoU32 dy = 0; dy < p_height; dy++) {
|
||||||
|
LegoU32 sy = dy * srcH / p_height;
|
||||||
|
const LegoU8* srcRow = src + sy * srcW;
|
||||||
|
LegoU8* dstRow = dst + dy * p_width;
|
||||||
|
for (LegoU32 dx = 0; dx < p_width; dx++) {
|
||||||
|
LegoU32 sx = dx * srcW / p_width;
|
||||||
|
dstRow[dx] = srcRow[sx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_DestroySurface(m_surface);
|
||||||
|
m_surface = newSurface;
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|||||||
@ -49,6 +49,7 @@ class LegoImage {
|
|||||||
LegoU8* GetBits() const { return (LegoU8*) m_surface->pixels; }
|
LegoU8* GetBits() const { return (LegoU8*) m_surface->pixels; }
|
||||||
LegoResult Read(LegoStorage* p_storage, LegoU32 p_square);
|
LegoResult Read(LegoStorage* p_storage, LegoU32 p_square);
|
||||||
LegoResult Write(LegoStorage* p_storage);
|
LegoResult Write(LegoStorage* p_storage);
|
||||||
|
LegoResult Resize(LegoU32 p_width, LegoU32 p_height);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SDL_Surface* m_surface;
|
SDL_Surface* m_surface;
|
||||||
|
|||||||
@ -77,7 +77,7 @@ tasks.register('compileSDL3AndroidArchive', Exec) {
|
|||||||
|
|
||||||
def sdl3Dir = "build/_deps/sdl3-src"
|
def sdl3Dir = "build/_deps/sdl3-src"
|
||||||
commandLine 'python', "${sdl3Dir}/build-scripts/build-release.py",
|
commandLine 'python', "${sdl3Dir}/build-scripts/build-release.py",
|
||||||
'--actions', 'android',
|
'--actions', 'download', 'android',
|
||||||
'--fast', '--force',
|
'--fast', '--force',
|
||||||
"--root=${sdl3Dir}", "--android-api=${android.defaultConfig.minSdk}"
|
"--root=${sdl3Dir}", "--android-api=${android.defaultConfig.minSdk}"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user