RenderTarget初步制作并测试成功
This commit is contained in:
@@ -88,7 +88,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->SetDepthTest(true);
|
||||
pipeline_creater->SetDepthWrite(true);
|
||||
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
||||
|
@@ -251,7 +251,7 @@ private:
|
||||
|
||||
bool InitCompositionPipeline(SubpassParam *sp)
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,sp->material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,sp->material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->SetDepthTest(false);
|
||||
pipeline_creater->SetDepthWrite(false);
|
||||
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
||||
@@ -408,7 +408,7 @@ private:
|
||||
gbuffer_cmd->EndRenderPass();
|
||||
gbuffer_cmd->End();
|
||||
|
||||
device->SubmitDraw(*gbuffer_cmd);
|
||||
device->Submit(*gbuffer_cmd);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ private:
|
||||
|
||||
bool InitUBO()
|
||||
{
|
||||
const VkExtent2D extent=swapchain->GetExtent();
|
||||
const VkExtent2D extent=sc_render_target->GetExtent();
|
||||
|
||||
world.mvp=ortho(extent.width,extent.height);
|
||||
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLE_FAN);
|
||||
|
||||
|
@@ -58,7 +58,7 @@ private:
|
||||
bool InitPipeline(MDP *mdp,const VkPrimitiveTopology primitive)
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,mdp->material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,mdp->material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(primitive);
|
||||
|
||||
|
@@ -11,8 +11,8 @@
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
constexpr uint32_t SCREEN_WIDTH=128;
|
||||
constexpr uint32_t SCREEN_HEIGHT=128;
|
||||
|
||||
class TestApp:public CameraAppFramework
|
||||
{
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->Set(PRIM_LINES);
|
||||
|
||||
pipeline_line=pipeline_creater->Create();
|
||||
|
@@ -163,7 +163,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->SetDepthTest(false);
|
||||
pipeline_creater->SetDepthWrite(false);
|
||||
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_LINE);
|
||||
|
@@ -75,7 +75,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->SetDepthTest(true);
|
||||
pipeline_creater->SetDepthWrite(true);
|
||||
pipeline_creater->CloseCullFace();
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include<hgl/graph/vulkan/VKFormat.h>
|
||||
#include<hgl/graph/vulkan/VKFramebuffer.h>
|
||||
#include<hgl/graph/vulkan/VKMaterial.h>
|
||||
#include<hgl/graph/vulkan/VKRenderTarget.h>
|
||||
#include<hgl/graph/SceneDB.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
|
||||
@@ -50,19 +51,19 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
vulkan::Device * device =nullptr;
|
||||
vulkan::Swapchain * swapchain =nullptr;
|
||||
vulkan::Device * device =nullptr;
|
||||
vulkan::SwapchainRenderTarget * sc_render_target =nullptr;
|
||||
|
||||
vulkan::Semaphore * present_complete_semaphore =nullptr,
|
||||
* render_complete_semaphore =nullptr;
|
||||
vulkan::Semaphore * present_complete_semaphore =nullptr,
|
||||
* render_complete_semaphore =nullptr;
|
||||
|
||||
vulkan::ShaderModuleManage *shader_manage =nullptr;
|
||||
vulkan::ShaderModuleManage * shader_manage =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
uint32_t swap_chain_count=0;
|
||||
uint32_t swap_chain_count=0;
|
||||
|
||||
vulkan::CommandBuffer ** cmd_buf =nullptr;
|
||||
vulkan::CommandBuffer ** cmd_buf =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -113,7 +114,7 @@ public:
|
||||
if(!device)
|
||||
return(false);
|
||||
|
||||
swapchain=device->GetSwapchain();
|
||||
sc_render_target=device->GetSwapchainRT();
|
||||
present_complete_semaphore =device->CreateSem();
|
||||
render_complete_semaphore =device->CreateSem();
|
||||
|
||||
@@ -147,10 +148,9 @@ public:
|
||||
if(cmd_buf)
|
||||
SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count);
|
||||
|
||||
|
||||
swap_chain_count=swapchain->GetImageCount();
|
||||
swap_chain_count=sc_render_target->GetImageCount();
|
||||
{
|
||||
const VkExtent2D extent=swapchain->GetExtent();
|
||||
const VkExtent2D extent=sc_render_target->GetExtent();
|
||||
|
||||
cmd_buf=hgl_zero_new<vulkan::CommandBuffer *>(swap_chain_count);
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
vulkan::CommandBuffer *cb=cmd_buf[index];
|
||||
|
||||
cb->Begin();
|
||||
cb->BeginRenderPass(swapchain->GetMainRenderPass(),swapchain->GetFramebuffer(index));
|
||||
cb->BeginRenderPass(sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index));
|
||||
cb->Bind(p);
|
||||
cb->Bind(ds);
|
||||
cb->Bind(r);
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
|
||||
void BuildCurrentCommandBuffer(vulkan::Pipeline *p,vulkan::DescriptorSets *ds,vulkan::Renderable *r)
|
||||
{
|
||||
BuildCommandBuffer(swapchain->GetCurrentFrameIndices(),p,ds,r);
|
||||
BuildCommandBuffer(sc_render_target->GetCurrentFrameIndices(),p,ds,r);
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(uint32_t index,RenderList *rl)
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
vulkan::CommandBuffer *cb=cmd_buf[index];
|
||||
|
||||
cb->Begin();
|
||||
cb->BeginRenderPass(swapchain->GetMainRenderPass(),swapchain->GetFramebuffer(index));
|
||||
cb->BeginRenderPass(sc_render_target->GetRenderPass(),sc_render_target->GetFramebuffer(index));
|
||||
rl->Render(cb);
|
||||
cb->EndRenderPass();
|
||||
cb->End();
|
||||
@@ -215,16 +215,16 @@ public:
|
||||
|
||||
void BuildCurrentCommandBuffer(RenderList *rl)
|
||||
{
|
||||
BuildCommandBuffer(swapchain->GetCurrentFrameIndices(),rl);
|
||||
BuildCommandBuffer(sc_render_target->GetCurrentFrameIndices(),rl);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
int AcquireNextImage()
|
||||
{
|
||||
if(swapchain->Wait())
|
||||
if(sc_render_target->Wait())
|
||||
{
|
||||
int cur=swapchain->AcquireNextImage(present_complete_semaphore);
|
||||
int cur=sc_render_target->AcquireNextImage(present_complete_semaphore);
|
||||
|
||||
return cur;
|
||||
}
|
||||
@@ -236,8 +236,8 @@ public:
|
||||
{
|
||||
VkCommandBuffer cb=*cmd_buf[index];
|
||||
|
||||
swapchain->SubmitDraw(cb,present_complete_semaphore,render_complete_semaphore);
|
||||
swapchain->PresentBackbuffer(render_complete_semaphore);
|
||||
sc_render_target->Submit(cb,present_complete_semaphore,render_complete_semaphore);
|
||||
sc_render_target->PresentBackbuffer(render_complete_semaphore);
|
||||
}
|
||||
|
||||
virtual void Draw()
|
||||
|
@@ -76,7 +76,7 @@ private:
|
||||
|
||||
bool InitUBO()
|
||||
{
|
||||
const VkExtent2D extent=swapchain->GetExtent();
|
||||
const VkExtent2D extent=sc_render_target->GetExtent();
|
||||
|
||||
world.mvp=ortho(extent.width,extent.height);
|
||||
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
|
@@ -77,7 +77,7 @@ private:
|
||||
|
||||
bool InitUBO()
|
||||
{
|
||||
const VkExtent2D extent=swapchain->GetExtent();
|
||||
const VkExtent2D extent=sc_render_target->GetExtent();
|
||||
|
||||
world.mvp=ortho(extent.width,extent.height);
|
||||
|
||||
@@ -108,7 +108,7 @@ private:
|
||||
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
@@ -119,7 +119,7 @@ private:
|
||||
void *data;
|
||||
uint size=filesystem::LoadFileToMemory(PIPELINE_FILENAME,(void **)&data);
|
||||
|
||||
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent(),(uchar *)data,size);
|
||||
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent(),(uchar *)data,size);
|
||||
|
||||
pipeline=pipeline_creater->Create();
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ private:
|
||||
|
||||
bool InitUBO()
|
||||
{
|
||||
const VkExtent2D extent=swapchain->GetExtent();
|
||||
const VkExtent2D extent=sc_render_target->GetExtent();
|
||||
|
||||
world.mvp=ortho(extent.width,extent.height);
|
||||
|
||||
@@ -149,7 +149,7 @@ private:
|
||||
bool InitPipeline()
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,swapchain->GetMainRenderPass(),swapchain->GetExtent());
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,sc_render_target->GetRenderPass(),sc_render_target->GetExtent());
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
|
Reference in New Issue
Block a user