michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef WEBGLUNIFORMINFO_H_ michael@0: #define WEBGLUNIFORMINFO_H_ michael@0: michael@0: #include "angle/ShaderLang.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: struct WebGLUniformInfo { michael@0: uint32_t arraySize; michael@0: bool isArray; michael@0: ShDataType type; michael@0: michael@0: WebGLUniformInfo(uint32_t s = 0, bool a = false, ShDataType t = SH_NONE) michael@0: : arraySize(s), isArray(a), type(t) {} michael@0: michael@0: int ElementSize() const { michael@0: switch (type) { michael@0: case SH_INT: michael@0: case SH_FLOAT: michael@0: case SH_BOOL: michael@0: case SH_SAMPLER_2D: michael@0: case SH_SAMPLER_CUBE: michael@0: return 1; michael@0: case SH_INT_VEC2: michael@0: case SH_FLOAT_VEC2: michael@0: case SH_BOOL_VEC2: michael@0: return 2; michael@0: case SH_INT_VEC3: michael@0: case SH_FLOAT_VEC3: michael@0: case SH_BOOL_VEC3: michael@0: return 3; michael@0: case SH_INT_VEC4: michael@0: case SH_FLOAT_VEC4: michael@0: case SH_BOOL_VEC4: michael@0: case SH_FLOAT_MAT2: michael@0: return 4; michael@0: case SH_FLOAT_MAT3: michael@0: return 9; michael@0: case SH_FLOAT_MAT4: michael@0: return 16; michael@0: default: michael@0: MOZ_ASSERT(false); // should never get here michael@0: return 0; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif