diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-03-25 03:09:13 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-03-25 03:09:13 +0000 |
| commit | 48dad2f3bfb3a26cd73eace45daef55ba8cfd1bc (patch) | |
| tree | 186b0eb72d31122dd2643ecbcf6da9e3c505789e /Graphics/GLSLTools | |
| parent | Updated cmake scripts to enable Vulkan back-end on iOS when VulkanSDK is spec... (diff) | |
| download | DiligentCore-48dad2f3bfb3a26cd73eace45daef55ba8cfd1bc.tar.gz DiligentCore-48dad2f3bfb3a26cd73eace45daef55ba8cfd1bc.zip | |
Allocating spirv-cross parser and compiler on the heap to fix crash on iOS apparently caused by stack allocation issues
Diffstat (limited to 'Graphics/GLSLTools')
| -rw-r--r-- | Graphics/GLSLTools/src/SPIRVShaderResources.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp index 4758a79f..85de1050 100644 --- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp +++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp @@ -22,6 +22,7 @@ */ #include <iomanip> +#include <memory> #include "SPIRVShaderResources.h" #include "spirv_parser.hpp" #include "spirv_cross.hpp" @@ -148,7 +149,7 @@ static spv::ExecutionModel ShaderTypeToExecutionModel(SHADER_TYPE ShaderType) } } -const std::string& GetUBName(spirv_cross::Compiler& Compiler, const spirv_cross::Resource& UB, const spirv_cross::ParsedIR::Source& IRSource) +const std::string& GetUBName(const spirv_cross::Compiler& Compiler, const spirv_cross::Resource& UB, const spirv_cross::ParsedIR::Source& IRSource) { // Consider the following HLSL constant buffer: // @@ -194,10 +195,11 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, m_ShaderType(shaderDesc.ShaderType) { // https://github.com/KhronosGroup/SPIRV-Cross/wiki/Reflection-API-user-guide - spirv_cross::Parser parser(move(spirv_binary)); - parser.parse(); - auto ParsedIRSource = parser.get_parsed_ir().source; - spirv_cross::Compiler Compiler(std::move(parser.get_parsed_ir())); + std::unique_ptr<spirv_cross::Parser> pParser(new spirv_cross::Parser(std::move(spirv_binary))); + pParser->parse(); + auto ParsedIRSource = pParser->get_parsed_ir().source; + std::unique_ptr<spirv_cross::Compiler> pCompiler(new spirv_cross::Compiler(std::move(pParser->get_parsed_ir()))); + const auto& Compiler = *pCompiler; spv::ExecutionModel ExecutionModel = ShaderTypeToExecutionModel(shaderDesc.ShaderType); auto EntryPoints = Compiler.get_entry_points_and_stages(); @@ -219,7 +221,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, { LOG_ERROR_AND_THROW("Unable to find entry point of type ", GetShaderTypeLiteralName(shaderDesc.ShaderType), " in SPIRV binary for shader '", shaderDesc.Name, "'"); } - Compiler.set_entry_point(EntryPoint, ExecutionModel); + pCompiler->set_entry_point(EntryPoint, ExecutionModel); // The SPIR-V is now parsed, and we can perform reflection on it. spirv_cross::ShaderResources resources = Compiler.get_shader_resources(); |
