|
VisuTwin Canvas
C++ 3D Engine — Metal Backend
|
#include <platform/graphics/metal/metalTextureBinder.h>
Public Member Functions | |
| void | bindCached (MTL::RenderCommandEncoder *encoder, int slot, Texture *texture) |
| Bind a texture at the given fragment slot, skipping if already bound. | |
| void | bindLocalShadowTextures (MTL::RenderCommandEncoder *encoder, Texture *shadow0, Texture *shadow1) |
| Bind local shadow depth textures at slots 11 and 12 (spot lights, 2D). | |
| void | bindMaterialTextures (MTL::RenderCommandEncoder *encoder, const std::vector< TextureSlot > &textureSlots) |
| void | bindOmniShadowTextures (MTL::RenderCommandEncoder *encoder, Texture *cube0, Texture *cube1) |
| Bind omni shadow cubemap depth textures at slots 15 and 16 (point lights, cube). | |
| void | bindQuadTextures (MTL::RenderCommandEncoder *encoder, const std::array< Texture *, 8 > &quadBindings) |
| Bind quad render textures for all 8 slots. | |
| void | bindSamplerCached (MTL::RenderCommandEncoder *encoder, MTL::SamplerState *sampler) |
| Bind a sampler at slot 0, skipping if already bound. | |
| void | bindSceneTextures (MTL::RenderCommandEncoder *encoder, Texture *envAtlas, Texture *shadow, Texture *sceneDepth, Texture *skyboxCubeMap, Texture *reflection=nullptr, Texture *reflectionDepth=nullptr, Texture *ssao=nullptr) |
| Bind scene-global textures (envAtlas, shadow, sceneDepth, skybox cubemap, reflection, reflectionDepth, ssao). | |
| void | clearAllMaterialSlots (MTL::RenderCommandEncoder *encoder) |
| Clear all 8 texture slots (used when no material is bound). | |
| void | clearCached (MTL::RenderCommandEncoder *encoder, int slot) |
| Clear (unbind) a texture slot, skipping if already nullptr. | |
| void | markClean () |
| Mark the cache as clean after the first draw in a pass. | |
| void | resetPassState () |
| Reset all cached state. Must be called at the start of each render pass. | |
Static Public Attributes | |
| static constexpr int | kMaxTextureSlots = 19 |
Tracks which textures and samplers are currently bound on a Metal render command encoder and skips redundant setFragmentTexture / setFragmentSamplerState calls. Instantiated as a member of MetalGraphicsDevice and reset at the start of each render pass.
Definition at line 24 of file metalTextureBinder.h.
| void visutwin::canvas::MetalTextureBinder::bindCached | ( | MTL::RenderCommandEncoder * | encoder, |
| int | slot, | ||
| Texture * | texture ) |
Bind a texture at the given fragment slot, skipping if already bound.
Definition at line 20 of file metalTextureBinder.cpp.
References visutwin::canvas::Texture::impl(), and kMaxTextureSlots.
Referenced by bindLocalShadowTextures(), bindMaterialTextures(), bindOmniShadowTextures(), bindQuadTextures(), and bindSceneTextures().
| void visutwin::canvas::MetalTextureBinder::bindLocalShadowTextures | ( | MTL::RenderCommandEncoder * | encoder, |
| Texture * | shadow0, | ||
| Texture * | shadow1 ) |
Bind local shadow depth textures at slots 11 and 12 (spot lights, 2D).
Definition at line 127 of file metalTextureBinder.cpp.
References bindCached().
| void visutwin::canvas::MetalTextureBinder::bindMaterialTextures | ( | MTL::RenderCommandEncoder * | encoder, |
| const std::vector< TextureSlot > & | textureSlots ) |
Bind material textures from a pre-queried list of texture slots. Clears material-owned slots (0,1,3,4,5) that are not present in the list.
Definition at line 70 of file metalTextureBinder.cpp.
References bindCached(), and clearCached().
| void visutwin::canvas::MetalTextureBinder::bindOmniShadowTextures | ( | MTL::RenderCommandEncoder * | encoder, |
| Texture * | cube0, | ||
| Texture * | cube1 ) |
Bind omni shadow cubemap depth textures at slots 15 and 16 (point lights, cube).
Definition at line 134 of file metalTextureBinder.cpp.
References bindCached().
| void visutwin::canvas::MetalTextureBinder::bindQuadTextures | ( | MTL::RenderCommandEncoder * | encoder, |
| const std::array< Texture *, 8 > & | quadBindings ) |
Bind quad render textures for all 8 slots.
Definition at line 115 of file metalTextureBinder.cpp.
References bindCached().
| void visutwin::canvas::MetalTextureBinder::bindSamplerCached | ( | MTL::RenderCommandEncoder * | encoder, |
| MTL::SamplerState * | sampler ) |
Bind a sampler at slot 0, skipping if already bound.
Definition at line 58 of file metalTextureBinder.cpp.
| void visutwin::canvas::MetalTextureBinder::bindSceneTextures | ( | MTL::RenderCommandEncoder * | encoder, |
| Texture * | envAtlas, | ||
| Texture * | shadow, | ||
| Texture * | sceneDepth, | ||
| Texture * | skyboxCubeMap, | ||
| Texture * | reflection = nullptr, | ||
| Texture * | reflectionDepth = nullptr, | ||
| Texture * | ssao = nullptr ) |
Bind scene-global textures (envAtlas, shadow, sceneDepth, skybox cubemap, reflection, reflectionDepth, ssao).
Definition at line 102 of file metalTextureBinder.cpp.
References bindCached().
| void visutwin::canvas::MetalTextureBinder::clearAllMaterialSlots | ( | MTL::RenderCommandEncoder * | encoder | ) |
Clear all 8 texture slots (used when no material is bound).
Definition at line 91 of file metalTextureBinder.cpp.
References clearCached().
| void visutwin::canvas::MetalTextureBinder::clearCached | ( | MTL::RenderCommandEncoder * | encoder, |
| int | slot ) |
Clear (unbind) a texture slot, skipping if already nullptr.
Definition at line 42 of file metalTextureBinder.cpp.
References kMaxTextureSlots.
Referenced by bindMaterialTextures(), and clearAllMaterialSlots().
|
inline |
Mark the cache as clean after the first draw in a pass.
Definition at line 65 of file metalTextureBinder.h.
| void visutwin::canvas::MetalTextureBinder::resetPassState | ( | ) |
Reset all cached state. Must be called at the start of each render pass.
Definition at line 145 of file metalTextureBinder.cpp.
|
staticconstexpr |
Definition at line 27 of file metalTextureBinder.h.
Referenced by bindCached(), and clearCached().