Commit 48705cad by Jamie Madill

Revert "Move Uniform and UBO info to the gl::Program layer."

Seems to be failing dEQP-GLES2.functional.uniform_api.value.unused_uniforms.* on Linux (possibly Win as well) BUG=angleproject:1123 This reverts commit 54f882c9. Change-Id: I7dbbf40aae8dd9ebd35895df0dd338a3b6b9cc96 Reviewed-on: https://chromium-review.googlesource.com/297051Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 54f882c9
...@@ -26,8 +26,6 @@ struct InterfaceBlock; ...@@ -26,8 +26,6 @@ struct InterfaceBlock;
struct COMPILER_EXPORT BlockMemberInfo struct COMPILER_EXPORT BlockMemberInfo
{ {
BlockMemberInfo() : offset(-1), arrayStride(-1), matrixStride(-1), isRowMajorMatrix(false) {}
BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix) BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
: offset(offset), : offset(offset),
arrayStride(arrayStride), arrayStride(arrayStride),
......
...@@ -189,16 +189,6 @@ class Program : angle::NonCopyable ...@@ -189,16 +189,6 @@ class Program : angle::NonCopyable
{ {
return mOutputVariables; return mOutputVariables;
} }
const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; }
const std::vector<VariableLocation> &getUniformLocations() const
{
return mUniformLocations;
}
const std::vector<UniformBlock> &getUniformBlocks() const { return mUniformBlocks; }
const LinkedUniform *getUniformByName(const std::string &name) const;
GLint getUniformLocation(const std::string &name) const;
GLuint getUniformIndex(const std::string &name) const;
private: private:
friend class Program; friend class Program;
...@@ -215,12 +205,10 @@ class Program : angle::NonCopyable ...@@ -215,12 +205,10 @@ class Program : angle::NonCopyable
std::vector<sh::Attribute> mAttributes; std::vector<sh::Attribute> mAttributes;
std::bitset<MAX_VERTEX_ATTRIBS> mActiveAttribLocationsMask; std::bitset<MAX_VERTEX_ATTRIBS> mActiveAttribLocationsMask;
std::vector<LinkedUniform> mUniforms;
std::vector<VariableLocation> mUniformLocations;
std::vector<UniformBlock> mUniformBlocks;
// TODO(jmadill): use unordered/hash map when available // TODO(jmadill): use unordered/hash map when available
std::map<int, VariableLocation> mOutputVariables; std::map<int, VariableLocation> mOutputVariables;
// TODO(jmadill): move more state into Data.
}; };
Program(rx::ImplFactory *factory, ResourceManager *manager, GLuint handle); Program(rx::ImplFactory *factory, ResourceManager *manager, GLuint handle);
...@@ -263,10 +251,11 @@ class Program : angle::NonCopyable ...@@ -263,10 +251,11 @@ class Program : angle::NonCopyable
GLint getActiveUniformMaxLength(); GLint getActiveUniformMaxLength();
GLint getActiveUniformi(GLuint index, GLenum pname) const; GLint getActiveUniformi(GLuint index, GLenum pname) const;
bool isValidUniformLocation(GLint location) const; bool isValidUniformLocation(GLint location) const;
const LinkedUniform &getUniformByLocation(GLint location) const; LinkedUniform *getUniformByLocation(GLint location) const;
LinkedUniform *getUniformByName(const std::string &name) const;
GLint getUniformLocation(const std::string &name) const; GLint getUniformLocation(const std::string &name);
GLuint getUniformIndex(const std::string &name) const; GLuint getUniformIndex(const std::string &name);
void setUniform1fv(GLint location, GLsizei count, const GLfloat *v); void setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform2fv(GLint location, GLsizei count, const GLfloat *v); void setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform3fv(GLint location, GLsizei count, const GLfloat *v); void setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
...@@ -303,7 +292,7 @@ class Program : angle::NonCopyable ...@@ -303,7 +292,7 @@ class Program : angle::NonCopyable
void bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding); void bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding);
GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const; GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const;
const UniformBlock &getUniformBlockByIndex(GLuint index) const; const UniformBlock *getUniformBlockByIndex(GLuint index) const;
void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode); void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode);
void getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const; void getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const;
...@@ -341,8 +330,7 @@ class Program : angle::NonCopyable ...@@ -341,8 +330,7 @@ class Program : angle::NonCopyable
static bool linkVaryings(InfoLog &infoLog, static bool linkVaryings(InfoLog &infoLog,
const Shader *vertexShader, const Shader *vertexShader,
const Shader *fragmentShader); const Shader *fragmentShader);
bool linkUniforms(gl::InfoLog &infoLog, const gl::Caps &caps); bool linkUniforms(gl::InfoLog &infoLog, const gl::Caps &caps) const;
void indexUniforms();
bool areMatchingInterfaceBlocks(gl::InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, bool areMatchingInterfaceBlocks(gl::InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock,
const sh::InterfaceBlock &fragmentInterfaceBlock); const sh::InterfaceBlock &fragmentInterfaceBlock);
...@@ -364,31 +352,6 @@ class Program : angle::NonCopyable ...@@ -364,31 +352,6 @@ class Program : angle::NonCopyable
std::vector<const sh::Varying *> getMergedVaryings() const; std::vector<const sh::Varying *> getMergedVaryings() const;
void linkOutputVariables(); void linkOutputVariables();
bool flattenUniformsAndCheckCaps(const Caps &caps, InfoLog &infoLog);
struct VectorAndSamplerCount
{
VectorAndSamplerCount() : vectorCount(0), samplerCount(0) {}
VectorAndSamplerCount(const VectorAndSamplerCount &other) = default;
VectorAndSamplerCount &operator=(const VectorAndSamplerCount &other) = default;
VectorAndSamplerCount &operator+=(const VectorAndSamplerCount &other)
{
vectorCount += other.vectorCount;
samplerCount += other.samplerCount;
return *this;
}
unsigned int vectorCount;
unsigned int samplerCount;
};
VectorAndSamplerCount flattenUniform(const sh::ShaderVariable &uniform,
const std::string &fullName);
void gatherInterfaceBlockInfo();
void defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenum shaderType);
Data mData; Data mData;
rx::ProgramImpl *mProgram; rx::ProgramImpl *mProgram;
......
...@@ -13,32 +13,55 @@ ...@@ -13,32 +13,55 @@
namespace gl namespace gl
{ {
LinkedUniform::LinkedUniform() LinkedUniform::LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize,
: blockIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo()) const int blockIndex, const sh::BlockMemberInfo &blockInfo)
: type(type),
precision(precision),
name(name),
arraySize(arraySize),
blockIndex(blockIndex),
blockInfo(blockInfo),
data(NULL),
dirty(true),
psRegisterIndex(GL_INVALID_INDEX),
vsRegisterIndex(GL_INVALID_INDEX),
registerCount(0),
registerElement(0)
{ {
// We use data storage for default block uniforms to cache values that are sent to D3D during rendering
// Uniform blocks/buffers are treated separately by the Renderer (ES3 path only)
if (isInDefaultBlock())
{
size_t bytes = dataSize();
data = new unsigned char[bytes];
memset(data, 0, bytes);
registerCount = VariableRowCount(type) * elementCount();
}
} }
LinkedUniform::LinkedUniform(GLenum typeIn, LinkedUniform::~LinkedUniform()
GLenum precisionIn,
const std::string &nameIn,
unsigned int arraySizeIn,
const int blockIndexIn,
const sh::BlockMemberInfo &blockInfoIn)
: blockIndex(blockIndexIn), blockInfo(blockInfoIn)
{ {
type = typeIn; delete[] data;
precision = precisionIn;
name = nameIn;
arraySize = arraySizeIn;
} }
LinkedUniform::LinkedUniform(const sh::Uniform &uniform) bool LinkedUniform::isArray() const
: sh::Uniform(uniform), blockIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo())
{ {
return arraySize > 0;
} }
LinkedUniform::~LinkedUniform() unsigned int LinkedUniform::elementCount() const
{
return arraySize > 0 ? arraySize : 1;
}
bool LinkedUniform::isReferencedByVertexShader() const
{
return vsRegisterIndex != GL_INVALID_INDEX;
}
bool LinkedUniform::isReferencedByFragmentShader() const
{ {
return psRegisterIndex != GL_INVALID_INDEX;
} }
bool LinkedUniform::isInDefaultBlock() const bool LinkedUniform::isInDefaultBlock() const
...@@ -57,32 +80,33 @@ bool LinkedUniform::isSampler() const ...@@ -57,32 +80,33 @@ bool LinkedUniform::isSampler() const
return IsSamplerType(type); return IsSamplerType(type);
} }
bool LinkedUniform::isField() const bool LinkedUniform::isBuiltIn() const
{ {
return name.find('.') != std::string::npos; return name.compare(0, 3, "gl_") == 0;
} }
UniformBlock::UniformBlock() UniformBlock::UniformBlock(const std::string &name, unsigned int elementIndex, unsigned int dataSize)
: isArray(false), : name(name),
arrayElement(0), elementIndex(elementIndex),
dataSize(0), dataSize(dataSize),
vertexStaticUse(false),
fragmentStaticUse(false),
psRegisterIndex(GL_INVALID_INDEX), psRegisterIndex(GL_INVALID_INDEX),
vsRegisterIndex(GL_INVALID_INDEX) vsRegisterIndex(GL_INVALID_INDEX)
{ {
} }
UniformBlock::UniformBlock(const std::string &nameIn, bool isArrayIn, unsigned int arrayElementIn) bool UniformBlock::isArrayElement() const
: name(nameIn), {
isArray(isArrayIn), return elementIndex != GL_INVALID_INDEX;
arrayElement(arrayElementIn), }
dataSize(0),
vertexStaticUse(false), bool UniformBlock::isReferencedByVertexShader() const
fragmentStaticUse(false), {
psRegisterIndex(GL_INVALID_INDEX), return vsRegisterIndex != GL_INVALID_INDEX;
vsRegisterIndex(GL_INVALID_INDEX) }
bool UniformBlock::isReferencedByFragmentShader() const
{ {
return psRegisterIndex != GL_INVALID_INDEX;
} }
} }
...@@ -19,39 +19,53 @@ namespace gl ...@@ -19,39 +19,53 @@ namespace gl
{ {
// Helper struct representing a single shader uniform // Helper struct representing a single shader uniform
struct LinkedUniform : public sh::Uniform struct LinkedUniform : angle::NonCopyable
{ {
LinkedUniform();
LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const sh::BlockMemberInfo &blockInfo); LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const sh::BlockMemberInfo &blockInfo);
LinkedUniform(const sh::Uniform &uniform);
LinkedUniform(const LinkedUniform &uniform) = default;
LinkedUniform &operator=(const LinkedUniform &uniform) = default;
~LinkedUniform(); ~LinkedUniform();
bool isArray() const;
unsigned int elementCount() const;
bool isReferencedByVertexShader() const;
bool isReferencedByFragmentShader() const;
bool isInDefaultBlock() const;
size_t dataSize() const; size_t dataSize() const;
bool isSampler() const; bool isSampler() const;
bool isInDefaultBlock() const; bool isBuiltIn() const;
bool isField() const;
const GLenum type;
const GLenum precision;
const std::string name;
const unsigned int arraySize;
const int blockIndex;
const sh::BlockMemberInfo blockInfo;
unsigned char *data;
bool dirty;
int blockIndex; unsigned int psRegisterIndex;
sh::BlockMemberInfo blockInfo; unsigned int vsRegisterIndex;
unsigned int registerCount;
// Register "elements" are used for uniform structs in ES3, to appropriately identify single uniforms
// inside aggregate types, which are packed according C-like structure rules.
unsigned int registerElement;
}; };
// Helper struct representing a single shader uniform block // Helper struct representing a single shader uniform block
struct UniformBlock struct UniformBlock : angle::NonCopyable
{ {
UniformBlock(); // use GL_INVALID_INDEX for non-array elements
UniformBlock(const std::string &nameIn, bool isArrayIn, unsigned int arrayElementIn); UniformBlock(const std::string &name, unsigned int elementIndex, unsigned int dataSize);
UniformBlock(const UniformBlock &other) = default;
UniformBlock &operator=(const UniformBlock &other) = default; bool isArrayElement() const;
bool isReferencedByVertexShader() const;
std::string name; bool isReferencedByFragmentShader() const;
bool isArray;
unsigned int arrayElement; const std::string name;
unsigned int dataSize; const unsigned int elementIndex;
const unsigned int dataSize;
bool vertexStaticUse;
bool fragmentStaticUse;
std::vector<unsigned int> memberUniformIndexes; std::vector<unsigned int> memberUniformIndexes;
......
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ProgramD3D.cpp: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
#include "libANGLE/renderer/ProgramImpl.h"
#include "common/utilities.h"
namespace rx
{
LinkResult::LinkResult(bool linkSuccess, const gl::Error &error)
: linkSuccess(linkSuccess),
error(error)
{
}
ProgramImpl::ProgramImpl(const gl::Program::Data &data) : mData(data)
{
}
ProgramImpl::~ProgramImpl()
{
// Ensure that reset was called by the inherited class during destruction
ASSERT(mUniformIndex.size() == 0);
}
gl::LinkedUniform *ProgramImpl::getUniformByLocation(GLint location) const
{
ASSERT(location >= 0 && mUniformIndex.find(location) != mUniformIndex.end());
return mUniforms[mUniformIndex.at(location).index];
}
gl::LinkedUniform *ProgramImpl::getUniformByName(const std::string &name) const
{
for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
{
if (mUniforms[uniformIndex]->name == name)
{
return mUniforms[uniformIndex];
}
}
return NULL;
}
gl::UniformBlock *ProgramImpl::getUniformBlockByIndex(GLuint blockIndex) const
{
ASSERT(blockIndex < mUniformBlocks.size());
return mUniformBlocks[blockIndex];
}
GLint ProgramImpl::getUniformLocation(const std::string &name) const
{
size_t subscript = GL_INVALID_INDEX;
std::string baseName = gl::ParseUniformName(name, &subscript);
for (const auto &info : mUniformIndex)
{
GLuint location = info.first;
const gl::VariableLocation &uniform = info.second;
if (uniform.name == baseName)
{
const bool isArray = mUniforms[uniform.index]->isArray();
if ((isArray && uniform.element == subscript) ||
(subscript == GL_INVALID_INDEX))
{
return location;
}
}
}
return -1;
}
GLuint ProgramImpl::getUniformIndex(const std::string &name) const
{
size_t subscript = GL_INVALID_INDEX;
std::string baseName = gl::ParseUniformName(name, &subscript);
// The app is not allowed to specify array indices other than 0 for arrays of basic types
if (subscript != 0 && subscript != GL_INVALID_INDEX)
{
return GL_INVALID_INDEX;
}
unsigned int numUniforms = static_cast<unsigned int>(mUniforms.size());
for (unsigned int index = 0; index < numUniforms; index++)
{
if (mUniforms[index]->name == baseName)
{
if (mUniforms[index]->isArray() || subscript == GL_INVALID_INDEX)
{
return index;
}
}
}
return GL_INVALID_INDEX;
}
GLuint ProgramImpl::getUniformBlockIndex(const std::string &name) const
{
size_t subscript = GL_INVALID_INDEX;
std::string baseName = gl::ParseUniformName(name, &subscript);
unsigned int numUniformBlocks = static_cast<unsigned int>(mUniformBlocks.size());
for (unsigned int blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++)
{
const gl::UniformBlock &uniformBlock = *mUniformBlocks[blockIndex];
if (uniformBlock.name == baseName)
{
const bool arrayElementZero = (subscript == GL_INVALID_INDEX && uniformBlock.elementIndex == 0);
if (subscript == uniformBlock.elementIndex || arrayElementZero)
{
return blockIndex;
}
}
}
return GL_INVALID_INDEX;
}
void ProgramImpl::reset()
{
SafeDeleteContainer(mUniforms);
mUniformIndex.clear();
SafeDeleteContainer(mUniformBlocks);
}
}
...@@ -23,17 +23,16 @@ namespace rx ...@@ -23,17 +23,16 @@ namespace rx
struct LinkResult struct LinkResult
{ {
LinkResult(bool linkSuccess, const gl::Error &error) : linkSuccess(linkSuccess), error(error) {}
bool linkSuccess; bool linkSuccess;
gl::Error error; gl::Error error;
LinkResult(bool linkSuccess, const gl::Error &error);
}; };
class ProgramImpl : angle::NonCopyable class ProgramImpl : angle::NonCopyable
{ {
public: public:
ProgramImpl(const gl::Program::Data &data) : mData(data) {} ProgramImpl(const gl::Program::Data &data);
virtual ~ProgramImpl() {} virtual ~ProgramImpl();
virtual int getShaderVersion() const = 0; virtual int getShaderVersion() const = 0;
...@@ -74,12 +73,33 @@ class ProgramImpl : angle::NonCopyable ...@@ -74,12 +73,33 @@ class ProgramImpl : angle::NonCopyable
// determine if they can be removed from this interface. // determine if they can be removed from this interface.
virtual bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) = 0; virtual bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) = 0;
// Gather uniform block active uniform indices, and uniform block offset info. const std::vector<gl::LinkedUniform*> &getUniforms() const { return mUniforms; }
virtual void gatherUniformBlockInfo(std::vector<gl::UniformBlock> *uniformBlocks, const std::map<GLuint, gl::VariableLocation> &getUniformIndices() const { return mUniformIndex; }
std::vector<gl::LinkedUniform> *uniforms) = 0; const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; }
std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; }
std::map<GLuint, gl::VariableLocation> &getUniformIndices() { return mUniformIndex; }
std::vector<gl::UniformBlock*> &getUniformBlocks() { return mUniformBlocks; }
gl::LinkedUniform *getUniformByLocation(GLint location) const;
gl::LinkedUniform *getUniformByName(const std::string &name) const;
gl::UniformBlock *getUniformBlockByIndex(GLuint blockIndex) const;
GLint getUniformLocation(const std::string &name) const;
GLuint getUniformIndex(const std::string &name) const;
GLuint getUniformBlockIndex(const std::string &name) const;
virtual void reset();
protected: protected:
const gl::Program::Data &mData; const gl::Program::Data &mData;
std::vector<gl::LinkedUniform*> mUniforms;
// TODO: use a hash map
std::map<GLuint, gl::VariableLocation> mUniformIndex;
std::vector<gl::UniformBlock*> mUniformBlocks;
}; };
} }
......
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
#include "libANGLE/renderer/d3d/DynamicHLSL.h" #include "libANGLE/renderer/d3d/DynamicHLSL.h"
#include "libANGLE/renderer/d3d/WorkaroundsD3D.h" #include "libANGLE/renderer/d3d/WorkaroundsD3D.h"
namespace gl
{
struct LinkedUniform;
struct VariableLocation;
struct VertexFormat;
}
namespace rx namespace rx
{ {
class RendererD3D; class RendererD3D;
...@@ -32,42 +39,6 @@ class ShaderExecutableD3D; ...@@ -32,42 +39,6 @@ class ShaderExecutableD3D;
#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL1 #define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL1
#endif #endif
// Helper struct representing a single shader uniform
struct D3DUniform
{
D3DUniform(GLenum typeIn,
const std::string &nameIn,
unsigned int arraySizeIn,
bool defaultBlock);
~D3DUniform();
bool isSampler() const;
unsigned int elementCount() const { return std::max(1u, arraySize); }
bool isReferencedByVertexShader() const;
bool isReferencedByFragmentShader() const;
// Duplicated from the GL layer
GLenum type;
std::string name;
unsigned int arraySize;
// Pointer to a system copy of the data.
unsigned char *data;
// Has the data been updated since the last sync?
bool dirty;
// Register information.
unsigned int vsRegisterIndex;
unsigned int psRegisterIndex;
unsigned int registerCount;
// Register "elements" are used for uniform structs in ES3, to appropriately identify single
// uniforms
// inside aggregate types, which are packed according C-like structure rules.
unsigned int registerElement;
};
class ProgramD3D : public ProgramImpl class ProgramD3D : public ProgramImpl
{ {
public: public:
...@@ -102,12 +73,13 @@ class ProgramD3D : public ProgramImpl ...@@ -102,12 +73,13 @@ class ProgramD3D : public ProgramImpl
LinkResult link(const gl::Data &data, gl::InfoLog &infoLog) override; LinkResult link(const gl::Data &data, gl::InfoLog &infoLog) override;
GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override; GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override;
void gatherUniformBlockInfo(std::vector<gl::UniformBlock> *uniformBlocks,
std::vector<gl::LinkedUniform> *uniforms) override;
void initializeUniformStorage(); void initializeUniformStorage();
gl::Error applyUniforms(); gl::Error applyUniforms();
gl::Error applyUniformBuffers(const gl::Data &data); gl::Error applyUniformBuffers(const gl::Data &data);
void assignUniformBlockRegister(gl::UniformBlock *uniformBlock,
GLenum shader,
unsigned int registerIndex,
const gl::Caps &caps);
void dirtyAllUniforms(); void dirtyAllUniforms();
void setUniform1fv(GLint location, GLsizei count, const GLfloat *v); void setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
...@@ -139,6 +111,8 @@ class ProgramD3D : public ProgramImpl ...@@ -139,6 +111,8 @@ class ProgramD3D : public ProgramImpl
const UniformStorageD3D &getVertexUniformStorage() const { return *mVertexUniformStorage; } const UniformStorageD3D &getVertexUniformStorage() const { return *mVertexUniformStorage; }
const UniformStorageD3D &getFragmentUniformStorage() const { return *mFragmentUniformStorage; } const UniformStorageD3D &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
void reset();
unsigned int getSerial() const; unsigned int getSerial() const;
void sortAttributesByLayout(const std::vector<TranslatedAttribute> &unsortedAttributes, void sortAttributesByLayout(const std::vector<TranslatedAttribute> &unsortedAttributes,
...@@ -201,24 +175,19 @@ class ProgramD3D : public ProgramImpl ...@@ -201,24 +175,19 @@ class ProgramD3D : public ProgramImpl
GLenum textureType; GLenum textureType;
}; };
typedef std::map<std::string, sh::BlockMemberInfo> BlockInfoMap; bool defineUniforms(gl::InfoLog &infoLog, const gl::Caps &caps);
void defineUniformBase(const ShaderD3D *shader, const sh::Uniform &uniform, unsigned int uniformRegister);
void assignUniformRegisters(); void defineUniform(const ShaderD3D *shader, const sh::ShaderVariable &uniform, const std::string &fullName,
void assignUniformRegistersBase(const ShaderD3D *shader, const sh::Uniform &uniform); sh::HLSLBlockEncoder *encoder);
void assignUniformRegisters(const ShaderD3D *shader, bool indexSamplerUniform(const gl::LinkedUniform &uniform, gl::InfoLog &infoLog, const gl::Caps &caps);
const sh::ShaderVariable &uniform, bool indexUniforms(gl::InfoLog &infoLog, const gl::Caps &caps);
const std::string &fullName, static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount,
sh::HLSLBlockEncoder *encoder); std::vector<Sampler> &outSamplers, GLuint *outUsedRange);
void assignAllSamplerRegisters();
void assignSamplerRegisters(const D3DUniform *d3dUniform);
static void AssignSamplers(unsigned int startSamplerIndex,
GLenum samplerType,
unsigned int samplerCount,
std::vector<Sampler> &outSamplers,
GLuint *outUsedRange);
size_t defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, BlockInfoMap *blockInfoOut); void defineUniformBlocks(const gl::Caps &caps);
void defineUniformBlock(const gl::Shader &shader,
const sh::InterfaceBlock &interfaceBlock,
const gl::Caps &caps);
template <typename T> template <typename T>
void setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType); void setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
...@@ -229,19 +198,20 @@ class ProgramD3D : public ProgramImpl ...@@ -229,19 +198,20 @@ class ProgramD3D : public ProgramImpl
template <typename T> template <typename T>
void getUniformv(GLint location, T *params, GLenum uniformType); void getUniformv(GLint location, T *params, GLenum uniformType);
template <typename VarT>
void defineUniformBlockMembers(const std::vector<VarT> &fields, const std::string &prefix, int blockIndex,
sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes,
bool inRowMajorLayout);
LinkResult compileProgramExecutables(gl::InfoLog &infoLog, LinkResult compileProgramExecutables(gl::InfoLog &infoLog,
int registers, int registers,
const std::vector<PackedVarying> &packedVaryings); const std::vector<PackedVarying> &packedVaryings);
void gatherTransformFeedbackVaryings(const std::vector<gl::LinkedVarying> &varyings); void gatherTransformFeedbackVaryings(const std::vector<gl::LinkedVarying> &varyings);
D3DUniform *getD3DUniformByName(const std::string &name);
D3DUniform *getD3DUniformFromLocation(GLint location);
void initSemanticIndex(); void initSemanticIndex();
void initAttributesByLayout(); void initAttributesByLayout();
void reset();
RendererD3D *mRenderer; RendererD3D *mRenderer;
DynamicHLSL *mDynamicHLSL; DynamicHLSL *mDynamicHLSL;
...@@ -289,7 +259,6 @@ class ProgramD3D : public ProgramImpl ...@@ -289,7 +259,6 @@ class ProgramD3D : public ProgramImpl
gl::InputLayout mCachedInputLayout; gl::InputLayout mCachedInputLayout;
std::vector<gl::LinkedVarying> mTransformFeedbackLinkedVaryings; std::vector<gl::LinkedVarying> mTransformFeedbackLinkedVaryings;
std::vector<D3DUniform *> mD3DUniforms;
static unsigned int issueSerial(); static unsigned int issueSerial();
static unsigned int mCurrentSerial; static unsigned int mCurrentSerial;
......
...@@ -37,10 +37,8 @@ class DebugAnnotator; ...@@ -37,10 +37,8 @@ class DebugAnnotator;
namespace rx namespace rx
{ {
struct D3DUniform;
class ImageD3D; class ImageD3D;
class IndexBuffer; class IndexBuffer;
class ProgramD3D;
class RenderTargetD3D; class RenderTargetD3D;
class ShaderExecutableD3D; class ShaderExecutableD3D;
class SwapChainD3D; class SwapChainD3D;
...@@ -159,8 +157,7 @@ class RendererD3D : public Renderer, public BufferFactoryD3D ...@@ -159,8 +157,7 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
const gl::Framebuffer *framebuffer, const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool rasterizerDiscard,
bool transformFeedbackActive) = 0; bool transformFeedbackActive) = 0;
virtual gl::Error applyUniforms(const ProgramD3D &programD3D, virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0;
const std::vector<D3DUniform *> &uniformArray) = 0;
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount, bool usesPointSize) = 0; virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount, bool usesPointSize) = 0;
virtual gl::Error applyVertexBuffer(const gl::State &state, GLenum mode, GLint first, GLsizei count, GLsizei instances, SourceIndexData *sourceIndexInfo) = 0; virtual gl::Error applyVertexBuffer(const gl::State &state, GLenum mode, GLint first, GLsizei count, GLsizei instances, SourceIndexData *sourceIndexInfo) = 0;
virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo, SourceIndexData *sourceIndexInfo) = 0; virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo, SourceIndexData *sourceIndexInfo) = 0;
......
...@@ -2095,8 +2095,7 @@ gl::Error Renderer11::applyShaders(gl::Program *program, ...@@ -2095,8 +2095,7 @@ gl::Error Renderer11::applyShaders(gl::Program *program,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, gl::Error Renderer11::applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray)
const std::vector<D3DUniform *> &uniformArray)
{ {
unsigned int totalRegisterCountVS = 0; unsigned int totalRegisterCountVS = 0;
unsigned int totalRegisterCountPS = 0; unsigned int totalRegisterCountPS = 0;
...@@ -2104,25 +2103,26 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, ...@@ -2104,25 +2103,26 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D,
bool vertexUniformsDirty = false; bool vertexUniformsDirty = false;
bool pixelUniformsDirty = false; bool pixelUniformsDirty = false;
for (const D3DUniform *uniform : uniformArray) for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
{ {
if (uniform->isReferencedByVertexShader() && !uniform->isSampler()) const gl::LinkedUniform &uniform = *uniformArray[uniformIndex];
if (uniform.isReferencedByVertexShader() && !uniform.isSampler())
{ {
totalRegisterCountVS += uniform->registerCount; totalRegisterCountVS += uniform.registerCount;
vertexUniformsDirty = (vertexUniformsDirty || uniform->dirty); vertexUniformsDirty = (vertexUniformsDirty || uniform.dirty);
} }
if (uniform->isReferencedByFragmentShader() && !uniform->isSampler()) if (uniform.isReferencedByFragmentShader() && !uniform.isSampler())
{ {
totalRegisterCountPS += uniform->registerCount; totalRegisterCountPS += uniform.registerCount;
pixelUniformsDirty = (pixelUniformsDirty || uniform->dirty); pixelUniformsDirty = (pixelUniformsDirty || uniform.dirty);
} }
} }
const UniformStorage11 *vertexUniformStorage = const ProgramD3D *programD3D = GetAs<ProgramD3D>(&program);
GetAs<UniformStorage11>(&programD3D.getVertexUniformStorage()); const UniformStorage11 *vertexUniformStorage = GetAs<UniformStorage11>(&programD3D->getVertexUniformStorage());
const UniformStorage11 *fragmentUniformStorage = const UniformStorage11 *fragmentUniformStorage = GetAs<UniformStorage11>(&programD3D->getFragmentUniformStorage());
GetAs<UniformStorage11>(&programD3D.getFragmentUniformStorage());
ASSERT(vertexUniformStorage); ASSERT(vertexUniformStorage);
ASSERT(fragmentUniformStorage); ASSERT(fragmentUniformStorage);
...@@ -2150,26 +2150,26 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, ...@@ -2150,26 +2150,26 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D,
mapPS = (float(*)[4])map.pData; mapPS = (float(*)[4])map.pData;
} }
for (const D3DUniform *uniform : uniformArray) for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
{ {
if (uniform->isSampler()) gl::LinkedUniform *uniform = uniformArray[uniformIndex];
continue;
unsigned int componentCount = (4 - uniform->registerElement); if (!uniform->isSampler())
{
unsigned int componentCount = (4 - uniform->registerElement);
// we assume that uniforms from structs are arranged in struct order in our uniforms list. // we assume that uniforms from structs are arranged in struct order in our uniforms list. otherwise we would
// otherwise we would overwrite previously written regions of memory. // overwrite previously written regions of memory.
if (uniform->isReferencedByVertexShader() && mapVS) if (uniform->isReferencedByVertexShader() && mapVS)
{ {
memcpy(&mapVS[uniform->vsRegisterIndex][uniform->registerElement], uniform->data, memcpy(&mapVS[uniform->vsRegisterIndex][uniform->registerElement], uniform->data, uniform->registerCount * sizeof(float) * componentCount);
uniform->registerCount * sizeof(float) * componentCount); }
}
if (uniform->isReferencedByFragmentShader() && mapPS) if (uniform->isReferencedByFragmentShader() && mapPS)
{ {
memcpy(&mapPS[uniform->psRegisterIndex][uniform->registerElement], uniform->data, memcpy(&mapPS[uniform->psRegisterIndex][uniform->registerElement], uniform->data, uniform->registerCount * sizeof(float) * componentCount);
uniform->registerCount * sizeof(float) * componentCount); }
} }
} }
...@@ -2255,7 +2255,7 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D, ...@@ -2255,7 +2255,7 @@ gl::Error Renderer11::applyUniforms(const ProgramD3D &programD3D,
} }
// GSSetConstantBuffers triggers device removal on 9_3, so we should only call it if necessary // GSSetConstantBuffers triggers device removal on 9_3, so we should only call it if necessary
if (programD3D.usesGeometryShader()) if (programD3D->usesGeometryShader())
{ {
// needed for the point sprite geometry shader // needed for the point sprite geometry shader
if (mCurrentGeometryConstantBuffer != mDriverConstantBufferPS) if (mCurrentGeometryConstantBuffer != mDriverConstantBufferPS)
......
...@@ -137,8 +137,7 @@ class Renderer11 : public RendererD3D ...@@ -137,8 +137,7 @@ class Renderer11 : public RendererD3D
bool rasterizerDiscard, bool rasterizerDiscard,
bool transformFeedbackActive) override; bool transformFeedbackActive) override;
gl::Error applyUniforms(const ProgramD3D &programD3D, virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
const std::vector<D3DUniform *> &uniformArray) override;
virtual gl::Error applyVertexBuffer(const gl::State &state, GLenum mode, GLint first, GLsizei count, GLsizei instances, SourceIndexData *sourceIndexInfo); virtual gl::Error applyVertexBuffer(const gl::State &state, GLenum mode, GLint first, GLsizei count, GLsizei instances, SourceIndexData *sourceIndexInfo);
virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo, SourceIndexData *sourceIndexInfo); virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo, SourceIndexData *sourceIndexInfo);
void applyTransformFeedbackBuffers(const gl::State &state) override; void applyTransformFeedbackBuffers(const gl::State &state) override;
......
...@@ -1910,45 +1910,46 @@ gl::Error Renderer9::applyShaders(gl::Program *program, ...@@ -1910,45 +1910,46 @@ gl::Error Renderer9::applyShaders(gl::Program *program,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer9::applyUniforms(const ProgramD3D &programD3D, gl::Error Renderer9::applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray)
const std::vector<D3DUniform *> &uniformArray)
{ {
for (const D3DUniform *targetUniform : uniformArray) for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
{ {
if (!targetUniform->dirty) gl::LinkedUniform *targetUniform = uniformArray[uniformIndex];
continue;
GLfloat *f = (GLfloat *)targetUniform->data; if (targetUniform->dirty)
GLint *i = (GLint *)targetUniform->data;
switch (targetUniform->type)
{ {
case GL_SAMPLER_2D: GLfloat *f = (GLfloat*)targetUniform->data;
case GL_SAMPLER_CUBE: GLint *i = (GLint*)targetUniform->data;
switch (targetUniform->type)
{
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
break; break;
case GL_BOOL: case GL_BOOL:
case GL_BOOL_VEC2: case GL_BOOL_VEC2:
case GL_BOOL_VEC3: case GL_BOOL_VEC3:
case GL_BOOL_VEC4: case GL_BOOL_VEC4:
applyUniformnbv(targetUniform, i); applyUniformnbv(targetUniform, i);
break; break;
case GL_FLOAT: case GL_FLOAT:
case GL_FLOAT_VEC2: case GL_FLOAT_VEC2:
case GL_FLOAT_VEC3: case GL_FLOAT_VEC3:
case GL_FLOAT_VEC4: case GL_FLOAT_VEC4:
case GL_FLOAT_MAT2: case GL_FLOAT_MAT2:
case GL_FLOAT_MAT3: case GL_FLOAT_MAT3:
case GL_FLOAT_MAT4: case GL_FLOAT_MAT4:
applyUniformnfv(targetUniform, f); applyUniformnfv(targetUniform, f);
break; break;
case GL_INT: case GL_INT:
case GL_INT_VEC2: case GL_INT_VEC2:
case GL_INT_VEC3: case GL_INT_VEC3:
case GL_INT_VEC4: case GL_INT_VEC4:
applyUniformniv(targetUniform, i); applyUniformniv(targetUniform, i);
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
}
} }
} }
...@@ -1963,7 +1964,7 @@ gl::Error Renderer9::applyUniforms(const ProgramD3D &programD3D, ...@@ -1963,7 +1964,7 @@ gl::Error Renderer9::applyUniforms(const ProgramD3D &programD3D,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
void Renderer9::applyUniformnfv(const D3DUniform *targetUniform, const GLfloat *v) void Renderer9::applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v)
{ {
if (targetUniform->isReferencedByFragmentShader()) if (targetUniform->isReferencedByFragmentShader())
{ {
...@@ -1976,7 +1977,7 @@ void Renderer9::applyUniformnfv(const D3DUniform *targetUniform, const GLfloat * ...@@ -1976,7 +1977,7 @@ void Renderer9::applyUniformnfv(const D3DUniform *targetUniform, const GLfloat *
} }
} }
void Renderer9::applyUniformniv(const D3DUniform *targetUniform, const GLint *v) void Renderer9::applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v)
{ {
ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9); ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4]; GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
...@@ -1992,7 +1993,7 @@ void Renderer9::applyUniformniv(const D3DUniform *targetUniform, const GLint *v) ...@@ -1992,7 +1993,7 @@ void Renderer9::applyUniformniv(const D3DUniform *targetUniform, const GLint *v)
applyUniformnfv(targetUniform, (GLfloat*)vector); applyUniformnfv(targetUniform, (GLfloat*)vector);
} }
void Renderer9::applyUniformnbv(const D3DUniform *targetUniform, const GLint *v) void Renderer9::applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v)
{ {
ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9); ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4]; GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
......
...@@ -32,12 +32,10 @@ namespace rx ...@@ -32,12 +32,10 @@ namespace rx
{ {
class Blit9; class Blit9;
class IndexDataManager; class IndexDataManager;
class ProgramD3D;
class StreamingIndexBufferInterface; class StreamingIndexBufferInterface;
class StaticIndexBufferInterface; class StaticIndexBufferInterface;
class VertexDataManager; class VertexDataManager;
struct ClearParameters; struct ClearParameters;
struct D3DUniform;
struct TranslatedAttribute; struct TranslatedAttribute;
enum D3D9InitError enum D3D9InitError
...@@ -113,8 +111,7 @@ class Renderer9 : public RendererD3D ...@@ -113,8 +111,7 @@ class Renderer9 : public RendererD3D
const gl::Framebuffer *framebuffer, const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool rasterizerDiscard,
bool transformFeedbackActive) override; bool transformFeedbackActive) override;
gl::Error applyUniforms(const ProgramD3D &programD3D, virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
const std::vector<D3DUniform *> &uniformArray) override;
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount, bool usesPointSize); virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount, bool usesPointSize);
virtual gl::Error applyVertexBuffer(const gl::State &state, GLenum mode, GLint first, GLsizei count, GLsizei instances, SourceIndexData *sourceInfo); virtual gl::Error applyVertexBuffer(const gl::State &state, GLenum mode, GLint first, GLsizei count, GLsizei instances, SourceIndexData *sourceInfo);
virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo, SourceIndexData *sourceIndexInfo); virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo, SourceIndexData *sourceIndexInfo);
...@@ -261,9 +258,9 @@ class Renderer9 : public RendererD3D ...@@ -261,9 +258,9 @@ class Renderer9 : public RendererD3D
void release(); void release();
void applyUniformnfv(const D3DUniform *targetUniform, const GLfloat *v); void applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v);
void applyUniformniv(const D3DUniform *targetUniform, const GLint *v); void applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v);
void applyUniformnbv(const D3DUniform *targetUniform, const GLint *v); void applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v);
gl::Error drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); gl::Error drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
gl::Error drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); gl::Error drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
......
...@@ -68,29 +68,26 @@ class ProgramGL : public ProgramImpl ...@@ -68,29 +68,26 @@ class ProgramGL : public ProgramImpl
bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) override; bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) override;
void gatherUniformBlockInfo(std::vector<gl::UniformBlock> *uniformBlocks, void reset() override;
std::vector<gl::LinkedUniform> *uniforms) override;
GLuint getProgramID() const; GLuint getProgramID() const;
const std::vector<SamplerBindingGL> &getAppliedSamplerUniforms() const; const std::vector<SamplerBindingGL> &getAppliedSamplerUniforms() const;
private: private:
void reset();
// Helper function, makes it simpler to type.
GLint uniLoc(GLint glLocation) const { return mUniformRealLocationMap[glLocation]; }
const FunctionsGL *mFunctions; const FunctionsGL *mFunctions;
StateManagerGL *mStateManager; StateManagerGL *mStateManager;
std::vector<GLint> mUniformRealLocationMap; // A map from uniform location to index of mSamplerBindings and array index of the uniform
struct SamplerLocation
{
size_t samplerIndex;
size_t arrayIndex;
};
std::map<GLint, SamplerLocation> mSamplerUniformMap;
// An array of the samplers that are used by the program // An array of the samplers that are used by the program
std::vector<SamplerBindingGL> mSamplerBindings; std::vector<SamplerBindingGL> mSamplerBindings;
// A map from a mData.getUniforms() index to a mSamplerBindings index.
std::vector<size_t> mUniformIndexToSamplerIndex;
GLuint mProgramID; GLuint mProgramID;
}; };
......
...@@ -1096,11 +1096,8 @@ bool ValidateEndQuery(gl::Context *context, GLenum target) ...@@ -1096,11 +1096,8 @@ bool ValidateEndQuery(gl::Context *context, GLenum target)
return true; return true;
} }
static bool ValidateUniformCommonBase(gl::Context *context, static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniformType,
GLenum targetUniformType, GLint location, GLsizei count, LinkedUniform **uniformOut)
GLint location,
GLsizei count,
const LinkedUniform **uniformOut)
{ {
if (count < 0) if (count < 0)
{ {
...@@ -1127,16 +1124,16 @@ static bool ValidateUniformCommonBase(gl::Context *context, ...@@ -1127,16 +1124,16 @@ static bool ValidateUniformCommonBase(gl::Context *context,
return false; return false;
} }
const LinkedUniform &uniform = program->getUniformByLocation(location); LinkedUniform *uniform = program->getUniformByLocation(location);
// attempting to write an array to a non-array uniform is an INVALID_OPERATION // attempting to write an array to a non-array uniform is an INVALID_OPERATION
if (!uniform.isArray() && count > 1) if (!uniform->isArray() && count > 1)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
} }
*uniformOut = &uniform; *uniformOut = uniform;
return true; return true;
} }
...@@ -1149,7 +1146,7 @@ bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, G ...@@ -1149,7 +1146,7 @@ bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, G
return false; return false;
} }
const LinkedUniform *uniform = nullptr; LinkedUniform *uniform = NULL;
if (!ValidateUniformCommonBase(context, uniformType, location, count, &uniform)) if (!ValidateUniformCommonBase(context, uniformType, location, count, &uniform))
{ {
return false; return false;
...@@ -1184,7 +1181,7 @@ bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint locati ...@@ -1184,7 +1181,7 @@ bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint locati
return false; return false;
} }
const LinkedUniform *uniform = nullptr; LinkedUniform *uniform = NULL;
if (!ValidateUniformCommonBase(context, matrixType, location, count, &uniform)) if (!ValidateUniformCommonBase(context, matrixType, location, count, &uniform))
{ {
return false; return false;
...@@ -1480,7 +1477,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz ...@@ -1480,7 +1477,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
// Uniform buffer validation // Uniform buffer validation
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++) for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++)
{ {
const gl::UniformBlock &uniformBlock = program->getUniformBlockByIndex(uniformBlockIndex); const gl::UniformBlock *uniformBlock = program->getUniformBlockByIndex(uniformBlockIndex);
GLuint blockBinding = program->getUniformBlockBinding(uniformBlockIndex); GLuint blockBinding = program->getUniformBlockBinding(uniformBlockIndex);
const gl::Buffer *uniformBuffer = state.getIndexedUniformBuffer(blockBinding); const gl::Buffer *uniformBuffer = state.getIndexedUniformBuffer(blockBinding);
...@@ -1499,7 +1496,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz ...@@ -1499,7 +1496,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
uniformBufferSize = static_cast<size_t>(uniformBuffer->getSize()); uniformBufferSize = static_cast<size_t>(uniformBuffer->getSize());
} }
if (uniformBufferSize < uniformBlock.dataSize) if (uniformBufferSize < uniformBlock->dataSize)
{ {
// undefined behaviour // undefined behaviour
context->recordError(Error(GL_INVALID_OPERATION, "It is undefined behaviour to use a uniform buffer that is too small.")); context->recordError(Error(GL_INVALID_OPERATION, "It is undefined behaviour to use a uniform buffer that is too small."));
...@@ -1899,8 +1896,8 @@ static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint loca ...@@ -1899,8 +1896,8 @@ static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint loca
ASSERT(programObject); ASSERT(programObject);
// sized queries -- ensure the provided buffer is large enough // sized queries -- ensure the provided buffer is large enough
const LinkedUniform &uniform = programObject->getUniformByLocation(location); LinkedUniform *uniform = programObject->getUniformByLocation(location);
size_t requiredBytes = VariableExternalSize(uniform.type); size_t requiredBytes = VariableExternalSize(uniform->type);
if (static_cast<size_t>(bufSize) < requiredBytes) if (static_cast<size_t>(bufSize) < requiredBytes)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
......
...@@ -140,6 +140,7 @@ ...@@ -140,6 +140,7 @@
'libANGLE/renderer/FramebufferImpl.h', 'libANGLE/renderer/FramebufferImpl.h',
'libANGLE/renderer/ImageImpl.h', 'libANGLE/renderer/ImageImpl.h',
'libANGLE/renderer/ImplFactory.h', 'libANGLE/renderer/ImplFactory.h',
'libANGLE/renderer/ProgramImpl.cpp',
'libANGLE/renderer/ProgramImpl.h', 'libANGLE/renderer/ProgramImpl.h',
'libANGLE/renderer/QueryImpl.h', 'libANGLE/renderer/QueryImpl.h',
'libANGLE/renderer/RenderbufferImpl.h', 'libANGLE/renderer/RenderbufferImpl.h',
......
...@@ -120,12 +120,9 @@ ...@@ -120,12 +120,9 @@
1031 WIN : dEQP-GLES2.functional.uniform_api.random.41 = FAIL 1031 WIN : dEQP-GLES2.functional.uniform_api.random.41 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.51 = FAIL 1031 WIN : dEQP-GLES2.functional.uniform_api.random.51 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.54 = FAIL 1031 WIN : dEQP-GLES2.functional.uniform_api.random.54 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.61 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.72 = FAIL 1031 WIN : dEQP-GLES2.functional.uniform_api.random.72 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.79 = FAIL 1031 WIN : dEQP-GLES2.functional.uniform_api.random.79 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.82 = FAIL 1031 WIN : dEQP-GLES2.functional.uniform_api.random.82 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.87 = FAIL
1031 WIN : dEQP-GLES2.functional.uniform_api.random.93 = FAIL
504 WIN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.basic_struct.sampler2D_samplerCube_* = FAIL 504 WIN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.basic_struct.sampler2D_samplerCube_* = FAIL
504 WIN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.struct_in_array.sampler2D_samplerCube_* = FAIL 504 WIN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.struct_in_array.sampler2D_samplerCube_* = FAIL
504 WIN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.array_in_struct.sampler2D_samplerCube_* = FAIL 504 WIN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.array_in_struct.sampler2D_samplerCube_* = FAIL
......
...@@ -1029,14 +1029,11 @@ ...@@ -1029,14 +1029,11 @@
1098 WIN : dEQP-GLES3.functional.uniform_api.random.3 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.3 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.6 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.6 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.8 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.8 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.17 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.20 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.20 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.21 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.21 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.29 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.29 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.54 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.81 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.81 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.83 = FAIL 1098 WIN : dEQP-GLES3.functional.uniform_api.random.83 = FAIL
1098 WIN : dEQP-GLES3.functional.uniform_api.random.87 = FAIL
1099 WIN : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond_float = FAIL 1099 WIN : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond_float = FAIL
1099 WIN : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond_float = FAIL 1099 WIN : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond_float = FAIL
1099 WIN : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond_vec2 = FAIL 1099 WIN : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond_vec2 = FAIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment