Bug 1842773 - Part 5: Add ArrayBuffer.prototype.{maxByteLength,resizable} getters...
[gecko.git] / dom / canvas / WebGLShaderValidator.h
blobab05528f198f73c56d8ad3436fe7942a6b2da3af
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::webgl {
19 class ShaderValidatorResults final {
20 public:
21 std::string mInfoLog;
22 bool mValid = false;
24 std::string mObjectCode;
25 int mShaderVersion = 0;
26 int mVertexShaderNumViews = 0;
28 std::vector<sh::Attribute> mAttributes;
29 std::vector<sh::InterfaceBlock> mInterfaceBlocks;
30 std::vector<sh::OutputVariable> mOutputVariables;
31 std::vector<sh::Uniform> mUniforms;
32 std::vector<sh::Varying> mVaryings;
34 std::unordered_map<std::string, std::string> mNameMap;
36 int mMaxVaryingVectors = 0;
38 bool mNeeds_webgl_gl_VertexID_Offset = false;
40 bool CanLinkTo(const ShaderValidatorResults& vert,
41 nsCString* const out_log) const;
42 size_t SizeOfIncludingThis(MallocSizeOf) const;
45 class ShaderValidator final {
46 public:
47 const ShHandle mHandle;
49 private:
50 const ShCompileOptions mCompileOptions;
51 const int mMaxVaryingVectors;
53 public:
54 bool mIfNeeded_webgl_gl_VertexID_Offset = false;
56 static std::unique_ptr<ShaderValidator> Create(
57 GLenum shaderType, ShShaderSpec spec, ShShaderOutput outputLanguage,
58 const ShBuiltInResources& resources, ShCompileOptions compileOptions);
60 private:
61 ShaderValidator(ShHandle handle, ShCompileOptions compileOptions,
62 int maxVaryingVectors)
63 : mHandle(handle),
64 mCompileOptions(compileOptions),
65 mMaxVaryingVectors(maxVaryingVectors) {}
67 public:
68 ~ShaderValidator();
70 std::unique_ptr<const ShaderValidatorResults> ValidateAndTranslate(
71 const char*) const;
74 } // namespace mozilla::webgl
76 #endif // WEBGL_SHADER_VALIDATOR_H_