From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- dom/canvas/WebGLShaderValidator.h | 76 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 dom/canvas/WebGLShaderValidator.h (limited to 'dom/canvas/WebGLShaderValidator.h') diff --git a/dom/canvas/WebGLShaderValidator.h b/dom/canvas/WebGLShaderValidator.h new file mode 100644 index 0000000000..ab05528f19 --- /dev/null +++ b/dom/canvas/WebGLShaderValidator.h @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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 +#include +#include + +#include "GLDefs.h" +#include "GLSLANG/ShaderLang.h" +#include "nsString.h" + +namespace mozilla::webgl { + +class ShaderValidatorResults final { + public: + std::string mInfoLog; + bool mValid = false; + + std::string mObjectCode; + int mShaderVersion = 0; + int mVertexShaderNumViews = 0; + + std::vector mAttributes; + std::vector mInterfaceBlocks; + std::vector mOutputVariables; + std::vector mUniforms; + std::vector mVaryings; + + std::unordered_map mNameMap; + + int mMaxVaryingVectors = 0; + + bool mNeeds_webgl_gl_VertexID_Offset = false; + + bool CanLinkTo(const ShaderValidatorResults& vert, + nsCString* const out_log) const; + size_t SizeOfIncludingThis(MallocSizeOf) const; +}; + +class ShaderValidator final { + public: + const ShHandle mHandle; + + private: + const ShCompileOptions mCompileOptions; + const int mMaxVaryingVectors; + + public: + bool mIfNeeded_webgl_gl_VertexID_Offset = false; + + static std::unique_ptr Create( + GLenum shaderType, ShShaderSpec spec, ShShaderOutput outputLanguage, + const ShBuiltInResources& resources, ShCompileOptions compileOptions); + + private: + ShaderValidator(ShHandle handle, ShCompileOptions compileOptions, + int maxVaryingVectors) + : mHandle(handle), + mCompileOptions(compileOptions), + mMaxVaryingVectors(maxVaryingVectors) {} + + public: + ~ShaderValidator(); + + std::unique_ptr ValidateAndTranslate( + const char*) const; +}; + +} // namespace mozilla::webgl + +#endif // WEBGL_SHADER_VALIDATOR_H_ -- cgit v1.2.3