changed many size/count type why to equal vkCmdDraw/vkCmdDrawIndexed
This commit is contained in:
parent
bf5e401566
commit
9947d46ab8
@ -7,7 +7,7 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 可绘制图元创建器
|
||||
* 可绘制原始图形创建器
|
||||
*/
|
||||
class PrimitiveCreater
|
||||
{
|
||||
@ -23,9 +23,9 @@ protected:
|
||||
AnsiString prim_name;
|
||||
PrimitiveData * prim_data;
|
||||
|
||||
VkDeviceSize vertices_number; ///<顶点数量
|
||||
uint32_t vertices_number; ///<顶点数量
|
||||
|
||||
VkDeviceSize index_number; ///<索引数量
|
||||
uint32_t index_number; ///<索引数量
|
||||
IndexType index_type; ///<索引类型
|
||||
IBAccess * iba; ///<索引缓冲区
|
||||
|
||||
@ -35,13 +35,22 @@ public:
|
||||
PrimitiveCreater(VertexDataManager *);
|
||||
virtual ~PrimitiveCreater();
|
||||
|
||||
virtual bool Init(const AnsiString &name,const VkDeviceSize vertices_count,const VkDeviceSize index_count=0,IndexType it=IndexType::AUTO); ///<初始化,参数为顶点数量
|
||||
/**
|
||||
* 初始化一个原始图形创建
|
||||
* @parama name 原始图形名称
|
||||
* @parama vertices_count 顶点数量
|
||||
* @parama index_count 索引数量
|
||||
* @parama it 索引类型(注:当使用VDM时,此值无效)
|
||||
*/
|
||||
bool Init(const AnsiString &name,
|
||||
const uint32_t vertices_count,
|
||||
const uint32_t index_count=0,IndexType it=IndexType::AUTO);
|
||||
|
||||
void Clear(); ///<清除创建器数据
|
||||
|
||||
public: //顶点缓冲区
|
||||
|
||||
const VkDeviceSize GetVertexCount()const{ return vertices_number; } ///<取得顶点数量
|
||||
const uint32_t GetVertexCount()const{ return vertices_number; } ///<取得顶点数量
|
||||
|
||||
VABAccess * AcquireVAB (const AnsiString &name,const VkFormat &format,const void *data=nullptr); ///<请求一个顶点属性数据区
|
||||
bool WriteVAB (const AnsiString &name,const VkFormat &format,const void *data) ///<直接写入顶点属性数据
|
||||
@ -51,19 +60,20 @@ public: //顶点缓冲区
|
||||
|
||||
public: //索引缓冲区
|
||||
|
||||
const IndexType GetIndexType()const{return index_type;}
|
||||
const IndexType GetIndexType()const{return index_type;} ///<取得索引类型
|
||||
const uint32_t GetIndexCount()const{return index_number;} ///<取得索引数量
|
||||
|
||||
void * MapIBO();
|
||||
void UnmapIBO();
|
||||
|
||||
bool WriteIBO(const void *data,const VkDeviceSize count);
|
||||
bool WriteIBO(const void *data,const uint32_t count);
|
||||
|
||||
template<typename T>
|
||||
bool WriteIBO(const T *data){return WriteIBO(data,index_number);}
|
||||
|
||||
public: //创建可渲染对象
|
||||
|
||||
virtual Primitive * Create(); ///<创建一个可渲染对象,并清除创建器数据
|
||||
Primitive * Create(); ///<创建一个可渲染对象,并清除创建器数据
|
||||
};//class PrimitiveCreater
|
||||
|
||||
/**
|
||||
|
@ -63,8 +63,8 @@ using VAB=VertexAttribBuffer;
|
||||
struct VABAccess
|
||||
{
|
||||
VAB *vab;
|
||||
VkDeviceSize start;
|
||||
VkDeviceSize count;
|
||||
uint32_t start;
|
||||
uint32_t count;
|
||||
|
||||
public:
|
||||
|
||||
@ -76,8 +76,8 @@ class IndexBuffer;
|
||||
struct IndexBufferAccess
|
||||
{
|
||||
IndexBuffer *buffer;
|
||||
VkDeviceSize start;
|
||||
VkDeviceSize count;
|
||||
uint32_t start;
|
||||
uint32_t count;
|
||||
};
|
||||
|
||||
using IBAccess=IndexBufferAccess;
|
||||
|
@ -234,6 +234,9 @@ void MaterialRenderList::Render(RenderItem *ri)
|
||||
ri->dd->index_start,
|
||||
ri->dd->vab_offset[0],
|
||||
ri->first);
|
||||
|
||||
//因为vkCmdDrawIndexed的vertexOffset是针对所有VAB的,所以所有的VAB数据都必须是对齐的,最终这里使用vab_offset[0]是可以的,因为它也等于其它所有的vab_offset。
|
||||
//未来考虑看看能不能统一成一个。
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ void PrimitiveCreater::Clear()
|
||||
iba =nullptr;
|
||||
}
|
||||
|
||||
bool PrimitiveCreater::Init(const AnsiString &pname,const VkDeviceSize vertex_count,const VkDeviceSize index_count,IndexType it)
|
||||
bool PrimitiveCreater::Init(const AnsiString &pname,const uint32_t vertex_count,const uint32_t index_count,IndexType it)
|
||||
{
|
||||
if(prim_data) //已经初始化过了
|
||||
return(false);
|
||||
@ -151,7 +151,7 @@ void PrimitiveCreater::UnmapIBO()
|
||||
iba->buffer->Unmap();
|
||||
}
|
||||
|
||||
bool PrimitiveCreater::WriteIBO(const void *data,const VkDeviceSize count)
|
||||
bool PrimitiveCreater::WriteIBO(const void *data,const uint32_t count)
|
||||
{
|
||||
if(!data)return(false);
|
||||
if(!prim_data)return(false);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
PrimitiveData::PrimitiveData(const VIL *_vil,const VkDeviceSize vc)
|
||||
PrimitiveData::PrimitiveData(const VIL *_vil,const uint32_t vc)
|
||||
{
|
||||
vil=_vil;
|
||||
|
||||
@ -100,7 +100,7 @@ namespace
|
||||
|
||||
VertexDataManager *GetVDM(){return nullptr;}
|
||||
|
||||
PrimitiveDataPrivateBuffer(GPUDevice *dev,const VIL *_vil,const VkDeviceSize vc):PrimitiveData(_vil,vc)
|
||||
PrimitiveDataPrivateBuffer(GPUDevice *dev,const VIL *_vil,const uint32_t vc):PrimitiveData(_vil,vc)
|
||||
{
|
||||
device=dev;
|
||||
}
|
||||
@ -127,7 +127,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
IBAccess *InitIBO(const VkDeviceSize index_count,IndexType it) override
|
||||
IBAccess *InitIBO(const uint32_t index_count,IndexType it) override
|
||||
{
|
||||
if(!device)return(nullptr);
|
||||
|
||||
@ -201,7 +201,7 @@ namespace
|
||||
|
||||
VertexDataManager *GetVDM(){return vdm;}
|
||||
|
||||
PrimitiveDataVDM(VertexDataManager *_vdm,const VkDeviceSize vc):PrimitiveData(_vdm->GetVIL(),vc)
|
||||
PrimitiveDataVDM(VertexDataManager *_vdm,const uint32_t vc):PrimitiveData(_vdm->GetVIL(),vc)
|
||||
{
|
||||
vdm=_vdm;
|
||||
|
||||
@ -218,7 +218,7 @@ namespace
|
||||
vdm->ReleaseVAB(vab_node);
|
||||
}
|
||||
|
||||
IBAccess *InitIBO(const VkDeviceSize index_count,IndexType it) override
|
||||
IBAccess *InitIBO(const uint32_t index_count,IndexType it) override
|
||||
{
|
||||
if(index_count<=0)return(nullptr);
|
||||
if(!vdm)return(nullptr);
|
||||
@ -277,7 +277,7 @@ namespace
|
||||
};//class PrimitiveDataVDM:public PrimitiveData
|
||||
}//namespace
|
||||
|
||||
PrimitiveData *CreatePrimitiveData(GPUDevice *dev,const VIL *_vil,const VkDeviceSize vc)
|
||||
PrimitiveData *CreatePrimitiveData(GPUDevice *dev,const VIL *_vil,const uint32_t vc)
|
||||
{
|
||||
if(!dev)return(nullptr);
|
||||
if(!_vil)return(nullptr);
|
||||
@ -286,7 +286,7 @@ PrimitiveData *CreatePrimitiveData(GPUDevice *dev,const VIL *_vil,const VkDevice
|
||||
return(new PrimitiveDataPrivateBuffer(dev,_vil,vc));
|
||||
}
|
||||
|
||||
PrimitiveData *CreatePrimitiveData(VertexDataManager *vdm,const VkDeviceSize vc)
|
||||
PrimitiveData *CreatePrimitiveData(VertexDataManager *vdm,const uint32_t vc)
|
||||
{
|
||||
if(!vdm)return(nullptr);
|
||||
if(vc<=0)return(nullptr);
|
||||
|
@ -21,19 +21,19 @@ protected:
|
||||
|
||||
const VIL * vil;
|
||||
|
||||
VkDeviceSize vertex_count;
|
||||
uint32_t vertex_count;
|
||||
|
||||
VABAccess *vab_access;
|
||||
IBAccess ib_access;
|
||||
|
||||
public:
|
||||
|
||||
PrimitiveData(const VIL *_vil,const VkDeviceSize vc);
|
||||
PrimitiveData(const VIL *_vil,const uint32_t vc);
|
||||
virtual ~PrimitiveData();
|
||||
|
||||
public:
|
||||
|
||||
const VkDeviceSize GetVertexCount ()const{return vertex_count;}
|
||||
const uint32_t GetVertexCount ()const{return vertex_count;}
|
||||
const int GetVABCount ()const;
|
||||
const int GetVABIndex (const AnsiString &name)const;
|
||||
VABAccess * GetVABAccess (const int index);
|
||||
@ -48,10 +48,10 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
virtual IBAccess * InitIBO(const VkDeviceSize index_count,IndexType it)=0;
|
||||
virtual IBAccess * InitIBO(const uint32_t index_count,IndexType it)=0;
|
||||
virtual VABAccess *InitVAB(const AnsiString &name,const VkFormat &format,const void *data)=0;
|
||||
};//class PrimitiveData
|
||||
|
||||
PrimitiveData *CreatePrimitiveData(GPUDevice *dev,const VIL *_vil,const VkDeviceSize vc);
|
||||
PrimitiveData *CreatePrimitiveData(VertexDataManager *vdm,const VkDeviceSize vc);
|
||||
PrimitiveData *CreatePrimitiveData(GPUDevice *dev,const VIL *_vil,const uint32_t vc);
|
||||
PrimitiveData *CreatePrimitiveData(VertexDataManager *vdm,const uint32_t vc);
|
||||
VK_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user