mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 14:01:17 +12:00
Separate imgui contexts for TV and Pad windows. (#664)
This commit is contained in:
parent
daf3ef060a
commit
cbb79fd34c
8 changed files with 131 additions and 184 deletions
|
@ -178,6 +178,43 @@ uint32 LatteShaderCache_getPipelineCacheExtraVersion(uint64 titleId)
|
|||
return extraVersion;
|
||||
}
|
||||
|
||||
void LatteShaderCache_drawBackgroundImage(ImTextureID texture, int width, int height)
|
||||
{
|
||||
// clear framebuffers and clean up
|
||||
const auto kPopupFlags =
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize;
|
||||
auto& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos({0, 0}, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(io.DisplaySize, ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {0, 0});
|
||||
if (ImGui::Begin("Background texture", nullptr, kPopupFlags))
|
||||
{
|
||||
if (texture)
|
||||
{
|
||||
float imageDisplayWidth = io.DisplaySize.x;
|
||||
float imageDisplayHeight = height * imageDisplayWidth / width;
|
||||
|
||||
float paddingLeftAndRight = 0.0f;
|
||||
float paddingTopAndBottom = (io.DisplaySize.y - imageDisplayHeight) / 2.0f;
|
||||
if (imageDisplayHeight > io.DisplaySize.y)
|
||||
{
|
||||
imageDisplayHeight = io.DisplaySize.y;
|
||||
imageDisplayWidth = width * imageDisplayHeight / height;
|
||||
paddingLeftAndRight = (io.DisplaySize.x - imageDisplayWidth) / 2.0f;
|
||||
paddingTopAndBottom = 0.0f;
|
||||
}
|
||||
|
||||
ImGui::GetWindowDrawList()->AddImage(texture, ImVec2(paddingLeftAndRight, paddingTopAndBottom),
|
||||
ImVec2(io.DisplaySize.x - paddingLeftAndRight,
|
||||
io.DisplaySize.y - paddingTopAndBottom), {0, 1}, {1, 0});
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void LatteShaderCache_load()
|
||||
{
|
||||
shaderCacheScreenStats.compiledShaderCount = 0;
|
||||
|
@ -231,48 +268,36 @@ void LatteShaderCache_load()
|
|||
g_shaderCacheLoaderState.loadedShaderFiles = 0;
|
||||
|
||||
// get game background loading image
|
||||
TGAFILE TVfile{};
|
||||
g_shaderCacheLoaderState.textureTVId = nullptr;
|
||||
|
||||
std::string tvTexPath = fmt::format("{}/meta/bootTvTex.tga", CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()));
|
||||
sint32 statusTV;
|
||||
auto fscfile = fsc_open(tvTexPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &statusTV);
|
||||
if (fscfile)
|
||||
auto loadBackgroundTexture = [](bool isTV, ImTextureID& out)
|
||||
{
|
||||
uint32 size = fsc_getFileSize(fscfile);
|
||||
if (size > 0)
|
||||
TGAFILE file{};
|
||||
out = nullptr;
|
||||
|
||||
std::string fileName = isTV ? "bootTvTex.tga" : "bootDRCTex.tga";
|
||||
|
||||
std::string texPath = fmt::format("{}/meta/{}", CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()), fileName);
|
||||
sint32 status;
|
||||
auto fscfile = fsc_open(texPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &status);
|
||||
if (fscfile)
|
||||
{
|
||||
std::vector<uint8> tmpData(size);
|
||||
fsc_readFile(fscfile, tmpData.data(), size);
|
||||
const bool backgroundLoaded = LoadTGAFile(tmpData, &TVfile);
|
||||
uint32 size = fsc_getFileSize(fscfile);
|
||||
if (size > 0)
|
||||
{
|
||||
std::vector<uint8> tmpData(size);
|
||||
fsc_readFile(fscfile, tmpData.data(), size);
|
||||
const bool backgroundLoaded = LoadTGAFile(tmpData, &file);
|
||||
|
||||
if (backgroundLoaded)
|
||||
g_shaderCacheLoaderState.textureTVId = g_renderer->GenerateTexture(TVfile.imageData, { TVfile.imageWidth, TVfile.imageHeight });
|
||||
if (backgroundLoaded)
|
||||
out = g_renderer->GenerateTexture(file.imageData, { file.imageWidth, file.imageHeight });
|
||||
}
|
||||
|
||||
fsc_close(fscfile);
|
||||
}
|
||||
};
|
||||
|
||||
fsc_close(fscfile);
|
||||
}
|
||||
//get game background loading image for DRC
|
||||
TGAFILE DRCfile{};
|
||||
g_shaderCacheLoaderState.textureDRCId = nullptr;
|
||||
loadBackgroundTexture(true, g_shaderCacheLoaderState.textureTVId);
|
||||
loadBackgroundTexture(false, g_shaderCacheLoaderState.textureDRCId);
|
||||
|
||||
std::string drcTexPath = fmt::format("{}/meta/bootDRCTex.tga", CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()));
|
||||
sint32 statusDRC;
|
||||
auto fscfile2 = fsc_open(drcTexPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &statusDRC);
|
||||
if (fscfile2)
|
||||
{
|
||||
uint32 size = fsc_getFileSize(fscfile2);
|
||||
if (size > 0)
|
||||
{
|
||||
std::vector<uint8> tmpData(size);
|
||||
fsc_readFile(fscfile2, tmpData.data(), size);
|
||||
const bool backgroundLoaded = LoadTGAFile(tmpData, &DRCfile);
|
||||
|
||||
if (backgroundLoaded)
|
||||
g_shaderCacheLoaderState.textureDRCId = g_renderer->GenerateTexture(DRCfile.imageData, { DRCfile.imageWidth, DRCfile.imageHeight });
|
||||
}
|
||||
fsc_close(fscfile2);
|
||||
}
|
||||
sint32 numLoadedShaders = 0;
|
||||
uint32 loadIndex = 0;
|
||||
|
||||
|
@ -319,78 +344,21 @@ void LatteShaderCache_load()
|
|||
if (g_renderer->GetType() == RendererAPI::Vulkan)
|
||||
LatteShaderCache_loadVulkanPipelineCache(cacheTitleId);
|
||||
|
||||
// clear framebuffers and clean up
|
||||
auto& io = ImGui::GetIO();
|
||||
const auto kPopupFlags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
|
||||
g_renderer->BeginFrame(true);
|
||||
if (g_renderer->ImguiBegin(true))
|
||||
{
|
||||
g_renderer->BeginFrame(true);
|
||||
if (g_renderer->ImguiBegin(true))
|
||||
{
|
||||
ImGui::SetNextWindowPos({ 0,0 }, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(io.DisplaySize, ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0,0 });
|
||||
if (ImGui::Begin("Background texture", nullptr, kPopupFlags))
|
||||
{
|
||||
if (g_shaderCacheLoaderState.textureTVId)
|
||||
{
|
||||
float imageDisplayWidth = io.DisplaySize.x;
|
||||
float imageDisplayHeight = 720 * imageDisplayWidth / 1280;
|
||||
|
||||
float paddingLeftAndRight = 0.0f;
|
||||
float paddingTopAndBottom = (io.DisplaySize.y - imageDisplayHeight)/2.0f;
|
||||
if (imageDisplayHeight > io.DisplaySize.y)
|
||||
{
|
||||
imageDisplayHeight = io.DisplaySize.y;
|
||||
imageDisplayWidth = 1280 * imageDisplayHeight / 720;
|
||||
paddingLeftAndRight = (io.DisplaySize.x - imageDisplayWidth)/2.0f;
|
||||
paddingTopAndBottom = 0.0f;
|
||||
}
|
||||
|
||||
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureTVId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(2);
|
||||
g_renderer->ImguiEnd();
|
||||
}
|
||||
|
||||
g_renderer->BeginFrame(false);
|
||||
if (g_renderer->ImguiBegin(false))
|
||||
{
|
||||
ImGui::SetNextWindowPos({ 0,0 }, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(io.DisplaySize, ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0,0 });
|
||||
|
||||
if (ImGui::Begin("Background texture2", nullptr, kPopupFlags))
|
||||
{
|
||||
if (g_shaderCacheLoaderState.textureDRCId)
|
||||
{
|
||||
float imageDisplayWidth = io.DisplaySize.x;
|
||||
float imageDisplayHeight = 480 * imageDisplayWidth / 854;
|
||||
|
||||
float paddingLeftAndRight = 0.0f;
|
||||
float paddingTopAndBottom = (io.DisplaySize.y - imageDisplayHeight)/2.0f;
|
||||
if (imageDisplayHeight > io.DisplaySize.y)
|
||||
{
|
||||
imageDisplayHeight = io.DisplaySize.y;
|
||||
imageDisplayWidth = 854 * imageDisplayHeight / 480;
|
||||
paddingLeftAndRight = (io.DisplaySize.x - imageDisplayWidth)/2.0f;
|
||||
paddingTopAndBottom = 0.0f;
|
||||
}
|
||||
|
||||
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureDRCId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(2);
|
||||
g_renderer->ImguiEnd();
|
||||
}
|
||||
|
||||
g_renderer->SwapBuffers(true, true);
|
||||
LatteShaderCache_drawBackgroundImage(g_shaderCacheLoaderState.textureTVId, 1280, 720);
|
||||
g_renderer->ImguiEnd();
|
||||
}
|
||||
g_renderer->BeginFrame(false);
|
||||
if (g_renderer->ImguiBegin(false))
|
||||
{
|
||||
LatteShaderCache_drawBackgroundImage(g_shaderCacheLoaderState.textureDRCId, 854, 480);
|
||||
g_renderer->ImguiEnd();
|
||||
}
|
||||
|
||||
g_renderer->SwapBuffers(true, true);
|
||||
|
||||
if (g_shaderCacheLoaderState.textureTVId)
|
||||
g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureTVId);
|
||||
|
@ -427,35 +395,11 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
|
|||
g_renderer->BeginFrame(true);
|
||||
if (g_renderer->ImguiBegin(true))
|
||||
{
|
||||
// render background texture
|
||||
LatteShaderCache_drawBackgroundImage(g_shaderCacheLoaderState.textureTVId, 1280, 720);
|
||||
|
||||
const auto progress_font = ImGui_GetFont(window_size.y / 32.0f); // = 24 by default
|
||||
const auto shader_count_font = ImGui_GetFont(window_size.y / 48.0f); // = 16
|
||||
// render background texture
|
||||
if (g_shaderCacheLoaderState.textureTVId)
|
||||
{
|
||||
ImGui::SetNextWindowPos({ 0, 0 }, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(io.DisplaySize, ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0, 0 });
|
||||
if (ImGui::Begin("Background texture", nullptr, kPopupFlags | ImGuiWindowFlags_NoBringToFrontOnFocus))
|
||||
{
|
||||
float imageDisplayWidth = io.DisplaySize.x;
|
||||
float imageDisplayHeight = 720 * imageDisplayWidth / 1280;
|
||||
|
||||
float paddingLeftAndRight = 0.0f;
|
||||
float paddingTopAndBottom = (io.DisplaySize.y - imageDisplayHeight) / 2.0f;
|
||||
if (imageDisplayHeight > io.DisplaySize.y)
|
||||
{
|
||||
imageDisplayHeight = io.DisplaySize.y;
|
||||
imageDisplayWidth = 1280 * imageDisplayHeight / 720;
|
||||
paddingLeftAndRight = (io.DisplaySize.x - imageDisplayWidth) / 2.0f;
|
||||
paddingTopAndBottom = 0.0f;
|
||||
}
|
||||
|
||||
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureTVId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
ImVec2 position = { window_size.x / 2.0f, window_size.y / 2.0f };
|
||||
ImVec2 pivot = { 0.5f, 0.5f };
|
||||
|
@ -541,31 +485,7 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
|
|||
g_renderer->BeginFrame(false);
|
||||
if (g_renderer->ImguiBegin(false))
|
||||
{
|
||||
ImGui::SetNextWindowPos({ 0,0 }, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(io.DisplaySize, ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0,0 });
|
||||
if (ImGui::Begin("Background texture2", nullptr, kPopupFlags))
|
||||
{
|
||||
if (g_shaderCacheLoaderState.textureDRCId)
|
||||
{
|
||||
float imageDisplayWidth = io.DisplaySize.x;
|
||||
float imageDisplayHeight = 480 * imageDisplayWidth / 854;
|
||||
|
||||
float paddingLeftAndRight = 0.0f;
|
||||
float paddingTopAndBottom = (io.DisplaySize.y - imageDisplayHeight)/2.0f;
|
||||
if (imageDisplayHeight > io.DisplaySize.y)
|
||||
{
|
||||
imageDisplayHeight = io.DisplaySize.y;
|
||||
imageDisplayWidth = 854 * imageDisplayHeight / 480;
|
||||
paddingLeftAndRight = (io.DisplaySize.x - imageDisplayWidth)/2.0f;
|
||||
paddingTopAndBottom = 0.0f;
|
||||
}
|
||||
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureDRCId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(2);
|
||||
LatteShaderCache_drawBackgroundImage(g_shaderCacheLoaderState.textureDRCId, 854, 480);
|
||||
g_renderer->ImguiEnd();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue