Commit 4f86d053 by Jamie Madill Committed by Commit Bot

Introduce MemoryProgramCache.

This class will manage GPU binary programs in memory. It will be owned by the Display, and shared between Contexts. Currently this CL just refactors the Program binary saving and loading into static members of this new class. BUG=angleproject:1897 Change-Id: I34f5afb2c02416f6fd80dd65ba3827a8637ce190 Reviewed-on: https://chromium-review.googlesource.com/522873 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 9cf9e871
...@@ -230,6 +230,6 @@ class BinaryOutputStream : angle::NonCopyable ...@@ -230,6 +230,6 @@ class BinaryOutputStream : angle::NonCopyable
} }
}; };
} } // namespace gl
#endif // LIBANGLE_BINARYSTREAM_H_ #endif // LIBANGLE_BINARYSTREAM_H_
//
// Copyright 2017 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.
//
// MemoryProgramCache: Stores compiled and linked programs in memory so they don't
// always have to be re-compiled. Can be used in conjunction with the platform
// layer to warm up the cache from disk.
#ifndef LIBANGLE_MEMORY_PROGRAM_CACHE_H_
#define LIBANGLE_MEMORY_PROGRAM_CACHE_H_
#include "common/MemoryBuffer.h"
#include "libANGLE/Error.h"
namespace gl
{
class Context;
class InfoLog;
class Program;
class ProgramState;
class MemoryProgramCache final : angle::NonCopyable
{
public:
// Writes a program's binary to the output memory buffer.
static void Serialize(const Context *context,
const Program *program,
angle::MemoryBuffer *binaryOut);
// Loads program state according to the specified binary blob.
static LinkResult Deserialize(const Context *context,
const Program *program,
ProgramState *state,
const uint8_t *binary,
size_t length,
InfoLog &infoLog);
};
} // namespace gl
#endif // LIBANGLE_MEMORY_PROGRAM_CACHE_H_
...@@ -229,11 +229,25 @@ class ProgramState final : angle::NonCopyable ...@@ -229,11 +229,25 @@ class ProgramState final : angle::NonCopyable
return mActiveAttribLocationsMask; return mActiveAttribLocationsMask;
} }
DrawBufferMask getActiveOutputVariables() const { return mActiveOutputVariables; } DrawBufferMask getActiveOutputVariables() const { return mActiveOutputVariables; }
const std::vector<sh::OutputVariable> &getOutputVariables() const { return mOutputVariables; }
const std::map<int, VariableLocation> &getOutputLocations() const { return mOutputLocations; } const std::map<int, VariableLocation> &getOutputLocations() const { return mOutputLocations; }
const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; } const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; }
const std::vector<VariableLocation> &getUniformLocations() const { return mUniformLocations; } const std::vector<VariableLocation> &getUniformLocations() const { return mUniformLocations; }
const std::vector<UniformBlock> &getUniformBlocks() const { return mUniformBlocks; } const std::vector<UniformBlock> &getUniformBlocks() const { return mUniformBlocks; }
const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; } const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; }
const sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; }
const RangeUI &getSamplerUniformRange() const { return mSamplerUniformRange; }
using UniformBlockBindingArray =
std::array<GLuint, IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS>;
const UniformBlockBindingArray &getUniformBlockBindings() const
{
return mUniformBlockBindings;
}
const std::vector<TransformFeedbackVarying> &getLinkedTransformFeedbackVaryings() const
{
return mLinkedTransformFeedbackVaryings;
}
GLint getUniformLocation(const std::string &name) const; GLint getUniformLocation(const std::string &name) const;
GLuint getUniformIndexFromName(const std::string &name) const; GLuint getUniformIndexFromName(const std::string &name) const;
...@@ -243,6 +257,7 @@ class ProgramState final : angle::NonCopyable ...@@ -243,6 +257,7 @@ class ProgramState final : angle::NonCopyable
GLuint getSamplerIndexFromUniformIndex(GLuint uniformIndex) const; GLuint getSamplerIndexFromUniformIndex(GLuint uniformIndex) const;
private: private:
friend class MemoryProgramCache;
friend class Program; friend class Program;
std::string mLabel; std::string mLabel;
...@@ -257,7 +272,7 @@ class ProgramState final : angle::NonCopyable ...@@ -257,7 +272,7 @@ class ProgramState final : angle::NonCopyable
std::vector<TransformFeedbackVarying> mLinkedTransformFeedbackVaryings; std::vector<TransformFeedbackVarying> mLinkedTransformFeedbackVaryings;
GLenum mTransformFeedbackBufferMode; GLenum mTransformFeedbackBufferMode;
std::array<GLuint, IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS> mUniformBlockBindings; UniformBlockBindingArray mUniformBlockBindings;
UniformBlockBindingMask mActiveUniformBlockBindings; UniformBlockBindingMask mActiveUniformBlockBindings;
std::vector<sh::Attribute> mAttributes; std::vector<sh::Attribute> mAttributes;
......
...@@ -160,6 +160,8 @@ ...@@ -160,6 +160,8 @@
'libANGLE/IndexRangeCache.h', 'libANGLE/IndexRangeCache.h',
'libANGLE/LoggingAnnotator.cpp', 'libANGLE/LoggingAnnotator.cpp',
'libANGLE/LoggingAnnotator.h', 'libANGLE/LoggingAnnotator.h',
'libANGLE/MemoryProgramCache.cpp',
'libANGLE/MemoryProgramCache.h',
'libANGLE/Path.h', 'libANGLE/Path.h',
'libANGLE/Path.cpp', 'libANGLE/Path.cpp',
'libANGLE/Platform.cpp', 'libANGLE/Platform.cpp',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment