2015-01-16 02:40:39 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* 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_
|
|
|
|
|
|
|
|
#include "angle/ShaderLang.h"
|
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace webgl {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ShaderValidator final
|
2015-01-16 02:40:39 +03:00
|
|
|
{
|
|
|
|
const ShHandle mHandle;
|
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;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
|
|
|
|
ShShaderOutput outputLanguage,
|
|
|
|
const ShBuiltInResources& resources,
|
2016-12-22 03:37:25 +03:00
|
|
|
ShCompileOptions compileOptions);
|
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)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
public:
|
|
|
|
~ShaderValidator();
|
|
|
|
|
|
|
|
bool ValidateAndTranslate(const char* source);
|
|
|
|
void GetInfoLog(nsACString* out) const;
|
|
|
|
void GetOutput(nsACString* out) const;
|
|
|
|
bool CanLinkTo(const ShaderValidator* prev, nsCString* const out_log) const;
|
|
|
|
size_t CalcNumSamplerUniforms() const;
|
2015-10-24 07:35:16 +03:00
|
|
|
size_t NumAttributes() const;
|
2015-01-16 02:40:39 +03:00
|
|
|
|
|
|
|
bool FindAttribUserNameByMappedName(const std::string& mappedName,
|
|
|
|
const std::string** const out_userName) const;
|
|
|
|
|
|
|
|
bool FindAttribMappedNameByUserName(const std::string& userName,
|
|
|
|
const std::string** const out_mappedName) const;
|
|
|
|
|
2015-11-03 19:02:29 +03:00
|
|
|
bool FindVaryingMappedNameByUserName(const std::string& userName,
|
|
|
|
const std::string** const out_mappedName) const;
|
|
|
|
|
2015-11-14 06:27:17 +03:00
|
|
|
bool FindVaryingByMappedName(const std::string& mappedName,
|
|
|
|
std::string* const out_userName,
|
|
|
|
bool* const out_isArray) const;
|
2015-01-16 02:40:39 +03:00
|
|
|
bool FindUniformByMappedName(const std::string& mappedName,
|
|
|
|
std::string* const out_userName,
|
|
|
|
bool* const out_isArray) const;
|
2015-11-03 19:02:29 +03:00
|
|
|
bool FindUniformBlockByMappedName(const std::string& mappedName,
|
|
|
|
std::string* const out_userName) const;
|
|
|
|
|
2016-07-18 15:19:04 +03:00
|
|
|
void EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const;
|
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_
|