diff --git a/example/Vulkan/TGATexture.cpp b/example/Vulkan/TGATexture.cpp index fcb21eb0..42f2c8a8 100644 --- a/example/Vulkan/TGATexture.cpp +++ b/example/Vulkan/TGATexture.cpp @@ -1,6 +1,7 @@ #include #include #include +#include VK_NAMESPACE_BEGIN namespace @@ -54,6 +55,25 @@ namespace src+=3; } } + + void SwapRow(uint8 *data,uint line_size,uint height) + { + uint8 *top=data; + uint8 *bottom=data+(height-1)*line_size; + uint8 *tmp=new uint8[line_size]; + + while(top failed."< failed.")); return(nullptr); } TGAHeader *header=(TGAHeader *)data; + TGAImageDesc image_desc; + uint8 *pixel_data=data+sizeof(TGAHeader); + + image_desc.image_desc=header->image_desc; VkFormat format; - uint pixels_size=0; + uint line_size; if(header->image_type==2) { if(header->bit==24) { - RGB8to565(data+sizeof(TGAHeader),header->width*header->height); + RGB8to565(pixel_data,header->width*header->height); - format=FMT_RGB565; - pixels_size=header->width*header->height*2; + format=FMT_BGR565; + line_size=header->width*2; } else if(header->bit==32) { format=FMT_RGBA8UN; - pixels_size=header->width*header->height*4; + line_size=header->width*4; } } else if(header->image_type==3&&header->bit==8) { format=FMT_R8UN; - pixels_size=header->width*header->height; + line_size=header->width; } else { - std::cerr<<"[ERROR] Image format error,filename: "<CreateTexture2D(format,data+sizeof(TGAHeader),header->width,header->height,pixels_size); + if(image_desc.direction==0) + SwapRow(pixel_data,line_size,header->height); + + Texture2D *tex=device->CreateTexture2D(format,pixel_data,header->width,header->height,line_size*header->height); if(tex) { - std::cout<<"load image file<"<:<"<width<<"x"<height<<"> to texture ok"<:<")+OSString(header->width)+OS_TEXT("x")+OSString(header->height)+OS_TEXT("> to texture ok")); } else { - std::cout<<"load image file<"<:<"<width<<"x"<height<<"> to texture failed."<:<")+OSString(header->width)+OS_TEXT("x")+OSString(header->height)+OS_TEXT("> to texture failed.")); } delete[] data; return(tex); } - -//GLuint CreateSamplerObject(GLint min_filter,GLint mag_filter,GLint clamp,const GLfloat *border_color) -//{ -// GLuint sampler_object; - -// glGenSamplers(1,&sampler_object); - -// glSamplerParameteri(sampler_object,GL_TEXTURE_MIN_FILTER,min_filter); -// glSamplerParameteri(sampler_object,GL_TEXTURE_MAG_FILTER,mag_filter); -// glSamplerParameteri(sampler_object,GL_TEXTURE_WRAP_S,clamp); -// glSamplerParameteri(sampler_object,GL_TEXTURE_WRAP_T,clamp); - -// glSamplerParameterfv(sampler_object,GL_TEXTURE_BORDER_COLOR,border_color); - -// return(sampler_object); -//} VK_NAMESPACE_END \ No newline at end of file diff --git a/example/Vulkan/texture_rect.cpp b/example/Vulkan/texture_rect.cpp index 43831224..413cc521 100644 --- a/example/Vulkan/texture_rect.cpp +++ b/example/Vulkan/texture_rect.cpp @@ -3,6 +3,7 @@ #include"VulkanAppFramework.h" #include +#include #include using namespace hgl; @@ -24,10 +25,18 @@ constexpr uint32_t VERTEX_COUNT=4; constexpr float vertex_data[VERTEX_COUNT][2]= { - {SCREEN_WIDTH*0.25, SCREEN_HEIGHT*0.25}, - {SCREEN_WIDTH*0.75, SCREEN_HEIGHT*0.25}, - {SCREEN_WIDTH*0.25, SCREEN_HEIGHT*0.75}, - {SCREEN_WIDTH*0.75, SCREEN_HEIGHT*0.75} + {0, 0}, + {SCREEN_WIDTH, 0}, + {0, SCREEN_HEIGHT}, + {SCREEN_WIDTH, SCREEN_HEIGHT} +}; + +constexpr float tex_coord_data[VERTEX_COUNT][2]= +{ + {0,0}, + {1,0}, + {0,1}, + {1,1} }; constexpr uint32_t INDEX_COUNT=6; @@ -46,6 +55,7 @@ private: vulkan::Material * material =nullptr; vulkan::Texture2D * texture =nullptr; + vulkan::Sampler * sampler =nullptr; vulkan::DescriptorSets * desciptor_sets =nullptr; vulkan::Renderable * render_obj =nullptr; vulkan::Buffer * ubo_mvp =nullptr; @@ -54,6 +64,7 @@ private: vulkan::CommandBuffer ** cmd_buf =nullptr; vulkan::VertexBuffer * vertex_buffer =nullptr; + vulkan::VertexBuffer * tex_coord_buffer =nullptr; vulkan::IndexBuffer * index_buffer =nullptr; public: @@ -61,12 +72,14 @@ public: ~TestApp() { SAFE_CLEAR(index_buffer); + SAFE_CLEAR(tex_coord_buffer); SAFE_CLEAR(vertex_buffer); SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count); SAFE_CLEAR(pipeline); SAFE_CLEAR(ubo_mvp); SAFE_CLEAR(render_obj); SAFE_CLEAR(desciptor_sets); + SAFE_CLEAR(sampler); SAFE_CLEAR(texture); SAFE_CLEAR(material); } @@ -75,8 +88,8 @@ private: bool InitMaterial() { - material=shader_manage->CreateMaterial(OS_TEXT("OnlyPosition.vert.spv"), - OS_TEXT("FlatColor.frag.spv")); + material=shader_manage->CreateMaterial(OS_TEXT("FlatTexture.vert.spv"), + OS_TEXT("FlatTexture.frag.spv")); if(!material) return(false); @@ -84,6 +97,28 @@ private: desciptor_sets=material->CreateDescriptorSets(); texture=vulkan::LoadTGATexture(OS_TEXT("lena.tga"),device); + + VkSamplerCreateInfo sampler_create_info{}; + + sampler_create_info.magFilter = VK_FILTER_LINEAR; + sampler_create_info.minFilter = VK_FILTER_LINEAR; + sampler_create_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; + sampler_create_info.addressModeU= VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + sampler_create_info.addressModeV= VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + sampler_create_info.addressModeW= VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + sampler_create_info.mipLodBias = 0.0f; + sampler_create_info.compareOp = VK_COMPARE_OP_NEVER; + sampler_create_info.minLod = 0.0f; + sampler_create_info.maxLod = 1.0f; + + sampler=device->CreateSampler(&sampler_create_info); + + VkDescriptorImageInfo image_info; + image_info.imageView =*texture; + image_info.imageLayout =*texture; + image_info.sampler =*sampler; + + desciptor_sets->UpdateSampler(material->GetCombindImageSampler("texture_lena"),&image_info); return(true); } @@ -104,9 +139,11 @@ private: void InitVBO() { vertex_buffer =device->CreateVBO(FMT_RG32F,VERTEX_COUNT,vertex_data); + tex_coord_buffer=device->CreateVBO(FMT_RG32F,VERTEX_COUNT,tex_coord_data); index_buffer =device->CreateIBO16(INDEX_COUNT,index_data); render_obj->Set("Vertex",vertex_buffer); + render_obj->Set("TexCoord",tex_coord_buffer); render_obj->Set(index_buffer); } diff --git a/inc/hgl/graph/vulkan/VKCommandBuffer.h b/inc/hgl/graph/vulkan/VKCommandBuffer.h index 27a30ed0..7a4a42d3 100644 --- a/inc/hgl/graph/vulkan/VKCommandBuffer.h +++ b/inc/hgl/graph/vulkan/VKCommandBuffer.h @@ -67,7 +67,7 @@ public: bool BeginRenderPass(RenderPass *rp,Framebuffer *fb); bool Bind(Pipeline *p); - bool Bind(DescriptorSets *,int first=0,int count=0); + bool Bind(DescriptorSets *); bool Bind(Renderable *); void EndRenderPass(); bool End(); diff --git a/inc/hgl/graph/vulkan/VKDescriptorSets.h b/inc/hgl/graph/vulkan/VKDescriptorSets.h index 605d5a7f..33afa5f2 100644 --- a/inc/hgl/graph/vulkan/VKDescriptorSets.h +++ b/inc/hgl/graph/vulkan/VKDescriptorSets.h @@ -10,7 +10,7 @@ class DescriptorSets { Device *device; int count; - VkDescriptorSet *desc_set_list; + VkDescriptorSet desc_set; const Map *index_by_binding; VkPipelineLayout pipeline_layout; @@ -19,31 +19,27 @@ private: friend class DescriptorSetLayoutCreater; - DescriptorSets(Device *dev,const int c,VkPipelineLayout pl,VkDescriptorSet *desc_set,const Map *bi):index_by_binding(bi) + DescriptorSets(Device *dev,const int c,VkPipelineLayout pl,VkDescriptorSet ds,const Map *bi):index_by_binding(bi) { device=dev; count=c; - desc_set_list=desc_set; + desc_set=ds; pipeline_layout=pl; } public: - ~DescriptorSets(); + ~DescriptorSets()=default; const uint32_t GetCount ()const{return count;} - const VkDescriptorSet * GetDescriptorSets ()const{return desc_set_list;} - VkDescriptorSet GetDescriptorSet (const uint32_t binding)const; + const VkDescriptorSet * GetDescriptorSets ()const{return &desc_set;} const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;} - bool UpdateUBO(const uint32_t binding,const VkDescriptorBufferInfo *buf_info); - //bool UpdateUBO(const UTF8String &name,const VkDescriptorBufferInfo *buf_info) - //{ - // if(name.IsEmpty()||!buf_info) - // return(false); + //未来统合所有的write descriptor sets,这里的update改为只是添加记录 + //最终bind到cmd时一次性写入。 - // return UpdateUBO(GetUBOBinding(name),buf_info); - //} + bool UpdateUBO(const uint32_t binding,const VkDescriptorBufferInfo *); + bool UpdateSampler(const uint32_t binding,const VkDescriptorImageInfo *); };//class DescriptorSets VK_NAMESPACE_END #endif//HGL_GRAPH_VULKAN_DESCRIPTOR_SETS_LAYOUT_INCLUDE diff --git a/inc/hgl/graph/vulkan/VKTexture.h b/inc/hgl/graph/vulkan/VKTexture.h index 3e9847db..270a3140 100644 --- a/inc/hgl/graph/vulkan/VKTexture.h +++ b/inc/hgl/graph/vulkan/VKTexture.h @@ -2,9 +2,11 @@ #define HGL_GRAPH_VULKAN_TEXTURE_INCLUDE #include +#include VK_NAMESPACE_BEGIN struct TextureData { + VkDeviceMemory memory; VkImage image; VkImageLayout image_layout; ImageView *image_view; @@ -23,7 +25,7 @@ public: operator VkImage (){return data?data->image:nullptr;} operator VkImageLayout (){return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;} - operator ImageView * (){return data?data->image_view:nullptr;} + operator VkImageView (){return data?data->image_view->operator VkImageView():nullptr;} const uint32 GetMipLevels()const{return data?data->mip_levels:0;} const bool IsLinear ()const{return data?data->linear:false;} diff --git a/res/shader/FlatTexture.frag b/res/shader/FlatTexture.frag new file mode 100644 index 00000000..18735663 --- /dev/null +++ b/res/shader/FlatTexture.frag @@ -0,0 +1,11 @@ +#version 450 core + +layout(binding = 2) uniform sampler2D texture_lena; + +layout(location = 0) in vec2 FragmentTexCoord; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor=texture(texture_lena,FragmentTexCoord); +} diff --git a/res/shader/FlatTexture.vert b/res/shader/FlatTexture.vert new file mode 100644 index 00000000..38c51763 --- /dev/null +++ b/res/shader/FlatTexture.vert @@ -0,0 +1,18 @@ +#version 450 core + +layout(location = 0) in vec2 Vertex; +layout(location = 1) in vec2 TexCoord; + +layout(binding = 0) uniform WorldConfig +{ + mat4 mvp; +} world; + +layout(location = 0) out vec2 FragmentTexCoord; + +void main() +{ + FragmentTexCoord=TexCoord; + + gl_Position=vec4(Vertex,0.0,1.0)*world.mvp; +} diff --git a/res/shader/shader_compile.sh b/res/shader/shader_compile.sh index f7a4814a..68909989 100755 --- a/res/shader/shader_compile.sh +++ b/res/shader/shader_compile.sh @@ -1,3 +1,6 @@ glslangValidator -V -o FlatColor.vert.spv FlatColor.vert glslangValidator -V -o OnlyPosition.vert.spv OnlyPosition.vert glslangValidator -V -o FlatColor.frag.spv FlatColor.frag + +glslangValidator -V -o FlatTexture.vert.spv FlatTexture.vert +glslangValidator -V -o FlatTexture.frag.spv FlatTexture.frag diff --git a/src/RenderDevice/Vulkan/VKCommandBuffer.cpp b/src/RenderDevice/Vulkan/VKCommandBuffer.cpp index 99b26368..6c451344 100644 --- a/src/RenderDevice/Vulkan/VKCommandBuffer.cpp +++ b/src/RenderDevice/Vulkan/VKCommandBuffer.cpp @@ -80,19 +80,12 @@ bool CommandBuffer::Bind(Pipeline *p) return(true); } -bool CommandBuffer::Bind(DescriptorSets *dsl,int first,int count) +bool CommandBuffer::Bind(DescriptorSets *dsl) { if(!dsl) return(false); - if(first<0) - first=0; - - if(count==0||first+count>dsl->GetCount()) - count=dsl->GetCount()-first; - - if(count>0) - vkCmdBindDescriptorSets(cmd_buf,VK_PIPELINE_BIND_POINT_GRAPHICS,dsl->GetPipelineLayout(),first,count,dsl->GetDescriptorSets(),0,nullptr); + vkCmdBindDescriptorSets(cmd_buf,VK_PIPELINE_BIND_POINT_GRAPHICS,dsl->GetPipelineLayout(),0,1,dsl->GetDescriptorSets(),0,nullptr); return(true); } diff --git a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp index df6ce4fc..4cdac091 100644 --- a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp +++ b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.cpp @@ -3,31 +3,13 @@ #include VK_NAMESPACE_BEGIN -namespace -{ - void DestroyDescriptorSetLayout(VkDevice device,const int count,VkDescriptorSetLayout *dsl_list) - { - if(count<=0) - return; - - for(int i=0;iGetDescriptorPool(); - alloc_info.descriptorSetCount = count; - alloc_info.pSetLayouts = dsl_list; + alloc_info.descriptorSetCount = 1; + alloc_info.pSetLayouts = &dsl; - VkDescriptorSet *desc_set=new VkDescriptorSet[count]; + VkDescriptorSet desc_set; - if(vkAllocateDescriptorSets(*device,&alloc_info,desc_set)!=VK_SUCCESS) - { - delete[] desc_set; + if(vkAllocateDescriptorSets(*device,&alloc_info,&desc_set)!=VK_SUCCESS) return(nullptr); - } return(new DescriptorSets(device,count,pipeline_layout,desc_set,&index_by_binding)); } diff --git a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h index af472986..67a61e25 100644 --- a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h +++ b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h @@ -13,7 +13,7 @@ class DescriptorSetLayoutCreater Device *device; List layout_binding_list; - VkDescriptorSetLayout *dsl_list=nullptr; + VkDescriptorSetLayout dsl=nullptr; Map index_by_binding; VkPipelineLayout pipeline_layout=nullptr; @@ -25,11 +25,14 @@ public: void Bind(const uint32_t binding,VkDescriptorType,VkShaderStageFlagBits); void Bind(const uint32_t *binding,const uint32_t count,VkDescriptorType type,VkShaderStageFlagBits stage); - void Bind(const ShaderResourceList &srl,VkDescriptorType type,VkShaderStageFlagBits stage){Bind(srl.binding_list.GetData(),srl.binding_list.GetCount(),type,stage);} + void Bind(const ShaderResourceList &srl,VkDescriptorType type,VkShaderStageFlagBits stage){if(srl.binding_list.GetCount()>0)Bind(srl.binding_list.GetData(),srl.binding_list.GetCount(),type,stage);} void Bind(const ShaderResource &sr,VkShaderStageFlagBits stage) { for(uint32_t i=VK_DESCRIPTOR_TYPE_BEGIN_RANGE;i<=VK_DESCRIPTOR_TYPE_END_RANGE;i++) - Bind(sr[i],(VkDescriptorType)i,stage); + { + if(sr[i].binding_list.GetCount()>0) + Bind(sr[i],(VkDescriptorType)i,stage); + } } //以下代码不再需要,使用一个void Bind(const ShaderResource &sr,VkShaderStageFlagBits stage)即可全部替代,而且更方便,但以此为提示 diff --git a/src/RenderDevice/Vulkan/VKDescriptorSets.cpp b/src/RenderDevice/Vulkan/VKDescriptorSets.cpp index 6c0dff51..ddd330b2 100644 --- a/src/RenderDevice/Vulkan/VKDescriptorSets.cpp +++ b/src/RenderDevice/Vulkan/VKDescriptorSets.cpp @@ -2,32 +2,12 @@ #include VK_NAMESPACE_BEGIN -VkDescriptorSet DescriptorSets::GetDescriptorSet(const uint32_t binding)const -{ - int index; - - if(!index_by_binding->Get(binding,index)) - return(nullptr); - - return desc_set_list[index]; -} - -DescriptorSets::~DescriptorSets() -{ - //if(count>0) - // vkFreeDescriptorSets(device->GetDevice(),device->GetDescriptorPool(),count,desc_set_list); - - delete[] desc_set_list; -} - bool DescriptorSets::UpdateUBO(const uint32_t binding,const VkDescriptorBufferInfo *buf_info) { - VkDescriptorSet set=GetDescriptorSet(binding); - VkWriteDescriptorSet writeDescriptorSet = {}; writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - writeDescriptorSet.dstSet = set; + writeDescriptorSet.dstSet = desc_set; writeDescriptorSet.descriptorCount = 1; writeDescriptorSet.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; writeDescriptorSet.pBufferInfo = buf_info; @@ -36,4 +16,19 @@ bool DescriptorSets::UpdateUBO(const uint32_t binding,const VkDescriptorBufferIn vkUpdateDescriptorSets(*device,1,&writeDescriptorSet,0,nullptr); return(true); } + +bool DescriptorSets::UpdateSampler(const uint32_t binding,const VkDescriptorImageInfo *image_info) +{ + VkWriteDescriptorSet writeDescriptorSet = {}; + + writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; + writeDescriptorSet.dstSet = desc_set; + writeDescriptorSet.descriptorCount = 1; + writeDescriptorSet.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + writeDescriptorSet.pImageInfo = image_info; + writeDescriptorSet.dstBinding = binding; + + vkUpdateDescriptorSets(*device,1,&writeDescriptorSet,0,nullptr); + return(true); +} VK_NAMESPACE_END diff --git a/src/RenderDevice/Vulkan/VKDeviceCreater.cpp b/src/RenderDevice/Vulkan/VKDeviceCreater.cpp index 2b14425f..70fd753b 100644 --- a/src/RenderDevice/Vulkan/VKDeviceCreater.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceCreater.cpp @@ -242,21 +242,18 @@ namespace VkDescriptorPool CreateDescriptorPool(VkDevice device,int sets_count) { - constexpr size_t DESC_POOL_COUNT=1; + VkDescriptorPoolSize pool_size[2]; - VkDescriptorPoolSize pool_size[DESC_POOL_COUNT]; - - for(size_t i=0;idesc_pool=CreateDescriptorPool(attr->device,1); + attr->desc_pool=CreateDescriptorPool(attr->device,1024); if(!attr->desc_pool) return(nullptr); diff --git a/src/RenderDevice/Vulkan/VKDeviceTexture.cpp b/src/RenderDevice/Vulkan/VKDeviceTexture.cpp index 3cd1d29f..ab3b0387 100644 --- a/src/RenderDevice/Vulkan/VKDeviceTexture.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceTexture.cpp @@ -47,6 +47,7 @@ Texture2D *Device::CreateTexture2D(const VkFormat video_format,void *data,uint32 TextureData *tex_data=new TextureData(); + tex_data->memory=nullptr; tex_data->image=nullptr; tex_data->image_view=nullptr; @@ -76,8 +77,6 @@ Texture2D *Device::CreateTexture2D(const VkFormat video_format,void *data,uint32 tex_data->image_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - VkDeviceMemory device_memory; - VkImageCreateInfo imageCreateInfo{}; imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; imageCreateInfo.imageType = VK_IMAGE_TYPE_2D; @@ -101,8 +100,8 @@ Texture2D *Device::CreateTexture2D(const VkFormat video_format,void *data,uint32 vkGetImageMemoryRequirements(attr->device, tex_data->image, &memReqs); memAllocInfo.allocationSize = memReqs.size; attr->CheckMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,&memAllocInfo.memoryTypeIndex); - VK_CHECK_RESULT(vkAllocateMemory(attr->device, &memAllocInfo, nullptr, &device_memory)) - VK_CHECK_RESULT(vkBindImageMemory(attr->device, tex_data->image, device_memory, 0)) + VK_CHECK_RESULT(vkAllocateMemory(attr->device, &memAllocInfo, nullptr, &tex_data->memory)) + VK_CHECK_RESULT(vkBindImageMemory(attr->device, tex_data->image, tex_data->memory, 0)) CommandBuffer *cmd_buf=CreateCommandBuffer(); @@ -188,12 +187,14 @@ Sampler *Device::CreateSampler(VkSamplerCreateInfo *sci) VkSampler sampler; - if(attr->physical_device->features.samplerAnisotropy) - { - sci->maxAnisotropy = attr->physical_device->properties.limits.maxSamplerAnisotropy; - sci->anisotropyEnable = VK_TRUE; - } - else + sci->sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; + + //if(attr->physical_device->features.samplerAnisotropy) //不知道为什么不准,先全部禁用吧 + //{ + // sci->maxAnisotropy = attr->physical_device->properties.limits.maxSamplerAnisotropy; + // sci->anisotropyEnable = VK_TRUE; + //} + //else { sci->maxAnisotropy = 1.0; sci->anisotropyEnable = VK_FALSE; diff --git a/src/RenderDevice/Vulkan/VKShaderModule.cpp b/src/RenderDevice/Vulkan/VKShaderModule.cpp index de2f03e0..1e5bdcc5 100644 --- a/src/RenderDevice/Vulkan/VKShaderModule.cpp +++ b/src/RenderDevice/Vulkan/VKShaderModule.cpp @@ -28,7 +28,7 @@ ShaderModule::ShaderModule(VkDevice dev,int id,VkPipelineShaderStageCreateInfo * EnumShaderResource(sp,resource[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER],sp->GetUBO()); EnumShaderResource(sp,resource[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER],sp->GetSSBO()); - EnumShaderResource(sp,resource[VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE],sp->GetSampler()); + EnumShaderResource(sp,resource[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER],sp->GetSampler()); } ShaderModule::~ShaderModule() diff --git a/src/RenderDevice/Vulkan/VKTexture.cpp b/src/RenderDevice/Vulkan/VKTexture.cpp index b0722856..c9d937c6 100644 --- a/src/RenderDevice/Vulkan/VKTexture.cpp +++ b/src/RenderDevice/Vulkan/VKTexture.cpp @@ -10,5 +10,8 @@ Texture::~Texture() if(data->image) vkDestroyImage(device,data->image,nullptr); + + if(data->memory) + vkFreeMemory(device,data->memory,nullptr); } VK_NAMESPACE_END