1 #include "precompiled.h"
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.
8 #include "libGLESv2/Uniform.h"
10 #include "common/utilities.h"
15 LinkedUniform::LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize,
16 const int blockIndex, const sh::BlockMemberInfo &blockInfo)
21 blockIndex(blockIndex),
25 psRegisterIndex(GL_INVALID_INDEX),
26 vsRegisterIndex(GL_INVALID_INDEX),
30 // We use data storage for default block uniforms to cache values that are sent to D3D during rendering
31 // Uniform blocks/buffers are treated separately by the Renderer (ES3 path only)
32 if (isInDefaultBlock())
34 size_t bytes = dataSize();
35 data = new unsigned char[bytes];
36 memset(data, 0, bytes);
37 registerCount = VariableRowCount(type) * elementCount();
41 LinkedUniform::~LinkedUniform()
46 bool LinkedUniform::isArray() const
51 unsigned int LinkedUniform::elementCount() const
53 return arraySize > 0 ? arraySize : 1;
56 bool LinkedUniform::isReferencedByVertexShader() const
58 return vsRegisterIndex != GL_INVALID_INDEX;
61 bool LinkedUniform::isReferencedByFragmentShader() const
63 return psRegisterIndex != GL_INVALID_INDEX;
66 bool LinkedUniform::isInDefaultBlock() const
68 return blockIndex == -1;
71 size_t LinkedUniform::dataSize() const
73 ASSERT(type != GL_STRUCT_ANGLEX);
74 return VariableInternalSize(type) * elementCount();
77 bool LinkedUniform::isSampler() const
79 return IsSampler(type);
82 UniformBlock::UniformBlock(const std::string &name, unsigned int elementIndex, unsigned int dataSize)
84 elementIndex(elementIndex),
86 psRegisterIndex(GL_INVALID_INDEX),
87 vsRegisterIndex(GL_INVALID_INDEX)
91 bool UniformBlock::isArrayElement() const
93 return elementIndex != GL_INVALID_INDEX;
96 bool UniformBlock::isReferencedByVertexShader() const
98 return vsRegisterIndex != GL_INVALID_INDEX;
101 bool UniformBlock::isReferencedByFragmentShader() const
103 return psRegisterIndex != GL_INVALID_INDEX;