used newly VKBufferMap in PrimitiveCreater
This commit is contained in:
@@ -24,12 +24,18 @@ protected:
|
||||
|
||||
uint32_t vertices_number; ///<顶点数量
|
||||
|
||||
void_pointer *map_ptr_list; ///<映射指针列表
|
||||
VKBufferMap * vab_map_list;
|
||||
|
||||
uint32_t index_number; ///<索引数量
|
||||
IndexType index_type; ///<索引类型
|
||||
IndexBuffer * ibo; ///<索引缓冲区
|
||||
|
||||
VKBufferMap ibo_map;
|
||||
|
||||
protected:
|
||||
|
||||
const int GetVABIndex (const AnsiString &name,const VkFormat &format); ///<取得顶点属性索引
|
||||
|
||||
public:
|
||||
|
||||
PrimitiveCreater(GPUDevice *,const VIL *);
|
||||
@@ -53,10 +59,7 @@ public: //顶点缓冲区
|
||||
|
||||
const uint32_t GetVertexCount()const{ return vertices_number; } ///<取得顶点数量
|
||||
|
||||
const int GetVABIndex (const AnsiString &name,const VkFormat &format); ///<取得顶点属性索引
|
||||
|
||||
void * MapVAB (const int vab_index); ///<映射一个顶点属性数据区
|
||||
void UnmapVAB (const int vab_index); ///<取消映射
|
||||
VKBufferMap * MapVAB (const AnsiString &name,const VkFormat &format);
|
||||
|
||||
bool WriteVAB (const AnsiString &name,const VkFormat &format,const void *data); ///<直接写入顶点属性数据
|
||||
|
||||
@@ -65,8 +68,7 @@ public: //索引缓冲区
|
||||
const IndexType GetIndexType()const{return index_type;} ///<取得索引类型
|
||||
const uint32_t GetIndexCount()const{return index_number;} ///<取得索引数量
|
||||
|
||||
void * MapIBO();
|
||||
void UnmapIBO();
|
||||
VKBufferMap * MapIBO();
|
||||
|
||||
bool WriteIBO(const void *data,const uint32_t count);
|
||||
|
||||
@@ -79,89 +81,78 @@ public: //创建可渲染对象
|
||||
};//class PrimitiveCreater
|
||||
|
||||
/**
|
||||
* VAB原生数据访问映射
|
||||
* 顶点属性缓冲区原生数据访问映射
|
||||
*/
|
||||
template<typename T> class VABRawMap
|
||||
{
|
||||
PrimitiveCreater *pc;
|
||||
int vab_index;
|
||||
VKBufferMap *buf_map;
|
||||
|
||||
T *map_ptr;
|
||||
|
||||
public:
|
||||
|
||||
VABRawMap(PrimitiveCreater *c,const VkFormat &format,const AnsiString &name)
|
||||
{
|
||||
pc=c;
|
||||
vab_index=pc->GetVABIndex(name,format);
|
||||
|
||||
map_ptr=(T *)(pc->MapVAB(vab_index));
|
||||
VABRawMap(PrimitiveCreater *pc,const VkFormat &format,const AnsiString &name)
|
||||
{
|
||||
buf_map=pc->MapVAB(name,format);
|
||||
|
||||
if(buf_map)
|
||||
map_ptr=(T *)(buf_map->Map());
|
||||
else
|
||||
map_ptr=nullptr;
|
||||
}
|
||||
|
||||
~VABRawMap()
|
||||
{
|
||||
if(map_ptr)
|
||||
pc->UnmapVAB(vab_index);
|
||||
buf_map->Unmap();
|
||||
}
|
||||
|
||||
const bool IsValid()const{ return map_ptr; }
|
||||
const bool IsValid()const{ return buf_map?buf_map->IsValid():false; }
|
||||
|
||||
operator T *(){ return map_ptr; }
|
||||
T *operator->(){ return map_ptr; }
|
||||
};//template<typename T> class VABRawMap
|
||||
|
||||
typedef VABRawMap<int8> VABRawMapi8, VABRawMapByte;
|
||||
typedef VABRawMap<int16> VABRawMapi16,VABRawMapShort;
|
||||
typedef VABRawMap<int32> VABRawMapi32,VABRawMapInt;
|
||||
typedef VABRawMap<uint8> VABRawMapu8, VABRawMapUByte;
|
||||
typedef VABRawMap<uint16> VABRawMapu16,VABRawMapUShort;
|
||||
typedef VABRawMap<uint32> VABRawMapu32,VABRawMapUInt;
|
||||
typedef VABRawMap<float> VABRawMapFloat;
|
||||
typedef VABRawMap<double> VABRawMapDouble;
|
||||
typedef VABRawMap<int8> VABMapI8, VABMapByte;
|
||||
typedef VABRawMap<int16> VABMapI16, VABMapShort;
|
||||
typedef VABRawMap<int32> VABMapI32, VABMapInt;
|
||||
typedef VABRawMap<uint8> VABMapU8, VABMapUByte;
|
||||
typedef VABRawMap<uint16> VABMapU16, VABMapUShort;
|
||||
typedef VABRawMap<uint32> VABMapU32, VABMapUInt;
|
||||
typedef VABRawMap<float> VABMapFloat;
|
||||
typedef VABRawMap<double> VABMapDouble;
|
||||
|
||||
/**
|
||||
* VAB VertexAttribDataAccess数据访问映射
|
||||
* 顶点属性缓冲区数据访问映射
|
||||
*/
|
||||
template<typename T> class VABMap
|
||||
{
|
||||
PrimitiveCreater *pc;
|
||||
int vab_index;
|
||||
T *vb;
|
||||
VKBufferMap *buf_map;
|
||||
|
||||
T *map_ptr;
|
||||
|
||||
public:
|
||||
|
||||
VABMap(PrimitiveCreater *c,const AnsiString &name)
|
||||
{
|
||||
pc=c;
|
||||
vab_index=pc->GetVABIndex(name,T::GetVulkanFormat());
|
||||
VABMap(PrimitiveCreater *pc,const AnsiString &name)
|
||||
{
|
||||
buf_map=pc->MapVAB(name,T::GetVulkanFormat());
|
||||
|
||||
void *map_ptr=(T *)(pc->MapVAB(vab_index));
|
||||
|
||||
if(map_ptr)
|
||||
{
|
||||
vb=T::Create(pc->GetVertexCount(),map_ptr);
|
||||
|
||||
vb->Begin();
|
||||
}
|
||||
if(buf_map)
|
||||
map_ptr=(T *)(buf_map->Map());
|
||||
else
|
||||
{
|
||||
vb=nullptr;
|
||||
}
|
||||
map_ptr=nullptr;
|
||||
}
|
||||
|
||||
~VABMap()
|
||||
{
|
||||
if(pc&&vab_index>=0)
|
||||
pc->UnmapVAB(vab_index);
|
||||
if(map_ptr)
|
||||
buf_map->Unmap();
|
||||
}
|
||||
|
||||
void Restart()
|
||||
{
|
||||
if(vb)
|
||||
vb->Begin();
|
||||
}
|
||||
const bool IsValid()const{ return buf_map?buf_map->IsValid():false; }
|
||||
|
||||
const bool IsValid()const{ return vb; }
|
||||
|
||||
T *operator->(){ return vb; }
|
||||
operator T *(){ return map_ptr; }
|
||||
T *operator->(){ return map_ptr; }
|
||||
};//template<typename T> class VABMap
|
||||
|
||||
typedef VABMap<VB1i8> VABMap1i8 ,VABMap1b;
|
||||
@@ -197,38 +188,39 @@ typedef VABMap<VB4f> VABMap4f;
|
||||
typedef VABMap<VB4d> VABMap4d;
|
||||
|
||||
/**
|
||||
* 索引缓冲区映射访问
|
||||
* 索引缓冲区数据访问映射
|
||||
*/
|
||||
template<typename T> class IBMap
|
||||
{
|
||||
PrimitiveCreater *pc;
|
||||
VKBufferMap *buf_map;
|
||||
|
||||
T *map_ptr;
|
||||
|
||||
public:
|
||||
|
||||
IBMap(PrimitiveCreater *c)
|
||||
{
|
||||
pc=c;
|
||||
IBMap(PrimitiveCreater *pc)
|
||||
{
|
||||
buf_map=pc->MapIBO();
|
||||
|
||||
if(pc)
|
||||
map_ptr=(T *)(pc->MapIBO());
|
||||
if(buf_map)
|
||||
map_ptr=(T *)(buf_map->Map());
|
||||
else
|
||||
map_ptr=nullptr;
|
||||
}
|
||||
|
||||
~IBMap()
|
||||
{
|
||||
if(map_ptr&&pc)
|
||||
pc->UnmapIBO();
|
||||
if(map_ptr)
|
||||
buf_map->Unmap();
|
||||
}
|
||||
|
||||
const bool IsValid()const{ return map_ptr; }
|
||||
|
||||
operator T *(){ return map_ptr; }
|
||||
T *operator->(){ return map_ptr; }
|
||||
};//template<typename T> class IBMap
|
||||
|
||||
using IBMapU8=IBMap<uint8>;
|
||||
using IBMapU8 =IBMap<uint8>;
|
||||
using IBMapU16=IBMap<uint16>;
|
||||
using IBMapU32=IBMap<uint32>;
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
Reference in New Issue
Block a user