support for nullptr in texture binding array

This commit is contained in:
Jack Andersen 2016-07-30 16:05:20 -10:00
parent c01b0b4c6a
commit bec368dfe7
2 changed files with 20 additions and 29 deletions

View File

@ -517,7 +517,7 @@ IShaderPipeline* GLDataFactory::Context::newShaderPipeline
{
GLint texLoc = glGetUniformLocation(shader.m_prog, texNames[i]);
if (texLoc < 0)
Log.report(logvisor::Error, "unable to find sampler variable '%s'", texNames[i]);
Log.report(logvisor::Warning, "unable to find sampler variable '%s'", texNames[i]);
else
glUniform1i(texLoc, i);
}
@ -583,13 +583,7 @@ struct GLShaderDataBinding : IShaderDataBinding
m_ubufs[i] = ubufs[i];
}
for (size_t i=0 ; i<texCount ; ++i)
{
#ifndef NDEBUG
if (!texs[i])
Log.report(logvisor::Fatal, "null texture %d provided to newShaderDataBinding", int(i));
#endif
m_texs[i] = texs[i];
}
}
void bind(int b) const
{
@ -629,21 +623,24 @@ struct GLShaderDataBinding : IShaderDataBinding
for (size_t i=0 ; i<m_texCount ; ++i)
{
ITexture* tex = m_texs[i];
switch (tex->type())
if (tex)
{
case TextureType::Dynamic:
static_cast<GLTextureD*>(tex)->bind(i, b);
break;
case TextureType::Static:
static_cast<GLTextureS*>(tex)->bind(i);
break;
case TextureType::StaticArray:
static_cast<GLTextureSA*>(tex)->bind(i);
break;
case TextureType::Render:
static_cast<GLTextureR*>(tex)->bind(i);
break;
default: break;
switch (tex->type())
{
case TextureType::Dynamic:
static_cast<GLTextureD*>(tex)->bind(i, b);
break;
case TextureType::Static:
static_cast<GLTextureS*>(tex)->bind(i);
break;
case TextureType::StaticArray:
static_cast<GLTextureSA*>(tex)->bind(i);
break;
case TextureType::Render:
static_cast<GLTextureR*>(tex)->bind(i);
break;
default: break;
}
}
}
}

View File

@ -1982,13 +1982,7 @@ struct VulkanShaderDataBinding : IShaderDataBinding
m_ubufs[i] = ubufs[i];
}
for (size_t i=0 ; i<texCount ; ++i)
{
#ifndef NDEBUG
if (!texs[i])
Log.report(logvisor::Fatal, "null texture %d provided to newShaderDataBinding", int(i));
#endif
m_texs[i] = texs[i];
}
size_t totalDescs = ubufCount + texCount;
if (totalDescs > 0)
@ -2099,7 +2093,7 @@ struct VulkanShaderDataBinding : IShaderDataBinding
for (size_t i=0 ; i<BOO_GLSL_MAX_TEXTURE_COUNT ; ++i)
{
if (i<m_texCount)
if (i<m_texCount && m_texs[i])
{
writes[totalWrites].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writes[totalWrites].pNext = nullptr;
@ -2137,7 +2131,7 @@ struct VulkanShaderDataBinding : IShaderDataBinding
size_t totalWrites = 0;
for (size_t i=0 ; i<BOO_GLSL_MAX_TEXTURE_COUNT ; ++i)
{
if (i<m_texCount)
if (i<m_texCount && m_texs[i])
{
const VkDescriptorImageInfo* resComp = GetTextureGPUResource(m_texs[i], b);
if (resComp->imageView != m_knownViewHandles[b][i])