mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-29 00:55:41 +00:00
(libretro/Vulkan) Fix glslang shader-related crashes
This commit is contained in:
parent
60e44c232b
commit
363804c48b
|
@ -158,6 +158,7 @@ bool DetachProcess()
|
||||||
|
|
||||||
OS_FreeTLSIndex(ThreadInitializeIndex);
|
OS_FreeTLSIndex(ThreadInitializeIndex);
|
||||||
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||||
|
DeinitializePoolIndex();
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
namespace glslang {
|
namespace glslang {
|
||||||
|
|
||||||
bool InitializePoolIndex();
|
bool InitializePoolIndex();
|
||||||
|
bool DeinitializePoolIndex();
|
||||||
|
|
||||||
} // end namespace glslang
|
} // end namespace glslang
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,15 @@ bool InitializePoolIndex()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DeinitializePoolIndex()
|
||||||
|
{
|
||||||
|
if (PoolIndex == OS_INVALID_TLS_INDEX)
|
||||||
|
return false;
|
||||||
|
OS_FreeTLSIndex(PoolIndex);
|
||||||
|
PoolIndex = OS_INVALID_TLS_INDEX;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implement the functionality of the TPoolAllocator class, which
|
// Implement the functionality of the TPoolAllocator class, which
|
||||||
// is documented in PoolAlloc.h.
|
// is documented in PoolAlloc.h.
|
||||||
|
|
|
@ -1429,6 +1429,7 @@ int ShFinalize()
|
||||||
glslang::HlslScanContext::deleteKeywordMap();
|
glslang::HlslScanContext::deleteKeywordMap();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DetachProcess();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ bool InitializeGlslang();
|
||||||
|
|
||||||
static unsigned s_next_bad_shader_id = 1;
|
static unsigned s_next_bad_shader_id = 1;
|
||||||
|
|
||||||
|
static bool glslang_initialized = false;
|
||||||
|
|
||||||
static std::optional<SPIRVCodeVector> CompileShaderToSPV(EShLanguage stage, const char* stage_filename,
|
static std::optional<SPIRVCodeVector> CompileShaderToSPV(EShLanguage stage, const char* stage_filename,
|
||||||
std::string_view source)
|
std::string_view source)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +115,6 @@ static std::optional<SPIRVCodeVector> CompileShaderToSPV(EShLanguage stage, cons
|
||||||
|
|
||||||
bool InitializeGlslang()
|
bool InitializeGlslang()
|
||||||
{
|
{
|
||||||
static bool glslang_initialized = false;
|
|
||||||
if (glslang_initialized)
|
if (glslang_initialized)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -123,12 +124,23 @@ bool InitializeGlslang()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef LIBRETRO
|
||||||
std::atexit([]() { glslang::FinalizeProcess(); });
|
std::atexit([]() { glslang::FinalizeProcess(); });
|
||||||
|
#endif
|
||||||
|
|
||||||
glslang_initialized = true;
|
glslang_initialized = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeinitializeGlslang()
|
||||||
|
{
|
||||||
|
if (!glslang_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
glslang::FinalizeProcess();
|
||||||
|
glslang_initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<SPIRVCodeVector> CompileVertexShader(std::string_view source_code)
|
std::optional<SPIRVCodeVector> CompileVertexShader(std::string_view source_code)
|
||||||
{
|
{
|
||||||
return CompileShaderToSPV(EShLangVertex, "vs", source_code);
|
return CompileShaderToSPV(EShLangVertex, "vs", source_code);
|
||||||
|
|
|
@ -21,6 +21,8 @@ enum class Type
|
||||||
Compute
|
Compute
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void DeinitializeGlslang();
|
||||||
|
|
||||||
// SPIR-V compiled code type
|
// SPIR-V compiled code type
|
||||||
using SPIRVCodeType = u32;
|
using SPIRVCodeType = u32;
|
||||||
using SPIRVCodeVector = std::vector<SPIRVCodeType>;
|
using SPIRVCodeVector = std::vector<SPIRVCodeType>;
|
||||||
|
|
|
@ -136,6 +136,7 @@ void LibretroVulkanHostDisplay::DestroyResources()
|
||||||
VulkanHostDisplay::DestroyResources();
|
VulkanHostDisplay::DestroyResources();
|
||||||
Vulkan::Util::SafeDestroyFramebuffer(m_frame_framebuffer);
|
Vulkan::Util::SafeDestroyFramebuffer(m_frame_framebuffer);
|
||||||
m_frame_texture.Destroy();
|
m_frame_texture.Destroy();
|
||||||
|
Vulkan::ShaderCompiler::DeinitializeGlslang();
|
||||||
}
|
}
|
||||||
|
|
||||||
VkRenderPass LibretroVulkanHostDisplay::GetRenderPassForDisplay() const
|
VkRenderPass LibretroVulkanHostDisplay::GetRenderPassForDisplay() const
|
||||||
|
|
Loading…
Reference in a new issue