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