mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 09:35:09 +02:00
Fix pipeline lifetime issue, misc.
This commit is contained in:
@@ -1196,12 +1196,15 @@ void VulkanContext::DestroyDevice() {
|
||||
device_ = nullptr;
|
||||
}
|
||||
|
||||
bool VulkanContext::CreateShaderModule(const std::vector<uint32_t> &spirv, VkShaderModule *shaderModule) {
|
||||
bool VulkanContext::CreateShaderModule(const std::vector<uint32_t> &spirv, VkShaderModule *shaderModule, const char *tag) {
|
||||
VkShaderModuleCreateInfo sm{ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO };
|
||||
sm.pCode = spirv.data();
|
||||
sm.codeSize = spirv.size() * sizeof(uint32_t);
|
||||
sm.flags = 0;
|
||||
VkResult result = vkCreateShaderModule(device_, &sm, nullptr, shaderModule);
|
||||
if (tag) {
|
||||
SetDebugName(*shaderModule, VK_OBJECT_TYPE_SHADER_MODULE, tag);
|
||||
}
|
||||
if (result != VK_SUCCESS) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
|
||||
// Utility functions for shorter code
|
||||
VkFence CreateFence(bool presignalled);
|
||||
bool CreateShaderModule(const std::vector<uint32_t> &spirv, VkShaderModule *shaderModule);
|
||||
bool CreateShaderModule(const std::vector<uint32_t> &spirv, VkShaderModule *shaderModule, const char *tag);
|
||||
|
||||
int GetBackbufferWidth() { return (int)swapChainExtent_.width; }
|
||||
int GetBackbufferHeight() { return (int)swapChainExtent_.height; }
|
||||
|
||||
@@ -118,11 +118,11 @@ void VKRGraphicsPipeline::QueueForDeletion(VulkanContext *vulkan) {
|
||||
continue;
|
||||
VkPipeline pipeline = this->pipeline[i]->BlockUntilReady();
|
||||
vulkan->Delete().QueueDeletePipeline(pipeline);
|
||||
vulkan->Delete().QueueCallback([](void *p) {
|
||||
VKRGraphicsPipeline *pipeline = (VKRGraphicsPipeline *)p;
|
||||
delete pipeline;
|
||||
}, this);
|
||||
}
|
||||
vulkan->Delete().QueueCallback([](void *p) {
|
||||
VKRGraphicsPipeline *pipeline = (VKRGraphicsPipeline *)p;
|
||||
delete pipeline;
|
||||
}, this);
|
||||
}
|
||||
|
||||
u32 VKRGraphicsPipeline::GetVariantsBitmask() const {
|
||||
@@ -634,7 +634,9 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile
|
||||
|
||||
VLOG("PUSH: Fencing %d", curFrame);
|
||||
|
||||
vkWaitForFences(device, 1, &frameData.fence, true, UINT64_MAX);
|
||||
if (vkWaitForFences(device, 1, &frameData.fence, true, UINT64_MAX) == VK_ERROR_DEVICE_LOST) {
|
||||
_assert_msg_(false, "Device lost in vkWaitForFences");
|
||||
}
|
||||
vkResetFences(device, 1, &frameData.fence);
|
||||
|
||||
// Can't set this until after the fence.
|
||||
|
||||
@@ -231,7 +231,7 @@ bool VKShaderModule::Compile(VulkanContext *vulkan, ShaderLanguage language, con
|
||||
}
|
||||
#endif
|
||||
|
||||
if (vulkan->CreateShaderModule(spirv, &module_)) {
|
||||
if (vulkan->CreateShaderModule(spirv, &module_, vkstage_ == VK_SHADER_STAGE_VERTEX_BIT ? "thin3d_vs" : "thin3d_fs")) {
|
||||
ok_ = true;
|
||||
} else {
|
||||
WARN_LOG(G3D, "vkCreateShaderModule failed");
|
||||
|
||||
@@ -38,9 +38,9 @@ void PipelineManagerVulkan::Clear() {
|
||||
if (!value->pipeline) {
|
||||
// Something went wrong.
|
||||
ERROR_LOG(G3D, "Null pipeline found in PipelineManagerVulkan::Clear - didn't wait for asyncs?");
|
||||
delete value;
|
||||
} else {
|
||||
value->pipeline->QueueForDeletion(vulkan_);
|
||||
}
|
||||
value->pipeline->QueueForDeletion(vulkan_);
|
||||
delete value;
|
||||
});
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ Promise<VkShaderModule> *CompileShaderModuleAsync(VulkanContext *vulkan, VkShade
|
||||
|
||||
VkShaderModule shaderModule = VK_NULL_HANDLE;
|
||||
if (success) {
|
||||
success = vulkan->CreateShaderModule(spirv, &shaderModule);
|
||||
success = vulkan->CreateShaderModule(spirv, &shaderModule, stage == VK_SHADER_STAGE_VERTEX_BIT ? "game_vertex" : "game_fragment");
|
||||
#ifdef SHADERLOG
|
||||
OutputDebugStringA("OK");
|
||||
#endif
|
||||
@@ -81,7 +81,7 @@ Promise<VkShaderModule> *CompileShaderModuleAsync(VulkanContext *vulkan, VkShade
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Don't parallelize in debug mode, pathological behavior due to mutex locks in allocator.
|
||||
// Don't parallelize in debug mode, pathological behavior due to mutex locks in allocator which is HEAVILY used by glslang.
|
||||
return Promise<VkShaderModule>::AlreadyDone(compile());
|
||||
#else
|
||||
return Promise<VkShaderModule>::Spawn(&g_threadManager, compile, TaskType::CPU_COMPUTE);
|
||||
|
||||
@@ -44,7 +44,7 @@ VkShaderModule CompileShaderModule(VulkanContext *vulkan, VkShaderStageFlagBits
|
||||
return VK_NULL_HANDLE;
|
||||
} else {
|
||||
VkShaderModule module;
|
||||
if (vulkan->CreateShaderModule(spirv, &module)) {
|
||||
if (vulkan->CreateShaderModule(spirv, &module, stage == VK_SHADER_STAGE_VERTEX_BIT ? "system_vs" : "system_fs")) {
|
||||
return module;
|
||||
} else {
|
||||
return VK_NULL_HANDLE;
|
||||
|
||||
Reference in New Issue
Block a user