Skip to content

Commit

Permalink
Silence D3D debug warnings about unbound samplers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcy committed Apr 2, 2016
1 parent ead4577 commit ab9e94c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
6 changes: 5 additions & 1 deletion code/renderer_bgfx/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ void Main::renderCamera(uint8_t visCacheId, vec3 pvsPosition, vec3 position, mat
if (alphaTestStage)
{
alphaTestStage->setShaderUniforms(matStageUniforms_.get(), MaterialStageSetUniformsFlags::TexGen);
alphaTestStage->setTextureSamplers(matStageUniforms_.get());
bgfx::setTexture(0, uniforms_->textureSampler.handle, alphaTestStage->bundles[0].textures[0]->getHandle());
shaderVariant |= DepthShaderProgramVariant::AlphaTest;
}
else
Expand Down Expand Up @@ -1167,6 +1167,10 @@ void Main::renderCamera(uint8_t visCacheId, vec3 pvsPosition, vec3 position, mat
matStageUniforms_->vertexColor.set(vec4::black);
const int sky_texorder[6] = { 0, 2, 1, 3, 4, 5 };
bgfx::setTexture(TextureUnit::Diffuse, matStageUniforms_->diffuseSampler.handle, mat->sky.outerbox[sky_texorder[dc.skyboxSide]]->getHandle());
#ifdef _DEBUG
bgfx::setTexture(TextureUnit::Diffuse2, matStageUniforms_->diffuseSampler2.handle, Texture::getWhite()->getHandle());
bgfx::setTexture(TextureUnit::Light, matStageUniforms_->lightSampler.handle, Texture::getWhite()->getHandle());
#endif
SetDrawCallGeometry(dc);
bgfx::setTransform(dc.modelMatrix.get());
bgfx::setState(dc.state);
Expand Down
24 changes: 20 additions & 4 deletions code/renderer_bgfx/Material_calculate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ void MaterialStage::setTextureSamplers(Uniforms_MaterialStage *uniforms) const
if (diffuseBundle.numImageAnimations <= 1)
{
bgfx::setTexture(TextureUnit::Diffuse, uniforms->diffuseSampler.handle, diffuseBundle.textures[0]->getHandle());

#ifdef _DEBUG
bgfx::setTexture(TextureUnit::Diffuse2, uniforms->diffuseSampler2.handle, Texture::getWhite()->getHandle());
#endif
}
else
{
Expand All @@ -177,15 +181,27 @@ void MaterialStage::setTextureSamplers(Uniforms_MaterialStage *uniforms) const
{
bgfx::setTexture(TextureUnit::Diffuse2, uniforms->diffuseSampler2.handle, diffuseBundle.textures[nextFrame]->getHandle());
}
#ifdef _DEBUG
else
{
bgfx::setTexture(TextureUnit::Diffuse2, uniforms->diffuseSampler2.handle, Texture::getWhite()->getHandle());
}
#endif
}

// Lightmap.
const Texture *lightmap = bundles[MaterialTextureBundleIndex::Lightmap].textures[0];

if (!lightmap)
lightmap = Texture::getWhite();

bgfx::setTexture(TextureUnit::Light, uniforms->lightSampler.handle, lightmap->getHandle());
if (lightmap)
{
bgfx::setTexture(TextureUnit::Light, uniforms->lightSampler.handle, lightmap->getHandle());
}
#ifdef _DEBUG
else
{
bgfx::setTexture(TextureUnit::Light, uniforms->lightSampler.handle, Texture::getWhite()->getHandle());
}
#endif
}

bool MaterialStage::shouldLerpTextureAnimation() const
Expand Down

0 comments on commit ab9e94c

Please sign in to comment.