Avoid redundant bindings/states based on Metal profiler feedback. (#2006)

This commit is contained in:
Tim Sylvester
2024-01-22 07:02:36 -08:00
committed by GitHub
parent cd3de6d3ad
commit 5c304614d6
9 changed files with 90 additions and 35 deletions

View File

@@ -186,22 +186,21 @@ void Texture2D::updateSamplerConfiguration() noexcept {
metalSamplerState = context.createMetalSamplerState(samplerDescriptor);
}
void Texture2D::bind(const RenderPass& renderPass, int32_t location) noexcept {
void Texture2D::bind(RenderPass& renderPass, int32_t location) noexcept {
assert(!textureDirty);
const auto& encoder = renderPass.getMetalEncoder();
// Update the sampler state if it was changed after resource creation
if (samplerStateDirty) {
updateSamplerConfiguration();
}
encoder->setFragmentTexture(metalTexture.get(), location);
encoder->setFragmentSamplerState(metalSamplerState.get(), location);
renderPass.setFragmentTexture(metalTexture, location);
renderPass.setFragmentSamplerState(metalSamplerState, location);
context.renderingStats().numTextureBindings++;
}
void Texture2D::unbind(const RenderPass&, int32_t /*location*/) noexcept {
void Texture2D::unbind(RenderPass&, int32_t /*location*/) noexcept {
context.renderingStats().numTextureBindings--;
}