author Jeff Muizelaar <>
Tue, 03 Nov 2015 11:02:29 -0500
changeset 292854 6c14623c763ea5b0f52e4f2d7dfd178147491854
parent 253200 ac4464790ec4896a5188fa50cfc69ae0ffeddc08
child 292855 13c39f24d52fe6fc26eefecdebf19226ecb729a8
permissions -rw-r--r--
Bug 1218944. Transform feedback linking should use varyings intead of attribs. r=jgilbert

/* -*- 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 */


#include "angle/ShaderLang.h"
#include "GLDefs.h"
#include "nsString.h"
#include <string>

namespace mozilla {
namespace webgl {

class ShaderValidator final
    const ShHandle mHandle;
    const int mCompileOptions;
    const int mMaxVaryingVectors;
    bool mHasRun;

    static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
                                   ShShaderOutput outputLanguage,
                                   const ShBuiltInResources& resources,
                                   int compileOptions);

    ShaderValidator(ShHandle handle, int compileOptions, int maxVaryingVectors)
        : mHandle(handle)
        , mCompileOptions(compileOptions)
        , mMaxVaryingVectors(maxVaryingVectors)
        , mHasRun(false)
    { }


    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;

    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;

    bool FindVaryingMappedNameByUserName(const std::string& userName,
                                         const std::string** const out_mappedName) const;

    bool FindUniformByMappedName(const std::string& mappedName,
                                 std::string* const out_userName,
                                 bool* const out_isArray) const;

} // namespace webgl
} // namespace mozilla