2015-01-15 23:40:39 +00: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 16:28:04 +00:00
|
|
|
class ShaderValidator final
|
2015-01-15 23:40:39 +00:00
|
|
|
{
|
|
|
|
const ShHandle mHandle;
|
|
|
|
const int mCompileOptions;
|
2015-03-12 03:12:43 +00:00
|
|
|
const int mMaxVaryingVectors;
|
2015-01-15 23:40:39 +00:00
|
|
|
bool mHasRun;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
|
|
|
|
ShShaderOutput outputLanguage,
|
|
|
|
const ShBuiltInResources& resources,
|
|
|
|
int compileOptions);
|
|
|
|
|
|
|
|
private:
|
2015-03-12 03:12:43 +00:00
|
|
|
ShaderValidator(ShHandle handle, int compileOptions, int maxVaryingVectors)
|
2015-01-15 23:40:39 +00:00
|
|
|
: mHandle(handle)
|
|
|
|
, mCompileOptions(compileOptions)
|
2015-03-12 03:12:43 +00:00
|
|
|
, mMaxVaryingVectors(maxVaryingVectors)
|
2015-01-15 23:40:39 +00: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 04:35:16 +00:00
|
|
|
size_t NumAttributes() const;
|
2015-01-15 23:40:39 +00: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 16:02:29 +00:00
|
|
|
bool FindVaryingMappedNameByUserName(const std::string& userName,
|
|
|
|
const std::string** const out_mappedName) const;
|
|
|
|
|
2015-11-14 03:27:17 +00:00
|
|
|
bool FindVaryingByMappedName(const std::string& mappedName,
|
|
|
|
std::string* const out_userName,
|
|
|
|
bool* const out_isArray) const;
|
2015-01-15 23:40:39 +00:00
|
|
|
bool FindUniformByMappedName(const std::string& mappedName,
|
|
|
|
std::string* const out_userName,
|
|
|
|
bool* const out_isArray) const;
|
2015-11-03 16:02:29 +00:00
|
|
|
bool FindUniformBlockByMappedName(const std::string& mappedName,
|
|
|
|
std::string* const out_userName) const;
|
|
|
|
|
2015-01-15 23:40:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace webgl
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // WEBGL_SHADER_VALIDATOR_H_
|