blob: ed8d490c8e9e2d269da9caa40be1c43c66a343cc [file] [log] [blame]
shannon.woods@transgaming.combdf2d802013-02-28 23:16:20 +00001#include "precompiled.h"
shannonwoods@chromium.org7e0904d2013-05-30 00:06:45 +00002//
3// Copyright (c) 2010-2013 The ANGLE Project Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6//
7
8#include "libGLESv2/Uniform.h"
9
10#include "libGLESv2/utilities.h"
11
12namespace gl
13{
14
15Uniform::Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize)
16 : type(type), precision(precision), name(name), arraySize(arraySize)
17{
18 int bytes = gl::UniformInternalSize(type) * elementCount();
19 data = new unsigned char[bytes];
20 memset(data, 0, bytes);
21 dirty = true;
22
shannonwoods@chromium.org38676dc2013-05-30 00:06:52 +000023 psRegisterIndex = GL_INVALID_INDEX;
24 vsRegisterIndex = GL_INVALID_INDEX;
shannonwoods@chromium.org7e0904d2013-05-30 00:06:45 +000025 registerCount = VariableRowCount(type) * elementCount();
26}
27
28Uniform::~Uniform()
29{
30 delete[] data;
31}
32
33bool Uniform::isArray() const
34{
35 return arraySize > 0;
36}
37
38unsigned int Uniform::elementCount() const
39{
40 return arraySize > 0 ? arraySize : 1;
41}
42
shannonwoods@chromium.org38676dc2013-05-30 00:06:52 +000043bool Uniform::isReferencedByVertexShader() const
44{
45 return vsRegisterIndex != GL_INVALID_INDEX;
46}
47
48bool Uniform::isReferencedByFragmentShader() const
49{
50 return psRegisterIndex != GL_INVALID_INDEX;
51}
52
shannonwoods@chromium.org7e0904d2013-05-30 00:06:45 +000053}