Commit 48fed633 by Olli Etuaho

Set sampler uniform values from binding qualifiers

The usual set uniform call is used to set initial sampler uniform values based on binding layout qualifiers. This is the simplest way to ensure that the uniform values are set correctly in both internal data structures of the Program class and on the different backends. This is done as one of the last steps of program linking. TEST=dEQP-GLES31.functional.uniform_binding.sampler* BUG=angleproject:1442 Change-Id: I2f58c98e175f6a10a90042050f4fcbea77ad97ac Reviewed-on: https://chromium-review.googlesource.com/456597Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent fc72a073
...@@ -711,6 +711,8 @@ Error Program::link(const gl::Context *context) ...@@ -711,6 +711,8 @@ Error Program::link(const gl::Context *context)
gatherTransformFeedbackVaryings(mergedVaryings); gatherTransformFeedbackVaryings(mergedVaryings);
} }
setUniformValuesFromBindingQualifiers();
gatherInterfaceBlockInfo(); gatherInterfaceBlockInfo();
return NoError(); return NoError();
...@@ -1933,12 +1935,12 @@ bool Program::linkUniforms(InfoLog &infoLog, ...@@ -1933,12 +1935,12 @@ bool Program::linkUniforms(InfoLog &infoLog,
linker.getResults(&mState.mUniforms, &mState.mUniformLocations); linker.getResults(&mState.mUniforms, &mState.mUniformLocations);
updateSamplerBindings(); linkSamplerBindings();
return true; return true;
} }
void Program::updateSamplerBindings() void Program::linkSamplerBindings()
{ {
mState.mSamplerUniformRange.end = static_cast<unsigned int>(mState.mUniforms.size()); mState.mSamplerUniformRange.end = static_cast<unsigned int>(mState.mUniforms.size());
mState.mSamplerUniformRange.start = mState.mSamplerUniformRange.end; mState.mSamplerUniformRange.start = mState.mSamplerUniformRange.end;
...@@ -2574,6 +2576,28 @@ void Program::linkOutputVariables() ...@@ -2574,6 +2576,28 @@ void Program::linkOutputVariables()
} }
} }
void Program::setUniformValuesFromBindingQualifiers()
{
for (unsigned int samplerIndex = mState.mSamplerUniformRange.start;
samplerIndex < mState.mSamplerUniformRange.end; ++samplerIndex)
{
const auto &samplerUniform = mState.mUniforms[samplerIndex];
if (samplerUniform.binding != -1)
{
GLint location = mState.getUniformLocation(samplerUniform.name);
ASSERT(location != -1);
std::vector<GLint> boundTextureUnits;
for (unsigned int elementIndex = 0; elementIndex < samplerUniform.elementCount();
++elementIndex)
{
boundTextureUnits.push_back(samplerUniform.binding + elementIndex);
}
setUniform1iv(location, static_cast<GLsizei>(boundTextureUnits.size()),
boundTextureUnits.data());
}
}
}
void Program::gatherInterfaceBlockInfo() void Program::gatherInterfaceBlockInfo()
{ {
ASSERT(mState.mUniformBlocks.empty()); ASSERT(mState.mUniformBlocks.empty());
......
...@@ -456,7 +456,7 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -456,7 +456,7 @@ class Program final : angle::NonCopyable, public LabeledObject
bool linkVaryings(InfoLog &infoLog) const; bool linkVaryings(InfoLog &infoLog) const;
bool linkUniforms(InfoLog &infoLog, const Caps &caps, const Bindings &uniformLocationBindings); bool linkUniforms(InfoLog &infoLog, const Caps &caps, const Bindings &uniformLocationBindings);
void updateSamplerBindings(); void linkSamplerBindings();
bool areMatchingInterfaceBlocks(InfoLog &infoLog, bool areMatchingInterfaceBlocks(InfoLog &infoLog,
const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &vertexInterfaceBlock,
...@@ -478,6 +478,8 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -478,6 +478,8 @@ class Program final : angle::NonCopyable, public LabeledObject
std::vector<PackedVarying> getPackedVaryings(const MergedVaryings &mergedVaryings) const; std::vector<PackedVarying> getPackedVaryings(const MergedVaryings &mergedVaryings) const;
void linkOutputVariables(); void linkOutputVariables();
void setUniformValuesFromBindingQualifiers();
void gatherInterfaceBlockInfo(); void gatherInterfaceBlockInfo();
template <typename VarT> template <typename VarT>
void defineUniformBlockMembers(const std::vector<VarT> &fields, void defineUniformBlockMembers(const std::vector<VarT> &fields,
......
...@@ -1422,8 +1422,6 @@ ...@@ -1422,8 +1422,6 @@
1442 OPENGL D3D11 : dEQP-GLES31.functional.fbo.no_attachments.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.fbo.no_attachments.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.fbo.completeness.no_attachments = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.fbo.completeness.no_attachments = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.program_interface_query.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.program_interface_query.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.sampler.sampler2d.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.sampler.sampler3d.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.ubo.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.ubo.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.ssbo.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.ssbo.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.image.image2d.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.image.image2d.* = 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