diff --git a/hecl/lib/Backend/HLSL.cpp b/hecl/lib/Backend/HLSL.cpp index 983d5b067..66514b6f6 100644 --- a/hecl/lib/Backend/HLSL.cpp +++ b/hecl/lib/Backend/HLSL.cpp @@ -373,10 +373,13 @@ struct HLSLBackendFactory : IShaderBackendFactory boo::IGraphicsDataFactory::Context& ctx) { const ShaderTag& tag = data.m_tag; - athena::io::MemoryReader r(data.m_data.get(), data.m_sz); + athena::io::MemoryReader r(data.m_data.get(), data.m_sz, false, false); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); + if (r.hasError()) + return nullptr; + atUint32 vertSz = r.readUint32Big(); ComPtr vertBlob; if (vertSz) @@ -401,6 +404,9 @@ struct HLSLBackendFactory : IShaderBackendFactory r.readUBytesToBuf(pipelineBlob->GetBufferPointer(), pipelineSz); } + if (r.hasError()) + return nullptr; + boo::IShaderPipeline* ret = static_cast(ctx). newShaderPipeline(nullptr, nullptr, @@ -499,16 +505,19 @@ struct HLSLBackendFactory : IShaderBackendFactory return dataOut; } - void buildExtendedShaderFromCache(const ShaderCachedData& data, + bool buildExtendedShaderFromCache(const ShaderCachedData& data, const std::vector& extensionSlots, boo::IGraphicsDataFactory::Context& ctx, FReturnExtensionShader returnFunc) { const ShaderTag& tag = data.m_tag; - athena::io::MemoryReader r(data.m_data.get(), data.m_sz); + athena::io::MemoryReader r(data.m_data.get(), data.m_sz, false, false); hecl::Backend::BlendFactor blendSrc = hecl::Backend::BlendFactor(r.readUByte()); hecl::Backend::BlendFactor blendDst = hecl::Backend::BlendFactor(r.readUByte()); + if (r.hasError()) + return false; + for (const ShaderCacheExtensions::ExtensionSlot& slot : extensionSlots) { atUint32 vertSz = r.readUint32Big(); @@ -535,6 +544,9 @@ struct HLSLBackendFactory : IShaderBackendFactory r.readUBytesToBuf(pipelineBlob->GetBufferPointer(), pipelineSz); } + if (r.hasError()) + return false; + boo::IShaderPipeline* ret = static_cast(ctx). newShaderPipeline(nullptr, nullptr, @@ -549,6 +561,8 @@ struct HLSLBackendFactory : IShaderBackendFactory Log.report(logvisor::Fatal, "unable to build shader"); returnFunc(ret); } + + return true; } };