1.RenderPass记录color/depth格式
2.建立ImageView类,封装imageview部分信息 3.改进CreateFramebuffer,增加ImageView传入格式检测
This commit is contained in:
parent
4110844938
commit
19b5b08c25
@ -10,6 +10,7 @@ SET(VULKAN_TEST_SOURCE_FILES main.cpp
|
||||
VKFormat.cpp
|
||||
VKInstance.cpp
|
||||
VKPhysicalDevice.cpp
|
||||
VKImageView.cpp
|
||||
VKCommandBuffer.cpp
|
||||
VKDeviceAttribute.cpp
|
||||
VKDeviceCreater.cpp
|
||||
@ -31,6 +32,7 @@ SET(VULKAN_TEST_HEADER_FILES VK.h
|
||||
VKPrimivate.h
|
||||
VKInstance.h
|
||||
VKPhysicalDevice.h
|
||||
VKImageView.h
|
||||
VKCommandBuffer.h
|
||||
VKSurfaceExtensionName.h
|
||||
VKDeviceAttribute.h
|
||||
|
@ -53,7 +53,7 @@ DescriptorSets *DescriptorSetLayout::CreateSets()const
|
||||
return(new DescriptorSets(device,desc_set));
|
||||
}
|
||||
|
||||
void DescriptorSetLayoutCreater::Bind(const int binding,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
||||
void DescriptorSetLayoutCreater::Bind(const uint32_t binding,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
||||
{
|
||||
VkDescriptorSetLayoutBinding layout_binding = {};
|
||||
layout_binding.binding = binding;
|
||||
|
@ -54,9 +54,9 @@ public:
|
||||
DescriptorSetLayoutCreater(Device *dev):device(dev){}
|
||||
~DescriptorSetLayoutCreater()=default;
|
||||
|
||||
void Bind(const int binding,VkDescriptorType,VkShaderStageFlagBits);
|
||||
void Bind(const uint32_t binding,VkDescriptorType,VkShaderStageFlagBits);
|
||||
|
||||
#define DESC_SET_BIND_FUNC(name,vkname) void Bind##name(const int binding,VkShaderStageFlagBits stage_flag){Bind(binding,VK_DESCRIPTOR_TYPE_##vkname,stage_flag);}
|
||||
#define DESC_SET_BIND_FUNC(name,vkname) void Bind##name(const uint32_t binding,VkShaderStageFlagBits stage_flag){Bind(binding,VK_DESCRIPTOR_TYPE_##vkname,stage_flag);}
|
||||
|
||||
DESC_SET_BIND_FUNC(Sampler, SAMPLER);
|
||||
DESC_SET_BIND_FUNC(UBO, UNIFORM_BUFFER);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include"VKDevice.h"
|
||||
#include<hgl/type/Pair.h>
|
||||
#include"VKBuffer.h"
|
||||
#include"VKImageView.h"
|
||||
#include"VKCommandBuffer.h"
|
||||
//#include"VKDescriptorSet.h"
|
||||
#include"VKRenderPass.h"
|
||||
@ -134,28 +135,9 @@ CommandBuffer *Device::CreateCommandBuffer()
|
||||
return(new CommandBuffer(attr->device,attr->swapchain_extent,attr->cmd_pool,cmd_buf));
|
||||
}
|
||||
|
||||
RenderPass *Device::CreateRenderPass()
|
||||
RenderPass *Device::CreateRenderPass(VkFormat color_format,VkFormat depth_format)
|
||||
{
|
||||
VkAttachmentDescription attachments[2];
|
||||
attachments[0].format=attr->format;
|
||||
attachments[0].samples=VK_SAMPLE_COUNT_1_BIT;
|
||||
attachments[0].loadOp=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
attachments[0].storeOp=VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachments[0].stencilLoadOp=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachments[0].stencilStoreOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[0].initialLayout=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachments[0].finalLayout=VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
attachments[0].flags=0;
|
||||
|
||||
attachments[1].format=attr->depth.format;
|
||||
attachments[1].samples=VK_SAMPLE_COUNT_1_BIT;
|
||||
attachments[1].loadOp=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
attachments[1].storeOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[1].stencilLoadOp=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachments[1].stencilStoreOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[1].initialLayout=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachments[1].finalLayout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
attachments[1].flags=0;
|
||||
|
||||
VkAttachmentReference color_reference={0,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
|
||||
VkAttachmentReference depth_reference={1,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL};
|
||||
@ -165,13 +147,58 @@ RenderPass *Device::CreateRenderPass()
|
||||
subpass.flags=0;
|
||||
subpass.inputAttachmentCount=0;
|
||||
subpass.pInputAttachments=nullptr;
|
||||
subpass.colorAttachmentCount=1;
|
||||
subpass.pColorAttachments=&color_reference;
|
||||
subpass.pResolveAttachments=nullptr;
|
||||
subpass.pDepthStencilAttachment=&depth_reference;
|
||||
subpass.preserveAttachmentCount=0;
|
||||
subpass.pPreserveAttachments=nullptr;
|
||||
|
||||
int att_count=0;
|
||||
|
||||
if(color_format!=VK_FORMAT_UNDEFINED)
|
||||
{
|
||||
attachments[0].format=color_format;
|
||||
attachments[0].samples=VK_SAMPLE_COUNT_1_BIT;
|
||||
attachments[0].loadOp=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
attachments[0].storeOp=VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachments[0].stencilLoadOp=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachments[0].stencilStoreOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[0].initialLayout=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachments[0].finalLayout=VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
attachments[0].flags=0;
|
||||
|
||||
++att_count;
|
||||
|
||||
subpass.colorAttachmentCount=1;
|
||||
subpass.pColorAttachments=&color_reference;
|
||||
}
|
||||
else
|
||||
{
|
||||
subpass.colorAttachmentCount=0;
|
||||
subpass.pColorAttachments=nullptr;
|
||||
}
|
||||
|
||||
if(depth_format!=VK_FORMAT_UNDEFINED)
|
||||
{
|
||||
attachments[att_count].format=depth_format;
|
||||
attachments[att_count].samples=VK_SAMPLE_COUNT_1_BIT;
|
||||
attachments[att_count].loadOp=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
attachments[att_count].storeOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[att_count].stencilLoadOp=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachments[att_count].stencilStoreOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
attachments[att_count].initialLayout=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachments[att_count].finalLayout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
attachments[att_count].flags=0;
|
||||
|
||||
depth_reference.attachment=att_count;
|
||||
|
||||
++att_count;
|
||||
|
||||
subpass.pDepthStencilAttachment=&depth_reference;
|
||||
}
|
||||
else
|
||||
{
|
||||
subpass.pDepthStencilAttachment=nullptr;
|
||||
}
|
||||
|
||||
VkSubpassDependency dependency = {};
|
||||
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependency.dstSubpass = 0;
|
||||
@ -183,7 +210,7 @@ RenderPass *Device::CreateRenderPass()
|
||||
VkRenderPassCreateInfo rp_info={};
|
||||
rp_info.sType=VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
rp_info.pNext=nullptr;
|
||||
rp_info.attachmentCount=2;
|
||||
rp_info.attachmentCount=att_count;
|
||||
rp_info.pAttachments=attachments;
|
||||
rp_info.subpassCount=1;
|
||||
rp_info.pSubpasses=&subpass;
|
||||
@ -195,7 +222,7 @@ RenderPass *Device::CreateRenderPass()
|
||||
if(vkCreateRenderPass(attr->device,&rp_info,nullptr,&render_pass)!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new RenderPass(attr->device,render_pass));
|
||||
return(new RenderPass(attr->device,render_pass,color_format,depth_format));
|
||||
}
|
||||
|
||||
Fence *Device::CreateFence()
|
||||
|
@ -49,8 +49,8 @@ public:
|
||||
public:
|
||||
|
||||
const uint32_t GetSwapChainImageCount ()const {return attr->sc_image_views.GetCount();}
|
||||
VkImageView GetColorImageView (int index) {return GetObject(attr->sc_image_views,index);}
|
||||
VkImageView GetDepthImageView () {return attr->depth.view;}
|
||||
ImageView *GetColorImageView (int index) {return attr->sc_image_views[index];}
|
||||
ImageView *GetDepthImageView () {return attr->depth.view;}
|
||||
|
||||
const uint32_t GetCurrentFrameIndices () {return current_frame;}
|
||||
|
||||
@ -73,7 +73,7 @@ public:
|
||||
#undef CREATE_BUFFER_OBJECT
|
||||
|
||||
CommandBuffer * CreateCommandBuffer();
|
||||
RenderPass * CreateRenderPass();
|
||||
RenderPass * CreateRenderPass(VkFormat color_format,VkFormat depth_format);
|
||||
Fence * CreateFence();
|
||||
Semaphore * CreateSem();
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include"VKDeviceAttribute.h"
|
||||
#include"VKPhysicalDevice.h"
|
||||
#include"VKImageView.h"
|
||||
#include<iostream>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
@ -137,8 +138,7 @@ DeviceAttribute::~DeviceAttribute()
|
||||
if(desc_pool)
|
||||
vkDestroyDescriptorPool(device,desc_pool,nullptr);
|
||||
|
||||
if(depth.view)
|
||||
vkDestroyImageView(device,depth.view,nullptr);
|
||||
SAFE_CLEAR(depth.view);
|
||||
|
||||
if(depth.image)
|
||||
vkDestroyImage(device,depth.image,nullptr);
|
||||
@ -146,20 +146,7 @@ DeviceAttribute::~DeviceAttribute()
|
||||
if(depth.mem)
|
||||
vkFreeMemory(device,depth.mem,nullptr);
|
||||
|
||||
{
|
||||
const uint32_t iv_count=sc_image_views.GetCount();
|
||||
|
||||
if(iv_count>0)
|
||||
{
|
||||
VkImageView *iv=sc_image_views.GetData();
|
||||
|
||||
for(uint32_t i=0;i<iv_count;i++)
|
||||
{
|
||||
vkDestroyImageView(device,*iv,nullptr);
|
||||
++iv;
|
||||
}
|
||||
}
|
||||
}
|
||||
sc_image_views.Clear();
|
||||
|
||||
if(swap_chain)
|
||||
vkDestroySwapchainKHR(device,swap_chain,nullptr);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include"VK.h"
|
||||
#include"VKImageView.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
@ -38,7 +39,7 @@ struct DeviceAttribute
|
||||
VkSwapchainKHR swap_chain =nullptr;
|
||||
|
||||
List<VkImage> sc_images;
|
||||
List<VkImageView> sc_image_views;
|
||||
ObjectList<ImageView> sc_image_views;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -46,7 +47,7 @@ struct DeviceAttribute
|
||||
|
||||
VkImage image =nullptr;
|
||||
VkDeviceMemory mem =nullptr;
|
||||
VkImageView view =nullptr;
|
||||
ImageView * view =nullptr;
|
||||
}depth;
|
||||
|
||||
VkDescriptorPool desc_pool =nullptr;
|
||||
|
@ -135,40 +135,12 @@ namespace
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
VkImageView CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,VkImageAspectFlags aspectMask,VkImage img=nullptr)
|
||||
{
|
||||
VkImageViewCreateInfo iv_createinfo={};
|
||||
|
||||
iv_createinfo.sType=VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
iv_createinfo.pNext=nullptr;
|
||||
iv_createinfo.flags=0;
|
||||
iv_createinfo.image=img;
|
||||
iv_createinfo.format=format;
|
||||
iv_createinfo.viewType=type;
|
||||
iv_createinfo.components.r=VK_COMPONENT_SWIZZLE_R;
|
||||
iv_createinfo.components.g=VK_COMPONENT_SWIZZLE_G;
|
||||
iv_createinfo.components.b=VK_COMPONENT_SWIZZLE_B;
|
||||
iv_createinfo.components.a=VK_COMPONENT_SWIZZLE_A;
|
||||
iv_createinfo.subresourceRange.aspectMask=aspectMask;
|
||||
iv_createinfo.subresourceRange.baseMipLevel=0;
|
||||
iv_createinfo.subresourceRange.levelCount=1;
|
||||
iv_createinfo.subresourceRange.baseArrayLayer=0;
|
||||
iv_createinfo.subresourceRange.layerCount=1;
|
||||
|
||||
VkImageView iv;
|
||||
|
||||
if(vkCreateImageView(device,&iv_createinfo,nullptr,&iv)!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return iv;
|
||||
}
|
||||
|
||||
VkImageView Create2DImageView(VkDevice device,VkFormat format,VkImage img=nullptr)
|
||||
ImageView *Create2DImageView(VkDevice device,VkFormat format,VkImage img=nullptr)
|
||||
{
|
||||
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,VK_IMAGE_ASPECT_COLOR_BIT,img);
|
||||
}
|
||||
|
||||
VkImageView CreateDepthImageView(VkDevice device,VkFormat format,VkImage img=nullptr)
|
||||
ImageView *CreateDepthImageView(VkDevice device,VkFormat format,VkImage img=nullptr)
|
||||
{
|
||||
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,VK_IMAGE_ASPECT_DEPTH_BIT,img);
|
||||
}
|
||||
@ -188,19 +160,18 @@ namespace
|
||||
return(false);
|
||||
}
|
||||
|
||||
rsa->sc_image_views.SetCount(count);
|
||||
|
||||
VkImage *ip=rsa->sc_images.GetData();
|
||||
VkImageView *vp=rsa->sc_image_views.GetData();
|
||||
ImageView *vp;
|
||||
for(uint32_t i=0; i<count; i++)
|
||||
{
|
||||
*vp=Create2DImageView(rsa->device,rsa->format,*ip);
|
||||
vp=Create2DImageView(rsa->device,rsa->format,*ip);
|
||||
|
||||
if(*vp==nullptr)
|
||||
if(vp==nullptr)
|
||||
return(false);
|
||||
|
||||
rsa->sc_image_views.Add(vp);
|
||||
|
||||
++ip;
|
||||
++vp;
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
@ -1,18 +1,28 @@
|
||||
#include"VKFramebuffer.h"
|
||||
#include"VKDevice.h"
|
||||
#include"VKImageView.h"
|
||||
#include"VKRenderPass.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Framebuffer::~Framebuffer()
|
||||
{
|
||||
vkDestroyFramebuffer(device,frame_buffer,nullptr);
|
||||
}
|
||||
|
||||
Framebuffer *CreateFramebuffer(Device *dev,RenderPass *rp,VkImageView color,VkImageView depth)
|
||||
Framebuffer *CreateFramebuffer(Device *dev,RenderPass *rp,ImageView *color,ImageView *depth)
|
||||
{
|
||||
if(!dev||!rp)return(nullptr);
|
||||
|
||||
if(!dev)return(nullptr);
|
||||
if(!rp)return(nullptr);
|
||||
if(!color&&!depth)return(nullptr);
|
||||
|
||||
if(color)
|
||||
if(rp->GetColorFormat()!=color->GetFormat())
|
||||
return(nullptr);
|
||||
|
||||
if(depth)
|
||||
if(rp->GetDepthFormat()!=depth->GetFormat())
|
||||
return(nullptr);
|
||||
|
||||
const VkExtent2D extent=dev->GetExtent();
|
||||
VkImageView attachments[2];
|
||||
|
||||
@ -27,11 +37,11 @@ Framebuffer *CreateFramebuffer(Device *dev,RenderPass *rp,VkImageView color,VkIm
|
||||
|
||||
if(color)
|
||||
{
|
||||
attachments[0]=color;
|
||||
attachments[0]=*color;
|
||||
|
||||
if(depth)
|
||||
{
|
||||
attachments[1]=depth;
|
||||
attachments[1]=*depth;
|
||||
fb_info.attachmentCount = 2;
|
||||
}
|
||||
else
|
||||
@ -39,7 +49,7 @@ Framebuffer *CreateFramebuffer(Device *dev,RenderPass *rp,VkImageView color,VkIm
|
||||
}
|
||||
else
|
||||
{
|
||||
attachments[0]=depth;
|
||||
attachments[0]=*depth;
|
||||
fb_info.attachmentCount = 1;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Device;
|
||||
class RenderPass;
|
||||
class ImageView;
|
||||
|
||||
class Framebuffer
|
||||
{
|
||||
@ -13,7 +14,7 @@ class Framebuffer
|
||||
|
||||
private:
|
||||
|
||||
friend Framebuffer *CreateFramebuffer(Device *,RenderPass *,VkImageView color,VkImageView depth);;
|
||||
friend Framebuffer *CreateFramebuffer(Device *,RenderPass *,ImageView *color,ImageView *depth);
|
||||
|
||||
Framebuffer(VkDevice dev,VkFramebuffer fb)
|
||||
{
|
||||
@ -28,6 +29,6 @@ public:
|
||||
operator VkFramebuffer(){return frame_buffer;}
|
||||
};//class Framebuffer
|
||||
|
||||
Framebuffer *CreateFramebuffer(Device *,RenderPass *,VkImageView color,VkImageView depth=nullptr);
|
||||
Framebuffer *CreateFramebuffer(Device *,RenderPass *,ImageView *color,ImageView *depth=nullptr);
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||
|
38
example/Vulkan/VKImageView.h
Normal file
38
example/Vulkan/VKImageView.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_IMAGE_VIEW_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_IMAGE_VIEW_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
VK_NAMESPACE_BEGIN
|
||||
class ImageView
|
||||
{
|
||||
VkDevice device;
|
||||
VkImageView image_view;
|
||||
VkImageViewCreateInfo info;
|
||||
|
||||
private:
|
||||
|
||||
friend ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,VkImageAspectFlags aspectMask,VkImage img);
|
||||
|
||||
ImageView(VkDevice dev,VkImageView iv,const VkImageViewCreateInfo &ci)
|
||||
{
|
||||
device=dev;
|
||||
image_view=iv;
|
||||
info=ci;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
~ImageView();
|
||||
|
||||
operator VkImageView(){return image_view;}
|
||||
|
||||
public:
|
||||
|
||||
const VkImageViewType GetViewType ()const{return info.viewType;}
|
||||
const VkFormat GetFormat ()const{return info.format;}
|
||||
const VkImageAspectFlags GetAspectFlags ()const{return info.subresourceRange.aspectMask;}
|
||||
};//class ImageView
|
||||
|
||||
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,VkImageAspectFlags aspectMask,VkImage img=nullptr);
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_IMAGE_VIEW_INCLUDE
|
@ -3,21 +3,31 @@
|
||||
|
||||
#include"VK.h"
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Framebuffer;
|
||||
class ImageView;
|
||||
|
||||
class RenderPass
|
||||
{
|
||||
VkDevice device;
|
||||
VkRenderPass render_pass;
|
||||
|
||||
VkFormat color_format,depth_format;
|
||||
|
||||
public:
|
||||
|
||||
RenderPass(VkDevice d,VkRenderPass rp)
|
||||
RenderPass(VkDevice d,VkRenderPass rp,VkFormat cf,VkFormat df)
|
||||
{
|
||||
device=d;
|
||||
render_pass=rp;
|
||||
color_format=cf;
|
||||
depth_format=df;
|
||||
}
|
||||
virtual ~RenderPass();
|
||||
|
||||
operator VkRenderPass(){return render_pass;}
|
||||
|
||||
const VkFormat GetColorFormat()const{return color_format;}
|
||||
const VkFormat GetDepthFormat()const{return depth_format;}
|
||||
};//class RenderPass
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_RENDER_PASS_INCLUDE
|
||||
|
36
example/Vulkan/VkImageView.cpp
Normal file
36
example/Vulkan/VkImageView.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include"VKImageView.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
ImageView::~ImageView()
|
||||
{
|
||||
vkDestroyImageView(device,image_view,nullptr);
|
||||
}
|
||||
|
||||
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,VkImageAspectFlags aspectMask,VkImage img)
|
||||
{
|
||||
VkImageViewCreateInfo iv_createinfo={};
|
||||
|
||||
iv_createinfo.sType=VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
iv_createinfo.pNext=nullptr;
|
||||
iv_createinfo.flags=0;
|
||||
iv_createinfo.image=img;
|
||||
iv_createinfo.format=format;
|
||||
iv_createinfo.viewType=type;
|
||||
iv_createinfo.components.r=VK_COMPONENT_SWIZZLE_R;
|
||||
iv_createinfo.components.g=VK_COMPONENT_SWIZZLE_G;
|
||||
iv_createinfo.components.b=VK_COMPONENT_SWIZZLE_B;
|
||||
iv_createinfo.components.a=VK_COMPONENT_SWIZZLE_A;
|
||||
iv_createinfo.subresourceRange.aspectMask=aspectMask;
|
||||
iv_createinfo.subresourceRange.baseMipLevel=0;
|
||||
iv_createinfo.subresourceRange.levelCount=1;
|
||||
iv_createinfo.subresourceRange.baseArrayLayer=0;
|
||||
iv_createinfo.subresourceRange.layerCount=1;
|
||||
|
||||
VkImageView iv;
|
||||
|
||||
if(vkCreateImageView(device,&iv_createinfo,nullptr,&iv)!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new ImageView(device,iv,iv_createinfo));
|
||||
}
|
||||
VK_NAMESPACE_END
|
@ -4,6 +4,7 @@
|
||||
#include"VKDevice.h"
|
||||
#include"VKBuffer.h"
|
||||
#include"VKShader.h"
|
||||
#include"VKImageView.h"
|
||||
#include"VKVertexInput.h"
|
||||
#include"VKDescriptorSets.h"
|
||||
#include"VKRenderPass.h"
|
||||
@ -174,10 +175,24 @@ int main(int,char **)
|
||||
|
||||
vulkan::Semaphore *sem=device->CreateSem();
|
||||
|
||||
|
||||
vulkan::VertexInput *vi=CreateVertexBuffer(device);
|
||||
const int image_count=device->GetSwapChainImageCount();
|
||||
vulkan::Framebuffer **fb=new vulkan::Framebuffer *[image_count];
|
||||
|
||||
vulkan::ImageView *color_iv=device->GetColorImageView(0);
|
||||
vulkan::ImageView *depth_iv=device->GetDepthImageView();
|
||||
|
||||
vulkan::RenderPass *rp=device->CreateRenderPass(color_iv->GetFormat(),depth_iv->GetFormat());
|
||||
|
||||
for(int i=0;i<image_count;i++)
|
||||
{
|
||||
color_iv=device->GetColorImageView(i);
|
||||
|
||||
fb[i]=vulkan::CreateFramebuffer(device,rp,color_iv,depth_iv);
|
||||
}
|
||||
|
||||
vulkan::PipelineCreater pc(device);
|
||||
vulkan::RenderPass *rp=device->CreateRenderPass();
|
||||
|
||||
vulkan::DescriptorSetLayoutCreater dslc(device);
|
||||
vulkan::DescriptorSetLayout *dsl=dslc.Create();
|
||||
@ -196,12 +211,6 @@ int main(int,char **)
|
||||
|
||||
device->AcquireNextImage();
|
||||
|
||||
const int image_count=device->GetSwapChainImageCount();
|
||||
vulkan::Framebuffer **fb=new vulkan::Framebuffer *[image_count];
|
||||
|
||||
for(int i=0;i<image_count;i++)
|
||||
fb[i]=vulkan::CreateFramebuffer(device,rp,device->GetColorImageView(i),device->GetDepthImageView());
|
||||
|
||||
cmd_buf->Begin(rp,fb[0]);
|
||||
cmd_buf->Bind(pipeline);
|
||||
cmd_buf->Bind(pl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user