use Prim instead macros.
use IndexType instead VkIndexType
This commit is contained in:
parent
1e6e0e305c
commit
3fd9d1535d
@ -92,7 +92,7 @@ private:
|
|||||||
pipeline_creater->SetDepthTest(true);
|
pipeline_creater->SetDepthTest(true);
|
||||||
pipeline_creater->SetDepthWrite(true);
|
pipeline_creater->SetDepthWrite(true);
|
||||||
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(Prim::Triangles);
|
||||||
pipeline_solid=pipeline_creater->Create();
|
pipeline_solid=pipeline_creater->Create();
|
||||||
|
|
||||||
if(!pipeline_solid)
|
if(!pipeline_solid)
|
||||||
|
@ -108,7 +108,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_RECTANGLES);
|
pipeline_creater->Set(Prim::Rectangles);
|
||||||
|
|
||||||
pipeline=pipeline_creater->Create();
|
pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_RECTANGLES);
|
pipeline_creater->Set(Prim::Rectangles);
|
||||||
|
|
||||||
pipeline=pipeline_creater->Create();
|
pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_TRIANGLE_FAN);
|
pipeline_creater->Set(Prim::Fan);
|
||||||
|
|
||||||
pipeline=pipeline_creater->Create();
|
pipeline=pipeline_creater->Create();
|
||||||
if(!pipeline)return(false);
|
if(!pipeline)return(false);
|
||||||
|
@ -59,7 +59,7 @@ private:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitPipeline(MDP *mdp,const VkPrimitiveTopology primitive)
|
bool InitPipeline(MDP *mdp,const Prim primitive)
|
||||||
{
|
{
|
||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,mdp->material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,mdp->material,sc_render_target);
|
||||||
@ -75,7 +75,7 @@ private:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitMDP(MDP *mdp,const VkPrimitiveTopology primitive,const OSString &vs,const OSString &fs)
|
bool InitMDP(MDP *mdp,const Prim primitive,const OSString &vs,const OSString &fs)
|
||||||
{
|
{
|
||||||
if(!InitMaterial(mdp,vs,fs))
|
if(!InitMaterial(mdp,vs,fs))
|
||||||
return(false);
|
return(false);
|
||||||
@ -152,11 +152,11 @@ public:
|
|||||||
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitMDP(&m3d,PRIM_LINES,OS_TEXT("res/shader/PositionColor3D.vert"),
|
if(!InitMDP(&m3d,Prim::Lines,OS_TEXT("res/shader/PositionColor3D.vert"),
|
||||||
OS_TEXT("res/shader/VertexColor.frag")))
|
OS_TEXT("res/shader/VertexColor.frag")))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitMDP(&m2d,PRIM_TRIANGLE_FAN, OS_TEXT("res/shader/OnlyPosition.vert"),
|
if(!InitMDP(&m2d,Prim::Fan, OS_TEXT("res/shader/OnlyPosition.vert"),
|
||||||
OS_TEXT("res/shader/FlatColor.frag")))
|
OS_TEXT("res/shader/FlatColor.frag")))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,mpd->material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,mpd->material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(Prim::Triangles);
|
||||||
|
|
||||||
mpd->pipeline=pipeline_creater->Create();
|
mpd->pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ private:
|
|||||||
{
|
{
|
||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->Set(PRIM_LINES);
|
pipeline_creater->Set(Prim::Lines);
|
||||||
|
|
||||||
pipeline_line=pipeline_creater->Create();
|
pipeline_line=pipeline_creater->Create();
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ private:
|
|||||||
|
|
||||||
db->Add(pipeline_line);
|
db->Add(pipeline_line);
|
||||||
|
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(Prim::Triangles);
|
||||||
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_FILL);
|
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_FILL);
|
||||||
pipeline_solid=pipeline_creater->Create();
|
pipeline_solid=pipeline_creater->Create();
|
||||||
|
|
||||||
|
@ -272,11 +272,11 @@ public:
|
|||||||
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))//,model_data->bounding_box))
|
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))//,model_data->bounding_box))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitMP(&mp_solid, PRIM_TRIANGLES, OS_TEXT("res/shader/pbr_Light.vert"),
|
if(!InitMP(&mp_solid, Prim::Triangles, OS_TEXT("res/shader/pbr_Light.vert"),
|
||||||
OS_TEXT("res/shader/pbr_DirectionLight.frag")))
|
OS_TEXT("res/shader/pbr_DirectionLight.frag")))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitMP(&mp_line, PRIM_LINES, OS_TEXT("res/shader/PositionColor3D.vert"),
|
if(!InitMP(&mp_line, Prim::Lines, OS_TEXT("res/shader/PositionColor3D.vert"),
|
||||||
OS_TEXT("res/shader/VertexColor.frag")))
|
OS_TEXT("res/shader/VertexColor.frag")))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_RECTANGLES);
|
pipeline_creater->Set(Prim::Rectangles);
|
||||||
|
|
||||||
pipeline=pipeline_creater->Create();
|
pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ private:
|
|||||||
pipeline_creater->SetDepthWrite(true);
|
pipeline_creater->SetDepthWrite(true);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_FILL);
|
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_FILL);
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(Prim::Triangles);
|
||||||
|
|
||||||
pipeline_line=pipeline_creater->Create();
|
pipeline_line=pipeline_creater->Create();
|
||||||
if(!pipeline_line)
|
if(!pipeline_line)
|
||||||
|
@ -63,9 +63,9 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Database * db =nullptr;
|
vulkan::Database * db =nullptr;
|
||||||
|
|
||||||
bool key_status[kbRangeSize];
|
bool key_status[kbRangeSize];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
render_complete_semaphore =device->CreateSem();
|
render_complete_semaphore =device->CreateSem();
|
||||||
|
|
||||||
shader_manage=device->CreateShaderModuleManage();
|
shader_manage=device->CreateShaderModuleManage();
|
||||||
db=new Database(device);
|
db=new vulkan::Database(device);
|
||||||
|
|
||||||
InitCommandBuffer();
|
InitCommandBuffer();
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(Prim::Triangles);
|
||||||
|
|
||||||
SaveToFile(PIPELINE_FILENAME,pipeline_creater);
|
SaveToFile(PIPELINE_FILENAME,pipeline_creater);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(Prim::Triangles);
|
||||||
|
|
||||||
pipeline=pipeline_creater->Create();
|
pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater>
|
AutoDelete<vulkan::PipelineCreater>
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(Prim::Triangles);
|
||||||
|
|
||||||
pipeline=pipeline_creater->Create();
|
pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
{
|
{
|
||||||
class Database;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 矩形创建信息(扇形/三角形条)
|
* 矩形创建信息(扇形/三角形条)
|
||||||
*/
|
*/
|
||||||
@ -19,12 +17,12 @@ namespace hgl
|
|||||||
RectScope2f scope;
|
RectScope2f scope;
|
||||||
};//struct RectangleCreateInfo
|
};//struct RectangleCreateInfo
|
||||||
|
|
||||||
vulkan::Renderable *CreateRenderableRectangle(Database *db,vulkan::Material *mtl,const RectangleCreateInfo *rci);
|
vulkan::Renderable *CreateRenderableRectangle(vulkan::Database *db,vulkan::Material *mtl,const RectangleCreateInfo *rci);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建延迟渲染用全屏平面
|
* 创建延迟渲染用全屏平面
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableGBufferComposition(Database *db,vulkan::Material *mtl);
|
vulkan::Renderable *CreateRenderableGBufferComposition(vulkan::Database *db,vulkan::Material *mtl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 圆角矩形创建信息(扇形/线圈)
|
* 圆角矩形创建信息(扇形/线圈)
|
||||||
@ -35,7 +33,7 @@ namespace hgl
|
|||||||
uint32_t round_per; ///<圆角精度
|
uint32_t round_per; ///<圆角精度
|
||||||
};//struct RoundRectangleCreateInfo:public RectangleCreateInfo
|
};//struct RoundRectangleCreateInfo:public RectangleCreateInfo
|
||||||
|
|
||||||
vulkan::Renderable *CreateRenderableRoundRectangle(Database *db,vulkan::Material *mtl,const RoundRectangleCreateInfo *rci);
|
vulkan::Renderable *CreateRenderableRoundRectangle(vulkan::Database *db,vulkan::Material *mtl,const RoundRectangleCreateInfo *rci);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 圆形创建信息
|
* 圆形创建信息
|
||||||
@ -50,7 +48,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个2D圆形(扇形/线圈)
|
* 创建一个2D圆形(扇形/线圈)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableCircle(Database *db,vulkan::Material *mtl,const CircleCreateInfo *rci);
|
vulkan::Renderable *CreateRenderableCircle(vulkan::Database *db,vulkan::Material *mtl,const CircleCreateInfo *rci);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平面网格创建信息
|
* 平面网格创建信息
|
||||||
@ -69,7 +67,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个平面网格(线条)
|
* 创建一个平面网格(线条)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderablePlaneGrid(Database *db,vulkan::Material *mtl,const PlaneGridCreateInfo *pgci);
|
vulkan::Renderable *CreateRenderablePlaneGrid(vulkan::Database *db,vulkan::Material *mtl,const PlaneGridCreateInfo *pgci);
|
||||||
|
|
||||||
struct PlaneCreateInfo
|
struct PlaneCreateInfo
|
||||||
{
|
{
|
||||||
@ -86,7 +84,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个平面(三角形)
|
* 创建一个平面(三角形)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderablePlane(Database *db,vulkan::Material *mtl,const PlaneCreateInfo *pci);
|
vulkan::Renderable *CreateRenderablePlane(vulkan::Database *db,vulkan::Material *mtl,const PlaneCreateInfo *pci);
|
||||||
|
|
||||||
struct CubeCreateInfo
|
struct CubeCreateInfo
|
||||||
{
|
{
|
||||||
@ -126,17 +124,17 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个立方体(三角形)
|
* 创建一个立方体(三角形)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableCube(Database *db,vulkan::Material *mtl,const CubeCreateInfo *cci);
|
vulkan::Renderable *CreateRenderableCube(vulkan::Database *db,vulkan::Material *mtl,const CubeCreateInfo *cci);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个绑定盒(线条)
|
* 创建一个绑定盒(线条)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableBoundingBox(Database *db,vulkan::Material *mtl,const CubeCreateInfo *cci);
|
vulkan::Renderable *CreateRenderableBoundingBox(vulkan::Database *db,vulkan::Material *mtl,const CubeCreateInfo *cci);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个球心坐标为0,0,0,半径为1的球体(三角形)
|
* 创建一个球心坐标为0,0,0,半径为1的球体(三角形)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableSphere(Database *db,vulkan::Material *mtl,const uint numberSlices);
|
vulkan::Renderable *CreateRenderableSphere(vulkan::Database *db,vulkan::Material *mtl,const uint numberSlices);
|
||||||
|
|
||||||
struct DomeCreateInfo
|
struct DomeCreateInfo
|
||||||
{
|
{
|
||||||
@ -147,7 +145,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个穹顶(三角形)
|
* 创建一个穹顶(三角形)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableDome(Database *db,vulkan::Material *mtl, const DomeCreateInfo *);
|
vulkan::Renderable *CreateRenderableDome(vulkan::Database *db,vulkan::Material *mtl, const DomeCreateInfo *);
|
||||||
|
|
||||||
struct TorusCreateInfo
|
struct TorusCreateInfo
|
||||||
{
|
{
|
||||||
@ -161,7 +159,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个圆环(三角形)
|
* 创建一个圆环(三角形)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableTorus(Database *db,vulkan::Material *mtl,const TorusCreateInfo *tci);
|
vulkan::Renderable *CreateRenderableTorus(vulkan::Database *db,vulkan::Material *mtl,const TorusCreateInfo *tci);
|
||||||
|
|
||||||
struct CylinderCreateInfo
|
struct CylinderCreateInfo
|
||||||
{
|
{
|
||||||
@ -173,7 +171,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个圆柱(三角形)
|
* 创建一个圆柱(三角形)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableCylinder(Database *db,vulkan::Material *mtl,const CylinderCreateInfo *cci);
|
vulkan::Renderable *CreateRenderableCylinder(vulkan::Database *db,vulkan::Material *mtl,const CylinderCreateInfo *cci);
|
||||||
|
|
||||||
struct ConeCreateInfo
|
struct ConeCreateInfo
|
||||||
{
|
{
|
||||||
@ -186,7 +184,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个圆锥(三角形)
|
* 创建一个圆锥(三角形)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableCone(Database *db,vulkan::Material *mtl,const ConeCreateInfo *cci);
|
vulkan::Renderable *CreateRenderableCone(vulkan::Database *db,vulkan::Material *mtl,const ConeCreateInfo *cci);
|
||||||
|
|
||||||
struct AxisCreateInfo
|
struct AxisCreateInfo
|
||||||
{
|
{
|
||||||
@ -226,7 +224,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 创建一个坐标线(线条)
|
* 创建一个坐标线(线条)
|
||||||
*/
|
*/
|
||||||
vulkan::Renderable *CreateRenderableAxis(Database *db,vulkan::Material *mtl,const AxisCreateInfo *aci);
|
vulkan::Renderable *CreateRenderableAxis(vulkan::Database *db,vulkan::Material *mtl,const AxisCreateInfo *aci);
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
};//namespace hgl
|
};//namespace hgl
|
||||||
#endif//HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|
#endif//HGL_GRAPH_INLINE_GEOMETRY_INCLUDE
|
||||||
|
@ -61,6 +61,8 @@ class VertexAttributeBinding;
|
|||||||
|
|
||||||
class Renderable;
|
class Renderable;
|
||||||
|
|
||||||
|
class Database;
|
||||||
|
|
||||||
enum class SharingMode
|
enum class SharingMode
|
||||||
{
|
{
|
||||||
Exclusive = 0,
|
Exclusive = 0,
|
||||||
@ -73,6 +75,12 @@ enum ImageTiling
|
|||||||
Linear
|
Linear
|
||||||
};//
|
};//
|
||||||
|
|
||||||
|
enum IndexType
|
||||||
|
{
|
||||||
|
U16=0,
|
||||||
|
U32
|
||||||
|
};
|
||||||
|
|
||||||
enum class ShaderStageBit
|
enum class ShaderStageBit
|
||||||
{
|
{
|
||||||
Vertex =VK_SHADER_STAGE_VERTEX_BIT,
|
Vertex =VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
|
@ -82,14 +82,14 @@ using VAB=VertexAttribBuffer;
|
|||||||
|
|
||||||
class IndexBuffer:public Buffer
|
class IndexBuffer:public Buffer
|
||||||
{
|
{
|
||||||
VkIndexType index_type;
|
IndexType index_type;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class Device;
|
friend class Device;
|
||||||
|
|
||||||
IndexBuffer(VkDevice d,const BufferData &vb,VkIndexType it,uint32_t _count):Buffer(d,vb)
|
IndexBuffer(VkDevice d,const BufferData &vb,IndexType it,uint32_t _count):Buffer(d,vb)
|
||||||
{
|
{
|
||||||
index_type=it;
|
index_type=it;
|
||||||
count=_count;
|
count=_count;
|
||||||
@ -99,8 +99,8 @@ public:
|
|||||||
|
|
||||||
~IndexBuffer()=default;
|
~IndexBuffer()=default;
|
||||||
|
|
||||||
const VkIndexType GetType ()const{return index_type;}
|
const IndexType GetType ()const{return index_type;}
|
||||||
const uint32 GetCount()const{return count;}
|
const uint32 GetCount()const{return count;}
|
||||||
};//class IndexBuffer:public Buffer
|
};//class IndexBuffer:public Buffer
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_BUFFER_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_BUFFER_INCLUDE
|
||||||
|
@ -75,13 +75,13 @@ public: //Create
|
|||||||
|
|
||||||
#undef SCENE_DB_CREATE_FUNC
|
#undef SCENE_DB_CREATE_FUNC
|
||||||
|
|
||||||
IndexBuffer *CreateIBO(VkIndexType index_type,uint32_t count,const void *data,SharingMode sm=SharingMode::Exclusive);
|
IndexBuffer *CreateIBO(IndexType index_type,uint32_t count,const void *data,SharingMode sm=SharingMode::Exclusive);
|
||||||
IndexBuffer *CreateIBO16(uint32_t count,const uint16 *data,SharingMode sm=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT16,count,(void *)data,sm);}
|
IndexBuffer *CreateIBO16(uint32_t count,const uint16 *data,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16,count,(void *)data,sm);}
|
||||||
IndexBuffer *CreateIBO32(uint32_t count,const uint32 *data,SharingMode sm=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT32,count,(void *)data,sm);}
|
IndexBuffer *CreateIBO32(uint32_t count,const uint32 *data,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32,count,(void *)data,sm);}
|
||||||
|
|
||||||
IndexBuffer *CreateIBO(VkIndexType index_type,uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(index_type,count,nullptr,sm);}
|
IndexBuffer *CreateIBO(IndexType index_type,uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(index_type,count,nullptr,sm);}
|
||||||
IndexBuffer *CreateIBO16(uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT16,count,nullptr,sm);}
|
IndexBuffer *CreateIBO16(uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16,count,nullptr,sm);}
|
||||||
IndexBuffer *CreateIBO32(uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT32,count,nullptr,sm);}
|
IndexBuffer *CreateIBO32(uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32,count,nullptr,sm);}
|
||||||
|
|
||||||
MaterialInstance * CreateMaterialInstance(Material *);
|
MaterialInstance * CreateMaterialInstance(Material *);
|
||||||
Renderable * CreateRenderable(Material *,const uint32_t vertex_count=0);
|
Renderable * CreateRenderable(Material *,const uint32_t vertex_count=0);
|
||||||
|
@ -97,13 +97,13 @@ public: //Buffer相关
|
|||||||
VAB * CreateVAB (VkFormat format,uint32_t count, SharingMode sharing_mode=SharingMode::Exclusive){return CreateVAB(format,count,nullptr,sharing_mode);}
|
VAB * CreateVAB (VkFormat format,uint32_t count, SharingMode sharing_mode=SharingMode::Exclusive){return CreateVAB(format,count,nullptr,sharing_mode);}
|
||||||
VAB * CreateVAB (const VAD *vad, SharingMode sharing_mode=SharingMode::Exclusive){return CreateVAB(vad->GetVulkanFormat(),vad->GetCount(),vad->GetData(),sharing_mode);}
|
VAB * CreateVAB (const VAD *vad, SharingMode sharing_mode=SharingMode::Exclusive){return CreateVAB(vad->GetVulkanFormat(),vad->GetCount(),vad->GetData(),sharing_mode);}
|
||||||
|
|
||||||
IndexBuffer * CreateIBO (VkIndexType index_type,uint32_t count,const void * data,SharingMode sharing_mode=SharingMode::Exclusive);
|
IndexBuffer * CreateIBO (IndexType index_type,uint32_t count,const void * data,SharingMode sharing_mode=SharingMode::Exclusive);
|
||||||
IndexBuffer * CreateIBO16 ( uint32_t count,const uint16 *data,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT16,count,(void *)data,sharing_mode);}
|
IndexBuffer * CreateIBO16 ( uint32_t count,const uint16 *data,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(IndexType::U16,count,(void *)data,sharing_mode);}
|
||||||
IndexBuffer * CreateIBO32 ( uint32_t count,const uint32 *data,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT32,count,(void *)data,sharing_mode);}
|
IndexBuffer * CreateIBO32 ( uint32_t count,const uint32 *data,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(IndexType::U32,count,(void *)data,sharing_mode);}
|
||||||
|
|
||||||
IndexBuffer * CreateIBO (VkIndexType index_type,uint32_t count,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(index_type,count,nullptr,sharing_mode);}
|
IndexBuffer * CreateIBO (IndexType index_type,uint32_t count,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(index_type,count,nullptr,sharing_mode);}
|
||||||
IndexBuffer * CreateIBO16 ( uint32_t count,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT16,count,nullptr,sharing_mode);}
|
IndexBuffer * CreateIBO16 ( uint32_t count,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(IndexType::U16,count,nullptr,sharing_mode);}
|
||||||
IndexBuffer * CreateIBO32 ( uint32_t count,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(VK_INDEX_TYPE_UINT32,count,nullptr,sharing_mode);}
|
IndexBuffer * CreateIBO32 ( uint32_t count,SharingMode sharing_mode=SharingMode::Exclusive){return CreateIBO(IndexType::U32,count,nullptr,sharing_mode);}
|
||||||
|
|
||||||
#define CREATE_BUFFER_OBJECT(LargeName,type) Buffer *Create##LargeName(VkDeviceSize size,void *data,SharingMode sharing_mode=SharingMode::Exclusive){return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size,data,sharing_mode);} \
|
#define CREATE_BUFFER_OBJECT(LargeName,type) Buffer *Create##LargeName(VkDeviceSize size,void *data,SharingMode sharing_mode=SharingMode::Exclusive){return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size,data,sharing_mode);} \
|
||||||
Buffer *Create##LargeName(VkDeviceSize size,SharingMode sharing_mode=SharingMode::Exclusive){return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size,nullptr,sharing_mode);}
|
Buffer *Create##LargeName(VkDeviceSize size,SharingMode sharing_mode=SharingMode::Exclusive){return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size,nullptr,sharing_mode);}
|
||||||
@ -124,7 +124,7 @@ public: //Image
|
|||||||
VkImage CreateCubemap (const VkFormat format,const uint32_t width,const uint32_t height, const uint usage,const ImageTiling tiling);
|
VkImage CreateCubemap (const VkFormat format,const uint32_t width,const uint32_t height, const uint usage,const ImageTiling tiling);
|
||||||
// VkImage CreateCubemapArray (const VkFormat format,const uint32_t width,const uint32_t height,const uint32_t count, const uint usage,const ImageTiling tiling);
|
// VkImage CreateCubemapArray (const VkFormat format,const uint32_t width,const uint32_t height,const uint32_t count, const uint usage,const ImageTiling tiling);
|
||||||
|
|
||||||
void DestoryImage (VkImage);
|
void DestoryImage (VkImage);
|
||||||
|
|
||||||
public: //Texture
|
public: //Texture
|
||||||
|
|
||||||
@ -176,13 +176,13 @@ public: //Texture
|
|||||||
const VkImageAspectFlags aspectMask =VK_IMAGE_ASPECT_COLOR_BIT,
|
const VkImageAspectFlags aspectMask =VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
const uint usage =VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT,
|
const uint usage =VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
const VkImageLayout image_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
const VkImageLayout image_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
const ImageTiling tiling =ImageTiling::Optimal);
|
const ImageTiling tiling =ImageTiling::Optimal);
|
||||||
|
|
||||||
Texture2D *CreateTexture2D( const VkFormat video_format,void *data,uint32_t width,uint32_t height,uint32_t size,
|
Texture2D *CreateTexture2D( const VkFormat video_format,void *data,uint32_t width,uint32_t height,uint32_t size,
|
||||||
const VkImageAspectFlags aspectMask =VK_IMAGE_ASPECT_COLOR_BIT,
|
const VkImageAspectFlags aspectMask =VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
const uint usage =VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT,
|
const uint usage =VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
const VkImageLayout image_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
const VkImageLayout image_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
const ImageTiling tiling =ImageTiling::Optimal);
|
const ImageTiling tiling =ImageTiling::Optimal);
|
||||||
|
|
||||||
bool ChangeTexture2D(Texture2D *,Buffer *buf,const VkBufferImageCopy *,const int count);
|
bool ChangeTexture2D(Texture2D *,Buffer *buf,const VkBufferImageCopy *,const int count);
|
||||||
bool ChangeTexture2D(Texture2D *,Buffer *buf,const List<ImageRegion> &);
|
bool ChangeTexture2D(Texture2D *,Buffer *buf,const List<ImageRegion> &);
|
||||||
|
@ -78,10 +78,10 @@ class PipelineCreater
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
PipelineCreater(Device *dev,const Material *,const RenderTarget *);
|
PipelineCreater(Device *dev,const Material *,const RenderTarget *);
|
||||||
PipelineCreater(Device *dev,const Material *,const RenderTarget *,uchar *,uint);
|
PipelineCreater(Device *dev,const Material *,const RenderTarget *,uchar *data,uint size);
|
||||||
~PipelineCreater()=default;
|
~PipelineCreater()=default;
|
||||||
|
|
||||||
bool Set(const uint prim,bool=false);
|
bool Set(const Prim prim,bool=false);
|
||||||
|
|
||||||
void SetViewport( float x,float y,float w,float h){viewport.x=x;viewport.y=y;viewport.width=w;viewport.height=h;}
|
void SetViewport( float x,float y,float w,float h){viewport.x=x;viewport.y=y;viewport.width=w;viewport.height=h;}
|
||||||
void SetDepthRange( float min_depth,float max_depth){viewport.minDepth=min_depth;viewport.maxDepth=max_depth;}
|
void SetDepthRange( float min_depth,float max_depth){viewport.minDepth=min_depth;viewport.maxDepth=max_depth;}
|
||||||
|
@ -1,22 +1,28 @@
|
|||||||
#ifndef HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
|
#ifndef HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
|
||||||
#define HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
|
#define HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
|
||||||
|
|
||||||
#include<vulkan/vulkan.h>
|
#include<hgl/TypeFunc.h>
|
||||||
|
|
||||||
#define PRIM_POINTS VK_PRIMITIVE_TOPOLOGY_POINT_LIST ///<点
|
/**
|
||||||
#define PRIM_LINES VK_PRIMITIVE_TOPOLOGY_LINE_LIST ///<线
|
* 图元类型枚举
|
||||||
#define PRIM_LINE_STRIP VK_PRIMITIVE_TOPOLOGY_LINE_STRIP ///<连续线
|
*/
|
||||||
#define PRIM_TRIANGLES VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST ///<三角形
|
enum class Prim
|
||||||
#define PRIM_TRIANGLE_STRIP VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP ///<三角形条
|
{
|
||||||
#define PRIM_TRIANGLE_FAN VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN ///<扇形
|
Points=0, ///<点
|
||||||
#define PRIM_LINES_ADJ VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY ///<代表一个有四个顶点的Primitive,其中第二个点与第三个点会形成线段,而第一个点与第四个点则用来提供2,3邻近点的信息.
|
Lines, ///<线
|
||||||
#define PRIM_LINE_STRIP_ADJ VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ///<与LINES_ADJACENCY类似,第一个点跟最后一个点提供信息,剩下的点则跟Line Strip一样形成线段.
|
LineStrip, ///<连续线
|
||||||
#define PRIM_TRIANGLES_ADJ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ///<代表一个有六个顶点的Primitive,其中第1,3,5个顶点代表一个Triangle,而地2,4,6个点提供邻近信息.(由1起算)
|
Triangles, ///<三角形
|
||||||
#define PRIM_TRIANGLE_STRIP_ADJ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ///<4+2N个Vertices代表N个Primitive,其中1,3,5,7,9...代表原本的Triangle strip形成Triangle,而2,4,6,8,10...代表邻近提供信息的点.(由1起算)
|
TriangleStrip, ///<三角形条
|
||||||
#define PRIM_PATCHS VK_PRIMITIVE_TOPOLOGY_PATCH_LIST
|
Fan, ///<扇形
|
||||||
#define PRIM_RECTANGLES 0x100 ///<矩形(并非原生支持。以画点形式在每个点的Position中传递Left,Top,Width,Height。在Geometry Shader中转换为2个三角形。用于2D游戏或UI)
|
LinesAdj, ///<代表一个有四个顶点的Primitive,其中第二个点与第三个点会形成线段,而第一个点与第四个点则用来提供2,3邻近点的信息.
|
||||||
#define PRIM_BEGIN VK_PRIMITIVE_TOPOLOGY_POINT_LIST
|
LineStripAdj, ///<与LINES_ADJACENCY类似,第一个点跟最后一个点提供信息,剩下的点则跟Line Strip一样形成线段.
|
||||||
#define PRIM_END VK_PRIMITIVE_TOPOLOGY_PATCH_LIST
|
TrianglesAdj, ///<代表一个有六个顶点的Primitive,其中第1,3,5个顶点代表一个Triangle,而地2,4,6个点提供邻近信息.(由1起算)
|
||||||
constexpr uint32_t PRIM_RANGE =PRIM_END-PRIM_BEGIN+1;
|
TriangleStripAdj, ///<4+2N个Vertices代表N个Primitive,其中1,3,5,7,9...代表原本的Triangle strip形成Triangle,而2,4,6,8,10...代表邻近提供信息的点.(由1起算)
|
||||||
|
Patchs,
|
||||||
|
|
||||||
|
Rectangles=0x100, ///<矩形(并非原生支持。以画点形式在每个点的Position中传递Left,Top,Width,Height。在Geometry Shader中转换为2个三角形。用于2D游戏或UI)
|
||||||
|
|
||||||
|
ENUM_CLASS_RANGE(Points,Patchs)
|
||||||
|
};//
|
||||||
|
|
||||||
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
|
||||||
|
@ -117,7 +117,7 @@ bool CommandBuffer::Bind(Renderable *render_obj)
|
|||||||
IndexBuffer *indices_buffer=render_obj->GetIndexBuffer();
|
IndexBuffer *indices_buffer=render_obj->GetIndexBuffer();
|
||||||
|
|
||||||
if(indices_buffer)
|
if(indices_buffer)
|
||||||
vkCmdBindIndexBuffer(cmd_buf,indices_buffer->GetBuffer(),render_obj->GetIndexOffset(),indices_buffer->GetType());
|
vkCmdBindIndexBuffer(cmd_buf,indices_buffer->GetBuffer(),render_obj->GetIndexOffset(),VkIndexType(indices_buffer->GetType()));
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ VAB *Database::CreateVAB(VkFormat format,uint32_t count,const void *data,Sharing
|
|||||||
|
|
||||||
#undef SCENE_DB_CREATE_BUFFER
|
#undef SCENE_DB_CREATE_BUFFER
|
||||||
|
|
||||||
IndexBuffer *Database::CreateIBO(VkIndexType index_type,uint32_t count,const void *data,SharingMode sharing_mode)
|
IndexBuffer *Database::CreateIBO(IndexType index_type,uint32_t count,const void *data,SharingMode sharing_mode)
|
||||||
{
|
{
|
||||||
IndexBuffer *buf=device->CreateIBO(index_type,count,data,sharing_mode);
|
IndexBuffer *buf=device->CreateIBO(index_type,count,data,sharing_mode);
|
||||||
|
|
||||||
|
@ -64,12 +64,12 @@ VAB *Device::CreateVAB(VkFormat format,uint32_t count,const void *data,SharingMo
|
|||||||
return(new VertexAttribBuffer(attr->device,buf,format,stride,count));
|
return(new VertexAttribBuffer(attr->device,buf,format,stride,count));
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexBuffer *Device::CreateIBO(VkIndexType index_type,uint32_t count,const void *data,SharingMode sharing_mode)
|
IndexBuffer *Device::CreateIBO(IndexType index_type,uint32_t count,const void *data,SharingMode sharing_mode)
|
||||||
{
|
{
|
||||||
uint32_t stride;
|
uint32_t stride;
|
||||||
|
|
||||||
if(index_type==VK_INDEX_TYPE_UINT16)stride=2;else
|
if(index_type==IndexType::U16)stride=2;else
|
||||||
if(index_type==VK_INDEX_TYPE_UINT32)stride=4;else
|
if(index_type==IndexType::U32)stride=4;else
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
const VkDeviceSize size=stride*count;
|
const VkDeviceSize size=stride*count;
|
||||||
|
@ -217,15 +217,15 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,const Rend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PipelineCreater::Set(const uint topology,bool restart)
|
bool PipelineCreater::Set(const Prim topology,bool restart)
|
||||||
{
|
{
|
||||||
if(topology<PRIM_BEGIN||topology>PRIM_END)
|
if(topology<Prim::BEGIN_RANGE||topology>Prim::END_RANGE)
|
||||||
if(topology!=PRIM_RECTANGLES)return(false);
|
if(topology!=Prim::Rectangles)return(false);
|
||||||
|
|
||||||
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||||
inputAssembly.pNext = nullptr;
|
inputAssembly.pNext = nullptr;
|
||||||
inputAssembly.flags = 0;
|
inputAssembly.flags = 0;
|
||||||
inputAssembly.topology = VkPrimitiveTopology(topology==PRIM_RECTANGLES?VK_PRIMITIVE_TOPOLOGY_POINT_LIST:topology);
|
inputAssembly.topology = VkPrimitiveTopology(topology==Prim::Rectangles?Prim::Points:topology);
|
||||||
inputAssembly.primitiveRestartEnable = restart;
|
inputAssembly.primitiveRestartEnable = restart;
|
||||||
|
|
||||||
pipelineInfo.pInputAssemblyState = &inputAssembly;
|
pipelineInfo.pInputAssemblyState = &inputAssembly;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user