Layout codes.
This commit is contained in:
parent
40094a7529
commit
03491dbed8
@ -1,23 +1,19 @@
|
||||
#ifndef HGL_GRAPH_PRIMITIVE_CREATER_INCLUDE
|
||||
#define HGL_GRAPH_PRIMITIVE_CREATER_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/VertexAttribDataAccess.h>
|
||||
#include<hgl/graph/VKShaderModule.h>
|
||||
#include<hgl/graph/VKIndexBuffer.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class VertexDataManager;
|
||||
VK_NAMESPACE_BEGIN
|
||||
class VertexDataManager;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 可绘制图元创建器
|
||||
*/
|
||||
class PrimitiveCreater
|
||||
{
|
||||
protected:
|
||||
class PrimitiveCreater
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUDevice *device;
|
||||
const GPUPhysicalDevice *phy_device;
|
||||
@ -27,7 +23,7 @@ namespace hgl
|
||||
|
||||
const VIL *vil;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
VkDeviceSize vertices_number;
|
||||
VkDeviceSize index_number;
|
||||
@ -36,13 +32,13 @@ namespace hgl
|
||||
void * ibo_map;
|
||||
VABAccessMap vab_map;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
bool AcquirePVB(VABAccess *,const AnsiString &,const void *data); ///<请求一个顶点属性数据区
|
||||
|
||||
void ClearAllData();
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
PrimitiveCreater(RenderResource *sdb,const VIL *);
|
||||
PrimitiveCreater(VertexDataManager *);
|
||||
@ -92,7 +88,5 @@ namespace hgl
|
||||
}
|
||||
|
||||
virtual Primitive * Finish(const AnsiString &); ///<结束并创建可渲染对象
|
||||
};//class PrimitiveCreater
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_PRIMITIVE_CREATER_INCLUDE
|
||||
};//class PrimitiveCreater
|
||||
VK_NAMESPACE_END
|
@ -4,12 +4,9 @@
|
||||
#include<hgl/graph/VKPrimitive.h>
|
||||
#include<hgl/graph/VertexDataManager.h>
|
||||
|
||||
namespace hgl
|
||||
VK_NAMESPACE_BEGIN
|
||||
PrimitiveCreater::PrimitiveCreater(RenderResource *sdb,const VIL *v)
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
PrimitiveCreater::PrimitiveCreater(RenderResource *sdb,const VIL *v)
|
||||
{
|
||||
device =sdb->GetDevice();
|
||||
phy_device =device->GetPhysicalDevice();
|
||||
|
||||
@ -21,10 +18,10 @@ namespace hgl
|
||||
index_number =0;
|
||||
ibo =nullptr;
|
||||
ibo_map =nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PrimitiveCreater::PrimitiveCreater(VertexDataManager *_vdm)
|
||||
{
|
||||
PrimitiveCreater::PrimitiveCreater(VertexDataManager *_vdm)
|
||||
{
|
||||
device =_vdm->GetDevice();
|
||||
phy_device =device->GetPhysicalDevice();
|
||||
|
||||
@ -36,19 +33,19 @@ namespace hgl
|
||||
index_number =0;
|
||||
ibo =nullptr;
|
||||
ibo_map =nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PrimitiveCreater::~PrimitiveCreater()
|
||||
{
|
||||
PrimitiveCreater::~PrimitiveCreater()
|
||||
{
|
||||
if(ibo)
|
||||
{
|
||||
ibo->Unmap();
|
||||
delete ibo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PrimitiveCreater::Init(const uint32 vertex_count,const uint32 index_count,IndexType it)
|
||||
{
|
||||
bool PrimitiveCreater::Init(const uint32 vertex_count,const uint32 index_count,IndexType it)
|
||||
{
|
||||
if(vertex_count<=0)return(false);
|
||||
|
||||
vertices_number=vertex_count;
|
||||
@ -84,10 +81,10 @@ namespace hgl
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool PrimitiveCreater::AcquirePVB(VABAccess *vad,const AnsiString &name,const void *data)
|
||||
{
|
||||
bool PrimitiveCreater::AcquirePVB(VABAccess *vad,const AnsiString &name,const void *data)
|
||||
{
|
||||
if(!vad)return(false);
|
||||
if(!vil)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
@ -110,10 +107,10 @@ namespace hgl
|
||||
vab_map.Add(name,*vad);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool PrimitiveCreater::WriteVAB(const AnsiString &name,const void *data,const uint32_t bytes)
|
||||
{
|
||||
bool PrimitiveCreater::WriteVAB(const AnsiString &name,const void *data,const uint32_t bytes)
|
||||
{
|
||||
if(!vil)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
if(!data)return(false);
|
||||
@ -130,10 +127,10 @@ namespace hgl
|
||||
VABAccess vad;
|
||||
|
||||
return AcquirePVB(&vad,name,data);
|
||||
}
|
||||
}
|
||||
|
||||
void PrimitiveCreater::ClearAllData()
|
||||
{
|
||||
void PrimitiveCreater::ClearAllData()
|
||||
{
|
||||
if(vab_map.GetCount()>0)
|
||||
{
|
||||
const auto *sp=vab_map.GetDataList();
|
||||
@ -155,10 +152,10 @@ namespace hgl
|
||||
delete ibo;
|
||||
ibo=nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Primitive *PrimitiveCreater::Finish(const AnsiString &prim_name)
|
||||
{
|
||||
Primitive *PrimitiveCreater::Finish(const AnsiString &prim_name)
|
||||
{
|
||||
const uint si_count=vil->GetCount(VertexInputGroup::Basic);
|
||||
|
||||
if(vab_map.GetCount()!=si_count)
|
||||
@ -197,6 +194,5 @@ namespace hgl
|
||||
db->Add(primitive);
|
||||
|
||||
return primitive;
|
||||
}
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
}
|
||||
VK_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user