From e8877ad3d64ded50e059079537089f0d79eee9ec Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 8 Jul 2019 20:53:07 +0800 Subject: [PATCH] =?UTF-8?q?init=20gbuffer=20pipeline=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Vulkan/Deferred.cpp | 31 +++++++++++++++++-- .../Vulkan/VKDeviceRenderPass.cpp | 1 + src/RenderDevice/Vulkan/VKPipeline.cpp | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/example/Vulkan/Deferred.cpp b/example/Vulkan/Deferred.cpp index a52fd81a..bfea2c94 100644 --- a/example/Vulkan/Deferred.cpp +++ b/example/Vulkan/Deferred.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include using namespace hgl; @@ -91,10 +92,13 @@ private: *specular=nullptr; }texture; + vulkan::CommandBuffer *gbuffer_cmd=nullptr; + public: ~TestApp() { + SAFE_CLEAR(gbuffer_cmd); SAFE_CLEAR(texture.specular); SAFE_CLEAR(texture.normal); SAFE_CLEAR(texture.color); @@ -229,6 +233,7 @@ private: pipeline_creater->SetDepthWrite(false); pipeline_creater->SetCullMode(VK_CULL_MODE_NONE); pipeline_creater->Set(PRIM_TRIANGLES); + sp->pipeline=pipeline_creater->Create(); if(!sp->pipeline) @@ -241,10 +246,10 @@ private: bool InitMaterial() { if(!InitSubpass(&sp_gbuffer, OS_TEXT("gbuffer_opaque.vert.spv"),OS_TEXT("gbuffer_opaque.frag.spv")))return(false); - if(!InitSubpass(&sp_composition,OS_TEXT("ds_composition.vert.spv"),OS_TEXT("ds_composition.frag.spv")))return(false); + //if(!InitSubpass(&sp_composition,OS_TEXT("ds_composition.vert.spv"),OS_TEXT("ds_composition.frag.spv")))return(false); if(!InitGBufferPipeline(&sp_gbuffer))return(false); - if(!InitCompositionPipeline(&sp_composition))return(false); + //if(!InitCompositionPipeline(&sp_composition))return(false); texture.color =vulkan::LoadTGATexture(OS_TEXT("cardboardPlainStain.tga"),device); texture.normal =vulkan::LoadTGATexture(OS_TEXT("APOCWALL029_NRM.tga"),device); @@ -301,6 +306,25 @@ private: return(true); } + bool InitGBufferCommandBuffer() + { + gbuffer_cmd=device->CreateCommandBuffer(); + + if(!gbuffer_cmd) + return(false); + + gbuffer_cmd->Begin(); + if(!gbuffer_cmd->BeginRenderPass(gbuffer.renderpass,gbuffer.framebuffer)) + return(false); + + + + gbuffer_cmd->EndRenderPass(); + gbuffer_cmd->End(); + + return(true); + } + public: bool Init() @@ -317,6 +341,9 @@ public: if(!InitScene(&sp_gbuffer)) return(false); + if(!InitGBufferCommandBuffer()) + return(false); + return(true); } diff --git a/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp b/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp index 98fc72f1..b483b6cf 100644 --- a/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp @@ -218,6 +218,7 @@ RenderPass *Device::CreateRenderPass( const List &des VkRenderPassCreateInfo rp_info; rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; rp_info.pNext = nullptr; + rp_info.flags = 0; rp_info.attachmentCount = desc_list.GetCount(); rp_info.pAttachments = desc_list.GetData(); rp_info.subpassCount = subpass.GetCount(); diff --git a/src/RenderDevice/Vulkan/VKPipeline.cpp b/src/RenderDevice/Vulkan/VKPipeline.cpp index 9730d909..d08270a8 100644 --- a/src/RenderDevice/Vulkan/VKPipeline.cpp +++ b/src/RenderDevice/Vulkan/VKPipeline.cpp @@ -153,7 +153,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass colorBlending.pNext = nullptr; colorBlending.flags = 0; colorBlending.logicOpEnable = VK_FALSE; - colorBlending.logicOp = VK_LOGIC_OP_COPY; + colorBlending.logicOp = VK_LOGIC_OP_CLEAR; colorBlending.attachmentCount = colorBlendAttachments.GetCount(); colorBlending.pAttachments = colorBlendAttachments.GetData(); colorBlending.blendConstants[0] = 0.0f;