Restore VkShaderModule caching

This commit is contained in:
Jack Andersen 2017-11-07 16:24:07 -10:00
parent 2cd7de7a28
commit 3cd375e67b
5 changed files with 28 additions and 28 deletions

View File

@ -17,7 +17,7 @@ add_subdirectory(xxhash)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
find_package(IPP)
if (IPP_FOUND)
add_definitions(-DINTEL_IPP=1)
list(APPEND _BOO_SYS_DEFINES -DINTEL_IPP=1)
include_directories(${IPP_INCLUDE_DIRS})
list(APPEND _BOO_SYS_LIBS ${IPP_LIBRARIES})
endif ()

View File

@ -1,5 +1,6 @@
#include "boo/graphicsdev/GL.hpp"
#include "boo/graphicsdev/glew.h"
#include "boo/IApplication.hpp"
#include "Common.hpp"
#include <thread>
#include <condition_variable>
@ -1123,7 +1124,8 @@ struct GLCommandQueue : IGraphicsCommandQueue
static void RenderingWorker(GLCommandQueue* self)
{
logvisor::RegisterThreadName("Boo GL Rendering Thread");
std::string thrName = APP->getFriendlyName() + " GL Rendering Thread";
logvisor::RegisterThreadName(thrName.c_str());
{
std::unique_lock<std::mutex> lk(self->m_initmt);
self->m_parent->makeCurrent();

View File

@ -26,10 +26,11 @@ class VulkanDataFactoryImpl;
struct VulkanShareableShader : IShareableShader<VulkanDataFactoryImpl, VulkanShareableShader>
{
VkDevice m_dev;
std::vector<unsigned int> m_shader;
VkShaderModule m_shader;
VulkanShareableShader(VulkanDataFactoryImpl& fac, uint64_t srcKey, uint64_t binKey,
VkDevice dev, const std::vector<unsigned int>& s)
VkDevice dev, VkShaderModule s)
: IShareableShader(fac, srcKey, binKey), m_dev(dev), m_shader(s) {}
~VulkanShareableShader() { vk::DestroyShaderModule(m_dev, m_shader, nullptr); }
};
class VulkanDataFactoryImpl : public VulkanDataFactory, public GraphicsDataFactoryHead
@ -328,9 +329,9 @@ void VulkanContext::initVulkan(const char* appName)
#ifndef NDEBUG
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_object_tracker");
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);
@ -1910,23 +1911,11 @@ public:
VkPipelineShaderStageCreateInfo stages[2] = {};
VkShaderModuleCreateInfo smCreateInfo = {};
smCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
VkShaderModule vertModule, fragModule;
const auto& vertShader = m_vert.get().m_shader;
smCreateInfo.codeSize = vertShader.size() * sizeof(unsigned int);
smCreateInfo.pCode = vertShader.data();
ThrowIfFailed(vk::CreateShaderModule(m_ctx->m_dev, &smCreateInfo, nullptr, &vertModule));
const auto& fragShader = m_frag.get().m_shader;
smCreateInfo.codeSize = fragShader.size() * sizeof(unsigned int);
smCreateInfo.pCode = fragShader.data();
ThrowIfFailed(vk::CreateShaderModule(m_ctx->m_dev, &smCreateInfo, nullptr, &fragModule));
stages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stages[0].pNext = nullptr;
stages[0].flags = 0;
stages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
stages[0].module = vertModule;
stages[0].module = m_vert.get().m_shader;
stages[0].pName = "main";
stages[0].pSpecializationInfo = nullptr;
@ -1934,7 +1923,7 @@ public:
stages[1].pNext = nullptr;
stages[1].flags = 0;
stages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
stages[1].module = fragModule;
stages[1].module = m_frag.get().m_shader;
stages[1].pName = "main";
stages[1].pSpecializationInfo = nullptr;
@ -2051,9 +2040,6 @@ public:
ThrowIfFailed(vk::CreateGraphicsPipelines(m_ctx->m_dev, m_pipelineCache, 1, &pipelineCreateInfo,
nullptr, &m_pipeline));
vk::DestroyShaderModule(m_ctx->m_dev, vertModule, nullptr);
vk::DestroyShaderModule(m_ctx->m_dev, fragModule, nullptr);
m_vert.reset();
m_frag.reset();
}
@ -3249,10 +3235,15 @@ boo::ObjToken<IShaderPipeline> VulkanDataFactory::Context::newShaderPipeline
binHashes[0] = CompileVert(vertBlob, vertSource, srcHashes[0], factory);
}
VkShaderModule vertModule;
smCreateInfo.codeSize = useVertBlob->size() * sizeof(unsigned int);
smCreateInfo.pCode = useVertBlob->data();
ThrowIfFailed(vk::CreateShaderModule(factory.m_ctx->m_dev, &smCreateInfo, nullptr, &vertModule));
auto it =
factory.m_sharedShaders.emplace(std::make_pair(binHashes[0],
std::make_unique<VulkanShareableShader>(factory, srcHashes[0], binHashes[0],
factory.m_ctx->m_dev, *useVertBlob))).first;
factory.m_ctx->m_dev, vertModule))).first;
vertShader = it->second->lock();
}
auto fragFind = binHashes[1] ? factory.m_sharedShaders.find(binHashes[1]) :
@ -3275,10 +3266,15 @@ boo::ObjToken<IShaderPipeline> VulkanDataFactory::Context::newShaderPipeline
binHashes[1] = CompileFrag(fragBlob, fragSource, srcHashes[1], factory);
}
VkShaderModule fragModule;
smCreateInfo.codeSize = useFragBlob->size() * sizeof(unsigned int);
smCreateInfo.pCode = useFragBlob->data();
ThrowIfFailed(vk::CreateShaderModule(factory.m_ctx->m_dev, &smCreateInfo, nullptr, &fragModule));
auto it =
factory.m_sharedShaders.emplace(std::make_pair(binHashes[1],
std::make_unique<VulkanShareableShader>(factory, srcHashes[1], binHashes[1],
factory.m_ctx->m_dev, *useFragBlob))).first;
factory.m_ctx->m_dev, fragModule))).first;
fragShader = it->second->lock();
}

View File

@ -56,7 +56,8 @@ int ApplicationRun(IApplication::EPlatformType platform,
const std::vector<std::string>& args,
bool singleInstance)
{
logvisor::RegisterThreadName("Boo Main Thread");
std::string thrName = friendlyName + " Main Thread";
logvisor::RegisterThreadName(thrName.c_str());
if (APP)
return 1;
if (platform == IApplication::EPlatformType::Wayland)

View File

@ -433,7 +433,8 @@ public:
std::unique_lock<std::mutex> innerLk(initmt);
innerLk.unlock();
initcv.notify_one();
logvisor::RegisterThreadName("Boo Client Thread");
std::string thrName = getFriendlyName() + " Client Thread";
logvisor::RegisterThreadName(thrName.c_str());
clientReturn = m_callback.appMain(this);
pthread_kill(mainThread, SIGUSR2);
});