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) ...@@ -652,7 +652,7 @@ void Context::linkProgram(GLuint program)
{ {
Program *programObject = mResourceManager->getProgram(program); Program *programObject = mResourceManager->getProgram(program);
bool linked = programObject->link(); bool linked = programObject->link(getCaps());
// if the current program was relinked successfully we // if the current program was relinked successfully we
// need to install the new executables // need to install the new executables
...@@ -1409,7 +1409,7 @@ size_t Context::getCurrentTexturesAndSamplerStates(ProgramBinary *programBinary, ...@@ -1409,7 +1409,7 @@ size_t Context::getCurrentTexturesAndSamplerStates(ProgramBinary *programBinary,
for (size_t i = 0; i < samplerRange; i++) for (size_t i = 0; i < samplerRange; i++)
{ {
outTextureTypes[i] = programBinary->getSamplerTextureType(type, 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) if (textureUnit != -1)
{ {
outTextures[i] = getSamplerTexture(textureUnit, outTextureTypes[i]); outTextures[i] = getSamplerTexture(textureUnit, outTextureTypes[i]);
...@@ -1508,7 +1508,7 @@ bool Context::applyUniformBuffers() ...@@ -1508,7 +1508,7 @@ bool Context::applyUniformBuffers()
} }
} }
return programBinary->applyUniformBuffers(boundBuffers); return programBinary->applyUniformBuffers(boundBuffers, getCaps());
} }
bool Context::applyTransformFeedbackBuffers() bool Context::applyTransformFeedbackBuffers()
......
...@@ -243,7 +243,7 @@ void Program::bindAttributeLocation(GLuint index, const char *name) ...@@ -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, // 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 // compiling them into binaries, determining the attribute mappings, and collecting
// a list of uniforms // a list of uniforms
bool Program::link() bool Program::link(const Caps &caps)
{ {
unlink(false); unlink(false);
...@@ -252,7 +252,7 @@ bool Program::link() ...@@ -252,7 +252,7 @@ bool Program::link()
mProgramBinary.set(new ProgramBinary(mRenderer)); mProgramBinary.set(new ProgramBinary(mRenderer));
mLinked = mProgramBinary->link(mInfoLog, mAttributeBindings, mFragmentShader, mVertexShader, mLinked = mProgramBinary->link(mInfoLog, mAttributeBindings, mFragmentShader, mVertexShader,
mTransformFeedbackVaryings, mTransformFeedbackBufferMode); mTransformFeedbackVaryings, mTransformFeedbackBufferMode, caps);
return mLinked; return mLinked;
} }
...@@ -501,14 +501,14 @@ bool Program::isFlaggedForDeletion() const ...@@ -501,14 +501,14 @@ bool Program::isFlaggedForDeletion() const
return mDeleteStatus; return mDeleteStatus;
} }
void Program::validate() void Program::validate(const Caps &caps)
{ {
mInfoLog.reset(); mInfoLog.reset();
ProgramBinary *programBinary = getProgramBinary(); ProgramBinary *programBinary = getProgramBinary();
if (isLinked() && programBinary) if (isLinked() && programBinary)
{ {
programBinary->validate(mInfoLog); programBinary->validate(mInfoLog, caps);
} }
else else
{ {
......
...@@ -28,6 +28,7 @@ class Renderer; ...@@ -28,6 +28,7 @@ class Renderer;
namespace gl namespace gl
{ {
struct Caps;
class ResourceManager; class ResourceManager;
class Shader; class Shader;
...@@ -76,7 +77,7 @@ class Program ...@@ -76,7 +77,7 @@ class Program
void bindAttributeLocation(GLuint index, const char *name); void bindAttributeLocation(GLuint index, const char *name);
bool link(); bool link(const Caps &caps);
bool isLinked(); bool isLinked();
bool setProgramBinary(GLenum binaryFormat, const void *binary, GLsizei length); bool setProgramBinary(GLenum binaryFormat, const void *binary, GLsizei length);
ProgramBinary *getProgramBinary() const; ProgramBinary *getProgramBinary() const;
...@@ -111,7 +112,7 @@ class Program ...@@ -111,7 +112,7 @@ class Program
void flagForDeletion(); void flagForDeletion();
bool isFlaggedForDeletion() const; bool isFlaggedForDeletion() const;
void validate(); void validate(const Caps &caps);
bool isValidated() const; bool isValidated() const;
GLint getProgramBinaryLength() const; GLint getProgramBinaryLength() const;
......
...@@ -384,7 +384,7 @@ bool ProgramBinary::usesGeometryShader() const ...@@ -384,7 +384,7 @@ bool ProgramBinary::usesGeometryShader() const
// Returns the index of the texture image unit (0-19) corresponding to a Direct3D 9 sampler // Returns the index of the texture image unit (0-19) corresponding to a Direct3D 9 sampler
// index (0-15 for the pixel shader and 0-3 for the vertex shader). // index (0-15 for the pixel shader and 0-3 for the vertex shader).
GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerIndex) GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerIndex, const Caps &caps)
{ {
GLint logicalTextureUnit = -1; GLint logicalTextureUnit = -1;
...@@ -409,8 +409,7 @@ GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerInd ...@@ -409,8 +409,7 @@ GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerInd
default: UNREACHABLE(); default: UNREACHABLE();
} }
// TODO (geofflang): Use context's caps if (logicalTextureUnit >= 0 && logicalTextureUnit < static_cast<GLint>(caps.maxCombinedTextureImageUnits))
if (logicalTextureUnit >= 0 && logicalTextureUnit < (GLint)mRenderer->getRendererCaps().maxCombinedTextureImageUnits)
{ {
return logicalTextureUnit; return logicalTextureUnit;
} }
...@@ -1014,7 +1013,7 @@ void ProgramBinary::applyUniforms() ...@@ -1014,7 +1013,7 @@ void ProgramBinary::applyUniforms()
} }
} }
bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers) bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers, const Caps &caps)
{ {
const gl::Buffer *vertexUniformBuffers[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS] = {NULL}; const gl::Buffer *vertexUniformBuffers[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS] = {NULL};
const gl::Buffer *fragmentUniformBuffers[gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS] = {NULL}; const gl::Buffer *fragmentUniformBuffers[gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS] = {NULL};
...@@ -1043,7 +1042,7 @@ bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuff ...@@ -1043,7 +1042,7 @@ bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuff
{ {
unsigned int registerIndex = uniformBlock->vsRegisterIndex - reservedBuffersInVS; unsigned int registerIndex = uniformBlock->vsRegisterIndex - reservedBuffersInVS;
ASSERT(vertexUniformBuffers[registerIndex] == NULL); ASSERT(vertexUniformBuffers[registerIndex] == NULL);
ASSERT(registerIndex < mRenderer->getRendererCaps().maxVertexUniformBlocks); ASSERT(registerIndex < caps.maxVertexUniformBlocks);
vertexUniformBuffers[registerIndex] = uniformBuffer; vertexUniformBuffers[registerIndex] = uniformBuffer;
} }
...@@ -1051,7 +1050,7 @@ bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuff ...@@ -1051,7 +1050,7 @@ bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuff
{ {
unsigned int registerIndex = uniformBlock->psRegisterIndex - reservedBuffersInFS; unsigned int registerIndex = uniformBlock->psRegisterIndex - reservedBuffersInFS;
ASSERT(fragmentUniformBuffers[registerIndex] == NULL); ASSERT(fragmentUniformBuffers[registerIndex] == NULL);
ASSERT(registerIndex < mRenderer->getRendererCaps().maxFragmentUniformBlocks); ASSERT(registerIndex < caps.maxFragmentUniformBlocks);
fragmentUniformBuffers[registerIndex] = uniformBuffer; fragmentUniformBuffers[registerIndex] = uniformBuffer;
} }
} }
...@@ -1601,7 +1600,7 @@ GLint ProgramBinary::getLength() ...@@ -1601,7 +1600,7 @@ GLint ProgramBinary::getLength()
} }
bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBindings, Shader *fragmentShader, Shader *vertexShader, bool ProgramBinary::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)
{ {
if (!fragmentShader || !fragmentShader->isCompiled()) if (!fragmentShader || !fragmentShader->isCompiled())
{ {
...@@ -1660,7 +1659,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1660,7 +1659,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
success = false; success = false;
} }
if (!linkUniforms(infoLog, *vertexShader, *fragmentShader)) if (!linkUniforms(infoLog, *vertexShader, *fragmentShader, caps))
{ {
success = false; success = false;
} }
...@@ -1675,13 +1674,13 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1675,13 +1674,13 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, defaultInfo)); mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, defaultInfo));
} }
if (!linkUniformBlocks(infoLog, *vertexShader, *fragmentShader)) if (!linkUniformBlocks(infoLog, *vertexShader, *fragmentShader, caps))
{ {
success = false; success = false;
} }
if (!gatherTransformFeedbackLinkedVaryings(infoLog, linkedVaryings, transformFeedbackVaryings, if (!gatherTransformFeedbackLinkedVaryings(infoLog, linkedVaryings, transformFeedbackVaryings,
transformFeedbackBufferMode, &mTransformFeedbackLinkedVaryings)) transformFeedbackBufferMode, &mTransformFeedbackLinkedVaryings, caps))
{ {
success = false; success = false;
} }
...@@ -1898,7 +1897,7 @@ bool ProgramBinary::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std ...@@ -1898,7 +1897,7 @@ bool ProgramBinary::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std
return true; return true;
} }
bool ProgramBinary::linkUniforms(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader) bool ProgramBinary::linkUniforms(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps)
{ {
const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader.getImplementation()); const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader.getImplementation());
const rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader.getImplementation()); const rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader.getImplementation());
...@@ -1943,7 +1942,7 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const Shader &vertexShader, c ...@@ -1943,7 +1942,7 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const Shader &vertexShader, c
defineUniformBase(GL_FRAGMENT_SHADER, uniform, fragmentShaderD3D->getUniformRegister(uniform.name)); defineUniformBase(GL_FRAGMENT_SHADER, uniform, fragmentShaderD3D->getUniformRegister(uniform.name));
} }
if (!indexUniforms(infoLog)) if (!indexUniforms(infoLog, caps))
{ {
return false; return false;
} }
...@@ -2026,12 +2025,11 @@ void ProgramBinary::defineUniform(GLenum shader, const sh::ShaderVariable &unifo ...@@ -2026,12 +2025,11 @@ void ProgramBinary::defineUniform(GLenum shader, const sh::ShaderVariable &unifo
} }
} }
bool ProgramBinary::indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog) bool ProgramBinary::indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog, const Caps &caps)
{ {
ASSERT(IsSampler(uniform.type)); ASSERT(IsSampler(uniform.type));
ASSERT(uniform.vsRegisterIndex != GL_INVALID_INDEX || uniform.psRegisterIndex != GL_INVALID_INDEX); ASSERT(uniform.vsRegisterIndex != GL_INVALID_INDEX || uniform.psRegisterIndex != GL_INVALID_INDEX);
const gl::Caps &caps = mRenderer->getRendererCaps();
if (uniform.vsRegisterIndex != GL_INVALID_INDEX) if (uniform.vsRegisterIndex != GL_INVALID_INDEX)
{ {
if (!assignSamplers(uniform.vsRegisterIndex, uniform.type, uniform.arraySize, mSamplersVS, if (!assignSamplers(uniform.vsRegisterIndex, uniform.type, uniform.arraySize, mSamplersVS,
...@@ -2073,7 +2071,7 @@ bool ProgramBinary::indexSamplerUniform(const LinkedUniform &uniform, InfoLog &i ...@@ -2073,7 +2071,7 @@ bool ProgramBinary::indexSamplerUniform(const LinkedUniform &uniform, InfoLog &i
return true; return true;
} }
bool ProgramBinary::indexUniforms(InfoLog &infoLog) bool ProgramBinary::indexUniforms(InfoLog &infoLog, const Caps &caps)
{ {
for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++) for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
{ {
...@@ -2081,7 +2079,7 @@ bool ProgramBinary::indexUniforms(InfoLog &infoLog) ...@@ -2081,7 +2079,7 @@ bool ProgramBinary::indexUniforms(InfoLog &infoLog)
if (IsSampler(uniform.type)) if (IsSampler(uniform.type))
{ {
if (!indexSamplerUniform(uniform, infoLog)) if (!indexSamplerUniform(uniform, infoLog, caps))
{ {
return false; return false;
} }
...@@ -2171,7 +2169,7 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter ...@@ -2171,7 +2169,7 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter
return true; return true;
} }
bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader) bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps)
{ {
const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader.getImplementation()); const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader.getImplementation());
const rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader.getImplementation()); const rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader.getImplementation());
...@@ -2205,7 +2203,7 @@ bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShad ...@@ -2205,7 +2203,7 @@ bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShad
for (unsigned int blockIndex = 0; blockIndex < vertexInterfaceBlocks.size(); blockIndex++) for (unsigned int blockIndex = 0; blockIndex < vertexInterfaceBlocks.size(); blockIndex++)
{ {
if (!defineUniformBlock(infoLog, vertexShader, vertexInterfaceBlocks[blockIndex])) if (!defineUniformBlock(infoLog, vertexShader, vertexInterfaceBlocks[blockIndex], caps))
{ {
return false; return false;
} }
...@@ -2213,7 +2211,7 @@ bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShad ...@@ -2213,7 +2211,7 @@ bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShad
for (unsigned int blockIndex = 0; blockIndex < fragmentInterfaceBlocks.size(); blockIndex++) for (unsigned int blockIndex = 0; blockIndex < fragmentInterfaceBlocks.size(); blockIndex++)
{ {
if (!defineUniformBlock(infoLog, fragmentShader, fragmentInterfaceBlocks[blockIndex])) if (!defineUniformBlock(infoLog, fragmentShader, fragmentInterfaceBlocks[blockIndex], caps))
{ {
return false; return false;
} }
...@@ -2225,13 +2223,11 @@ bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShad ...@@ -2225,13 +2223,11 @@ bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShad
bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings, bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
const std::vector<std::string> &transformFeedbackVaryingNames, const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode, GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings,
const Caps &caps) const
{ {
size_t totalComponents = 0; size_t totalComponents = 0;
// TODO (geofflang): Use context's caps.
const gl::Caps &caps = mRenderer->getRendererCaps();
// Gather the linked varyings that are used for transform feedback, they should all exist. // Gather the linked varyings that are used for transform feedback, they should all exist.
outTransformFeedbackLinkedVaryings->clear(); outTransformFeedbackLinkedVaryings->clear();
for (size_t i = 0; i < transformFeedbackVaryingNames.size(); i++) for (size_t i = 0; i < transformFeedbackVaryingNames.size(); i++)
...@@ -2321,7 +2317,7 @@ void ProgramBinary::defineUniformBlockMembers(const std::vector<VarT> &fields, c ...@@ -2321,7 +2317,7 @@ void ProgramBinary::defineUniformBlockMembers(const std::vector<VarT> &fields, c
} }
} }
bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock) bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock, const Caps &caps)
{ {
const rx::ShaderD3D* shaderD3D = rx::ShaderD3D::makeShaderD3D(shader.getImplementation()); const rx::ShaderD3D* shaderD3D = rx::ShaderD3D::makeShaderD3D(shader.getImplementation());
...@@ -2380,7 +2376,7 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c ...@@ -2380,7 +2376,7 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c
ASSERT(uniformBlock->name == interfaceBlock.name); ASSERT(uniformBlock->name == interfaceBlock.name);
if (!assignUniformBlockRegister(infoLog, uniformBlock, shader.getType(), if (!assignUniformBlockRegister(infoLog, uniformBlock, shader.getType(),
interfaceBlockRegister + uniformBlockElement)) interfaceBlockRegister + uniformBlockElement, caps))
{ {
return false; return false;
} }
...@@ -2389,9 +2385,8 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c ...@@ -2389,9 +2385,8 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c
return true; return true;
} }
bool ProgramBinary::assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex) bool ProgramBinary::assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex, const Caps &caps)
{ {
const gl::Caps &caps = mRenderer->getRendererCaps();
if (shader == GL_VERTEX_SHADER) if (shader == GL_VERTEX_SHADER)
{ {
uniformBlock->vsRegisterIndex = registerIndex; uniformBlock->vsRegisterIndex = registerIndex;
...@@ -2676,10 +2671,10 @@ GLuint ProgramBinary::getActiveUniformBlockMaxLength() const ...@@ -2676,10 +2671,10 @@ GLuint ProgramBinary::getActiveUniformBlockMaxLength() const
return maxLength; return maxLength;
} }
void ProgramBinary::validate(InfoLog &infoLog) void ProgramBinary::validate(InfoLog &infoLog, const Caps &caps)
{ {
applyUniforms(); applyUniforms();
if (!validateSamplers(&infoLog)) if (!validateSamplers(&infoLog, caps))
{ {
mValidated = false; mValidated = false;
} }
...@@ -2689,15 +2684,14 @@ void ProgramBinary::validate(InfoLog &infoLog) ...@@ -2689,15 +2684,14 @@ void ProgramBinary::validate(InfoLog &infoLog)
} }
} }
bool ProgramBinary::validateSamplers(InfoLog *infoLog) bool ProgramBinary::validateSamplers(InfoLog *infoLog, const Caps &caps)
{ {
// if any two active samplers in a program are of different types, but refer to the same // if any two active samplers in a program are of different types, but refer to the same
// texture image unit, and this is the current program, then ValidateProgram will fail, and // texture image unit, and this is the current program, then ValidateProgram will fail, and
// DrawArrays and DrawElements will issue the INVALID_OPERATION error. // DrawArrays and DrawElements will issue the INVALID_OPERATION error.
updateSamplerMapping(); updateSamplerMapping();
// TODO (geofflang): Use context's caps const unsigned int maxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits;
const unsigned int maxCombinedTextureImageUnits = mRenderer->getRendererCaps().maxCombinedTextureImageUnits;
TextureType textureUnitType[IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS]; TextureType textureUnitType[IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
for (unsigned int i = 0; i < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; ++i) for (unsigned int i = 0; i < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; ++i)
......
...@@ -46,6 +46,7 @@ class UniformStorage; ...@@ -46,6 +46,7 @@ class UniformStorage;
namespace gl namespace gl
{ {
struct Caps;
class Shader; class Shader;
class InfoLog; class InfoLog;
class AttributeBindings; class AttributeBindings;
...@@ -99,7 +100,7 @@ class ProgramBinary : public RefCountObject ...@@ -99,7 +100,7 @@ class ProgramBinary : public RefCountObject
GLuint getAttributeLocation(const char *name); GLuint getAttributeLocation(const char *name);
int getSemanticIndex(int attributeIndex); 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); TextureType getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
GLint getUsedSamplerRange(SamplerType type); GLint getUsedSamplerRange(SamplerType type);
bool usesPointSize() const; bool usesPointSize() const;
...@@ -137,14 +138,14 @@ class ProgramBinary : public RefCountObject ...@@ -137,14 +138,14 @@ class ProgramBinary : public RefCountObject
void dirtyAllUniforms(); void dirtyAllUniforms();
void applyUniforms(); 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 load(InfoLog &infoLog, GLenum binaryFormat, const void *binary, GLsizei length);
bool save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length); bool save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length);
GLint getLength(); GLint getLength();
bool link(InfoLog &infoLog, const AttributeBindings &attributeBindings, Shader *fragmentShader, Shader *vertexShader, 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 getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const; void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
...@@ -171,8 +172,8 @@ class ProgramBinary : public RefCountObject ...@@ -171,8 +172,8 @@ class ProgramBinary : public RefCountObject
const LinkedVarying &getTransformFeedbackVarying(size_t idx) const; const LinkedVarying &getTransformFeedbackVarying(size_t idx) const;
GLenum getTransformFeedbackBufferMode() const; GLenum getTransformFeedbackBufferMode() const;
void validate(InfoLog &infoLog); void validate(InfoLog &infoLog, const Caps &caps);
bool validateSamplers(InfoLog *infoLog); bool validateSamplers(InfoLog *infoLog, const Caps &caps);
bool isValidated() const; bool isValidated() const;
void updateSamplerMapping(); void updateSamplerMapping();
...@@ -212,25 +213,26 @@ class ProgramBinary : public RefCountObject ...@@ -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 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 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 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 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); void defineUniform(GLenum shader, const sh::ShaderVariable &uniform, const std::string &fullName, sh::HLSLBlockEncoder *encoder);
bool indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog); bool indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog, const Caps &caps);
bool indexUniforms(InfoLog &infoLog); bool indexUniforms(InfoLog &infoLog, const Caps &caps);
static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount, static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount,
Sampler *outArray, GLuint *usedRange, unsigned int limit); Sampler *outArray, GLuint *usedRange, unsigned int limit);
bool areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock); 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, bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
const std::vector<std::string> &transformFeedbackVaryingNames, const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode, GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const; std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings,
const Caps &caps) const;
template <typename VarT> template <typename VarT>
void defineUniformBlockMembers(const std::vector<VarT> &fields, const std::string &prefix, int blockIndex, void defineUniformBlockMembers(const std::vector<VarT> &fields, const std::string &prefix, int blockIndex,
sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes, sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes,
bool inRowMajorLayout); bool inRowMajorLayout);
bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock); 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); bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex, const Caps &caps);
void defineOutputVariables(Shader *fragmentShader); void defineOutputVariables(Shader *fragmentShader);
void initializeUniformStorage(); void initializeUniformStorage();
......
...@@ -4632,7 +4632,7 @@ void __stdcall glValidateProgram(GLuint program) ...@@ -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 ...@@ -1466,7 +1466,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
} }
gl::ProgramBinary *programBinary = state.getCurrentProgramBinary(); gl::ProgramBinary *programBinary = state.getCurrentProgramBinary();
if (!programBinary->validateSamplers(NULL)) if (!programBinary->validateSamplers(NULL, context->getCaps()))
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; 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