Hash :
f3c1de36
Author :
Date :
2023-08-17T15:29:24
Make shader recompile while parallel linking safe Prior to this change, Program* objects held references to Shader* objects. This poses a problem where a shader recompile can race with a program link, if the program link is done in parallel. As a result, a good chunk of the link job is done serially and under the share group lock. After this change, that is no longer a problem, and most of the link can be made lockless/parallelized. This change separates out the "compiled state" from the rest of the shader state. This was already done for the front-end state (for the sake of caching), but is also now done for the backends that need it. The compiled state in turn is placed in a shared_ptr, and is shared with the program. When a shader is compiled, its own shared_ptr is replaced with a new object, leaving all programs currently compiling unaffected and using the previous compilation results. Once a program is linked, its references to compiled shader states is updated. Bug: angleproject:8297 Change-Id: Iff7094a37088fbad99c6241f1c48b0bd4c820eb2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4791065 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ShaderMtl.h:
// Defines the class interface for ShaderMtl, implementing ShaderImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_SHADERMTL_H_
#define LIBANGLE_RENDERER_METAL_SHADERMTL_H_
#include <map>
#include "libANGLE/renderer/ShaderImpl.h"
#include "libANGLE/renderer/metal/mtl_msl_utils.h"
namespace rx
{
class ShaderMtl : public ShaderImpl
{
public:
ShaderMtl(const gl::ShaderState &state);
~ShaderMtl() override;
std::shared_ptr<WaitableCompileEvent> compile(const gl::Context *context,
gl::ShCompilerInstance *compilerInstance,
ShCompileOptions *options) override;
const SharedCompiledShaderStateMtl &getCompiledState() const { return mCompiledState; }
std::string getDebugInfo() const override;
private:
std::shared_ptr<WaitableCompileEvent> compileImplMtl(const gl::Context *context,
gl::ShCompilerInstance *compilerInstance,
const std::string &source,
ShCompileOptions *compileOptions);
SharedCompiledShaderStateMtl mCompiledState;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_SHADERMTL_H_ */