used newly Bind series function.
This commit is contained in:
parent
edbecbb86d
commit
15e80cbc5a
@ -98,17 +98,7 @@ private:
|
||||
sky_mi=db->CreateMaterialInstance(sky_material);
|
||||
if(!sky_mi)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=sky_mi->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("tex" ,texture, sampler))
|
||||
return(false);
|
||||
|
||||
mp_texture->Update();
|
||||
}
|
||||
if(!sky_mi->BindSampler(DescriptorSetsType::Value,"tex" ,texture, sampler))return(false);
|
||||
|
||||
sky_pipeline=CreatePipeline(sky_mi,InlinePipeline::Sky,Prim::Triangles);
|
||||
if(!sky_pipeline)return(false);
|
||||
@ -121,17 +111,7 @@ private:
|
||||
envmap_mi=db->CreateMaterialInstance(envmap_material);
|
||||
if(!envmap_mi)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=envmap_mi->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("EnvCubemap" ,texture, sampler))
|
||||
return(false);
|
||||
|
||||
mp_texture->Update();
|
||||
}
|
||||
if(!envmap_mi->BindSampler(DescriptorSetsType::Value,"EnvCubemap" ,texture, sampler))return(false);
|
||||
|
||||
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
}
|
||||
|
@ -166,27 +166,8 @@ private:
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
|
||||
if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
}
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("tex",tile_data->GetTexture(),sampler))return(false);
|
||||
|
||||
mp_texture->Update();
|
||||
}
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info))return(false);
|
||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",tile_data->GetTexture(),sampler))return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@ -48,29 +48,7 @@ private:
|
||||
if(!texture)
|
||||
return(false);
|
||||
|
||||
VkSamplerCreateInfo sampler_create_info=
|
||||
{
|
||||
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||
nullptr,
|
||||
0,
|
||||
VK_FILTER_LINEAR,
|
||||
VK_FILTER_LINEAR,
|
||||
VK_SAMPLER_MIPMAP_MODE_LINEAR,
|
||||
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
0.0f,
|
||||
VK_FALSE,
|
||||
0,
|
||||
false,
|
||||
VK_COMPARE_OP_NEVER,
|
||||
0.0f,
|
||||
0,
|
||||
VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK,
|
||||
false
|
||||
};
|
||||
|
||||
sampler =db->CreateSampler(&sampler_create_info);
|
||||
sampler =db->CreateSampler();
|
||||
}
|
||||
|
||||
{
|
||||
@ -80,17 +58,7 @@ private:
|
||||
envmap_mi=db->CreateMaterialInstance(envmap_material);
|
||||
if(!envmap_mi)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=envmap_mi->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("Envmap" ,texture, sampler))
|
||||
return(false);
|
||||
|
||||
mp_texture->Update();
|
||||
}
|
||||
if(!envmap_mi->BindSampler(DescriptorSetsType::Value,"Envmap" ,texture, sampler))return(false);
|
||||
|
||||
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
}
|
||||
|
@ -53,23 +53,15 @@ private:
|
||||
cam.vp_width=cam.width=extent.width;
|
||||
cam.vp_height=cam.height=extent.height;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&cam.info);
|
||||
|
||||
if(!ubo_camera_info)
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info))return(false);
|
||||
|
||||
if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -112,7 +104,7 @@ public:
|
||||
cam.vp_width=w;
|
||||
cam.vp_height=h;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info->Write(&cam.info);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
ro->cam.width=extent.width;
|
||||
ro->cam.height=extent.height;
|
||||
|
||||
ro->cam.Refresh();
|
||||
ro->cam.RefreshCameraInfo();
|
||||
|
||||
ro->ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&ro->cam.info);
|
||||
|
||||
|
@ -60,29 +60,9 @@ private:
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info))return(false);
|
||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",texture,sampler))return(false);
|
||||
|
||||
if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
}
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("tex",texture,sampler))return(false);
|
||||
|
||||
mp_texture->Update();
|
||||
}
|
||||
|
||||
db->Add(texture);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ private:
|
||||
double start_time;
|
||||
|
||||
SceneNode render_root;
|
||||
RenderList render_list;
|
||||
RenderList *render_list;
|
||||
|
||||
Material * material =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
@ -81,14 +81,11 @@ private:
|
||||
ubo_sun=device->CreateUBO(sizeof(sun_direction),&sun_direction);
|
||||
if(!ubo_sun)return(false);
|
||||
|
||||
material_instance->BindUBO("world",GetCameraMatrixBuffer());
|
||||
material_instance->BindUBO("color_material",ubo_color);
|
||||
material_instance->BindUBO("sun",ubo_sun);
|
||||
|
||||
material_instance->Update();
|
||||
|
||||
db->Add(ubo_color);
|
||||
db->Add(ubo_sun);
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -123,8 +120,7 @@ private:
|
||||
}
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
render_list.Clear();
|
||||
render_root.ExpendToList(&render_list);
|
||||
render_list->Expend(camera->info,&render_root);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -71,16 +71,8 @@ private:
|
||||
if(!ubo_sky_color)
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp)return(false);
|
||||
|
||||
if(!mp->BindUBO("sky_color",ubo_sky_color))
|
||||
return(false);
|
||||
|
||||
mp->Update();
|
||||
}
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Value,"sky_color",ubo_sky_color))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@ -67,16 +67,9 @@ private:
|
||||
|
||||
if(!ubo_camera_info)
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info))return(false);
|
||||
|
||||
mp_global->BindUBO("g_camera",ubo_camera_info);
|
||||
mp_global->Update();
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -62,23 +62,15 @@ private:
|
||||
cam.vp_width=cam.width=extent.width;
|
||||
cam.vp_height=cam.height=extent.height;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&cam.info);
|
||||
|
||||
if(!ubo_camera_info)
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info))return(false);
|
||||
|
||||
if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -121,7 +113,7 @@ public:
|
||||
cam.vp_width=w;
|
||||
cam.vp_height=h;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info->Write(&cam.info);
|
||||
|
||||
|
@ -74,16 +74,7 @@ private:
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("tex",texture,sampler))return(false);
|
||||
|
||||
mp_texture->Update();
|
||||
}
|
||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",texture,sampler))return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -95,23 +86,14 @@ private:
|
||||
cam.vp_width =cam.width =extent.width;
|
||||
cam.vp_height=cam.height=extent.height;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&cam.info);
|
||||
|
||||
if(!ubo_camera_info)
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
|
||||
if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
}
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info))return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -156,7 +138,7 @@ public:
|
||||
cam.width=w;
|
||||
cam.height=h;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info->Write(&cam.info);
|
||||
|
||||
|
@ -63,22 +63,15 @@ private:
|
||||
cam.width=extent.width;
|
||||
cam.height=extent.height;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&cam.info);
|
||||
|
||||
if(!ubo_camera_info)
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info))return(false);
|
||||
|
||||
mp_global->BindUBO("g_camera",ubo_camera_info);
|
||||
mp_global->Update();
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -134,7 +127,7 @@ public:
|
||||
cam.width=w;
|
||||
cam.height=h;
|
||||
|
||||
cam.Refresh();
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info->Write(&cam.info);
|
||||
|
||||
|
@ -27,6 +27,10 @@ public:
|
||||
const VAB *GetVAB()const{return vab;}
|
||||
MaterialParameters *GetMP(){return mp_value;}
|
||||
MaterialParameters *GetMP(const DescriptorSetsType &type);
|
||||
|
||||
bool BindUBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSampler(const DescriptorSetsType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
};//class MaterialInstance
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||
|
@ -44,4 +44,43 @@ MaterialParameters *MaterialInstance::GetMP(const DescriptorSetsType &type)
|
||||
|
||||
return material->GetMP(type);
|
||||
}
|
||||
|
||||
bool MaterialInstance::BindUBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic)
|
||||
{
|
||||
MaterialParameters *mp_global=GetMP(type);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
|
||||
if(!mp_global->BindUBO(name,ubo,dynamic))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool MaterialInstance::BindSSBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic)
|
||||
{
|
||||
MaterialParameters *mp_global=GetMP(type);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
|
||||
if(!mp_global->BindSSBO(name,ubo,dynamic))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool MaterialInstance::BindSampler(const DescriptorSetsType &type,const AnsiString &name,Texture *tex,Sampler *sampler)
|
||||
{
|
||||
MaterialParameters *mp_global=GetMP(type);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
|
||||
if(!mp_global->BindSampler(name,tex,sampler))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
return(true);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
Loading…
x
Reference in New Issue
Block a user