Multi swapchain support (#257)
* multi swapchain draft * uwp fix * swapchain resize handling * swapchain buffercount * vsync toggle * tests fix * update * everything removed from graphicsdevice regarding global screen params, engine refactor * added GetSwapChainTexture() function to graphics device; screenshot() now requires swapChain * linux fix: vulkan device needs window handle for instance creation * refactor * removed unused includes * shader refactor and lensflare fix * swapchain clearcolor and other refactors * vulkan: no vector allocation in submit * tests fix * refactors * lens flare canvas size fix * gui refactor for canvas support * refactors * removed global canvas state * msaa fix * fixes * refactor to minimize interface changes * gui changes * checkbox fix * gui fixes * fixes * input system will accept window handle * editor fixes * refactor and removed resolution related system events * small editor update * refactor: renderpath inherits from canvas * fixed tests duh * image refactor * image fix * removed every using namespace std * pushconstant fix * editor: object picking only when necessary * removed include * dx12: copy fence waiting performed on CPU * dx12 copyallocator update * vulkan: copy allocator with timeline semaphores * missing include * dx12 copy allocator update * refactor * editor update * vulkan copy allocator fix * dx12 update * vulkan, dx12 fixes * version bump * vsync event helper * documentation update * updated vulkan, dx12, dxc
This commit is contained in:
+34
-38
@@ -33,12 +33,11 @@
|
||||
#include "Utility/portable-file-dialogs.h"
|
||||
#endif // _WIN32
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace wiHelper
|
||||
{
|
||||
|
||||
string toUpper(const std::string& s)
|
||||
std::string toUpper(const std::string& s)
|
||||
{
|
||||
std::string result;
|
||||
std::locale loc;
|
||||
@@ -55,7 +54,7 @@ namespace wiHelper
|
||||
#ifndef PLATFORM_UWP
|
||||
MessageBoxA(GetActiveWindow(), msg.c_str(), caption.c_str(), 0);
|
||||
#else
|
||||
wstring wmessage, wcaption;
|
||||
std::wstring wmessage, wcaption;
|
||||
StringConvert(msg, wmessage);
|
||||
StringConvert(caption, wcaption);
|
||||
// UWP can only show message box on main thread:
|
||||
@@ -68,22 +67,19 @@ namespace wiHelper
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
void screenshot(const std::string& name)
|
||||
void screenshot(const wiGraphics::SwapChain& swapchain, const std::string& name)
|
||||
{
|
||||
std::string directory;
|
||||
if (name.empty())
|
||||
{
|
||||
directory = "screenshots";
|
||||
directory = std::filesystem::current_path().string() + "/screenshots";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = GetDirectoryFromPath(name);
|
||||
}
|
||||
|
||||
if (!std::filesystem::create_directory(directory.c_str()))
|
||||
{
|
||||
wiBackLog::post(("Directory couoldn't be created: " + directory).c_str());
|
||||
}
|
||||
DirectoryCreate(directory);
|
||||
|
||||
std::string filename = name;
|
||||
if (filename.empty())
|
||||
@@ -91,7 +87,7 @@ namespace wiHelper
|
||||
filename = directory + "/sc_" + getCurrentDateTimeAsString() + ".jpg";
|
||||
}
|
||||
|
||||
bool result = saveTextureToFile(wiRenderer::GetDevice()->GetBackBuffer(), filename);
|
||||
bool result = saveTextureToFile(wiRenderer::GetDevice()->GetBackBuffer(&swapchain), filename);
|
||||
assert(result);
|
||||
|
||||
if (result)
|
||||
@@ -234,7 +230,7 @@ namespace wiHelper
|
||||
}
|
||||
};
|
||||
|
||||
string extension = wiHelper::toUpper(fileExtension);
|
||||
std::string extension = wiHelper::toUpper(fileExtension);
|
||||
if (!extension.compare("JPG") || !extension.compare("JPEG"))
|
||||
{
|
||||
write_result = stbi_write_jpg_to_func(func, &filedata, (int)desc.Width, (int)desc.Height, 4, texturedata.data(), 100);
|
||||
@@ -259,7 +255,7 @@ namespace wiHelper
|
||||
return write_result != 0;
|
||||
}
|
||||
|
||||
bool saveTextureToFile(const wiGraphics::Texture& texture, const string& fileName)
|
||||
bool saveTextureToFile(const wiGraphics::Texture& texture, const std::string& fileName)
|
||||
{
|
||||
using namespace wiGraphics;
|
||||
TextureDesc desc = texture.GetDesc();
|
||||
@@ -275,7 +271,7 @@ namespace wiHelper
|
||||
{
|
||||
using namespace wiGraphics;
|
||||
|
||||
string ext = GetExtensionFromFileName(fileName);
|
||||
std::string ext = GetExtensionFromFileName(fileName);
|
||||
std::vector<uint8_t> filedata;
|
||||
if (saveTextureToMemoryFile(texturedata, desc, ext, filedata))
|
||||
{
|
||||
@@ -285,7 +281,7 @@ namespace wiHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
string getCurrentDateTimeAsString()
|
||||
std::string getCurrentDateTimeAsString()
|
||||
{
|
||||
time_t t = std::time(nullptr);
|
||||
struct tm time_info;
|
||||
@@ -294,12 +290,12 @@ namespace wiHelper
|
||||
#else
|
||||
localtime(&t);
|
||||
#endif
|
||||
stringstream ss("");
|
||||
std::stringstream ss("");
|
||||
ss << std::put_time(&time_info, "%d-%m-%Y %H-%M-%S");
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void SplitPath(const std::string& fullPath, string& dir, string& fileName)
|
||||
void SplitPath(const std::string& fullPath, std::string& dir, std::string& fileName)
|
||||
{
|
||||
size_t found;
|
||||
found = fullPath.find_last_of("/\\");
|
||||
@@ -307,31 +303,31 @@ namespace wiHelper
|
||||
fileName = fullPath.substr(found + 1);
|
||||
}
|
||||
|
||||
string GetFileNameFromPath(const std::string& fullPath)
|
||||
std::string GetFileNameFromPath(const std::string& fullPath)
|
||||
{
|
||||
if (fullPath.empty())
|
||||
{
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
string ret, empty;
|
||||
std::string ret, empty;
|
||||
SplitPath(fullPath, empty, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
string GetDirectoryFromPath(const std::string& fullPath)
|
||||
std::string GetDirectoryFromPath(const std::string& fullPath)
|
||||
{
|
||||
if (fullPath.empty())
|
||||
{
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
string ret, empty;
|
||||
std::string ret, empty;
|
||||
SplitPath(fullPath, ret, empty);
|
||||
return ret;
|
||||
}
|
||||
|
||||
string GetExtensionFromFileName(const string& filename)
|
||||
std::string GetExtensionFromFileName(const std::string& filename)
|
||||
{
|
||||
size_t idx = filename.rfind('.');
|
||||
|
||||
@@ -400,9 +396,9 @@ namespace wiHelper
|
||||
#ifdef SDL_FILESYSTEM_UNIX
|
||||
std::string filepath = fileName;
|
||||
std::replace(filepath.begin(), filepath.end(), '\\', '/');
|
||||
ifstream file(filepath, ios::binary | ios::ate);
|
||||
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
||||
#else
|
||||
ifstream file(fileName, ios::binary | ios::ate);
|
||||
std::ifstream file(fileName, std::ios::binary | std::ios::ate);
|
||||
#endif // SDL_FILESYSTEM_UNIX
|
||||
if (file.is_open())
|
||||
{
|
||||
@@ -417,7 +413,7 @@ namespace wiHelper
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
wstring wstr;
|
||||
std::wstring wstr;
|
||||
std::filesystem::path filepath = fileName;
|
||||
filepath = std::filesystem::absolute(filepath);
|
||||
StringConvert(filepath.string(), wstr);
|
||||
@@ -479,10 +475,10 @@ namespace wiHelper
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_UWP
|
||||
ofstream file(fileName, ios::binary | ios::trunc);
|
||||
std::ofstream file(fileName, std::ios::binary | std::ios::trunc);
|
||||
if (file.is_open())
|
||||
{
|
||||
file.write((const char*)data, (streamsize)size);
|
||||
file.write((const char*)data, (std::streamsize)size);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
@@ -491,7 +487,7 @@ namespace wiHelper
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
wstring wstr;
|
||||
std::wstring wstr;
|
||||
std::filesystem::path filepath = fileName;
|
||||
filepath = std::filesystem::absolute(filepath);
|
||||
StringConvert(filepath.string(), wstr);
|
||||
@@ -643,7 +639,7 @@ namespace wiHelper
|
||||
|
||||
for (auto& x : params.extensions)
|
||||
{
|
||||
wstring wstr;
|
||||
std::wstring wstr;
|
||||
StringConvert(x, wstr);
|
||||
wstr = L"." + wstr;
|
||||
picker.FileTypeFilter().Append(wstr);
|
||||
@@ -656,8 +652,8 @@ namespace wiHelper
|
||||
auto futureaccess = StorageApplicationPermissions::FutureAccessList();
|
||||
futureaccess.Clear();
|
||||
futureaccess.Add(file);
|
||||
wstring wstr = file.Path().data();
|
||||
string str;
|
||||
std::wstring wstr = file.Path().data();
|
||||
std::string str;
|
||||
StringConvert(wstr, str);
|
||||
|
||||
onSuccess(str);
|
||||
@@ -669,12 +665,12 @@ namespace wiHelper
|
||||
FileSavePicker picker;
|
||||
picker.SuggestedStartLocation(PickerLocationId::Objects3D);
|
||||
|
||||
wstring wdesc;
|
||||
std::wstring wdesc;
|
||||
StringConvert(params.description, wdesc);
|
||||
winrt::Windows::Foundation::Collections::IVector<winrt::hstring> extensions{ winrt::single_threaded_vector<winrt::hstring>() };
|
||||
for (auto& x : params.extensions)
|
||||
{
|
||||
wstring wstr;
|
||||
std::wstring wstr;
|
||||
StringConvert(x, wstr);
|
||||
wstr = L"." + wstr;
|
||||
extensions.Append(wstr);
|
||||
@@ -687,8 +683,8 @@ namespace wiHelper
|
||||
auto futureaccess = StorageApplicationPermissions::FutureAccessList();
|
||||
futureaccess.Clear();
|
||||
futureaccess.Add(file);
|
||||
wstring wstr = file.Path().data();
|
||||
string str;
|
||||
std::wstring wstr = file.Path().data();
|
||||
std::string str;
|
||||
StringConvert(wstr, str);
|
||||
onSuccess(str);
|
||||
}
|
||||
@@ -752,7 +748,7 @@ namespace wiHelper
|
||||
{
|
||||
ss << (uint32_t)data[i] << ",";
|
||||
}
|
||||
ss << "};" << endl;
|
||||
ss << "};" << std::endl;
|
||||
return FileWrite(dst_filename, (uint8_t*)ss.str().c_str(), ss.str().length());
|
||||
}
|
||||
|
||||
@@ -826,12 +822,12 @@ namespace wiHelper
|
||||
void Spin(float milliseconds)
|
||||
{
|
||||
milliseconds /= 1000.0f;
|
||||
chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
|
||||
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||||
double ms = 0;
|
||||
while (ms < milliseconds)
|
||||
{
|
||||
chrono::high_resolution_clock::time_point t2 = chrono::high_resolution_clock::now();
|
||||
chrono::duration<double> time_span = chrono::duration_cast<chrono::duration<double>>(t2 - t1);
|
||||
std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(t2 - t1);
|
||||
ms = time_span.count();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user