preparing to support uint8 index
This commit is contained in:
parent
4fc74d38ba
commit
621e056315
@ -25,6 +25,9 @@ namespace hgl
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
GPUDevice *device;
|
||||||
|
const GPUPhysicalDevice *phy_device;
|
||||||
|
|
||||||
VertexDataManager *vdm;
|
VertexDataManager *vdm;
|
||||||
RenderResource *db;
|
RenderResource *db;
|
||||||
|
|
||||||
@ -49,7 +52,7 @@ namespace hgl
|
|||||||
PrimitiveCreater(VertexDataManager *);
|
PrimitiveCreater(VertexDataManager *);
|
||||||
virtual ~PrimitiveCreater()=default;
|
virtual ~PrimitiveCreater()=default;
|
||||||
|
|
||||||
virtual bool Init(const uint32 vertices_count); ///<初始化,参数为顶点数量
|
virtual bool Init(const uint32 vertices_count,const uint32 index_count,IndexType it=IndexType::ERR); ///<初始化,参数为顶点数量
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T * AccessVBO(const AnsiString &name) ///<创建一个顶点属性数据缓冲区以及访问器
|
T * AccessVBO(const AnsiString &name) ///<创建一个顶点属性数据缓冲区以及访问器
|
||||||
|
@ -14,8 +14,8 @@ namespace hgl
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
VIL * vil; ///<顶点输入格式列表
|
const VIL * vil; ///<顶点输入格式列表
|
||||||
uint vi_count; ///<顶点输入流数量
|
uint vi_count; ///<顶点输入流数量
|
||||||
const VIF * vif_list; ///<顶点输入格式列表
|
const VIF * vif_list; ///<顶点输入格式列表
|
||||||
|
|
||||||
VkDeviceSize vbo_max_size; ///<顶点缓冲区分配空间大小
|
VkDeviceSize vbo_max_size; ///<顶点缓冲区分配空间大小
|
||||||
@ -35,6 +35,8 @@ namespace hgl
|
|||||||
VertexDataManager(GPUDevice *dev,const VIL *_vil);
|
VertexDataManager(GPUDevice *dev,const VIL *_vil);
|
||||||
~VertexDataManager();
|
~VertexDataManager();
|
||||||
|
|
||||||
|
GPUDevice * GetDevice ()const{return device;} ///<取得GPU设备
|
||||||
|
|
||||||
const VIL * GetVIL ()const{return vil;} ///<取得顶点输入格式列表
|
const VIL * GetVIL ()const{return vil;} ///<取得顶点输入格式列表
|
||||||
|
|
||||||
const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量
|
const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量
|
||||||
|
@ -18,7 +18,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
PrimitiveCreater rc(db,vil);
|
PrimitiveCreater rc(db,vil);
|
||||||
|
|
||||||
if(!rc.Init(4))
|
if(!rc.Init(4,0))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
||||||
@ -46,7 +46,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(rci->radius==0||rci->round_per<=1) //这是要画矩形
|
if(rci->radius==0||rci->round_per<=1) //这是要画矩形
|
||||||
{
|
{
|
||||||
if(!rc.Init(4))
|
if(!rc.Init(4,0))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
||||||
@ -60,7 +60,7 @@ namespace hgl
|
|||||||
if(radius>rci->scope.GetWidth()/2.0f)radius=rci->scope.GetWidth()/2.0f;
|
if(radius>rci->scope.GetWidth()/2.0f)radius=rci->scope.GetWidth()/2.0f;
|
||||||
if(radius>rci->scope.GetHeight()/2.0f)radius=rci->scope.GetHeight()/2.0f;
|
if(radius>rci->scope.GetHeight()/2.0f)radius=rci->scope.GetHeight()/2.0f;
|
||||||
|
|
||||||
if(!rc.Init(rci->round_per*4))
|
if(!rc.Init(rci->round_per*4,8))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
||||||
@ -123,12 +123,12 @@ namespace hgl
|
|||||||
if(cci->has_color)
|
if(cci->has_color)
|
||||||
{
|
{
|
||||||
edge=cci->field_count+1;
|
edge=cci->field_count+1;
|
||||||
if(!rc.Init(cci->field_count+2))return(nullptr);
|
if(!rc.Init(cci->field_count+2,0))return(nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
edge=cci->field_count;
|
edge=cci->field_count;
|
||||||
if(!rc.Init(cci->field_count))return(nullptr);
|
if(!rc.Init(cci->field_count,0))return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
AutoDelete<VB2f> vertex=rc.AccessVBO<VB2f>(VAN::Position);
|
||||||
@ -166,7 +166,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
PrimitiveCreater rc(db,vil);
|
PrimitiveCreater rc(db,vil);
|
||||||
|
|
||||||
if(!rc.Init(((pgci->grid_size.Width()+1)+(pgci->grid_size.Height()+1))*2))
|
if(!rc.Init(((pgci->grid_size.Width()+1)+(pgci->grid_size.Height()+1))*2,8))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
AutoDelete<VB3f> vertex=rc.AccessVBO<VB3f>(VAN::Position);
|
AutoDelete<VB3f> vertex=rc.AccessVBO<VB3f>(VAN::Position);
|
||||||
@ -221,7 +221,7 @@ namespace hgl
|
|||||||
|
|
||||||
PrimitiveCreater rc(db,vil);
|
PrimitiveCreater rc(db,vil);
|
||||||
|
|
||||||
if(!rc.Init(4))
|
if(!rc.Init(4,8))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
rc.WriteVBO(VAN::Position,xy_vertices,sizeof(xy_vertices));
|
rc.WriteVBO(VAN::Position,xy_vertices,sizeof(xy_vertices));
|
||||||
|
@ -9,6 +9,9 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
PrimitiveCreater::PrimitiveCreater(RenderResource *sdb,const VIL *v)
|
PrimitiveCreater::PrimitiveCreater(RenderResource *sdb,const VIL *v)
|
||||||
{
|
{
|
||||||
|
device=sdb->GetDevice();
|
||||||
|
phy_device=device->GetPhysicalDevice();
|
||||||
|
|
||||||
db =sdb;
|
db =sdb;
|
||||||
vil =v;
|
vil =v;
|
||||||
|
|
||||||
@ -18,18 +21,39 @@ namespace hgl
|
|||||||
|
|
||||||
PrimitiveCreater::PrimitiveCreater(VertexDataManager *_vdm)
|
PrimitiveCreater::PrimitiveCreater(VertexDataManager *_vdm)
|
||||||
{
|
{
|
||||||
|
device=_vdm->GetDevice();
|
||||||
|
phy_device=device->GetPhysicalDevice();
|
||||||
|
|
||||||
vdm=_vdm;
|
vdm=_vdm;
|
||||||
vil=vdm->GetVIL();
|
vil=vdm->GetVIL();
|
||||||
|
|
||||||
vertices_number =0;
|
vertices_number =0;
|
||||||
ibo =nullptr;
|
ibo =nullptr;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrimitiveCreater::Init(const uint32 count)
|
bool PrimitiveCreater::Init(const uint32 vertex_count,const uint32 index_count,IndexType it)
|
||||||
{
|
{
|
||||||
if(count<=0)return(false);
|
if(vertex_count<=0)return(false);
|
||||||
|
|
||||||
vertices_number=count;
|
vertices_number=vertex_count;
|
||||||
|
|
||||||
|
if(index_count>0)
|
||||||
|
{
|
||||||
|
if(it==IndexType::ERR)
|
||||||
|
{
|
||||||
|
if(vertex_count<=0xFFFF)
|
||||||
|
it=IndexType::U16;
|
||||||
|
else
|
||||||
|
it=IndexType::U32;
|
||||||
|
}
|
||||||
|
|
||||||
|
ibo=db->CreateIBO(it,index_count);
|
||||||
|
if(!ibo)return(false);
|
||||||
|
|
||||||
|
ibo->Map();
|
||||||
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,9 @@ namespace
|
|||||||
|
|
||||||
// VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME,
|
// VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME,
|
||||||
|
|
||||||
|
VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME,
|
||||||
|
VK_KHR_INDEX_TYPE_UINT8_EXTENSION_NAME,
|
||||||
|
|
||||||
VK_KHR_SPIRV_1_4_EXTENSION_NAME,
|
VK_KHR_SPIRV_1_4_EXTENSION_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user