mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-03-06 14:27:44 +00:00
Core: Purge resources.cpp
Save around 64KB in binary size.
This commit is contained in:
parent
5b590d434b
commit
143acca03b
|
@ -97,8 +97,6 @@ add_library(core
|
||||||
playstation_mouse.h
|
playstation_mouse.h
|
||||||
psf_loader.cpp
|
psf_loader.cpp
|
||||||
psf_loader.h
|
psf_loader.h
|
||||||
resources.cpp
|
|
||||||
resources.h
|
|
||||||
save_state_version.h
|
save_state_version.h
|
||||||
settings.cpp
|
settings.cpp
|
||||||
settings.h
|
settings.h
|
||||||
|
|
|
@ -77,7 +77,6 @@
|
||||||
<ClCompile Include="pine_server.cpp" />
|
<ClCompile Include="pine_server.cpp" />
|
||||||
<ClCompile Include="playstation_mouse.cpp" />
|
<ClCompile Include="playstation_mouse.cpp" />
|
||||||
<ClCompile Include="psf_loader.cpp" />
|
<ClCompile Include="psf_loader.cpp" />
|
||||||
<ClCompile Include="resources.cpp" />
|
|
||||||
<ClCompile Include="settings.cpp" />
|
<ClCompile Include="settings.cpp" />
|
||||||
<ClCompile Include="sio.cpp" />
|
<ClCompile Include="sio.cpp" />
|
||||||
<ClCompile Include="spu.cpp" />
|
<ClCompile Include="spu.cpp" />
|
||||||
|
@ -156,7 +155,6 @@
|
||||||
<ClInclude Include="pine_server.h" />
|
<ClInclude Include="pine_server.h" />
|
||||||
<ClInclude Include="playstation_mouse.h" />
|
<ClInclude Include="playstation_mouse.h" />
|
||||||
<ClInclude Include="psf_loader.h" />
|
<ClInclude Include="psf_loader.h" />
|
||||||
<ClInclude Include="resources.h" />
|
|
||||||
<ClInclude Include="save_state_version.h" />
|
<ClInclude Include="save_state_version.h" />
|
||||||
<ClInclude Include="settings.h" />
|
<ClInclude Include="settings.h" />
|
||||||
<ClInclude Include="shader_cache_version.h" />
|
<ClInclude Include="shader_cache_version.h" />
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
<ClCompile Include="guncon.cpp" />
|
<ClCompile Include="guncon.cpp" />
|
||||||
<ClCompile Include="playstation_mouse.cpp" />
|
<ClCompile Include="playstation_mouse.cpp" />
|
||||||
<ClCompile Include="negcon.cpp" />
|
<ClCompile Include="negcon.cpp" />
|
||||||
<ClCompile Include="resources.cpp" />
|
|
||||||
<ClCompile Include="host_interface_progress_callback.cpp" />
|
<ClCompile Include="host_interface_progress_callback.cpp" />
|
||||||
<ClCompile Include="cpu_pgxp.cpp" />
|
<ClCompile Include="cpu_pgxp.cpp" />
|
||||||
<ClCompile Include="cheats.cpp" />
|
<ClCompile Include="cheats.cpp" />
|
||||||
|
@ -107,7 +106,6 @@
|
||||||
<ClInclude Include="guncon.h" />
|
<ClInclude Include="guncon.h" />
|
||||||
<ClInclude Include="playstation_mouse.h" />
|
<ClInclude Include="playstation_mouse.h" />
|
||||||
<ClInclude Include="negcon.h" />
|
<ClInclude Include="negcon.h" />
|
||||||
<ClInclude Include="resources.h" />
|
|
||||||
<ClInclude Include="host_interface_progress_callback.h" />
|
<ClInclude Include="host_interface_progress_callback.h" />
|
||||||
<ClInclude Include="gte_types.h" />
|
<ClInclude Include="gte_types.h" />
|
||||||
<ClInclude Include="cpu_pgxp.h" />
|
<ClInclude Include="cpu_pgxp.h" />
|
||||||
|
|
|
@ -116,6 +116,7 @@ using ImGuiFullscreen::BeginNavBar;
|
||||||
using ImGuiFullscreen::CenterImage;
|
using ImGuiFullscreen::CenterImage;
|
||||||
using ImGuiFullscreen::CloseChoiceDialog;
|
using ImGuiFullscreen::CloseChoiceDialog;
|
||||||
using ImGuiFullscreen::CloseFileSelector;
|
using ImGuiFullscreen::CloseFileSelector;
|
||||||
|
using ImGuiFullscreen::CreateTextureFromImage;
|
||||||
using ImGuiFullscreen::DrawShadowedText;
|
using ImGuiFullscreen::DrawShadowedText;
|
||||||
using ImGuiFullscreen::EndFullscreenColumns;
|
using ImGuiFullscreen::EndFullscreenColumns;
|
||||||
using ImGuiFullscreen::EndFullscreenColumnWindow;
|
using ImGuiFullscreen::EndFullscreenColumnWindow;
|
||||||
|
@ -436,7 +437,6 @@ static void InitializePlaceholderSaveStateListEntry(SaveStateListEntry* li, cons
|
||||||
static bool InitializeSaveStateListEntryFromSerial(SaveStateListEntry* li, const std::string& serial, s32 slot,
|
static bool InitializeSaveStateListEntryFromSerial(SaveStateListEntry* li, const std::string& serial, s32 slot,
|
||||||
bool global);
|
bool global);
|
||||||
static bool InitializeSaveStateListEntryFromPath(SaveStateListEntry* li, std::string path, s32 slot, bool global);
|
static bool InitializeSaveStateListEntryFromPath(SaveStateListEntry* li, std::string path, s32 slot, bool global);
|
||||||
static void PopulateSaveStateScreenshot(SaveStateListEntry* li, const ExtendedSaveStateInfo* ssi);
|
|
||||||
static void ClearSaveStateEntryList();
|
static void ClearSaveStateEntryList();
|
||||||
static u32 PopulateSaveStateListEntries(const std::string& title, const std::string& serial);
|
static u32 PopulateSaveStateListEntries(const std::string& title, const std::string& serial);
|
||||||
static bool OpenLoadStateSelectorForGame(const std::string& game_path);
|
static bool OpenLoadStateSelectorForGame(const std::string& game_path);
|
||||||
|
@ -5550,31 +5550,12 @@ bool FullscreenUI::InitializeSaveStateListEntryFromPath(SaveStateListEntry* li,
|
||||||
li->slot = slot;
|
li->slot = slot;
|
||||||
li->path = std::move(path);
|
li->path = std::move(path);
|
||||||
li->global = global;
|
li->global = global;
|
||||||
|
if (ssi->screenshot.IsValid())
|
||||||
|
li->preview_texture = CreateTextureFromImage(ssi->screenshot);
|
||||||
|
|
||||||
PopulateSaveStateScreenshot(li, &ssi.value());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::PopulateSaveStateScreenshot(SaveStateListEntry* li, const ExtendedSaveStateInfo* ssi)
|
|
||||||
{
|
|
||||||
li->preview_texture.reset();
|
|
||||||
if (ssi && ssi->screenshot.IsValid())
|
|
||||||
{
|
|
||||||
li->preview_texture = g_gpu_device->FetchTexture(ssi->screenshot.GetWidth(), ssi->screenshot.GetHeight(), 1, 1, 1,
|
|
||||||
GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
|
|
||||||
ssi->screenshot.GetPixels(), ssi->screenshot.GetPitch());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
li->preview_texture = g_gpu_device->FetchTexture(
|
|
||||||
Resources::PLACEHOLDER_ICON_WIDTH, Resources::PLACEHOLDER_ICON_HEIGHT, 1, 1, 1, GPUTexture::Type::Texture,
|
|
||||||
GPUTexture::Format::RGBA8, Resources::PLACEHOLDER_ICON_DATA, sizeof(u32) * Resources::PLACEHOLDER_ICON_WIDTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!li->preview_texture)
|
|
||||||
ERROR_LOG("Failed to upload save state image to GPU");
|
|
||||||
}
|
|
||||||
|
|
||||||
void FullscreenUI::ClearSaveStateEntryList()
|
void FullscreenUI::ClearSaveStateEntryList()
|
||||||
{
|
{
|
||||||
for (SaveStateListEntry& entry : s_save_state_selector_slots)
|
for (SaveStateListEntry& entry : s_save_state_selector_slots)
|
||||||
|
@ -5595,9 +5576,10 @@ u32 FullscreenUI::PopulateSaveStateListEntries(const std::string& title, const s
|
||||||
if (ssi)
|
if (ssi)
|
||||||
{
|
{
|
||||||
SaveStateListEntry li;
|
SaveStateListEntry li;
|
||||||
PopulateSaveStateScreenshot(&li, &ssi.value());
|
|
||||||
li.title = FSUI_STR("Undo Load State");
|
li.title = FSUI_STR("Undo Load State");
|
||||||
li.summary = FSUI_STR("Restores the state of the system prior to the last state loaded.");
|
li.summary = FSUI_STR("Restores the state of the system prior to the last state loaded.");
|
||||||
|
if (ssi->screenshot.IsValid())
|
||||||
|
li.preview_texture = CreateTextureFromImage(ssi->screenshot);
|
||||||
s_save_state_selector_slots.push_back(std::move(li));
|
s_save_state_selector_slots.push_back(std::move(li));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5896,7 +5878,7 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
|
||||||
bb.Max -= style.FramePadding;
|
bb.Max -= style.FramePadding;
|
||||||
|
|
||||||
GPUTexture* const screenshot =
|
GPUTexture* const screenshot =
|
||||||
entry.preview_texture ? entry.preview_texture.get() : GetPlaceholderTexture().get();
|
entry.preview_texture ? entry.preview_texture.get() : GetCachedTextureAsync("no-save.png");
|
||||||
const ImRect image_rect(
|
const ImRect image_rect(
|
||||||
CenterImage(ImRect(bb.Min, bb.Min + image_size),
|
CenterImage(ImRect(bb.Min, bb.Min + image_size),
|
||||||
ImVec2(static_cast<float>(screenshot->GetWidth()), static_cast<float>(screenshot->GetHeight()))));
|
ImVec2(static_cast<float>(screenshot->GetWidth()), static_cast<float>(screenshot->GetHeight()))));
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,18 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
||||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "types.h"
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace Resources {
|
|
||||||
|
|
||||||
constexpr int WINDOW_ICON_WIDTH = 64;
|
|
||||||
constexpr int WINDOW_ICON_HEIGHT = 64;
|
|
||||||
extern unsigned int WINDOW_ICON_DATA[WINDOW_ICON_WIDTH * WINDOW_ICON_HEIGHT];
|
|
||||||
|
|
||||||
constexpr int PLACEHOLDER_ICON_WIDTH = 128;
|
|
||||||
constexpr int PLACEHOLDER_ICON_HEIGHT = 96;
|
|
||||||
extern unsigned int PLACEHOLDER_ICON_DATA[PLACEHOLDER_ICON_WIDTH * PLACEHOLDER_ICON_HEIGHT];
|
|
||||||
|
|
||||||
} // namespace Resources
|
|
|
@ -283,6 +283,16 @@ const std::shared_ptr<GPUTexture>& ImGuiFullscreen::GetPlaceholderTexture()
|
||||||
return s_placeholder_texture;
|
return s_placeholder_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<GPUTexture> ImGuiFullscreen::CreateTextureFromImage(const RGBA8Image& image)
|
||||||
|
{
|
||||||
|
std::unique_ptr<GPUTexture> ret =
|
||||||
|
g_gpu_device->CreateTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,
|
||||||
|
GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch());
|
||||||
|
if (!ret) [[unlikely]]
|
||||||
|
ERROR_LOG("Failed to upload {}x{} RGBA8Image to GPU", image.GetWidth(), image.GetHeight());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(std::string_view path)
|
std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(std::string_view path)
|
||||||
{
|
{
|
||||||
std::optional<RGBA8Image> image;
|
std::optional<RGBA8Image> image;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class RGBA8Image;
|
||||||
class GPUTexture;
|
class GPUTexture;
|
||||||
class SmallStringBase;
|
class SmallStringBase;
|
||||||
|
|
||||||
|
@ -128,6 +129,7 @@ void Shutdown();
|
||||||
|
|
||||||
/// Texture cache.
|
/// Texture cache.
|
||||||
const std::shared_ptr<GPUTexture>& GetPlaceholderTexture();
|
const std::shared_ptr<GPUTexture>& GetPlaceholderTexture();
|
||||||
|
std::unique_ptr<GPUTexture> CreateTextureFromImage(const RGBA8Image& image);
|
||||||
std::shared_ptr<GPUTexture> LoadTexture(std::string_view path);
|
std::shared_ptr<GPUTexture> LoadTexture(std::string_view path);
|
||||||
GPUTexture* GetCachedTexture(std::string_view name);
|
GPUTexture* GetCachedTexture(std::string_view name);
|
||||||
GPUTexture* GetCachedTextureAsync(std::string_view name);
|
GPUTexture* GetCachedTextureAsync(std::string_view name);
|
||||||
|
|
Loading…
Reference in a new issue