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_
11 #include <unordered_map>
14 #include "GLSLANG/ShaderLang.h"
20 class ShaderValidatorResults final
{
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
{
46 const ShHandle mHandle
;
49 const ShCompileOptions mCompileOptions
;
50 const int mMaxVaryingVectors
;
53 static std::unique_ptr
<ShaderValidator
> Create(
54 GLenum shaderType
, ShShaderSpec spec
, ShShaderOutput outputLanguage
,
55 const ShBuiltInResources
& resources
, ShCompileOptions compileOptions
);
58 ShaderValidator(ShHandle handle
, ShCompileOptions compileOptions
,
59 int maxVaryingVectors
)
61 mCompileOptions(compileOptions
),
62 mMaxVaryingVectors(maxVaryingVectors
) {}
67 std::unique_ptr
<const ShaderValidatorResults
> ValidateAndTranslate(
72 } // namespace mozilla
74 #endif // WEBGL_SHADER_VALIDATOR_H_