refactor: add minimal material gpu binding
This commit is contained in:
@@ -65,6 +65,17 @@ private:
|
||||
Math::Vector4 mainLightColorAndFlags = Math::Vector4::Zero();
|
||||
};
|
||||
|
||||
struct PerMaterialConstants {
|
||||
Math::Vector4 baseColorFactor = Math::Vector4::One();
|
||||
};
|
||||
|
||||
struct CachedMaterialBindings {
|
||||
OwnedDescriptorSet constantSet = {};
|
||||
OwnedDescriptorSet textureSet = {};
|
||||
Core::uint64 materialVersion = 0;
|
||||
RHI::RHIResourceView* textureView = nullptr;
|
||||
};
|
||||
|
||||
bool EnsureInitialized(const RenderContext& context);
|
||||
bool CreatePipelineResources(const RenderContext& context);
|
||||
void DestroyPipelineResources();
|
||||
@@ -72,7 +83,9 @@ private:
|
||||
const RenderContext& context,
|
||||
const Resources::Material* material);
|
||||
RHI::RHIDescriptorSet* GetOrCreatePerObjectSet(Core::uint64 objectId);
|
||||
RHI::RHIDescriptorSet* GetOrCreateTextureSet(RHI::RHIResourceView* textureView);
|
||||
CachedMaterialBindings* GetOrCreateMaterialBindings(
|
||||
const Resources::Material* material,
|
||||
RHI::RHIResourceView* textureView);
|
||||
void DestroyOwnedDescriptorSet(OwnedDescriptorSet& descriptorSet);
|
||||
|
||||
const Resources::Texture* ResolveTexture(const Resources::Material* material) const;
|
||||
@@ -94,7 +107,7 @@ private:
|
||||
RHI::RHIPipelineLayout* m_pipelineLayout = nullptr;
|
||||
std::unordered_map<Resources::MaterialRenderState, RHI::RHIPipelineState*, MaterialRenderStateHash> m_pipelineStates;
|
||||
std::unordered_map<Core::uint64, OwnedDescriptorSet> m_perObjectSets;
|
||||
std::unordered_map<RHI::RHIResourceView*, OwnedDescriptorSet> m_textureSets;
|
||||
std::unordered_map<const Resources::Material*, CachedMaterialBindings> m_materialBindings;
|
||||
RHI::RHISampler* m_sampler = nullptr;
|
||||
RHI::RHITexture* m_fallbackTexture = nullptr;
|
||||
RHI::RHIResourceView* m_fallbackTextureView = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user