Files
godot-angle-static/src/libANGLE/renderer/metal/ProgramMtl.h
Shahbaz Youssefi 68bfa1edf5 Support for link to be entirely parallelized
The link job is split as such:

- Front-end link
- Back-end link
- Independent back-end link subtasks (typically native driver compile
  jobs)
- Post-link finalization

Each step depends on the previous.  These steps are executed as such:

1. Program::link calls into ProgramImpl::link
  - ProgramImpl::link runs whatever needs the Context, such as releasing
    resources
  - ProgramImpl::link returns a LinkTask
2. Program::link implements a closure that calls the front-end link and
   passes the results to the backend's LinkTask.
3. The LinkTask potentially returns a set of LinkSubTasks to be
   scheduled by the worker pool
4. Once the link is resolved, the post-link finalization is run

In the above, steps 1 and 4 are done under the share group lock.  Steps
2 and 3 can be done in threads or without holding the share group lock
if the backend supports it.  Step 2 is not yet made independent of the
Context on some backends, and a frontend feature is used to make that
step either run on the main thread or as a worker thread.

Bug: angleproject:8297
Change-Id: I12f1e6bbaf365543dfcac969e166e0b5aa622104
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4808191
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
2023-09-14 15:47:54 +00:00

139 lines
5.8 KiB
Objective-C

//
// 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.
//
// ProgramMtl.h:
// Defines the class interface for ProgramMtl, implementing ProgramImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_
#define LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_
#import <Metal/Metal.h>
#include <array>
#include "common/Optional.h"
#include "common/utilities.h"
#include "libANGLE/renderer/ProgramImpl.h"
#include "libANGLE/renderer/metal/ProgramExecutableMtl.h"
#include "libANGLE/renderer/metal/ShaderMtl.h"
#include "libANGLE/renderer/metal/mtl_context_device.h"
namespace rx
{
#define SHADER_ENTRY_NAME @"main0"
class ContextMtl;
class ProgramMtl : public ProgramImpl
{
public:
ProgramMtl(const gl::ProgramState &state);
~ProgramMtl() override;
void destroy(const gl::Context *context) override;
angle::Result load(const gl::Context *context,
gl::BinaryInputStream *stream,
std::shared_ptr<LinkTask> *loadTaskOut) override;
void save(const gl::Context *context, gl::BinaryOutputStream *stream) override;
void setBinaryRetrievableHint(bool retrievable) override;
void setSeparable(bool separable) override;
void prepareForLink(const gl::ShaderMap<ShaderImpl *> &shaders) override;
angle::Result link(const gl::Context *context, std::shared_ptr<LinkTask> *linkTaskOut) override;
GLboolean validate(const gl::Caps &caps) override;
void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform1iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform2iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform3iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform4iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniformMatrix2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix2x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix3x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix2x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix4x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix3x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix4x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void getUniformfv(const gl::Context *context, GLint location, GLfloat *params) const override;
void getUniformiv(const gl::Context *context, GLint location, GLint *params) const override;
void getUniformuiv(const gl::Context *context, GLint location, GLuint *params) const override;
const ProgramExecutableMtl *getExecutable() const
{
return mtl::GetImpl(&mState.getExecutable());
}
ProgramExecutableMtl *getExecutable() { return mtl::GetImpl(&mState.getExecutable()); }
private:
class LinkTaskMtl;
class LoadTaskMtl;
friend class LinkTaskMtl;
angle::Result linkJobImpl(const gl::Context *context,
const gl::ProgramLinkedResources &resources,
std::vector<std::shared_ptr<LinkSubTask>> *subTasksOut);
template <int cols, int rows>
void setUniformMatrixfv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
template <class T>
void getUniformImpl(GLint location, T *v, GLenum entryPointType) const;
template <typename T>
void setUniformImpl(GLint location, GLsizei count, const T *v, GLenum entryPointType);
void linkResources(const gl::ProgramLinkedResources &resources);
angle::Result compileMslShaderLibs(const gl::Context *context,
std::vector<std::shared_ptr<LinkSubTask>> *subTasksOut);
gl::ShaderMap<SharedCompiledShaderStateMtl> mAttachedShaders;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_ */