added GetVABMap and GetIBMap in Primitive
This commit is contained in:
@@ -56,7 +56,7 @@ public: //顶点缓冲区
|
||||
|
||||
const uint32_t GetVertexCount()const{ return vertices_number; } ///<取得顶点数量
|
||||
|
||||
VABMap * MapVAB (const AnsiString &name,const VkFormat format=VK_FORMAT_UNDEFINED);
|
||||
VABMap * GetVABMap (const AnsiString &name,const VkFormat format=VK_FORMAT_UNDEFINED);
|
||||
|
||||
bool WriteVAB (const AnsiString &name,const VkFormat format,const void *data); ///<直接写入顶点属性数据
|
||||
|
||||
@@ -65,7 +65,7 @@ public: //索引缓冲区
|
||||
const IndexType GetIndexType()const{return index_type;} ///<取得索引类型
|
||||
const uint32_t GetIndexCount()const{return index_number;} ///<取得索引数量
|
||||
|
||||
IBMap * MapIBO();
|
||||
IBMap * GetIBMap();
|
||||
|
||||
bool WriteIBO(const void *data,const uint32_t count);
|
||||
|
||||
|
@@ -62,6 +62,9 @@ using VAB=VertexAttribBuffer;
|
||||
|
||||
class IndexBuffer;
|
||||
|
||||
class VABMap;
|
||||
class IBMap;
|
||||
|
||||
class GPUCmdBuffer;
|
||||
class RenderCmdBuffer;
|
||||
class TextureCmdBuffer;
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 原始图元数据访问接口<br>
|
||||
* Primitive的存为是为了屏蔽PrimitiveData的初始化之类的访问接口,以便于更好的管理和使用
|
||||
@@ -37,10 +38,13 @@ public:
|
||||
VAB * GetVAB (const int);
|
||||
VAB * GetVAB (const AnsiString &name){return GetVAB(GetVABIndex(name));}
|
||||
const int32_t GetVertexOffset ()const; ///<取得顶点偏移(注意是顶点不是字节)
|
||||
VABMap * GetVABMap (const int); ///<取得VAB映射器
|
||||
VABMap * GetVABMap (const AnsiString &name){return GetVABMap(GetVABIndex(name));}
|
||||
|
||||
const uint32_t GetIndexCount ()const;
|
||||
IndexBuffer * GetIBO ();
|
||||
const uint32_t GetFirstIndex ()const; ///<取得第一个索引
|
||||
IBMap * GetIBMap (); ///<取得索引缓冲区映射器
|
||||
|
||||
VertexDataManager * GetVDM (); ///<取得顶点数据管理器
|
||||
|
||||
|
@@ -68,15 +68,24 @@ template<typename T> class VABRawMap
|
||||
|
||||
public:
|
||||
|
||||
VABRawMap(VABMap *map,const VkFormat check_format=VK_FORMAT_UNDEFINED)
|
||||
VABRawMap(VABMap *map,const VkFormat check_format=VK_FORMAT_UNDEFINED,bool now_map=true)
|
||||
{
|
||||
vab_map=map;
|
||||
map_ptr=nullptr;
|
||||
|
||||
if(vab_map)
|
||||
{
|
||||
if(check_format==VK_FORMAT_UNDEFINED
|
||||
||check_format==vab_map->GetFormat())
|
||||
map_ptr=(T *)(vab_map->Map());
|
||||
{
|
||||
if(now_map)
|
||||
map_ptr=(T *)(vab_map->Map());
|
||||
}
|
||||
else
|
||||
{
|
||||
vab_map=nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~VABRawMap()
|
||||
@@ -87,6 +96,26 @@ public:
|
||||
|
||||
const bool IsValid()const{ return vab_map?vab_map->IsValid():false; }
|
||||
|
||||
T *Map()
|
||||
{
|
||||
if(!vab_map)
|
||||
return(nullptr);
|
||||
|
||||
if(!map_ptr)
|
||||
map_ptr=(T *)(vab_map->Map());
|
||||
|
||||
return map_ptr;
|
||||
}
|
||||
|
||||
void Unmap()
|
||||
{
|
||||
if(vab_map)
|
||||
{
|
||||
if(map_ptr)
|
||||
vab_map->Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
operator T *(){ return map_ptr; }
|
||||
T *operator->(){ return map_ptr; }
|
||||
};//template<typename T> class VABRawMap
|
||||
@@ -111,14 +140,21 @@ template<typename T> class VABFormatMap
|
||||
|
||||
public:
|
||||
|
||||
VABFormatMap(VABMap *map)
|
||||
VABFormatMap(VABMap *map,bool now_map=true)
|
||||
{
|
||||
vab_map=map;
|
||||
|
||||
if(vab_map&&vab_map->GetFormat()==T::GetVulkanFormat())
|
||||
{
|
||||
map_ptr=T::Create(vab_map->GetCount(),vab_map->Map());
|
||||
map_ptr->Begin();
|
||||
if(now_map)
|
||||
{
|
||||
map_ptr=T::Create(vab_map->GetCount(),vab_map->Map());
|
||||
map_ptr->Begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
map_ptr=T::Create(vab_map->GetCount(),nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
map_ptr=nullptr;
|
||||
@@ -133,15 +169,48 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const bool IsValid()const{ return map_ptr; }
|
||||
const bool IsValid()const{ return map_ptr?map_ptr->IsValid():false; }
|
||||
|
||||
T *Map()
|
||||
{
|
||||
if(!vab_map)
|
||||
return(nullptr);
|
||||
|
||||
if(!map_ptr)
|
||||
{
|
||||
map_ptr=T::Create(vab_map->GetCount(),vab_map->Map());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!map_ptr->IsValid())
|
||||
map_ptr->SetData(vab_map->Map());
|
||||
}
|
||||
|
||||
map_ptr->Begin();
|
||||
return map_ptr;
|
||||
}
|
||||
|
||||
void Unmap()
|
||||
{
|
||||
if(vab_map)
|
||||
{
|
||||
if(map_ptr&&map_ptr->IsValid())
|
||||
{
|
||||
vab_map->Unmap();
|
||||
map_ptr->SetData(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Restart()
|
||||
{
|
||||
if(map_ptr)
|
||||
vab_map->Begin();
|
||||
return Map();
|
||||
}
|
||||
|
||||
T *operator->(){ return map_ptr; }
|
||||
T *operator->()
|
||||
{
|
||||
return map_ptr;
|
||||
}
|
||||
};//template<typename T> class VABFormatMap
|
||||
|
||||
typedef VABFormatMap<VB1i8> VABMap1i8 ,VABMap1b;
|
||||
|
@@ -44,6 +44,17 @@ namespace hgl
|
||||
|
||||
virtual ~VertexAttribDataAccess()=default;
|
||||
|
||||
void SetData(T *_data)
|
||||
{
|
||||
data =_data;
|
||||
data_end=_data+count*C;
|
||||
}
|
||||
|
||||
const bool IsValid()const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
void Write(const T *ptr)
|
||||
{
|
||||
if(!ptr)return;
|
||||
|
Reference in New Issue
Block a user