fixed a bug that MaterialParameters didn't support dynamic UBO/SSBO.
This commit is contained in:
parent
d82534b168
commit
72351af025
@ -1 +1 @@
|
|||||||
Subproject commit 7a5040224a162cd63f54e28d31eaf7eb710b48a0
|
Subproject commit c1a42765331c8c6161e12805f19877e53003cb07
|
@ -24,14 +24,14 @@ macro(CreateQtProject name)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
CreateProject(00.triangle first_triangle.cpp)
|
CreateProject(00.triangle first_triangle.cpp)
|
||||||
CreateProject(00.two_triangle two_triangle.cpp)
|
CreateProject(01.two_triangle two_triangle.cpp)
|
||||||
CreateProject(01.FragCoord FragCoordTest.cpp)
|
CreateProject(02.FragCoord FragCoordTest.cpp)
|
||||||
CreateProject(02.indices_rect indices_rect.cpp)
|
CreateProject(03.indices_rect indices_rect.cpp)
|
||||||
CreateProject(03.TextureFormat TextureFormat.cpp)
|
CreateProject(04.TextureFormat TextureFormat.cpp)
|
||||||
CreateProject(04.texture_rect texture_rect.cpp)
|
CreateProject(05.texture_rect texture_rect.cpp)
|
||||||
CreateProject(05.HQFilterTexture HQFilterTexture.cpp)
|
#CreateProject(05.HQFilterTexture HQFilterTexture.cpp)
|
||||||
CreateProject(06.Geometry2D Geometry2D.cpp)
|
#CreateProject(06.Geometry2D Geometry2D.cpp)
|
||||||
CreateProject(07.Geometry3D Geometry3D.cpp)
|
CreateProject(06.Geometry3D Geometry3D.cpp)
|
||||||
#CreateProject(08.SceneTree SceneTree.cpp)
|
#CreateProject(08.SceneTree SceneTree.cpp)
|
||||||
#CreateProject(09.LoadStaticMesh LoadStaticMesh.cpp LoadScene.cpp)
|
#CreateProject(09.LoadStaticMesh LoadStaticMesh.cpp LoadScene.cpp)
|
||||||
CreateProject(10.InlineGeometryScene InlineGeometryScene.cpp)
|
CreateProject(10.InlineGeometryScene InlineGeometryScene.cpp)
|
||||||
|
@ -34,6 +34,13 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool RecreatePipeline()
|
||||||
|
{
|
||||||
|
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::TriangleStrip);
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/FragColor"));
|
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/FragColor"));
|
||||||
@ -41,12 +48,7 @@ private:
|
|||||||
if(!material_instance)
|
if(!material_instance)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::TriangleStrip);
|
return RecreatePipeline();
|
||||||
|
|
||||||
if(!pipeline)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitUBO()
|
bool InitUBO()
|
||||||
@ -117,6 +119,9 @@ public:
|
|||||||
|
|
||||||
ubo_camera_info->Write(&cam.info);
|
ubo_camera_info->Write(&cam.info);
|
||||||
|
|
||||||
|
RecreatePipeline();
|
||||||
|
renderable_instance->UpdatePipeline(pipeline);
|
||||||
|
|
||||||
BuildCommandBuffer(renderable_instance);
|
BuildCommandBuffer(renderable_instance);
|
||||||
}
|
}
|
||||||
};//class TestApp:public VulkanApplicationFramework
|
};//class TestApp:public VulkanApplicationFramework
|
||||||
|
@ -42,6 +42,13 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool RecreatePipeline()
|
||||||
|
{
|
||||||
|
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,Prim::Fan);
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
material=db->CreateMaterial(OS_TEXT("res/material/PureColor2D"));
|
material=db->CreateMaterial(OS_TEXT("res/material/PureColor2D"));
|
||||||
@ -52,9 +59,7 @@ private:
|
|||||||
|
|
||||||
if(!material_instance)return(false);
|
if(!material_instance)return(false);
|
||||||
|
|
||||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,Prim::Fan);
|
return RecreatePipeline();
|
||||||
|
|
||||||
return pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateRenderObject()
|
void CreateRenderObject()
|
||||||
@ -166,6 +171,9 @@ public:
|
|||||||
|
|
||||||
ubo_camera_info->Write(&cam.info);
|
ubo_camera_info->Write(&cam.info);
|
||||||
|
|
||||||
|
RecreatePipeline();
|
||||||
|
renderable_instance->UpdatePipeline(pipeline);
|
||||||
|
|
||||||
BuildCommandBuffer(&render_list);
|
BuildCommandBuffer(&render_list);
|
||||||
}
|
}
|
||||||
};//class TestApp:public VulkanApplicationFramework
|
};//class TestApp:public VulkanApplicationFramework
|
||||||
|
@ -24,30 +24,35 @@ private:
|
|||||||
SceneNode render_root;
|
SceneNode render_root;
|
||||||
RenderList *render_list=nullptr;
|
RenderList *render_list=nullptr;
|
||||||
|
|
||||||
struct MDP
|
|
||||||
{
|
|
||||||
Material * material =nullptr;
|
Material * material =nullptr;
|
||||||
MaterialInstance * material_instance =nullptr;
|
MaterialInstance * material_instance =nullptr;
|
||||||
Pipeline * pipeline =nullptr;
|
Pipeline * pipeline =nullptr;
|
||||||
}m3d;//,m2d;
|
|
||||||
|
|
||||||
Renderable *ro_plane_grid[3],
|
Renderable * ro_plane_grid[3];
|
||||||
*ro_round_rectangle =nullptr;
|
RenderableInstance *ri_plane_grid[3];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool InitMDP(MDP *mdp,const Prim primitive,const OSString &mtl_name)
|
bool RecreatePipeline()
|
||||||
{
|
{
|
||||||
mdp->material=db->CreateMaterial(mtl_name);
|
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid3D,Prim::Lines);
|
||||||
if(!mdp->material)return(false);
|
|
||||||
|
|
||||||
mdp->material_instance=db->CreateMaterialInstance(mdp->material);
|
return pipeline;
|
||||||
if(!mdp->material_instance)return(false);
|
}
|
||||||
|
|
||||||
mdp->pipeline=CreatePipeline(mdp->material_instance,InlinePipeline::Solid3D,primitive);
|
bool InitMDP()
|
||||||
|
{
|
||||||
|
material=db->CreateMaterial(OS_TEXT("res/material/VertexColor3D"));
|
||||||
|
if(!material)return(false);
|
||||||
|
|
||||||
|
material_instance=db->CreateMaterialInstance(material);
|
||||||
|
if(!material_instance)return(false);
|
||||||
|
|
||||||
|
if(!RecreatePipeline())
|
||||||
|
return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_global=mdp->material_instance->GetMP(DescriptorSetType::Global);
|
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||||
|
|
||||||
if(!mp_global)
|
if(!mp_global)
|
||||||
return(false);
|
return(false);
|
||||||
@ -60,18 +65,13 @@ private:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Add(Renderable *r,MDP &mdp)
|
RenderableInstance *Add(Renderable *r,const Matrix4f &mat)
|
||||||
{
|
{
|
||||||
auto ri=db->CreateRenderableInstance(r,mdp.material_instance,mdp.pipeline);
|
RenderableInstance *ri=db->CreateRenderableInstance(r,material_instance,pipeline);
|
||||||
|
|
||||||
render_root.CreateSubNode(ri);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Add(Renderable *r,MDP &mdp,const Matrix4f &mat)
|
|
||||||
{
|
|
||||||
auto ri=db->CreateRenderableInstance(r,mdp.material_instance,mdp.pipeline);
|
|
||||||
|
|
||||||
render_root.CreateSubNode(mat,ri);
|
render_root.CreateSubNode(mat,ri);
|
||||||
|
|
||||||
|
return ri;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateRenderObject()
|
void CreateRenderObject()
|
||||||
@ -92,36 +92,25 @@ private:
|
|||||||
pgci.color.Set(0.5,0,0,1);
|
pgci.color.Set(0.5,0,0,1);
|
||||||
pgci.side_color.Set(1,0,0,1);
|
pgci.side_color.Set(1,0,0,1);
|
||||||
|
|
||||||
ro_plane_grid[0]=CreateRenderablePlaneGrid(db,m3d.material,&pgci);
|
ro_plane_grid[0]=CreateRenderablePlaneGrid(db,material,&pgci);
|
||||||
|
|
||||||
pgci.color.Set(0,0.5,0,1);
|
pgci.color.Set(0,0.5,0,1);
|
||||||
pgci.side_color.Set(0,1,0,1);
|
pgci.side_color.Set(0,1,0,1);
|
||||||
|
|
||||||
ro_plane_grid[1]=CreateRenderablePlaneGrid(db,m3d.material,&pgci);
|
ro_plane_grid[1]=CreateRenderablePlaneGrid(db,material,&pgci);
|
||||||
|
|
||||||
pgci.color.Set(0,0,0.5,1);
|
pgci.color.Set(0,0,0.5,1);
|
||||||
pgci.side_color.Set(0,0,1,1);
|
pgci.side_color.Set(0,0,1,1);
|
||||||
ro_plane_grid[2]=CreateRenderablePlaneGrid(db,m3d.material,&pgci);
|
ro_plane_grid[2]=CreateRenderablePlaneGrid(db,material,&pgci);
|
||||||
|
|
||||||
//{
|
|
||||||
// struct RoundRectangleCreateInfo rrci;
|
|
||||||
|
|
||||||
// rrci.scope.Set(SCREEN_WIDTH-30,10,20,20);
|
|
||||||
// rrci.radius=5;
|
|
||||||
// rrci.round_per=5;
|
|
||||||
|
|
||||||
// ro_round_rectangle=CreateRenderableRoundRectangle(db,m2d.material,&rrci);
|
|
||||||
//}
|
|
||||||
|
|
||||||
camera->pos.Set(200,200,200,1.0);
|
camera->pos.Set(200,200,200,1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitScene()
|
bool InitScene()
|
||||||
{
|
{
|
||||||
// Add(ro_round_rectangle,m2d);
|
ri_plane_grid[0]=Add(ro_plane_grid[0],Matrix4f::identity);
|
||||||
Add(ro_plane_grid[0],m3d);
|
ri_plane_grid[1]=Add(ro_plane_grid[1],rotate(HGL_RAD_90,0,1,0));
|
||||||
Add(ro_plane_grid[1],m3d,rotate(HGL_RAD_90,0,1,0));
|
ri_plane_grid[2]=Add(ro_plane_grid[2],rotate(HGL_RAD_90,1,0,0));
|
||||||
Add(ro_plane_grid[2],m3d,rotate(HGL_RAD_90,1,0,0));
|
|
||||||
|
|
||||||
render_root.RefreshMatrix();
|
render_root.RefreshMatrix();
|
||||||
render_list->Expend(camera->info,&render_root);
|
render_list->Expend(camera->info,&render_root);
|
||||||
@ -143,22 +132,9 @@ public:
|
|||||||
|
|
||||||
render_list=new RenderList(device);
|
render_list=new RenderList(device);
|
||||||
|
|
||||||
if(!InitMDP(&m3d,Prim::Lines,OS_TEXT("res/material/VertexColor3D")))
|
if(!InitMDP())
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
//if(!InitMDP(&m2d,Prim::Fan, OS_TEXT("res/material/PureColor2D")))
|
|
||||||
// return(false);
|
|
||||||
|
|
||||||
//{
|
|
||||||
// color.Set(1,1,0,1);
|
|
||||||
// ubo_color=device->CreateUBO(sizeof(Vector4f),&color);
|
|
||||||
|
|
||||||
// m2d.material_instance->BindUBO("color_material",ubo_color);
|
|
||||||
// m2d.material_instance->Update();
|
|
||||||
|
|
||||||
// db->Add(ubo_color);
|
|
||||||
//}
|
|
||||||
|
|
||||||
CreateRenderObject();
|
CreateRenderObject();
|
||||||
|
|
||||||
if(!InitScene())
|
if(!InitScene())
|
||||||
@ -171,6 +147,18 @@ public:
|
|||||||
{
|
{
|
||||||
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Resize(int w,int h)override
|
||||||
|
{
|
||||||
|
CameraAppFramework::Resize(w,h);
|
||||||
|
|
||||||
|
RecreatePipeline();
|
||||||
|
|
||||||
|
for(int i=0;i<3;i++)
|
||||||
|
ri_plane_grid[i]->UpdatePipeline(pipeline);
|
||||||
|
|
||||||
|
VulkanApplicationFramework::BuildCommandBuffer(render_list);
|
||||||
|
}
|
||||||
};//class TestApp:public CameraAppFramework
|
};//class TestApp:public CameraAppFramework
|
||||||
|
|
||||||
int main(int,char **)
|
int main(int,char **)
|
||||||
|
@ -37,7 +37,7 @@ constexpr uint16 index_data[INDEX_COUNT]=
|
|||||||
0,3,2
|
0,3,2
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestApp:public VulkanApplicationFramework
|
class TestApp:public CameraAppFramework
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -65,30 +65,26 @@ private:
|
|||||||
IndexBuffer * index_buffer =nullptr;
|
IndexBuffer * index_buffer =nullptr;
|
||||||
|
|
||||||
SceneNode render_root;
|
SceneNode render_root;
|
||||||
RenderList render_list;
|
RenderList *render_list =nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~TestApp()
|
~TestApp()
|
||||||
{
|
{
|
||||||
SAFE_CLEAR(index_buffer);
|
SAFE_CLEAR(render_list);
|
||||||
SAFE_CLEAR(tex_coord_buffer);
|
|
||||||
SAFE_CLEAR(vertex_buffer);
|
|
||||||
SAFE_CLEAR(sampler_nearest);
|
|
||||||
SAFE_CLEAR(sampler_linear);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool InitVBO()
|
bool InitVBO()
|
||||||
{
|
{
|
||||||
vertex_buffer =device->CreateVAB(VF_VEC2,VERTEX_COUNT,vertex_data);
|
vertex_buffer =db->CreateVAB(VF_VEC2,VERTEX_COUNT,vertex_data);
|
||||||
if(!vertex_buffer)return(false);
|
if(!vertex_buffer)return(false);
|
||||||
|
|
||||||
tex_coord_buffer=device->CreateVAB(VF_VEC2,VERTEX_COUNT,tex_coord_data);
|
tex_coord_buffer=db->CreateVAB(VF_VEC2,VERTEX_COUNT,tex_coord_data);
|
||||||
if(!tex_coord_buffer)return(false);
|
if(!tex_coord_buffer)return(false);
|
||||||
|
|
||||||
index_buffer =device->CreateIBO16(INDEX_COUNT,index_data);
|
index_buffer =db->CreateIBO16(INDEX_COUNT,index_data);
|
||||||
if(!index_buffer)return(false);
|
if(!index_buffer)return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
@ -103,6 +99,8 @@ private:
|
|||||||
render_obj->Set(VAN::TexCoord,tex_coord_buffer);
|
render_obj->Set(VAN::TexCoord,tex_coord_buffer);
|
||||||
render_obj->Set(index_buffer);
|
render_obj->Set(index_buffer);
|
||||||
|
|
||||||
|
render_list=new RenderList(device);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +124,7 @@ private:
|
|||||||
sampler_create_info.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
sampler_create_info.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
||||||
sampler_create_info.unnormalizedCoordinates = false;
|
sampler_create_info.unnormalizedCoordinates = false;
|
||||||
|
|
||||||
return device->CreateSampler(&sampler_create_info);
|
return db->CreateSampler(&sampler_create_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitTexture()
|
bool InitTexture()
|
||||||
@ -151,8 +149,8 @@ private:
|
|||||||
pipeline_data=GetPipelineData(InlinePipeline::Solid2D);
|
pipeline_data=GetPipelineData(InlinePipeline::Solid2D);
|
||||||
if(!pipeline_data)return(false);
|
if(!pipeline_data)return(false);
|
||||||
|
|
||||||
if(!InitMaterial(&mp_normal,OS_TEXT("res/material/Texture2DPC")))return(false);
|
if(!InitMaterial(&mp_normal,OS_TEXT("res/material/Texture2D")))return(false);
|
||||||
if(!InitMaterial(&mp_hq, OS_TEXT("res/material/Texture2DHQPC")))return(false);
|
if(!InitMaterial(&mp_hq, OS_TEXT("res/material/Texture2DHQ")))return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -162,6 +160,17 @@ private:
|
|||||||
mir->material_instance=db->CreateMaterialInstance(mp->material);
|
mir->material_instance=db->CreateMaterialInstance(mp->material);
|
||||||
if(!mir->material_instance)return(false);
|
if(!mir->material_instance)return(false);
|
||||||
|
|
||||||
|
{
|
||||||
|
MaterialParameters *mp_global=mir->material_instance->GetMP(DescriptorSetType::Global);
|
||||||
|
|
||||||
|
if(!mp_global)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(!mp_global->BindUBO("g_camera",GetCameraInfoBuffer()))return(false);
|
||||||
|
|
||||||
|
mp_global->Update();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_texture=mir->material_instance->GetMP(DescriptorSetType::Value);
|
MaterialParameters *mp_texture=mir->material_instance->GetMP(DescriptorSetType::Value);
|
||||||
|
|
||||||
@ -195,9 +204,6 @@ private:
|
|||||||
Add(&mir_nearest_hq,translate(-1, 0,0));
|
Add(&mir_nearest_hq,translate(-1, 0,0));
|
||||||
Add(&mir_linear_hq, translate( 0, 0,0));
|
Add(&mir_linear_hq, translate( 0, 0,0));
|
||||||
|
|
||||||
render_root.RefreshMatrix();
|
|
||||||
render_list.Expend(&render_root);
|
|
||||||
BuildCommandBuffer(&render_list);
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +211,7 @@ public:
|
|||||||
|
|
||||||
bool Init()
|
bool Init()
|
||||||
{
|
{
|
||||||
if(!VulkanApplicationFramework::Init(SCREEN_SIZE,SCREEN_SIZE))
|
if(!CameraAppFramework::Init(SCREEN_SIZE,SCREEN_SIZE))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitVBO())
|
if(!InitVBO())
|
||||||
@ -236,7 +242,15 @@ public:
|
|||||||
|
|
||||||
void Resize(int w,int h) override
|
void Resize(int w,int h) override
|
||||||
{
|
{
|
||||||
BuildCommandBuffer(&render_list);
|
VulkanApplicationFramework::BuildCommandBuffer(render_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BuildCommandBuffer(uint32_t index) override
|
||||||
|
{
|
||||||
|
render_root.RefreshMatrix();
|
||||||
|
render_list->Expend(camera->info,&render_root);
|
||||||
|
|
||||||
|
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
||||||
}
|
}
|
||||||
};//class TestApp:public VulkanApplicationFramework
|
};//class TestApp:public VulkanApplicationFramework
|
||||||
|
|
||||||
|
@ -44,13 +44,20 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool RecreatePipeline()
|
||||||
|
{
|
||||||
|
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||||
|
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/FragColor"));
|
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/FragColor"));
|
||||||
if(!material_instance)return(false);
|
if(!material_instance)return(false);
|
||||||
|
|
||||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D);
|
return RecreatePipeline();
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitUBO()
|
bool InitUBO()
|
||||||
@ -123,6 +130,9 @@ public:
|
|||||||
|
|
||||||
ubo_camera_info->Write(&cam.info);
|
ubo_camera_info->Write(&cam.info);
|
||||||
|
|
||||||
|
RecreatePipeline();
|
||||||
|
renderable_instance->UpdatePipeline(pipeline);
|
||||||
|
|
||||||
BuildCommandBuffer(renderable_instance);
|
BuildCommandBuffer(renderable_instance);
|
||||||
}
|
}
|
||||||
};//class TestApp:public VulkanApplicationFramework
|
};//class TestApp:public VulkanApplicationFramework
|
||||||
|
@ -58,13 +58,21 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool RecreatePipeline()
|
||||||
|
{
|
||||||
|
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||||
|
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/Texture2D"));
|
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/Texture2D"));
|
||||||
if(!material_instance)return(false);
|
if(!material_instance)return(false);
|
||||||
|
|
||||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D);
|
if(!RecreatePipeline())
|
||||||
if(!pipeline)return(false);
|
return(false);
|
||||||
|
|
||||||
texture=db->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"));
|
texture=db->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"));
|
||||||
if(!texture)return(false);
|
if(!texture)return(false);
|
||||||
@ -157,6 +165,9 @@ public:
|
|||||||
|
|
||||||
ubo_camera_info->Write(&cam.info);
|
ubo_camera_info->Write(&cam.info);
|
||||||
|
|
||||||
|
RecreatePipeline();
|
||||||
|
renderable_instance->UpdatePipeline(pipeline);
|
||||||
|
|
||||||
BuildCommandBuffer(renderable_instance);
|
BuildCommandBuffer(renderable_instance);
|
||||||
}
|
}
|
||||||
};//class TestApp:public VulkanApplicationFramework
|
};//class TestApp:public VulkanApplicationFramework
|
||||||
|
@ -43,6 +43,14 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool RecreatePipeline()
|
||||||
|
{
|
||||||
|
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||||
|
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/VertexColor2D"));
|
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/VertexColor2D"));
|
||||||
@ -50,10 +58,7 @@ private:
|
|||||||
if(!material_instance)
|
if(!material_instance)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
return RecreatePipeline();
|
||||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D); //等同上一行,为Framework重载,默认使用swapchain的render target
|
|
||||||
|
|
||||||
return pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitUBO()
|
bool InitUBO()
|
||||||
@ -138,6 +143,9 @@ public:
|
|||||||
|
|
||||||
ubo_camera_info->Write(&cam.info);
|
ubo_camera_info->Write(&cam.info);
|
||||||
|
|
||||||
|
RecreatePipeline();
|
||||||
|
render_instance->UpdatePipeline(pipeline);
|
||||||
|
|
||||||
BuildCommandBuffer(render_list);
|
BuildCommandBuffer(render_list);
|
||||||
}
|
}
|
||||||
};//class TestApp:public VulkanApplicationFramework
|
};//class TestApp:public VulkanApplicationFramework
|
||||||
|
@ -31,8 +31,8 @@ private:
|
|||||||
Window * win =nullptr;
|
Window * win =nullptr;
|
||||||
VulkanInstance * inst =nullptr;
|
VulkanInstance * inst =nullptr;
|
||||||
|
|
||||||
void OnKeyPressed (KeyboardButton kb){key_status[kb]=true;}
|
void OnKeyPressed (KeyboardButton kb){key_status[size_t(kb)]=true;}
|
||||||
void OnKeyReleased (KeyboardButton kb){key_status[kb]=false;}
|
void OnKeyReleased (KeyboardButton kb){key_status[size_t(kb)]=false;}
|
||||||
void OnKeyRepeat (KeyboardButton kb){KeyRepeat(kb);}
|
void OnKeyRepeat (KeyboardButton kb){KeyRepeat(kb);}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -62,7 +62,7 @@ protected:
|
|||||||
|
|
||||||
RenderResource * db =nullptr;
|
RenderResource * db =nullptr;
|
||||||
|
|
||||||
bool key_status[kbRangeSize];
|
bool key_status[size_t(KeyboardButton::RANGE_SIZE)];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -348,6 +348,10 @@ public:
|
|||||||
{
|
{
|
||||||
camera->width=w;
|
camera->width=w;
|
||||||
camera->height=h;
|
camera->height=h;
|
||||||
|
|
||||||
|
camera->Refresh();
|
||||||
|
|
||||||
|
ubo_camera_info->Write(&camera->info);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUBuffer *GetCameraInfoBuffer()
|
GPUBuffer *GetCameraInfoBuffer()
|
||||||
@ -357,6 +361,8 @@ public:
|
|||||||
|
|
||||||
virtual void BuildCommandBuffer(uint32_t index)=0;
|
virtual void BuildCommandBuffer(uint32_t index)=0;
|
||||||
|
|
||||||
|
inline bool isPush(enum class KeyboardButton kb)const{return key_status[size_t(kb)];}
|
||||||
|
|
||||||
virtual void Draw()override
|
virtual void Draw()override
|
||||||
{
|
{
|
||||||
camera->Refresh(); //更新相机矩阵
|
camera->Refresh(); //更新相机矩阵
|
||||||
@ -368,24 +374,24 @@ public:
|
|||||||
|
|
||||||
SubmitDraw(index);
|
SubmitDraw(index);
|
||||||
|
|
||||||
if(key_status[kbW])camera->Up (move_speed);else
|
if(isPush(KeyboardButton::W ))camera->Up (move_speed);else
|
||||||
if(key_status[kbS])camera->Down (move_speed);else
|
if(isPush(KeyboardButton::S ))camera->Down (move_speed);else
|
||||||
if(key_status[kbA])camera->Left (move_speed);else
|
if(isPush(KeyboardButton::A ))camera->Left (move_speed);else
|
||||||
if(key_status[kbD])camera->Right (move_speed);else
|
if(isPush(KeyboardButton::D ))camera->Right (move_speed);else
|
||||||
if(key_status[kbR])camera->Forward (move_speed);else
|
if(isPush(KeyboardButton::R ))camera->Forward (move_speed);else
|
||||||
if(key_status[kbF])camera->Backward (move_speed);else
|
if(isPush(KeyboardButton::F ))camera->Backward (move_speed);else
|
||||||
|
|
||||||
if(key_status[kbLeft ])camera->HoriRotate( move_speed);else
|
if(isPush(KeyboardButton::Left ))camera->HoriRotate( move_speed);else
|
||||||
if(key_status[kbRight ])camera->HoriRotate(-move_speed);else
|
if(isPush(KeyboardButton::Right ))camera->HoriRotate(-move_speed);else
|
||||||
if(key_status[kbUp ])camera->VertRotate( move_speed);else
|
if(isPush(KeyboardButton::Up ))camera->VertRotate( move_speed);else
|
||||||
if(key_status[kbDown ])camera->VertRotate(-move_speed);else
|
if(isPush(KeyboardButton::Down ))camera->VertRotate(-move_speed);else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void KeyRepeat(KeyboardButton kb)override
|
virtual void KeyRepeat(KeyboardButton kb)override
|
||||||
{
|
{
|
||||||
if(kb==kbMinus)move_speed*=0.9f;else
|
if(kb==KeyboardButton::Minus )move_speed*=0.9f;else
|
||||||
if(kb==kbEquals)move_speed*=1.1f;else
|
if(kb==KeyboardButton::Equals )move_speed*=1.1f;else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
|
|
||||||
const int GetUBO (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, name);}
|
const int GetUBO (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, name);}
|
||||||
const int GetSSBO (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, name);}
|
const int GetSSBO (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, name);}
|
||||||
|
const int GetUBODynamic (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, name);}
|
||||||
|
const int GetSSBODynamic(const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, name);}
|
||||||
const int GetSampler (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, name);}
|
const int GetSampler (const AnsiString &name)const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, name);}
|
||||||
|
|
||||||
const DescriptorSetLayoutCreateInfo *GetBinding(const DescriptorSetType &type)const{return sds+size_t(type);}
|
const DescriptorSetLayoutCreateInfo *GetBinding(const DescriptorSetType &type)const{return sds+size_t(type);}
|
||||||
|
2
res
2
res
@ -1 +1 @@
|
|||||||
Subproject commit 404938c1f73f3eaa0554e47c6ff5ff0979c1a281
|
Subproject commit 64d5e5910df49d3e913e28dd4781699d8eff0a51
|
@ -155,7 +155,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(mp)
|
if(mp)
|
||||||
{
|
{
|
||||||
mp->BindUBO("r_scene_info",mvp_array->GetBuffer(),true);
|
if(mp->BindUBO("r_scene_info",mvp_array->GetBuffer(),true))
|
||||||
mp->Update();
|
mp->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ bool MaterialParameters::BindUBO(const AnsiString &name,GPUBuffer *ubo,bool dyna
|
|||||||
if(name.IsEmpty()||!ubo)
|
if(name.IsEmpty()||!ubo)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
const int index=mds->GetUBO(name);
|
const int index=dynamic?mds->GetUBODynamic(name):mds->GetUBO(name);
|
||||||
|
|
||||||
if(index<0)
|
if(index<0)
|
||||||
return(false);
|
return(false);
|
||||||
@ -37,7 +37,7 @@ bool MaterialParameters::BindSSBO(const AnsiString &name,GPUBuffer *ssbo,bool dy
|
|||||||
if(name.IsEmpty()||!ssbo)
|
if(name.IsEmpty()||!ssbo)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
const int index=mds->GetSSBO(name);
|
const int index=dynamic?mds->GetSSBODynamic(name):mds->GetSSBO(name);
|
||||||
|
|
||||||
if(index<0)
|
if(index<0)
|
||||||
return(false);
|
return(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user