2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-01-16 02:40:39 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef WEBGL_SHADER_VALIDATOR_H_
|
|
|
|
#define WEBGL_SHADER_VALIDATOR_H_
|
|
|
|
|
2019-01-25 02:38:15 +03:00
|
|
|
#include <string>
|
|
|
|
|
2019-02-01 06:58:38 +03:00
|
|
|
#include "GLDefs.h"
|
2019-01-25 02:38:15 +03:00
|
|
|
#include "GLSLANG/ShaderLang.h"
|
2015-01-16 02:40:39 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace webgl {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ShaderValidator final {
|
2019-05-25 20:46:15 +03:00
|
|
|
public:
|
2015-01-16 02:40:39 +03:00
|
|
|
const ShHandle mHandle;
|
2019-05-25 20:46:15 +03:00
|
|
|
|
|
|
|
private:
|
2016-12-22 03:37:25 +03:00
|
|
|
const ShCompileOptions mCompileOptions;
|
2015-03-12 06:12:43 +03:00
|
|
|
const int mMaxVaryingVectors;
|
2015-01-16 02:40:39 +03:00
|
|
|
bool mHasRun;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
public:
|
|
|
|
static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
|
|
|
|
ShShaderOutput outputLanguage,
|
|
|
|
const ShBuiltInResources& resources,
|
2016-12-22 03:37:25 +03:00
|
|
|
ShCompileOptions compileOptions);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
private:
|
2016-12-22 03:37:25 +03:00
|
|
|
ShaderValidator(ShHandle handle, ShCompileOptions compileOptions,
|
|
|
|
int maxVaryingVectors)
|
2015-01-16 02:40:39 +03:00
|
|
|
: mHandle(handle),
|
|
|
|
mCompileOptions(compileOptions),
|
2015-03-12 06:12:43 +03:00
|
|
|
mMaxVaryingVectors(maxVaryingVectors),
|
2015-01-16 02:40:39 +03:00
|
|
|
mHasRun(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
public:
|
|
|
|
~ShaderValidator();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
bool ValidateAndTranslate(const char* source);
|
|
|
|
bool CanLinkTo(const ShaderValidator* prev, nsCString* const out_log) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
bool FindUniformByMappedName(const std::string& mappedName,
|
|
|
|
std::string* const out_userName,
|
|
|
|
bool* const out_isArray) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
bool ValidateTransformFeedback(
|
|
|
|
const std::vector<nsString>& userNames, uint32_t maxComponents,
|
|
|
|
nsCString* const out_errorText,
|
|
|
|
std::vector<std::string>* const out_mappedNames);
|
2015-01-16 02:40:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace webgl
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // WEBGL_SHADER_VALIDATOR_H_
|