Commit 43a53e24 by Brandon Jones

Converted ProgramBinary to use Context caps instead of Renderer

BUG=angle:731 Change-Id: I9bbce69cabf767fb5fb2c94f437a9950bc79d1aa Reviewed-on: https://chromium-review.googlesource.com/215370Tested-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent a502c749
......@@ -652,7 +652,7 @@ void Context::linkProgram(GLuint program)
{
Program *programObject = mResourceManager->getProgram(program);
bool linked = programObject->link();
bool linked = programObject->link(getCaps());
// if the current program was relinked successfully we
// need to install the new executables
......@@ -1409,7 +1409,7 @@ size_t Context::getCurrentTexturesAndSamplerStates(ProgramBinary *programBinary,
for (size_t i = 0; i < samplerRange; i++)
{
outTextureTypes[i] = programBinary->getSamplerTextureType(type, i);
GLint textureUnit = programBinary->getSamplerMapping(type, i); // OpenGL texture image unit index
GLint textureUnit = programBinary->getSamplerMapping(type, i, getCaps()); // OpenGL texture image unit index
if (textureUnit != -1)
{
outTextures[i] = getSamplerTexture(textureUnit, outTextureTypes[i]);
......@@ -1508,7 +1508,7 @@ bool Context::applyUniformBuffers()
}
}
return programBinary->applyUniformBuffers(boundBuffers);
return programBinary->applyUniformBuffers(boundBuffers, getCaps());
}
bool Context::applyTransformFeedbackBuffers()
......
......@@ -243,7 +243,7 @@ void Program::bindAttributeLocation(GLuint index, const char *name)
// Links the HLSL code of the vertex and pixel shader by matching up their varyings,
// compiling them into binaries, determining the attribute mappings, and collecting
// a list of uniforms
bool Program::link()
bool Program::link(const Caps &caps)
{
unlink(false);
......@@ -252,7 +252,7 @@ bool Program::link()
mProgramBinary.set(new ProgramBinary(mRenderer));
mLinked = mProgramBinary->link(mInfoLog, mAttributeBindings, mFragmentShader, mVertexShader,
mTransformFeedbackVaryings, mTransformFeedbackBufferMode);
mTransformFeedbackVaryings, mTransformFeedbackBufferMode, caps);
return mLinked;
}
......@@ -501,14 +501,14 @@ bool Program::isFlaggedForDeletion() const
return mDeleteStatus;
}
void Program::validate()
void Program::validate(const Caps &caps)
{
mInfoLog.reset();
ProgramBinary *programBinary = getProgramBinary();
if (isLinked() && programBinary)
{
programBinary->validate(mInfoLog);
programBinary->validate(mInfoLog, caps);
}
else
{
......
......@@ -28,6 +28,7 @@ class Renderer;
namespace gl
{
struct Caps;
class ResourceManager;
class Shader;
......@@ -76,7 +77,7 @@ class Program
void bindAttributeLocation(GLuint index, const char *name);
bool link();
bool link(const Caps &caps);
bool isLinked();
bool setProgramBinary(GLenum binaryFormat, const void *binary, GLsizei length);
ProgramBinary *getProgramBinary() const;
......@@ -111,7 +112,7 @@ class Program
void flagForDeletion();
bool isFlaggedForDeletion() const;
void validate();
void validate(const Caps &caps);
bool isValidated() const;
GLint getProgramBinaryLength() const;
......
......@@ -46,6 +46,7 @@ class UniformStorage;
namespace gl
{
struct Caps;
class Shader;
class InfoLog;
class AttributeBindings;
......@@ -99,7 +100,7 @@ class ProgramBinary : public RefCountObject
GLuint getAttributeLocation(const char *name);
int getSemanticIndex(int attributeIndex);
GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex);
GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex, const Caps &caps);
TextureType getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
GLint getUsedSamplerRange(SamplerType type);
bool usesPointSize() const;
......@@ -137,14 +138,14 @@ class ProgramBinary : public RefCountObject
void dirtyAllUniforms();
void applyUniforms();
bool applyUniformBuffers(const std::vector<Buffer*> boundBuffers);
bool applyUniformBuffers(const std::vector<Buffer*> boundBuffers, const Caps &caps);
bool load(InfoLog &infoLog, GLenum binaryFormat, const void *binary, GLsizei length);
bool save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length);
GLint getLength();
bool link(InfoLog &infoLog, const AttributeBindings &attributeBindings, Shader *fragmentShader, Shader *vertexShader,
const std::vector<std::string>& transformFeedbackVaryings, GLenum transformFeedbackBufferMode);
const std::vector<std::string>& transformFeedbackVaryings, GLenum transformFeedbackBufferMode, const Caps &caps);
void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
......@@ -171,8 +172,8 @@ class ProgramBinary : public RefCountObject
const LinkedVarying &getTransformFeedbackVarying(size_t idx) const;
GLenum getTransformFeedbackBufferMode() const;
void validate(InfoLog &infoLog);
bool validateSamplers(InfoLog *infoLog);
void validate(InfoLog &infoLog, const Caps &caps);
bool validateSamplers(InfoLog *infoLog, const Caps &caps);
bool isValidated() const;
void updateSamplerMapping();
......@@ -212,25 +213,26 @@ class ProgramBinary : public RefCountObject
bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
bool linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
bool linkUniforms(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader);
bool linkUniforms(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps);
void defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister);
void defineUniform(GLenum shader, const sh::ShaderVariable &uniform, const std::string &fullName, sh::HLSLBlockEncoder *encoder);
bool indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog);
bool indexUniforms(InfoLog &infoLog);
bool indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog, const Caps &caps);
bool indexUniforms(InfoLog &infoLog, const Caps &caps);
static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount,
Sampler *outArray, GLuint *usedRange, unsigned int limit);
bool areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock);
bool linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader);
bool linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps);
bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const;
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings,
const Caps &caps) const;
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);
bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock);
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock, const Caps &caps);
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex, const Caps &caps);
void defineOutputVariables(Shader *fragmentShader);
void initializeUniformStorage();
......
......@@ -4632,7 +4632,7 @@ void __stdcall glValidateProgram(GLuint program)
}
}
programObject->validate();
programObject->validate(context->getCaps());
}
}
......
......@@ -1466,7 +1466,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
}
gl::ProgramBinary *programBinary = state.getCurrentProgramBinary();
if (!programBinary->validateSamplers(NULL))
if (!programBinary->validateSamplers(NULL, context->getCaps()))
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
......
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