Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
5 :
6 : #ifndef WEBGL_SHADER_VALIDATOR_H_
7 : #define WEBGL_SHADER_VALIDATOR_H_
8 :
9 : #include "angle/ShaderLang.h"
10 : #include "GLDefs.h"
11 : #include "nsString.h"
12 : #include <string>
13 :
14 : namespace mozilla {
15 : namespace webgl {
16 :
17 : class ShaderValidator final
18 : {
19 : const ShHandle mHandle;
20 : const ShCompileOptions mCompileOptions;
21 : const int mMaxVaryingVectors;
22 : bool mHasRun;
23 :
24 : public:
25 : static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
26 : ShShaderOutput outputLanguage,
27 : const ShBuiltInResources& resources,
28 : ShCompileOptions compileOptions);
29 :
30 : private:
31 0 : ShaderValidator(ShHandle handle, ShCompileOptions compileOptions,
32 : int maxVaryingVectors)
33 0 : : mHandle(handle)
34 : , mCompileOptions(compileOptions)
35 : , mMaxVaryingVectors(maxVaryingVectors)
36 0 : , mHasRun(false)
37 0 : { }
38 :
39 : public:
40 : ~ShaderValidator();
41 :
42 : bool ValidateAndTranslate(const char* source);
43 : void GetInfoLog(nsACString* out) const;
44 : void GetOutput(nsACString* out) const;
45 : bool CanLinkTo(const ShaderValidator* prev, nsCString* const out_log) const;
46 : size_t CalcNumSamplerUniforms() const;
47 : size_t NumAttributes() const;
48 :
49 : bool FindAttribUserNameByMappedName(const std::string& mappedName,
50 : const std::string** const out_userName) const;
51 :
52 : bool FindAttribMappedNameByUserName(const std::string& userName,
53 : const std::string** const out_mappedName) const;
54 :
55 : bool FindVaryingMappedNameByUserName(const std::string& userName,
56 : const std::string** const out_mappedName) const;
57 :
58 : bool FindVaryingByMappedName(const std::string& mappedName,
59 : std::string* const out_userName,
60 : bool* const out_isArray) const;
61 : bool FindUniformByMappedName(const std::string& mappedName,
62 : std::string* const out_userName,
63 : bool* const out_isArray) const;
64 : bool UnmapUniformBlockName(const nsACString& baseMappedName,
65 : nsCString* const out_baseUserName) const;
66 :
67 : void EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const;
68 :
69 : bool ValidateTransformFeedback(const std::vector<nsString>& userNames,
70 : uint32_t maxComponents, nsCString* const out_errorText,
71 : std::vector<std::string>* const out_mappedNames);
72 : };
73 :
74 : } // namespace webgl
75 : } // namespace mozilla
76 :
77 : #endif // WEBGL_SHADER_VALIDATOR_H_
|