DescriptorSets多次update合并为一次

This commit is contained in:
2019-05-21 12:02:57 +08:00
parent 214079653e
commit 220a6798d2
6 changed files with 51 additions and 24 deletions

View File

@@ -89,7 +89,11 @@ private:
if(!ubo_mvp)
return(false);
return desciptor_sets->UpdateUBO(material->GetUBO("world"),*ubo_mvp);
if(!desciptor_sets->BindUBO(material->GetUBO("world"),*ubo_mvp))
return(false);
desciptor_sets->Update();
return(true);
}
void InitVBO()

View File

@@ -90,7 +90,11 @@ private:
if(!ubo_mvp)
return(false);
return desciptor_sets->UpdateUBO(material->GetUBO("world"),*ubo_mvp); //material中这里可以改成不区分类型返回的值包含类型和ID,这样descriptor_sets->Update也不再需要类型
if(!desciptor_sets->BindUBO(material->GetUBO("world"),*ubo_mvp))
return(false);
desciptor_sets->Update();
return(true);
}
void InitVBO()

View File

@@ -13,8 +13,8 @@ VK_NAMESPACE_BEGIN
Texture2D *LoadTGATexture(const OSString &filename,Device *device);
VK_NAMESPACE_END
constexpr uint32_t SCREEN_WIDTH=512;
constexpr uint32_t SCREEN_HEIGHT=512;
constexpr uint32_t SCREEN_WIDTH=128;
constexpr uint32_t SCREEN_HEIGHT=128;
struct WorldConfig
{
@@ -113,12 +113,10 @@ private:
sampler=device->CreateSampler(&sampler_create_info);
VkDescriptorImageInfo image_info;
image_info.imageView =*texture;
image_info.imageLayout =*texture;
image_info.sampler =*sampler;
desciptor_sets->BindSampler(material->GetSampler("texture_lena"),texture,sampler);
desciptor_sets->BindUBO(material->GetUBO("world"),*ubo_mvp);
desciptor_sets->Update();
desciptor_sets->UpdateSampler(material->GetSampler("texture_lena"),&image_info);
return(true);
}
@@ -130,10 +128,7 @@ private:
ubo_mvp=device->CreateUBO(sizeof(WorldConfig),&world);
if(!ubo_mvp)
return(false);
return desciptor_sets->UpdateUBO(material->GetUBO("world"),*ubo_mvp);
return ubo_mvp;
}
void InitVBO()
@@ -197,10 +192,10 @@ public:
swap_chain_count=device->GetSwapChainImageCount();
if(!InitMaterial())
if(!InitUBO())
return(false);
if(!InitUBO())
if(!InitMaterial())
return(false);
InitVBO();