diff --git a/glslang b/glslang index d0e9a99..2edde66 160000 --- a/glslang +++ b/glslang @@ -1 +1 @@ -Subproject commit d0e9a99ed20e43e1547473c4fb2f8ce0f665af22 +Subproject commit 2edde6665d9a56ead5ea0e55b4e64d9a803e6164 diff --git a/include/boo/BooObject.hpp b/include/boo/BooObject.hpp index fd818bf..5385eef 100644 --- a/include/boo/BooObject.hpp +++ b/include/boo/BooObject.hpp @@ -10,25 +10,16 @@ namespace boo class IObj { std::atomic_int m_refCount = {0}; -protected: - std::recursive_mutex* m_mutex = nullptr; public: virtual ~IObj() = default; + virtual std::unique_lock destructorLock() { return {}; } void increment() { m_refCount++; } void decrement() { if (m_refCount.fetch_sub(1) == 1) { - if (std::recursive_mutex* mutex = m_mutex) - { - mutex->lock(); - delete this; - mutex->unlock(); - } - else - { - delete this; - } + auto lk = destructorLock(); + delete this; } } }; diff --git a/lib/audiodev/WASAPI.cpp b/lib/audiodev/WASAPI.cpp index 2623883..4c240c0 100644 --- a/lib/audiodev/WASAPI.cpp +++ b/lib/audiodev/WASAPI.cpp @@ -427,10 +427,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine continue; #ifdef UNICODE - int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, nullptr, 0, nullptr, nullptr); - std::string strTo(sizeNeeded, 0); - WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, &strTo[0], sizeNeeded, nullptr, nullptr); - ret.push_back(std::make_pair(std::string(name), std::move(strTo))); + ret.push_back(std::make_pair(std::string(name), WCSTMBS(caps.szPname))); #else ret.push_back(std::make_pair(std::string(name), std::string(caps.szPname))); #endif @@ -446,10 +443,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine continue; #ifdef UNICODE - int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, nullptr, 0, nullptr, nullptr); - std::string strTo(sizeNeeded, 0); - WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, &strTo[0], sizeNeeded, nullptr, nullptr); - ret.push_back(std::make_pair(std::string(name), std::move(strTo))); + ret.push_back(std::make_pair(std::string(name), WCSTMBS(caps.szPname))); #else ret.push_back(std::make_pair(std::string(name), std::string(caps.szPname))); #endif @@ -493,10 +487,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine return {}; #ifdef UNICODE - int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, nullptr, 0, nullptr, nullptr); - std::string strTo(sizeNeeded, 0); - WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, &strTo[0], sizeNeeded, nullptr, nullptr); - return strTo; + return WCSTMBS(caps.szPname); #else return caps.szPname; #endif @@ -540,10 +531,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine return {}; #ifdef UNICODE - int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, nullptr, 0, nullptr, nullptr); - std::string strTo(sizeNeeded, 0); - WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, &strTo[0], sizeNeeded, nullptr, nullptr); - return strTo; + return WCSTMBS(caps.szPname); #else return caps.szPname; #endif @@ -598,10 +586,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine return {}; #ifdef UNICODE - int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, nullptr, 0, nullptr, nullptr); - std::string strTo(sizeNeeded, 0); - WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, &strTo[0], sizeNeeded, nullptr, nullptr); - return strTo; + return WCSTMBS(caps.szPname); #else return caps.szPname; #endif diff --git a/lib/graphicsdev/Common.hpp b/lib/graphicsdev/Common.hpp index 8664f4c..946fc89 100644 --- a/lib/graphicsdev/Common.hpp +++ b/lib/graphicsdev/Common.hpp @@ -64,11 +64,12 @@ struct BaseGraphicsData : IObj template GraphicsDataNode*& getHead(); template size_t countForward() { auto* head = getHead(); return head ? head->countForward() : 0; } + std::unique_lock destructorLock() override + { return std::unique_lock{m_head.m_dataMutex}; } explicit BaseGraphicsData(GraphicsDataFactoryHead& head) : m_head(head) { - IObj::m_mutex = &m_head.m_dataMutex; std::lock_guard lk(m_head.m_dataMutex); m_next = head.m_dataHead; if (m_next) @@ -127,11 +128,12 @@ struct BaseGraphicsPool : IObj template GraphicsDataNode*& getHead(); template size_t countForward() { auto* head = getHead(); return head ? head->countForward() : 0; } + std::unique_lock destructorLock() override + { return std::unique_lock{m_head.m_dataMutex}; } explicit BaseGraphicsPool(GraphicsDataFactoryHead& head) : m_head(head) { - IObj::m_mutex = &m_head.m_dataMutex; std::lock_guard lk(m_head.m_dataMutex); m_next = head.m_poolHead; if (m_next) @@ -172,11 +174,12 @@ struct GraphicsDataNode : NodeCls ObjToken m_data; GraphicsDataNode* m_next; GraphicsDataNode* m_prev = nullptr; + std::unique_lock destructorLock() override + { return std::unique_lock{m_data->m_head.m_dataMutex}; } explicit GraphicsDataNode(const ObjToken& data) : m_data(data) { - IObj::m_mutex = &m_data->m_head.m_dataMutex; std::lock_guard lk(m_data->m_head.m_dataMutex); m_next = data->template getHead(); if (m_next) diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index 18b16e0..945be21 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -9,6 +9,10 @@ #include #include "xxhash.h" +#if _WIN32 +#include "../win/WinCommon.hpp" +#endif + #include "logvisor/logvisor.hpp" #undef min @@ -1124,7 +1128,11 @@ struct GLCommandQueue : IGraphicsCommandQueue static void RenderingWorker(GLCommandQueue* self) { +#if _WIN32 + std::string thrName = WCSTMBS(APP->getFriendlyName().c_str()) + " GL Rendering Thread"; +#else std::string thrName = APP->getFriendlyName() + " GL Rendering Thread"; +#endif logvisor::RegisterThreadName(thrName.c_str()); { std::unique_lock lk(self->m_initmt); diff --git a/lib/graphicsdev/Vulkan.cpp b/lib/graphicsdev/Vulkan.cpp index 8ea6670..1d3151d 100644 --- a/lib/graphicsdev/Vulkan.cpp +++ b/lib/graphicsdev/Vulkan.cpp @@ -328,10 +328,11 @@ void VulkanContext::initVulkan(const char* appName) m_deviceExtensionNames.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); #ifndef NDEBUG - m_layerNames.push_back("VK_LAYER_LUNARG_core_validation"); + m_layerNames.push_back("VK_LAYER_LUNARG_standard_validation"); + //m_layerNames.push_back("VK_LAYER_LUNARG_core_validation"); //m_layerNames.push_back("VK_LAYER_LUNARG_object_tracker"); - m_layerNames.push_back("VK_LAYER_LUNARG_parameter_validation"); - m_layerNames.push_back("VK_LAYER_GOOGLE_threading"); + //m_layerNames.push_back("VK_LAYER_LUNARG_parameter_validation"); + //m_layerNames.push_back("VK_LAYER_GOOGLE_threading"); #endif demo_check_layers(m_instanceLayerProperties, m_layerNames); @@ -453,6 +454,17 @@ void VulkanContext::initDevice() deviceInfo.pEnabledFeatures = nullptr; ThrowIfFailed(vk::CreateDevice(m_gpus[0], &deviceInfo, nullptr, &m_dev)); + + std::string gpuName = m_gpuProps.deviceName; + Log.report(logvisor::Info, "Initialized %s", gpuName.c_str()); + Log.report(logvisor::Info, "Vulkan version %d.%d.%d", + m_gpuProps.apiVersion >> 22, + (m_gpuProps.apiVersion >> 12) & 0b1111111111, + m_gpuProps.apiVersion & 0b111111111111); + Log.report(logvisor::Info, "Driver version %d.%d.%d", + m_gpuProps.driverVersion >> 22, + (m_gpuProps.driverVersion >> 12) & 0b1111111111, + m_gpuProps.driverVersion & 0b111111111111); } void VulkanContext::initSwapChain(VulkanContext::Window& windowCtx, VkSurfaceKHR surface, VkFormat format, VkColorSpaceKHR colorspace) @@ -821,10 +833,10 @@ public: VkMemoryRequirements memReqs; vk::GetBufferMemoryRequirements(ctx->m_dev, m_bufferInfo.buffer, &memReqs); memTypeBits &= memReqs.memoryTypeBits; - m_memOffset = offset; - offset += m_sz; offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); + m_memOffset = offset; + offset += memReqs.size; return offset; } @@ -898,10 +910,10 @@ public: VkMemoryRequirements memReqs; vk::GetBufferMemoryRequirements(ctx->m_dev, m_bufferInfo[i].buffer, &memReqs); memTypeBits &= memReqs.memoryTypeBits; - m_memOffset[i] = offset; - offset += memReqs.size; offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); + m_memOffset[i] = offset; + offset += memReqs.size; } return offset; @@ -1035,9 +1047,9 @@ public: vk::GetImageMemoryRequirements(ctx->m_dev, m_gpuTex, &memReqs); memTypeBits &= memReqs.memoryTypeBits; + offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); m_gpuOffset = offset; offset += memReqs.size; - offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); return offset; } @@ -1232,9 +1244,9 @@ public: vk::GetImageMemoryRequirements(ctx->m_dev, m_gpuTex, &memReqs); memTypeBits &= memReqs.memoryTypeBits; + offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); m_gpuOffset = offset; offset += memReqs.size; - offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); return offset; } @@ -1367,15 +1379,14 @@ class VulkanTextureD : public GraphicsDataNode uint32_t memTypeBits = ~0; for (int i=0 ; i<2 ; ++i) { - m_cpuOffsets[i] = memAlloc.allocationSize; - /* create cpu buffer */ ThrowIfFailed(vk::CreateBuffer(ctx->m_dev, &bufCreateInfo, nullptr, &m_cpuBuf[i])); VkMemoryRequirements memReqs; vk::GetBufferMemoryRequirements(ctx->m_dev, m_cpuBuf[i], &memReqs); - memAlloc.allocationSize += memReqs.size; memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); + m_cpuOffsets[i] = memAlloc.allocationSize; + memAlloc.allocationSize += memReqs.size; memTypeBits &= memReqs.memoryTypeBits; } @@ -1439,9 +1450,9 @@ public: vk::GetImageMemoryRequirements(ctx->m_dev, m_gpuTex[i], &memReqs); memTypeBits &= memReqs.memoryTypeBits; + offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); m_gpuOffset[i] = offset; offset += memReqs.size; - offset = (offset + memReqs.alignment - 1) & ~(memReqs.alignment - 1); } return offset; @@ -1523,7 +1534,7 @@ class VulkanTextureR : public GraphicsDataNode ThrowIfFailed(vk::CreateImage(ctx->m_dev, &texCreateInfo, nullptr, &m_colorTex)); /* depth target */ - texCreateInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; + texCreateInfo.format = VK_FORMAT_D32_SFLOAT; texCreateInfo.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; ThrowIfFailed(vk::CreateImage(ctx->m_dev, &texCreateInfo, nullptr, &m_depthTex)); @@ -1543,13 +1554,12 @@ class VulkanTextureR : public GraphicsDataNode vk::GetImageMemoryRequirements(ctx->m_dev, m_colorTex, &memReqs); gpuOffsets[0] = memAlloc.allocationSize; memAlloc.allocationSize += memReqs.size; - memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); memTypeBits &= memReqs.memoryTypeBits; vk::GetImageMemoryRequirements(ctx->m_dev, m_depthTex, &memReqs); + memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); gpuOffsets[1] = memAlloc.allocationSize; memAlloc.allocationSize += memReqs.size; - memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); memTypeBits &= memReqs.memoryTypeBits; texCreateInfo.samples = VkSampleCountFlagBits(1); @@ -1562,9 +1572,9 @@ class VulkanTextureR : public GraphicsDataNode ThrowIfFailed(vk::CreateImage(ctx->m_dev, &texCreateInfo, nullptr, &m_colorBindTex[i])); vk::GetImageMemoryRequirements(ctx->m_dev, m_colorBindTex[i], &memReqs); + memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); colorOffsets[i] = memAlloc.allocationSize; memAlloc.allocationSize += memReqs.size; - memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); memTypeBits &= memReqs.memoryTypeBits; m_colorBindDescInfo[i].sampler = ctx->m_linearSamplers[int(m_clampMode)]; @@ -1574,14 +1584,14 @@ class VulkanTextureR : public GraphicsDataNode for (size_t i=0 ; im_dev, &texCreateInfo, nullptr, &m_depthBindTex[i])); vk::GetImageMemoryRequirements(ctx->m_dev, m_depthBindTex[i], &memReqs); + memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); depthOffsets[i] = memAlloc.allocationSize; memAlloc.allocationSize += memReqs.size; - memAlloc.allocationSize = (memAlloc.allocationSize + memReqs.alignment - 1) & ~(memReqs.alignment - 1); memTypeBits &= memReqs.memoryTypeBits; m_depthBindDescInfo[i].sampler = ctx->m_linearSamplers[int(m_clampMode)]; @@ -1593,10 +1603,10 @@ class VulkanTextureR : public GraphicsDataNode /* allocate memory */ ThrowIfFailed(vk::AllocateMemory(ctx->m_dev, &memAlloc, nullptr, &m_gpuMem)); - uint8_t* mappedData; - ThrowIfFailed(vk::MapMemory(ctx->m_dev, m_gpuMem, 0, memAlloc.allocationSize, 0, reinterpret_cast(&mappedData))); - memset(mappedData, 0, memAlloc.allocationSize); - vk::UnmapMemory(ctx->m_dev, m_gpuMem); + //uint8_t* mappedData; + //ThrowIfFailed(vk::MapMemory(ctx->m_dev, m_gpuMem, 0, memAlloc.allocationSize, 0, reinterpret_cast(&mappedData))); + //memset(mappedData, 0, memAlloc.allocationSize); + //vk::UnmapMemory(ctx->m_dev, m_gpuMem); /* bind memory */ ThrowIfFailed(vk::BindImageMemory(ctx->m_dev, m_colorTex, m_gpuMem, gpuOffsets[0])); @@ -1621,8 +1631,8 @@ class VulkanTextureR : public GraphicsDataNode ThrowIfFailed(vk::CreateImageView(ctx->m_dev, &viewCreateInfo, nullptr, &m_colorView)); viewCreateInfo.image = m_depthTex; - viewCreateInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; - viewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + viewCreateInfo.format = VK_FORMAT_D32_SFLOAT; + viewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; ThrowIfFailed(vk::CreateImageView(ctx->m_dev, &viewCreateInfo, nullptr, &m_depthView)); for (size_t i=0 ; i { ThrowIfFailed(vk::BindImageMemory(ctx->m_dev, m_depthBindTex[i], m_gpuMem, depthOffsets[i])); viewCreateInfo.image = m_depthBindTex[i]; - viewCreateInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; + viewCreateInfo.format = VK_FORMAT_D32_SFLOAT; viewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; ThrowIfFailed(vk::CreateImageView(ctx->m_dev, &viewCreateInfo, nullptr, &m_depthBindView[i])); m_depthBindDescInfo[i].imageView = m_depthBindView[i]; @@ -2540,13 +2550,13 @@ struct VulkanCommandQueue : IGraphicsCommandQueue VulkanTextureR* btarget = m_boundTarget.cast(); SetImageLayout(cmdBuf, btarget->m_colorTex, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 1, 1); - SetImageLayout(cmdBuf, btarget->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, + SetImageLayout(cmdBuf, btarget->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 1, 1); } SetImageLayout(cmdBuf, ctarget->m_colorTex, VK_IMAGE_ASPECT_COLOR_BIT, ctarget->m_layout, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 1, 1); - SetImageLayout(cmdBuf, ctarget->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, + SetImageLayout(cmdBuf, ctarget->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT, ctarget->m_layout, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 1, 1); ctarget->m_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; @@ -2624,7 +2634,7 @@ struct VulkanCommandQueue : IGraphicsCommandQueue clr[0].clearValue.color.float32[2] = m_clearColor[2]; clr[0].clearValue.color.float32[3] = m_clearColor[3]; clr[0].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - clr[1].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + clr[1].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; clr[1].clearValue.depthStencil.depth = 1.f; vk::CmdClearAttachments(m_cmdBufs[m_fillBuf], 2, clr, 1, &rect); } @@ -2639,7 +2649,7 @@ struct VulkanCommandQueue : IGraphicsCommandQueue } else if (depth) { - clr[0].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + clr[0].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; clr[0].clearValue.depthStencil.depth = 1.f; vk::CmdClearAttachments(m_cmdBufs[m_fillBuf], 1, clr, 1, &rect); } @@ -2797,14 +2807,14 @@ struct VulkanCommandQueue : IGraphicsCommandQueue if (depth && ctexture->m_depthBindCount) { if (ctexture == m_boundTarget.get()) - SetImageLayout(cmdBuf, ctexture->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, + SetImageLayout(cmdBuf, ctexture->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 1, 1); - SetImageLayout(cmdBuf, ctexture->m_depthBindTex[bindIdx], VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, + SetImageLayout(cmdBuf, ctexture->m_depthBindTex[bindIdx], VK_IMAGE_ASPECT_DEPTH_BIT, ctexture->m_depthBindLayout[bindIdx], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, 1); - copyInfo.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; - copyInfo.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + copyInfo.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + copyInfo.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; vk::CmdCopyImage(cmdBuf, ctexture->m_depthTex, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, @@ -2812,10 +2822,10 @@ struct VulkanCommandQueue : IGraphicsCommandQueue 1, ©Info); if (ctexture == m_boundTarget.get()) - SetImageLayout(cmdBuf, ctexture->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, + SetImageLayout(cmdBuf, ctexture->m_depthTex, VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 1, 1); - SetImageLayout(cmdBuf, ctexture->m_depthBindTex[bindIdx], VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, + SetImageLayout(cmdBuf, ctexture->m_depthBindTex[bindIdx], VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 1, 1); ctexture->m_depthBindLayout[bindIdx] = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } @@ -3075,7 +3085,7 @@ VulkanDataFactoryImpl::VulkanDataFactoryImpl(IGraphicsContext* parent, VkAttachmentReference colorAttachmentRef = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; /* depth attachment */ - attachments[1].format = VK_FORMAT_D24_UNORM_S8_UINT; + attachments[1].format = VK_FORMAT_D32_SFLOAT; attachments[1].samples = VkSampleCountFlagBits(drawSamples); attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE; diff --git a/lib/win/ApplicationUWP.cpp b/lib/win/ApplicationUWP.cpp index a0ebf34..1ecb4cf 100644 --- a/lib/win/ApplicationUWP.cpp +++ b/lib/win/ApplicationUWP.cpp @@ -256,7 +256,8 @@ public: int clientReturn = 0; std::thread clientThread([&]() { - logvisor::RegisterThreadName("Boo Client Thread"); + std::string thrName = WCSTMBS(getFriendlyName().c_str()) + " Client Thread"; + logvisor::RegisterThreadName(thrName.c_str()); clientReturn = m_callback.appMain(this); }); diff --git a/lib/win/ApplicationWin32.cpp b/lib/win/ApplicationWin32.cpp index c1bd188..4d9b1eb 100644 --- a/lib/win/ApplicationWin32.cpp +++ b/lib/win/ApplicationWin32.cpp @@ -375,7 +375,8 @@ public: int clientReturn = 0; std::thread clientThread([&]() { - logvisor::RegisterThreadName("Boo Client Thread"); + std::string thrName = WCSTMBS(getFriendlyName().c_str()) + " Client Thread"; + logvisor::RegisterThreadName(thrName.c_str()); CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE); clientReturn = m_callback.appMain(this); PostThreadMessage(g_mainThreadId, WM_USER+1, 0, 0); @@ -485,7 +486,8 @@ int ApplicationRun(IApplication::EPlatformType platform, const std::vector& args, bool singleInstance) { - logvisor::RegisterThreadName("Boo Main Thread"); + std::string thrName = WCSTMBS(friendlyName.c_str()) + " Main Thread"; + logvisor::RegisterThreadName(thrName.c_str()); if (APP) return 1; if (platform != IApplication::EPlatformType::Win32 && diff --git a/lib/win/WinCommon.hpp b/lib/win/WinCommon.hpp index ca77142..7786748 100644 --- a/lib/win/WinCommon.hpp +++ b/lib/win/WinCommon.hpp @@ -93,4 +93,12 @@ struct Boo3DAppContext } }; +static inline std::string WCSTMBS(const wchar_t* wstr) +{ + int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr) - 1; + std::string strTo(sizeNeeded, 0); + WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &strTo[0], sizeNeeded, nullptr, nullptr); + return strTo; +} + #endif // BOO_WINCOMMON_HPP diff --git a/lib/win/WindowWin32.cpp b/lib/win/WindowWin32.cpp index 3835703..2f198eb 100644 --- a/lib/win/WindowWin32.cpp +++ b/lib/win/WindowWin32.cpp @@ -503,10 +503,7 @@ public: if (m_ctx->m_instance == VK_NULL_HANDLE) { const SystemString& appName = APP->getUniqueName(); - int len = WideCharToMultiByte(CP_UTF8, 0, appName.c_str(), appName.size(), nullptr, 0, nullptr, nullptr); - std::string utf8(len, '\0'); - WideCharToMultiByte(CP_UTF8, 0, appName.c_str(), appName.size(), &utf8[0], len, nullptr, nullptr); - m_ctx->initVulkan(utf8.c_str()); + m_ctx->initVulkan(WCSTMBS(appName.c_str()).c_str()); } vk::init_dispatch_table_middle(m_ctx->m_instance, false);