init gbuffer pipeline失败

This commit is contained in:
hyzboy 2019-07-08 20:53:07 +08:00
parent ad630379b9
commit e8877ad3d6
3 changed files with 31 additions and 3 deletions

View File

@ -9,6 +9,7 @@
#include<hgl/graph/RenderList.h> #include<hgl/graph/RenderList.h>
#include<hgl/graph/vulkan/VKTexture.h> #include<hgl/graph/vulkan/VKTexture.h>
#include<hgl/graph/vulkan/VKImageView.h> #include<hgl/graph/vulkan/VKImageView.h>
#include<hgl/graph/vulkan/VKSampler.h>
#include<hgl/graph/vulkan/VKFramebuffer.h> #include<hgl/graph/vulkan/VKFramebuffer.h>
using namespace hgl; using namespace hgl;
@ -91,10 +92,13 @@ private:
*specular=nullptr; *specular=nullptr;
}texture; }texture;
vulkan::CommandBuffer *gbuffer_cmd=nullptr;
public: public:
~TestApp() ~TestApp()
{ {
SAFE_CLEAR(gbuffer_cmd);
SAFE_CLEAR(texture.specular); SAFE_CLEAR(texture.specular);
SAFE_CLEAR(texture.normal); SAFE_CLEAR(texture.normal);
SAFE_CLEAR(texture.color); SAFE_CLEAR(texture.color);
@ -229,6 +233,7 @@ private:
pipeline_creater->SetDepthWrite(false); pipeline_creater->SetDepthWrite(false);
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE); pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
pipeline_creater->Set(PRIM_TRIANGLES); pipeline_creater->Set(PRIM_TRIANGLES);
sp->pipeline=pipeline_creater->Create(); sp->pipeline=pipeline_creater->Create();
if(!sp->pipeline) if(!sp->pipeline)
@ -241,10 +246,10 @@ private:
bool InitMaterial() bool InitMaterial()
{ {
if(!InitSubpass(&sp_gbuffer, OS_TEXT("gbuffer_opaque.vert.spv"),OS_TEXT("gbuffer_opaque.frag.spv")))return(false); 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(!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.color =vulkan::LoadTGATexture(OS_TEXT("cardboardPlainStain.tga"),device);
texture.normal =vulkan::LoadTGATexture(OS_TEXT("APOCWALL029_NRM.tga"),device); texture.normal =vulkan::LoadTGATexture(OS_TEXT("APOCWALL029_NRM.tga"),device);
@ -301,6 +306,25 @@ private:
return(true); 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: public:
bool Init() bool Init()
@ -317,6 +341,9 @@ public:
if(!InitScene(&sp_gbuffer)) if(!InitScene(&sp_gbuffer))
return(false); return(false);
if(!InitGBufferCommandBuffer())
return(false);
return(true); return(true);
} }

View File

@ -218,6 +218,7 @@ RenderPass *Device::CreateRenderPass( const List<VkAttachmentDescription> &des
VkRenderPassCreateInfo rp_info; VkRenderPassCreateInfo rp_info;
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
rp_info.pNext = nullptr; rp_info.pNext = nullptr;
rp_info.flags = 0;
rp_info.attachmentCount = desc_list.GetCount(); rp_info.attachmentCount = desc_list.GetCount();
rp_info.pAttachments = desc_list.GetData(); rp_info.pAttachments = desc_list.GetData();
rp_info.subpassCount = subpass.GetCount(); rp_info.subpassCount = subpass.GetCount();

View File

@ -153,7 +153,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
colorBlending.pNext = nullptr; colorBlending.pNext = nullptr;
colorBlending.flags = 0; colorBlending.flags = 0;
colorBlending.logicOpEnable = VK_FALSE; colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY; colorBlending.logicOp = VK_LOGIC_OP_CLEAR;
colorBlending.attachmentCount = colorBlendAttachments.GetCount(); colorBlending.attachmentCount = colorBlendAttachments.GetCount();
colorBlending.pAttachments = colorBlendAttachments.GetData(); colorBlending.pAttachments = colorBlendAttachments.GetData();
colorBlending.blendConstants[0] = 0.0f; colorBlending.blendConstants[0] = 0.0f;