Bug 1700051: part 26) Correct typo in comment of `mozInlineSpellWordUtil::BuildSoftTe...
[gecko.git] / dom / canvas / WebGLShaderValidator.h
blobda8cadff3d668cb5cbce0a74f8c23eb072ee66bc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WEBGL_SHADER_VALIDATOR_H_
7 #define WEBGL_SHADER_VALIDATOR_H_
9 #include <memory>
10 #include <string>
11 #include <unordered_map>
13 #include "GLDefs.h"
14 #include "GLSLANG/ShaderLang.h"
15 #include "nsString.h"
17 namespace mozilla {
18 namespace webgl {
20 class ShaderValidatorResults final {
21 public:
22 std::string mInfoLog;
23 bool mValid = false;
25 std::string mObjectCode;
26 int mShaderVersion = 0;
27 int mVertexShaderNumViews = 0;
29 std::vector<sh::Attribute> mAttributes;
30 std::vector<sh::InterfaceBlock> mInterfaceBlocks;
31 std::vector<sh::OutputVariable> mOutputVariables;
32 std::vector<sh::Uniform> mUniforms;
33 std::vector<sh::Varying> mVaryings;
35 std::unordered_map<std::string, std::string> mNameMap;
37 int mMaxVaryingVectors = 0;
39 bool CanLinkTo(const ShaderValidatorResults& vert,
40 nsCString* const out_log) const;
41 size_t SizeOfIncludingThis(MallocSizeOf) const;
44 class ShaderValidator final {
45 public:
46 const ShHandle mHandle;
48 private:
49 const ShCompileOptions mCompileOptions;
50 const int mMaxVaryingVectors;
52 public:
53 static std::unique_ptr<ShaderValidator> Create(
54 GLenum shaderType, ShShaderSpec spec, ShShaderOutput outputLanguage,
55 const ShBuiltInResources& resources, ShCompileOptions compileOptions);
57 private:
58 ShaderValidator(ShHandle handle, ShCompileOptions compileOptions,
59 int maxVaryingVectors)
60 : mHandle(handle),
61 mCompileOptions(compileOptions),
62 mMaxVaryingVectors(maxVaryingVectors) {}
64 public:
65 ~ShaderValidator();
67 std::unique_ptr<const ShaderValidatorResults> ValidateAndTranslate(
68 const char*) const;
71 } // namespace webgl
72 } // namespace mozilla
74 #endif // WEBGL_SHADER_VALIDATOR_H_