修正诸多问题,MRT输出基本成功,但depth test失败,问题未知
This commit is contained in:
parent
5b4dad6941
commit
b7954338aa
@ -219,7 +219,8 @@ private:
|
|||||||
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,sp->material,gbuffer.renderpass,gbuffer.extent);
|
AutoDelete<vulkan::PipelineCreater> pipeline_creater=new vulkan::PipelineCreater(device,sp->material,gbuffer.renderpass,gbuffer.extent);
|
||||||
pipeline_creater->SetDepthTest(true);
|
pipeline_creater->SetDepthTest(true);
|
||||||
pipeline_creater->SetDepthWrite(true);
|
pipeline_creater->SetDepthWrite(true);
|
||||||
pipeline_creater->SetCullMode(VK_CULL_MODE_BACK_BIT);
|
//pipeline_creater->SetCullMode(VK_CULL_MODE_BACK_BIT);
|
||||||
|
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();
|
||||||
@ -360,13 +361,13 @@ private:
|
|||||||
bool InitScene(SubpassParam *sp)
|
bool InitScene(SubpassParam *sp)
|
||||||
{
|
{
|
||||||
CreateRenderObject(sp->material);
|
CreateRenderObject(sp->material);
|
||||||
|
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cube),scale(50,50,50));
|
||||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_plane_grid));
|
//render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_plane_grid));
|
||||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_torus));
|
//render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_torus));
|
||||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cube ),translate(-10, 0, 5)*scale(10,10,10));
|
//render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cube ),translate(-10, 0, 5)*scale(10,10,10));
|
||||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_sphere ),translate( 10, 0, 5)*scale(10,10,10));
|
//render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_sphere ),translate( 10, 0, 5)*scale(10,10,10));
|
||||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cylinder ),translate( 0, 16, 0));
|
//render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cylinder ),translate( 0, 16, 0));
|
||||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cone ),translate( 0,-16, 0));
|
//render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cone ),translate( 0,-16, 0));
|
||||||
|
|
||||||
render_root.RefreshMatrix();
|
render_root.RefreshMatrix();
|
||||||
render_root.ExpendToList(&render_list);
|
render_root.ExpendToList(&render_list);
|
||||||
@ -376,7 +377,7 @@ private:
|
|||||||
|
|
||||||
bool InitGBufferCommandBuffer()
|
bool InitGBufferCommandBuffer()
|
||||||
{
|
{
|
||||||
gbuffer_cmd=device->CreateCommandBuffer(&gbuffer.extent);
|
gbuffer_cmd=device->CreateCommandBuffer(&gbuffer.extent,gbuffer.attachment.desc_list.GetCount());
|
||||||
|
|
||||||
if(!gbuffer_cmd)
|
if(!gbuffer_cmd)
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -137,10 +137,12 @@ public:
|
|||||||
|
|
||||||
swap_chain_count=device->GetSwapChainImageCount();
|
swap_chain_count=device->GetSwapChainImageCount();
|
||||||
{
|
{
|
||||||
|
const VkExtent2D extent=device->GetExtent();
|
||||||
|
|
||||||
cmd_buf=hgl_zero_new<vulkan::CommandBuffer *>(swap_chain_count);
|
cmd_buf=hgl_zero_new<vulkan::CommandBuffer *>(swap_chain_count);
|
||||||
|
|
||||||
for(uint i=0;i<swap_chain_count;i++)
|
for(uint i=0;i<swap_chain_count;i++)
|
||||||
cmd_buf[i]=device->CreateCommandBuffer();
|
cmd_buf[i]=device->CreateCommandBuffer(&extent,2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,13 @@ struct PushConstant
|
|||||||
Matrix4f local_to_world;
|
Matrix4f local_to_world;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline void copy(VkExtent3D &e3d,const VkExtent2D &e2d)
|
||||||
|
{
|
||||||
|
e3d.width =e2d.width;
|
||||||
|
e3d.height =e2d.height;
|
||||||
|
e3d.depth =1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
bool CheckStrideBytesByFormat(); ///<检验所有数据类型长度数组是否符合规则
|
bool CheckStrideBytesByFormat(); ///<检验所有数据类型长度数组是否符合规则
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
|
@ -13,7 +13,8 @@ class CommandBuffer
|
|||||||
VkCommandPool pool;
|
VkCommandPool pool;
|
||||||
VkCommandBuffer cmd_buf;
|
VkCommandBuffer cmd_buf;
|
||||||
|
|
||||||
VkClearValue clear_values[2];
|
uint32_t cv_count;
|
||||||
|
VkClearValue *clear_values;
|
||||||
VkRect2D render_area;
|
VkRect2D render_area;
|
||||||
VkViewport viewport;
|
VkViewport viewport;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ class CommandBuffer
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CommandBuffer(VkDevice dev,const VkExtent2D &extent,VkCommandPool cp,VkCommandBuffer cb);
|
CommandBuffer(VkDevice dev,const VkExtent2D &extent,const uint32_t att_count,VkCommandPool cp,VkCommandBuffer cb);
|
||||||
~CommandBuffer();
|
~CommandBuffer();
|
||||||
|
|
||||||
operator VkCommandBuffer(){return cmd_buf;}
|
operator VkCommandBuffer(){return cmd_buf;}
|
||||||
@ -29,18 +30,26 @@ public:
|
|||||||
operator const VkCommandBuffer *()const{return &cmd_buf;}
|
operator const VkCommandBuffer *()const{return &cmd_buf;}
|
||||||
|
|
||||||
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
||||||
void SetClearColor(float r,float g,float b,float a=1.0f)
|
void SetClearColor(int index,float r,float g,float b,float a=1.0f)
|
||||||
{
|
{
|
||||||
clear_values[0].color.float32[0]=r;
|
if(index<0||index>cv_count)return;
|
||||||
clear_values[0].color.float32[1]=g;
|
|
||||||
clear_values[0].color.float32[2]=b;
|
VkClearValue *cv=clear_values+index;
|
||||||
clear_values[0].color.float32[3]=a;
|
|
||||||
|
cv->color.float32[0]=r;
|
||||||
|
cv->color.float32[1]=g;
|
||||||
|
cv->color.float32[2]=b;
|
||||||
|
cv->color.float32[3]=a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetClearDepthStencil(float d=1.0f,float s=0)
|
void SetClearDepthStencil(int index,float d=1.0f,float s=0)
|
||||||
{
|
{
|
||||||
clear_values[1].depthStencil.depth=d;
|
if(index<0||index>cv_count)return;
|
||||||
clear_values[1].depthStencil.stencil=s;
|
|
||||||
|
VkClearValue *cv=clear_values+index;
|
||||||
|
|
||||||
|
cv->depthStencil.depth=d;
|
||||||
|
cv->depthStencil.stencil=s;
|
||||||
}
|
}
|
||||||
|
|
||||||
//以上设定在Begin开始后即不可改变
|
//以上设定在Begin开始后即不可改变
|
||||||
|
@ -141,7 +141,7 @@ public: //material相关
|
|||||||
Texture2D *CreateAttachmentTextureDepth(const VkFormat video_format,uint32_t width,uint32_t height)
|
Texture2D *CreateAttachmentTextureDepth(const VkFormat video_format,uint32_t width,uint32_t height)
|
||||||
{
|
{
|
||||||
return CreateAttachmentTexture( video_format,width,height,
|
return CreateAttachmentTexture( video_format,width,height,
|
||||||
VK_IMAGE_ASPECT_DEPTH_BIT,
|
VK_IMAGE_ASPECT_DEPTH_BIT|VK_IMAGE_ASPECT_STENCIL_BIT,
|
||||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||||
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ public: //material相关
|
|||||||
|
|
||||||
public: //Command Buffer 相关
|
public: //Command Buffer 相关
|
||||||
|
|
||||||
CommandBuffer * CreateCommandBuffer(const VkExtent2D *extent=nullptr);
|
CommandBuffer * CreateCommandBuffer(const VkExtent2D *extent,const uint32_t atta_count);
|
||||||
|
|
||||||
bool CreateAttachment( List<VkAttachmentReference> &ref_list,
|
bool CreateAttachment( List<VkAttachmentReference> &ref_list,
|
||||||
List<VkAttachmentDescription> &desc_list,
|
List<VkAttachmentDescription> &desc_list,
|
||||||
|
@ -14,17 +14,20 @@ protected:
|
|||||||
VkFormat format;
|
VkFormat format;
|
||||||
VkImageAspectFlags aspect_mask;
|
VkImageAspectFlags aspect_mask;
|
||||||
|
|
||||||
|
VkExtent3D extent;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,VkImageAspectFlags aspectMask,VkImage img);
|
friend ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,const VkExtent3D &ext,VkImageAspectFlags aspectMask,VkImage img);
|
||||||
|
|
||||||
ImageView(VkDevice dev,VkImageView iv,const VkImageViewType vt,const VkFormat fmt,const VkImageAspectFlags am)
|
ImageView(VkDevice dev,VkImageView iv,const VkImageViewType vt,const VkFormat fmt,const VkExtent3D &ext,const VkImageAspectFlags am)
|
||||||
{
|
{
|
||||||
device =dev;
|
device =dev;
|
||||||
image_view =iv;
|
image_view =iv;
|
||||||
view_type =vt;
|
view_type =vt;
|
||||||
format =fmt;
|
format =fmt;
|
||||||
aspect_mask =am;
|
aspect_mask =am;
|
||||||
|
extent =ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -37,12 +40,13 @@ public:
|
|||||||
|
|
||||||
const VkImageViewType GetViewType ()const{return view_type;}
|
const VkImageViewType GetViewType ()const{return view_type;}
|
||||||
const VkFormat GetFormat ()const{return format;}
|
const VkFormat GetFormat ()const{return format;}
|
||||||
|
const VkExtent3D & GetExtent ()const{return extent;}
|
||||||
const VkImageAspectFlags GetAspectFlags ()const{return aspect_mask;}
|
const VkImageAspectFlags GetAspectFlags ()const{return aspect_mask;}
|
||||||
};//class ImageView
|
};//class ImageView
|
||||||
|
|
||||||
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,VkImageAspectFlags aspectMask,VkImage img);
|
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,const VkExtent3D &ext,VkImageAspectFlags aspectMask,VkImage img);
|
||||||
|
|
||||||
#define CREATE_IMAGE_VIEW(short_name,larget_name) inline ImageView *CreateImageView##short_name(VkDevice device,VkFormat format,VkImageAspectFlags aspectMask,VkImage img=VK_NULL_HANDLE){return CreateImageView(device,VK_IMAGE_VIEW_TYPE_##larget_name,format,aspectMask,img);}
|
#define CREATE_IMAGE_VIEW(short_name,larget_name) inline ImageView *CreateImageView##short_name(VkDevice device,VkFormat format,const VkExtent3D &ext,VkImageAspectFlags aspectMask,VkImage img=VK_NULL_HANDLE){return CreateImageView(device,VK_IMAGE_VIEW_TYPE_##larget_name,format,ext,aspectMask,img);}
|
||||||
CREATE_IMAGE_VIEW(1D,1D);
|
CREATE_IMAGE_VIEW(1D,1D);
|
||||||
CREATE_IMAGE_VIEW(2D,2D);
|
CREATE_IMAGE_VIEW(2D,2D);
|
||||||
CREATE_IMAGE_VIEW(3D,3D);
|
CREATE_IMAGE_VIEW(3D,3D);
|
||||||
|
@ -16,12 +16,15 @@ void main()
|
|||||||
{
|
{
|
||||||
outPosition=vec4(FragmentPosition,1.0);
|
outPosition=vec4(FragmentPosition,1.0);
|
||||||
|
|
||||||
vec3 N = normalize(FragmentNormal);
|
/* vec3 N = normalize(FragmentNormal);
|
||||||
|
N.y=-N.y;
|
||||||
vec3 T = normalize(FragmentTangent);
|
vec3 T = normalize(FragmentTangent);
|
||||||
vec3 B = cross(N,T);
|
vec3 B = cross(N,T);
|
||||||
mat3 TBN = mat3(T,B,N);
|
mat3 TBN = mat3(T,B,N);
|
||||||
vec3 tnorm = normalize(texture(TextureNormal,FragmentTexCoord).xyz*2.0-vec3(1.0))*TBN;
|
vec3 tnorm = normalize(texture(TextureNormal,FragmentTexCoord).xyz*2.0-vec3(1.0))*TBN;*/
|
||||||
|
|
||||||
outNormal=vec4(tnorm,1.0);
|
//outNormal=vec4(tnorm,1.0);
|
||||||
|
|
||||||
|
outNormal=vec4(FragmentNormal,1.0);
|
||||||
outColor=texture(TextureColor,FragmentTexCoord);
|
outColor=texture(TextureColor,FragmentTexCoord);
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,12 @@ void main()
|
|||||||
FragmentPosition=pos.xyz;
|
FragmentPosition=pos.xyz;
|
||||||
FragmentTexCoord=TexCoord;
|
FragmentTexCoord=TexCoord;
|
||||||
|
|
||||||
mat3 n=inverse(mat3(pc.local_to_world));
|
// mat3 n=inverse(mat3(pc.local_to_world));
|
||||||
|
|
||||||
FragmentNormal=normalize(Normal)*n;
|
// Normal.y=-Normal.y;
|
||||||
FragmentTangent=normalize(Tangent)*n;
|
// FragmentNormal=normalize(Normal)*n;
|
||||||
|
// FragmentTangent=normalize(Tangent)*n;
|
||||||
|
|
||||||
|
FragmentNormal=normalize((Normal+vec3(1.0))/2.0);
|
||||||
|
FragmentTangent=Tangent;
|
||||||
}
|
}
|
||||||
|
@ -8,18 +8,25 @@
|
|||||||
#include<hgl/graph/vulkan/VKDescriptorSets.h>
|
#include<hgl/graph/vulkan/VKDescriptorSets.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
CommandBuffer::CommandBuffer(VkDevice dev,const VkExtent2D &extent,VkCommandPool cp,VkCommandBuffer cb)
|
CommandBuffer::CommandBuffer(VkDevice dev,const VkExtent2D &extent,const uint32_t atta_count,VkCommandPool cp,VkCommandBuffer cb)
|
||||||
{
|
{
|
||||||
device=dev;
|
device=dev;
|
||||||
pool=cp;
|
pool=cp;
|
||||||
cmd_buf=cb;
|
cmd_buf=cb;
|
||||||
|
|
||||||
clear_values[0].color.float32[0] = 0.2f;
|
cv_count=atta_count;
|
||||||
clear_values[0].color.float32[1] = 0.2f;
|
|
||||||
clear_values[0].color.float32[2] = 0.2f;
|
if(cv_count>0)
|
||||||
clear_values[0].color.float32[3] = 0.2f;
|
{
|
||||||
clear_values[1].depthStencil.depth = 1.0f;
|
clear_values=hgl_zero_new<VkClearValue>(cv_count);
|
||||||
clear_values[1].depthStencil.stencil = 0;
|
|
||||||
|
clear_values[cv_count-1].depthStencil.depth = 1.0f;
|
||||||
|
clear_values[cv_count-1].depthStencil.stencil = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clear_values=nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
render_area.offset.x=0;
|
render_area.offset.x=0;
|
||||||
render_area.offset.y=0;
|
render_area.offset.y=0;
|
||||||
@ -30,6 +37,8 @@ CommandBuffer::CommandBuffer(VkDevice dev,const VkExtent2D &extent,VkCommandPool
|
|||||||
|
|
||||||
CommandBuffer::~CommandBuffer()
|
CommandBuffer::~CommandBuffer()
|
||||||
{
|
{
|
||||||
|
delete[] clear_values;
|
||||||
|
|
||||||
vkFreeCommandBuffers(device,pool,1,&cmd_buf);
|
vkFreeCommandBuffers(device,pool,1,&cmd_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +66,7 @@ bool CommandBuffer::BeginRenderPass(RenderPass *rp,Framebuffer *fb)
|
|||||||
rp_begin.renderPass = *rp;
|
rp_begin.renderPass = *rp;
|
||||||
rp_begin.framebuffer = *fb;
|
rp_begin.framebuffer = *fb;
|
||||||
rp_begin.renderArea = render_area;
|
rp_begin.renderArea = render_area;
|
||||||
rp_begin.clearValueCount = 2;
|
rp_begin.clearValueCount = cv_count;
|
||||||
rp_begin.pClearValues = clear_values;
|
rp_begin.pClearValues = clear_values;
|
||||||
|
|
||||||
vkCmdBeginRenderPass(cmd_buf, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(cmd_buf, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
@ -85,7 +85,7 @@ void Device::RecreateDevice()
|
|||||||
fence_list.Add(this->CreateFence(true));
|
fence_list.Add(this->CreateFence(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
texture_cmd_buf=CreateCommandBuffer();
|
texture_cmd_buf=CreateCommandBuffer(nullptr,0);
|
||||||
|
|
||||||
current_frame=0;
|
current_frame=0;
|
||||||
current_fence=0;
|
current_fence=0;
|
||||||
@ -100,7 +100,7 @@ bool Device::Resize(uint width,uint height)
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBuffer *Device::CreateCommandBuffer(const VkExtent2D *extent)
|
CommandBuffer *Device::CreateCommandBuffer(const VkExtent2D *extent,const uint32_t atta_count)
|
||||||
{
|
{
|
||||||
if(!attr->cmd_pool)
|
if(!attr->cmd_pool)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
@ -119,7 +119,7 @@ CommandBuffer *Device::CreateCommandBuffer(const VkExtent2D *extent)
|
|||||||
if(res!=VK_SUCCESS)
|
if(res!=VK_SUCCESS)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
return(new CommandBuffer(attr->device,extent?*extent:attr->swapchain_extent,attr->cmd_pool,cmd_buf));
|
return(new CommandBuffer(attr->device,extent?*extent:attr->swapchain_extent,atta_count,attr->cmd_pool,cmd_buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,14 +139,21 @@ namespace
|
|||||||
return(VK_NULL_HANDLE);
|
return(VK_NULL_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView *Create2DImageView(VkDevice device,VkFormat format,VkImage img=VK_NULL_HANDLE)
|
ImageView *Create2DImageView(VkDevice device,VkFormat format,const VkExtent2D &ext,VkImage img=VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,VK_IMAGE_ASPECT_COLOR_BIT,img);
|
VkExtent3D extent;
|
||||||
|
|
||||||
|
copy(extent,ext);
|
||||||
|
|
||||||
|
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,extent,VK_IMAGE_ASPECT_COLOR_BIT,img);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView *CreateDepthImageView(VkDevice device,VkFormat format,VkImage img=VK_NULL_HANDLE)
|
ImageView *CreateDepthImageView(VkDevice device,VkFormat format,const VkExtent2D &ext,VkImage img=VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,VK_IMAGE_ASPECT_DEPTH_BIT,img);
|
VkExtent3D extent;
|
||||||
|
|
||||||
|
copy(extent,ext);
|
||||||
|
return CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,extent,VK_IMAGE_ASPECT_DEPTH_BIT,img);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateSwapchainTexture(DeviceAttribute *rsa)
|
bool CreateSwapchainTexture(DeviceAttribute *rsa)
|
||||||
|
@ -44,7 +44,7 @@ Framebuffer *CreateFramebuffer(Device *dev,RenderPass *rp,ImageView **color_list
|
|||||||
attachments[color_count]=*depth;
|
attachments[color_count]=*depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VkExtent2D extent=dev->GetExtent();
|
const VkExtent3D extent=depth->GetExtent();
|
||||||
|
|
||||||
VkFramebufferCreateInfo fb_info;
|
VkFramebufferCreateInfo fb_info;
|
||||||
fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||||
|
@ -6,7 +6,7 @@ ImageView::~ImageView()
|
|||||||
vkDestroyImageView(device,image_view,nullptr);
|
vkDestroyImageView(device,image_view,nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,VkImageAspectFlags aspectMask,VkImage img)
|
ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,const VkExtent3D &ext,VkImageAspectFlags aspectMask,VkImage img)
|
||||||
{
|
{
|
||||||
VkImageViewCreateInfo iv_createinfo={};
|
VkImageViewCreateInfo iv_createinfo={};
|
||||||
|
|
||||||
@ -16,21 +16,32 @@ ImageView *CreateImageView(VkDevice device,VkImageViewType type,VkFormat format,
|
|||||||
iv_createinfo.image=img;
|
iv_createinfo.image=img;
|
||||||
iv_createinfo.format=format;
|
iv_createinfo.format=format;
|
||||||
iv_createinfo.viewType=type;
|
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.aspectMask=aspectMask;
|
||||||
iv_createinfo.subresourceRange.baseMipLevel=0;
|
iv_createinfo.subresourceRange.baseMipLevel=0;
|
||||||
iv_createinfo.subresourceRange.levelCount=1;
|
iv_createinfo.subresourceRange.levelCount=1;
|
||||||
iv_createinfo.subresourceRange.baseArrayLayer=0;
|
iv_createinfo.subresourceRange.baseArrayLayer=0;
|
||||||
iv_createinfo.subresourceRange.layerCount=1;
|
iv_createinfo.subresourceRange.layerCount=1;
|
||||||
|
|
||||||
|
if(aspectMask&VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||||
|
{
|
||||||
|
iv_createinfo.components.r=VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
iv_createinfo.components.g=VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
iv_createinfo.components.b=VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
iv_createinfo.components.a=VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
VkImageView img_view;
|
VkImageView img_view;
|
||||||
|
|
||||||
if(vkCreateImageView(device,&iv_createinfo,nullptr,&img_view)!=VK_SUCCESS)
|
if(vkCreateImageView(device,&iv_createinfo,nullptr,&img_view)!=VK_SUCCESS)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
return(new ImageView(device,img_view,type,format,aspectMask));
|
return(new ImageView(device,img_view,type,format,ext,aspectMask));
|
||||||
}
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -132,6 +132,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
|
|||||||
depthStencilState.back.depthFailOp = VK_STENCIL_OP_KEEP;
|
depthStencilState.back.depthFailOp = VK_STENCIL_OP_KEEP;
|
||||||
depthStencilState.back.writeMask = 0;
|
depthStencilState.back.writeMask = 0;
|
||||||
depthStencilState.front = depthStencilState.back;
|
depthStencilState.front = depthStencilState.back;
|
||||||
|
depthStencilState.front.compareOp=VK_COMPARE_OP_NEVER;
|
||||||
|
|
||||||
pipelineInfo.pDepthStencilState=&depthStencilState;
|
pipelineInfo.pDepthStencilState=&depthStencilState;
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
|
|||||||
|
|
||||||
{
|
{
|
||||||
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||||
pipelineInfo.basePipelineIndex = 0;
|
pipelineInfo.basePipelineIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
|
|||||||
|
|
||||||
{
|
{
|
||||||
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||||
pipelineInfo.basePipelineIndex = 0;
|
pipelineInfo.basePipelineIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,20 +22,20 @@ Texture2D *CreateTexture2D(VkDevice device,VkFormat format,uint32_t width,uint32
|
|||||||
{
|
{
|
||||||
TextureData *tex_data=new TextureData;
|
TextureData *tex_data=new TextureData;
|
||||||
|
|
||||||
|
tex_data->extent.width =width;
|
||||||
|
tex_data->extent.height =height;
|
||||||
|
tex_data->extent.depth =1;
|
||||||
|
|
||||||
tex_data->memory =nullptr;
|
tex_data->memory =nullptr;
|
||||||
tex_data->image =image;
|
tex_data->image =image;
|
||||||
tex_data->image_layout =image_layout;
|
tex_data->image_layout =image_layout;
|
||||||
tex_data->image_view =CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,aspectMask,image);
|
tex_data->image_view =CreateImageView(device,VK_IMAGE_VIEW_TYPE_2D,format,tex_data->extent,aspectMask,image);
|
||||||
|
|
||||||
tex_data->mip_levels =0;
|
tex_data->mip_levels =0;
|
||||||
tex_data->linear =false;
|
tex_data->linear =false;
|
||||||
tex_data->format =format;
|
tex_data->format =format;
|
||||||
tex_data->aspect =aspectMask;
|
tex_data->aspect =aspectMask;
|
||||||
|
|
||||||
tex_data->extent.width =width;
|
|
||||||
tex_data->extent.height =height;
|
|
||||||
tex_data->extent.depth =1;
|
|
||||||
|
|
||||||
return(new Texture2D(width,height,device,tex_data));
|
return(new Texture2D(width,height,device,tex_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ Texture2D *CreateTexture2D(VkDevice device,const PhysicalDevice *pd,const VkForm
|
|||||||
|
|
||||||
if(dm&&dm->BindImage(image))
|
if(dm&&dm->BindImage(image))
|
||||||
{
|
{
|
||||||
ImageView *image_view=CreateImageView2D(device,format,aspectMask,image);
|
ImageView *image_view=CreateImageView2D(device,format,imageCreateInfo.extent,aspectMask,image);
|
||||||
|
|
||||||
if(image_view)
|
if(image_view)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user