From 7ae40fb95d52fe9ae9a73fc35149a19d82145164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sun, 25 Apr 2021 19:09:26 -0700 Subject: [PATCH] texturev: Added renderer .ini setting. --- tools/texturev/texturev.cpp | 55 +++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/tools/texturev/texturev.cpp b/tools/texturev/texturev.cpp index 798debfd6..5dbf33943 100644 --- a/tools/texturev/texturev.cpp +++ b/tools/texturev/texturev.cpp @@ -247,10 +247,26 @@ extern "C" uint32_t __stdcall GetModuleFileNameA(void* _module, char* _outFilePa #endif // BX_PLATFORM_WINDOWS +struct RendererTypeRemap +{ + bx::StringView name; + bgfx::RendererType::Enum type; +}; + +static RendererTypeRemap s_rendererTypeRemap[] = +{ + { "gl", bgfx::RendererType::OpenGL }, + { "d3d11", bgfx::RendererType::Direct3D11 }, + { "d3d11", bgfx::RendererType::Direct3D12 }, + { "vk", bgfx::RendererType::Vulkan }, + { "mtl", bgfx::RendererType::Metal }, +}; + struct View { View() - : m_cubeMapGeo(Geometry::Quad) + : m_rendererType(bgfx::RendererType::Count) + , m_cubeMapGeo(Geometry::Quad) , m_outputFormat(Output::sRGB) , m_fileIndex(0) , m_scaleFn(0) @@ -801,6 +817,23 @@ struct View { m_height = 720; } + + bx::StringView rendererType = settings.get("view/renderer"); + if (!rendererType.isEmpty() ) + { + m_rendererType = bgfx::RendererType::Count; + + for (uint32_t ii = 0; ii < BX_COUNTOF(s_rendererTypeRemap); ++ii) + { + const RendererTypeRemap& remap = s_rendererTypeRemap[ii]; + + if (0 == bx::strCmpI(rendererType, remap.name) ) + { + m_rendererType = remap.type; + break; + } + } + } } } @@ -823,6 +856,20 @@ struct View bx::toString(tmp, sizeof(tmp), m_height); settings.set("view/height", tmp); + if (m_rendererType != bgfx::RendererType::Count) + { + for (uint32_t ii = 0; ii < BX_COUNTOF(s_rendererTypeRemap); ++ii) + { + const RendererTypeRemap& remap = s_rendererTypeRemap[ii]; + + if (m_rendererType == remap.type) + { + settings.set("view/renderer", remap.name); + break; + } + } + } + bx::FileWriter writer; if (bx::open(&writer, filePath) ) { @@ -837,6 +884,7 @@ struct View typedef stl::vector FileList; FileList m_fileList; + bgfx::RendererType::Enum m_rendererType; bgfx::TextureInfo m_textureInfo; Geometry::Enum m_cubeMapGeo; Output::Enum m_outputFormat; @@ -1291,9 +1339,10 @@ int _main_(int _argc, char** _argv) entry::setWindowSize(entry::WindowHandle{0}, view.m_width, view.m_height); bgfx::Init init; - init.resolution.width = view.m_width; + init.type = view.m_rendererType; + init.resolution.width = view.m_width; init.resolution.height = view.m_height; - init.resolution.reset = BGFX_RESET_VSYNC; + init.resolution.reset = BGFX_RESET_VSYNC; bgfx::init(init);