Clear material instance assignments at start of frame.
PiperOrigin-RevId: 945623848 Change-Id: I983efa6a14d25e2cb0f46b8bd529086d84247a50
This commit is contained in:
committed by
Copybara-Service
parent
f6f80cd0a0
commit
40feb498a1
@@ -236,7 +236,11 @@ MaterialManager::MaterialKey MaterialManager::PrepareMaterialInstance(
|
||||
return key;
|
||||
}
|
||||
|
||||
filament::MaterialInstance* MaterialManager::GetInstance(MaterialKey key) {
|
||||
const filament::MaterialInstance* MaterialManager::GetInstance(MaterialKey key) {
|
||||
if (key == 0) {
|
||||
return GetEngine()->getDefaultMaterial()->getDefaultInstance();
|
||||
}
|
||||
|
||||
auto it = instances_.find(key);
|
||||
if (it == instances_.end()) {
|
||||
return nullptr;
|
||||
|
||||
@@ -67,7 +67,7 @@ class MaterialManager {
|
||||
const Mesh* mesh);
|
||||
|
||||
// Returns the MaterialInstance associated with the given key.
|
||||
filament::MaterialInstance* GetInstance(MaterialKey key);
|
||||
const filament::MaterialInstance* GetInstance(MaterialKey key);
|
||||
|
||||
ObjectManager* GetObjectManager() const;
|
||||
filament::Engine* GetEngine() const;
|
||||
|
||||
@@ -239,6 +239,9 @@ const mjrfMaterial& Renderable::GetMaterial() const { return material_; }
|
||||
|
||||
void Renderable::Prepare(std::span<const mjrfRenderRequest*> requests,
|
||||
ReflectionManager* reflection_mgr) {
|
||||
// Ensure the renderable has no material instances set from the previous
|
||||
// frame. This will allow us to recycle material instances if needed.
|
||||
SetMaterialInstance(0);
|
||||
// We assume BindMaterialInstance will be called with the same requests in
|
||||
// the same order. As such, we'll just store the draw state in a deque rather
|
||||
// than trying to perform any kind of matching with the requests.
|
||||
@@ -388,7 +391,8 @@ MaterialManager::MaterialKey Renderable::SetMaterialInstance(
|
||||
MaterialManager::MaterialKey key) {
|
||||
MaterialManager::MaterialKey prev = curr_state_.material_key;
|
||||
if (key != curr_state_.material_key) {
|
||||
filament::MaterialInstance* instance = material_mgr_->GetInstance(key);
|
||||
const filament::MaterialInstance* instance =
|
||||
material_mgr_->GetInstance(key);
|
||||
filament::RenderableManager& rm = GetEngine()->getRenderableManager();
|
||||
for (Part& part : parts_) {
|
||||
filament::RenderableManager::Instance ri = rm.getInstance(part.entity);
|
||||
|
||||
Reference in New Issue
Block a user