improved VKBufferMap and added newly IBMap/VABMap
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
#include<hgl/graph/VKBufferMap.h>
|
||||
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
void VKBufferMap::Set(DeviceBuffer *buf,VkDeviceSize off,VkDeviceSize s)
|
||||
{
|
||||
buffer=buf;
|
||||
offset=off;
|
||||
size=s;
|
||||
|
||||
map_ptr=nullptr;
|
||||
}
|
||||
|
||||
void VKBufferMap::Clear()
|
||||
{
|
||||
if(buffer&&map_ptr)
|
||||
buffer->Unmap();
|
||||
|
||||
buffer=nullptr;
|
||||
offset=0;
|
||||
size=0;
|
||||
map_ptr=nullptr;
|
||||
}
|
||||
|
||||
VKBufferMap::VKBufferMap()
|
||||
{
|
||||
Set(nullptr,0,0);
|
||||
}
|
||||
|
||||
VKBufferMap::VKBufferMap(DeviceBuffer *buf,VkDeviceSize off,VkDeviceSize s)
|
||||
{
|
||||
Set(buf,off,s);
|
||||
}
|
||||
|
||||
VKBufferMap::~VKBufferMap()
|
||||
{
|
||||
if(buffer&&map_ptr)
|
||||
buffer->Unmap();
|
||||
}
|
||||
|
||||
void *VKBufferMap::Map()
|
||||
{
|
||||
if(map_ptr)
|
||||
return(map_ptr);
|
||||
|
||||
if(!buffer)
|
||||
return(nullptr);
|
||||
|
||||
map_ptr=buffer->Map(offset,size);
|
||||
return map_ptr;
|
||||
}
|
||||
|
||||
void VKBufferMap::Unmap()
|
||||
{
|
||||
if(buffer&&map_ptr)
|
||||
{
|
||||
buffer->Unmap();
|
||||
map_ptr=nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
@@ -97,7 +97,7 @@ namespace
|
||||
return(ibo);
|
||||
}
|
||||
|
||||
VAB *InitVAB(const int vab_index,const VkFormat &format,const void *data)
|
||||
VAB *InitVAB(const int vab_index,const void *data)
|
||||
{
|
||||
if(!device)return(nullptr);
|
||||
if(!vil)return(nullptr);
|
||||
@@ -109,12 +109,9 @@ namespace
|
||||
|
||||
if(!vif)return(nullptr);
|
||||
|
||||
if(vif->format!=format)
|
||||
return(nullptr);
|
||||
|
||||
if(!vab_list[vab_index])
|
||||
{
|
||||
vab_list[vab_index]=device->CreateVAB(format,vertex_count,data);
|
||||
vab_list[vab_index]=device->CreateVAB(vif->format,vertex_count,data);
|
||||
|
||||
if(!vab_list[vab_index])
|
||||
return(nullptr);
|
||||
@@ -184,7 +181,7 @@ namespace
|
||||
return ibo;
|
||||
}
|
||||
|
||||
VAB *InitVAB(const int vab_index,const VkFormat &format,const void *data)
|
||||
VAB *InitVAB(const int vab_index,const void *data)
|
||||
{
|
||||
if(!vdm)return(nullptr);
|
||||
if(!vil)return(nullptr);
|
||||
@@ -196,9 +193,6 @@ namespace
|
||||
|
||||
if(!vif)return(nullptr);
|
||||
|
||||
if(vif->format!=format)
|
||||
return(nullptr);
|
||||
|
||||
if (!vab_list[vab_index])
|
||||
{
|
||||
vab_list[vab_index]=vdm->GetVAB(vab_index);
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
public:
|
||||
|
||||
virtual IndexBuffer * InitIBO(const uint32_t index_count,IndexType it)=0;
|
||||
virtual VAB * InitVAB(const int vab_index,const VkFormat &format,const void *data)=0;
|
||||
virtual VAB * InitVAB(const int vab_index,const void *data)=0;
|
||||
};//class PrimitiveData
|
||||
|
||||
PrimitiveData *CreatePrimitiveData(GPUDevice *dev,const VIL *_vil,const uint32_t vc);
|
||||
|
Reference in New Issue
Block a user