Merge branch 'devel_23_instance' of https://github.com/hyzboy/ULRE into devel_23_instance
This commit is contained in:
commit
ef7068be08
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit 6c2f5b255c0c04e20531e2fc8ac7843df264fa5b
|
||||
Subproject commit bfed461c84e7b780a3ab7a86d2c45e27b247f29f
|
@ -109,12 +109,12 @@ private:
|
||||
|
||||
rb_config.Color.Set(1,1,1,1);
|
||||
rb_config.OutColor.Set(0,0,0,0);
|
||||
rb_config.InColor.Use(COLOR::MozillaOrange,1.0);
|
||||
rb_config.InColor=GetColor4f(COLOR::MozillaOrange,1.0);
|
||||
rb_config.Radius[0]=0;
|
||||
rb_config.Radius[1]=16;
|
||||
rb_config.Radius[2]=0;
|
||||
rb_config.Radius[3]=16;
|
||||
rb_config.LineWidth=1.5;
|
||||
rb_config.LineWidth=2;
|
||||
|
||||
ubo_rb_config =db->CreateUBO(sizeof(RoundedBoxConfig), &rb_config);
|
||||
|
||||
|
@ -17,7 +17,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
struct
|
||||
{
|
||||
Color4f color;
|
||||
Color4f diffuse; //虽然shader中写vec3,但这里依然用Color4f
|
||||
Color4f abiment;
|
||||
}color_material;
|
||||
|
||||
@ -46,15 +46,17 @@ public:
|
||||
{
|
||||
start_time=GetDoubleTime();
|
||||
}
|
||||
|
||||
~TestApp()=default;
|
||||
|
||||
~TestApp()
|
||||
{
|
||||
SAFE_CLEAR(render_list);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material=db->CreateMaterial(OS_TEXT("res/shader/VertexLight.vert"),
|
||||
OS_TEXT("res/shader/VertexColor.frag"));
|
||||
material=db->CreateMaterial(OS_TEXT("res/material/SimplestDirectionLight"));
|
||||
if(!material)
|
||||
return(false);
|
||||
|
||||
@ -70,21 +72,29 @@ private:
|
||||
|
||||
bool InitUBO()
|
||||
{
|
||||
color_material.color.Set(1,1,1,1);
|
||||
color_material.abiment.Set(0.25,0.25,0.25,1.0);
|
||||
color_material.diffuse.Set(1,1,1);
|
||||
color_material.abiment.Set(0.25,0.25,0.25);
|
||||
|
||||
ubo_color=device->CreateUBO(sizeof(color_material),&color_material);
|
||||
ubo_color=db->CreateUBO(sizeof(color_material),&color_material);
|
||||
if(!ubo_color)return(false);
|
||||
|
||||
sun_direction=normalized(Vector3f(rand(),rand(),rand()));
|
||||
|
||||
ubo_sun=device->CreateUBO(sizeof(sun_direction),&sun_direction);
|
||||
ubo_sun=db->CreateUBO(sizeof(sun_direction),&sun_direction);
|
||||
if(!ubo_sun)return(false);
|
||||
|
||||
material_instance->BindUBO("color_material",ubo_color);
|
||||
material_instance->BindUBO("sun",ubo_sun);
|
||||
{
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
material_instance->Update();
|
||||
if(!mp)return(false);
|
||||
|
||||
mp->BindUBO("material",ubo_color);
|
||||
mp->BindUBO("sun",ubo_sun);
|
||||
|
||||
mp->Update();
|
||||
}
|
||||
|
||||
BindCameraUBO(material_instance);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -103,7 +113,7 @@ private:
|
||||
uint count;
|
||||
float size;
|
||||
|
||||
RenderableInstance *ri=db->CreateRenderableInstance(pipeline,material_instance,renderable_object);
|
||||
RenderableInstance *ri=db->CreateRenderableInstance(renderable_object,material_instance,pipeline);
|
||||
|
||||
for(uint i=0;i<360;i++)
|
||||
{
|
||||
@ -131,6 +141,8 @@ public:
|
||||
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
return(false);
|
||||
|
||||
render_list=new RenderList(device);
|
||||
|
||||
if(!InitMaterial())
|
||||
return(false);
|
||||
|
||||
@ -152,16 +164,15 @@ public:
|
||||
{
|
||||
CameraAppFramework::Draw();
|
||||
|
||||
Matrix4f rot=rotate(GetDoubleTime()-start_time,camera.up_vector);
|
||||
Matrix4f rot=rotate(GetDoubleTime()-start_time,camera->world_up);
|
||||
|
||||
render_root.RefreshMatrix(&rot);
|
||||
render_list.Clear();
|
||||
render_root.ExpendToList(&render_list);
|
||||
render_list->Expend(GetCameraInfo(),&render_root);
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(uint32 index)
|
||||
{
|
||||
VulkanApplicationFramework::BuildCommandBuffer(index,&render_list);
|
||||
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
||||
}
|
||||
};//class TestApp:public CameraAppFramework
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
bool BindSSBO (const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
|
||||
bool BindSampler(const int binding,Texture *,Sampler *);
|
||||
bool BindInputAttachment(const int binding,Texture *);
|
||||
bool BindInputAttachment(const int binding,ImageView *);
|
||||
void Update();
|
||||
};//class DescriptorSets
|
||||
VK_NAMESPACE_END
|
||||
|
@ -29,10 +29,10 @@ public:
|
||||
|
||||
virtual ~ImageView();
|
||||
|
||||
operator VkImageView(){return image_view;}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
VkImageView GetImageView () {return image_view;}
|
||||
const VkImageViewType GetViewType ()const{return ivci->viewType;}
|
||||
const VkFormat GetFormat ()const{return ivci->format;}
|
||||
const VkExtent3D & GetExtent ()const{return extent;}
|
||||
|
@ -47,7 +47,8 @@ public:
|
||||
|
||||
const int GetUBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,name);}
|
||||
const int GetSSBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,name);}
|
||||
const int GetSampler (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, name);}
|
||||
const int GetSampler (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,name);}
|
||||
const int GetAttachment (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,name);}
|
||||
|
||||
const DescriptorSetLayoutCreateInfo *GetBinding(const DescriptorSetsType &type)const{return sds+size_t(type);}
|
||||
};//class MaterialDescriptorSets
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
bool BindUBO(const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSampler(const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
bool BindInputAttachment(const AnsiString &name,ImageView *);
|
||||
|
||||
void Update();
|
||||
};//class MaterialParameters
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
VkDeviceMemory GetDeviceMemory () {return data?data->memory->operator VkDeviceMemory():VK_NULL_HANDLE;}
|
||||
VkImage GetImage () {return data?data->image:VK_NULL_HANDLE;}
|
||||
VkImageLayout GetImageLayout () {return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;}
|
||||
VkImageView GetVulkanImageView () {return data?data->image_view->operator VkImageView():VK_NULL_HANDLE;}
|
||||
VkImageView GetVulkanImageView () {return data?data->image_view->GetImageView():VK_NULL_HANDLE;}
|
||||
|
||||
GPUMemory * GetMemory () {return data?data->memory:nullptr;}
|
||||
ImageView * GetImageView () {return data?data->image_view:nullptr;}
|
||||
|
2
res
2
res
@ -1 +1 @@
|
||||
Subproject commit fd0bd99c873a376121eb534b99fe7fbfb24c2fd2
|
||||
Subproject commit 70b697f13ef20e957d51efcb0ff8632f4615e3c0
|
@ -57,6 +57,13 @@ namespace
|
||||
imageView=tex->GetVulkanImageView();
|
||||
imageLayout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
}
|
||||
|
||||
DescriptorImageInfo(VkImageView iv)
|
||||
{
|
||||
sampler=VK_NULL_HANDLE;
|
||||
imageView=iv;
|
||||
imageLayout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
}
|
||||
};//struct DescriptorImageInfo:public VkDescriptorImageInfo
|
||||
}//namespace
|
||||
|
||||
@ -159,14 +166,14 @@ bool DescriptorSets::BindSampler(const int binding,Texture *tex,Sampler *sampler
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool DescriptorSets::BindInputAttachment(const int binding,Texture *tex)
|
||||
bool DescriptorSets::BindInputAttachment(const int binding,ImageView *iv)
|
||||
{
|
||||
if(binding<0||!tex)
|
||||
if(binding<0||!iv)
|
||||
return(false);
|
||||
|
||||
if(binded_sets.IsMember(binding))return(false);
|
||||
|
||||
DescriptorImageInfo *image_info=new DescriptorImageInfo(tex,nullptr);
|
||||
DescriptorImageInfo *image_info=new DescriptorImageInfo(iv->GetImageView());
|
||||
|
||||
image_list.Add(image_info);
|
||||
|
||||
|
@ -41,7 +41,7 @@ Framebuffer *GPUDevice::CreateFramebuffer(RenderPass *rp,ImageView **color_list,
|
||||
if(*cf!=(*iv)->GetFormat())
|
||||
return(nullptr);
|
||||
|
||||
*ap=**iv;
|
||||
*ap=(*iv)->GetImageView();
|
||||
|
||||
++ap;
|
||||
++cf;
|
||||
@ -59,7 +59,7 @@ Framebuffer *GPUDevice::CreateFramebuffer(RenderPass *rp,ImageView **color_list,
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
attachments[color_count]=*depth;
|
||||
attachments[color_count]=depth->GetImageView();
|
||||
|
||||
extent.width=depth->GetExtent().width;
|
||||
extent.height=depth->GetExtent().height;
|
||||
|
@ -64,6 +64,22 @@ bool MaterialParameters::BindSampler(const AnsiString &name,Texture *tex,Sampler
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool MaterialParameters::BindInputAttachment(const AnsiString &name,ImageView *iv)
|
||||
{
|
||||
if(name.IsEmpty()||!iv)
|
||||
return(false);
|
||||
|
||||
const int index=mds->GetAttachment(name);
|
||||
|
||||
if(index<0)
|
||||
return(false);
|
||||
|
||||
if(!descriptor_sets->BindInputAttachment(index,iv))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void MaterialParameters::Update()
|
||||
{
|
||||
descriptor_sets->Update();
|
||||
|
Loading…
x
Reference in New Issue
Block a user