From 11ebb841beeb6c080d4a1611d14dc72fa8502475 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sat, 27 Apr 2024 01:13:12 +0800 Subject: [PATCH] improved IBAccess in VKPrimitive/VKRenderable/MaterialRenderList --- inc/hgl/graph/VKPrimitive.h | 2 +- src/SceneGraph/MaterialRenderList.cpp | 6 ++---- src/SceneGraph/Vulkan/VKRenderable.cpp | 5 ++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/inc/hgl/graph/VKPrimitive.h b/inc/hgl/graph/VKPrimitive.h index 0df5ecd0..16c35ce6 100644 --- a/inc/hgl/graph/VKPrimitive.h +++ b/inc/hgl/graph/VKPrimitive.h @@ -53,7 +53,7 @@ public: bool GetVABAccess (const AnsiString &,VABAccess *); const int GetBufferCount ()const {return buffer_list.GetCount();} - const IBAccess * GetIBAccess ()const {return &ib_access;} + const IBAccess * GetIBAccess ()const {return ib_access.buffer?&ib_access:nullptr;} };//class Primitive VK_NAMESPACE_END #endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE diff --git a/src/SceneGraph/MaterialRenderList.cpp b/src/SceneGraph/MaterialRenderList.cpp index e8973d2b..3642460b 100644 --- a/src/SceneGraph/MaterialRenderList.cpp +++ b/src/SceneGraph/MaterialRenderList.cpp @@ -256,11 +256,9 @@ void MaterialRenderList::Render(RenderItem *ri) last_vid=ri->vid; } - const IBAccess *iba=last_vid->ib_access; - - if(iba->buffer) + if(last_vid->ib_access) { - cmd_buf->DrawIndexed(iba,ri->count); + cmd_buf->DrawIndexed(last_vid->ib_access,ri->count); } else { diff --git a/src/SceneGraph/Vulkan/VKRenderable.cpp b/src/SceneGraph/Vulkan/VKRenderable.cpp index c92c47ec..5bd646af 100644 --- a/src/SceneGraph/Vulkan/VKRenderable.cpp +++ b/src/SceneGraph/Vulkan/VKRenderable.cpp @@ -15,7 +15,10 @@ VertexInputData::VertexInputData(const uint32_t c,const uint32_t vc,const IBAcce vertex_count=vc; - ib_access=iba; + if(!iba||!iba->buffer) + ib_access=nullptr; + else + ib_access=iba; } VertexInputData::~VertexInputData()