From 4ead81b44c0e92fe6e75fe0af001509108e4be04 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 28 May 2019 14:25:58 +0800 Subject: [PATCH] =?UTF-8?q?Debug=E6=A8=A1=E5=BC=8F=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=89=A9=E7=90=86=E8=AE=BE=E5=A4=87=E5=B1=9E=E6=80=A7=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Vulkan/Geometry3D.cpp | 37 ++++- example/Vulkan/VulkanAppFramework.h | 4 - inc/hgl/graph/vulkan/VKPhysicalDevice.h | 4 + inc/hgl/math/Matrix.h | 8 +- src/RenderDevice/Vulkan/VKDeviceCreater.cpp | 153 ++++++++++++++++++++ src/SceneGraph/Camera.cpp | 2 +- 6 files changed, 193 insertions(+), 15 deletions(-) diff --git a/example/Vulkan/Geometry3D.cpp b/example/Vulkan/Geometry3D.cpp index b104178f..d26801ba 100644 --- a/example/Vulkan/Geometry3D.cpp +++ b/example/Vulkan/Geometry3D.cpp @@ -1,4 +1,4 @@ -// 4.Geometry3D +// 4.Geometry3D #include"VulkanAppFramework.h" #include @@ -42,6 +42,7 @@ private: vulkan::Buffer * ubo_mvp =nullptr; vulkan::Pipeline * pipeline_line =nullptr; + vulkan::Pipeline * pipeline_triangles =nullptr; vulkan::CommandBuffer ** cmd_buf =nullptr; public: @@ -57,19 +58,20 @@ private: void InitCamera() { + camera.type=CameraType::Perspective; camera.center.Set(0,0,0); camera.eye.Set(100,100,100); camera.up_vector.Set(0,0,1); camera.forward_vector.Set(0,1,0); camera.znear=4; camera.zfar=1000; - camera.fov=45; + camera.fov=90; camera.width=SCREEN_WIDTH; camera.height=SCREEN_HEIGHT; - camera.Refresh(); //¾ + camera.Refresh(); //更新矩阵计算 - world.mvp=camera.projection*camera.modelview; + world.mvp=camera.projection*camera.modelview*scale(50,50,50); } bool InitMaterial() @@ -101,6 +103,15 @@ private: ro_plane_grid=CreatePlaneGrid(db,material,&pgci); } + + { + struct CubeCreateInfo cci; + + cci.tile.x=0; + cci.tile.y=1; + + ro_cube=CreateCube(db,material,&cci); + } } bool InitUBO() @@ -131,7 +142,19 @@ private: pipeline_creater->Set(PRIM_LINES); pipeline_line=pipeline_creater->Create(); + if(!pipeline_line) + return(false); + db->Add(pipeline_line); + + pipeline_creater->Set(PRIM_TRIANGLES); + + pipeline_triangles=pipeline_creater->Create(); + if(!pipeline_triangles) + return(false); + + db->Add(pipeline_triangles); + delete pipeline_creater; } @@ -140,10 +163,12 @@ private: bool InitScene() { - render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid)); - //render_root.Add(db->CreateRenderableInstance(pipeline,descriptor_sets,ro_round_rectangle)); + //render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid)); + render_root.Add(db->CreateRenderableInstance(pipeline_triangles,descriptor_sets,ro_cube)); //render_root.Add(db->CreateRenderableInstance(pipeline,descriptor_sets,ro_circle)); + Matrix4f s10=scale(10,10,10); + render_root.RefreshMatrix(); render_root.ExpendToList(&render_list); diff --git a/example/Vulkan/VulkanAppFramework.h b/example/Vulkan/VulkanAppFramework.h index 96454183..f244a314 100644 --- a/example/Vulkan/VulkanAppFramework.h +++ b/example/Vulkan/VulkanAppFramework.h @@ -67,10 +67,6 @@ public: return(false); shader_manage=device->CreateShaderModuleManage(); - - const vulkan::PhysicalDevice *render_device=device->GetPhysicalDevice(); - - std::cout<<"auto select physical device: "<GetDeviceName()< +#include #endif//_DEBUG VK_NAMESPACE_BEGIN @@ -300,6 +301,156 @@ namespace return(true); } + + void DebugOutVersion(uint32_t version) + { + std::cout<(pdp.pipelineCacheUUID); + + std::cout<<"pipelineCahceUUID: "<GetProperties()); } #endif//_DEBUG diff --git a/src/SceneGraph/Camera.cpp b/src/SceneGraph/Camera.cpp index 1b872c77..e933b115 100644 --- a/src/SceneGraph/Camera.cpp +++ b/src/SceneGraph/Camera.cpp @@ -26,7 +26,7 @@ namespace hgl void Camera::Refresh() { if(type==CameraType::Perspective) - projection=perspective(width/height,fov,znear,zfar); + projection=perspective(fov,width/height,znear,zfar); else projection=ortho(width,height,znear,zfar);