change values name.

This commit is contained in:
hyzboy 2020-07-14 20:42:01 +08:00
parent 6b943e8210
commit b041fb5c14
8 changed files with 46 additions and 56 deletions

View File

@ -28,7 +28,7 @@ private:
vulkan::Sampler * sampler =nullptr; vulkan::Sampler * sampler =nullptr;
vulkan::MaterialInstance * material_instance =nullptr; vulkan::MaterialInstance * material_instance =nullptr;
vulkan::Renderable * render_obj =nullptr; vulkan::Renderable * render_obj =nullptr;
vulkan::Buffer * ubo_mvp =nullptr; vulkan::Buffer * ubo_world_matrix =nullptr;
vulkan::Pipeline * pipeline =nullptr; vulkan::Pipeline * pipeline =nullptr;
@ -53,7 +53,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
material_instance->BindSampler("tex",texture,sampler); material_instance->BindSampler("tex",texture,sampler);
material_instance->BindUBO("world",ubo_mvp); material_instance->BindUBO("world",ubo_world_matrix);
material_instance->Update(); material_instance->Update();
db->Add(material); db->Add(material);
@ -72,9 +72,9 @@ private:
cam.Refresh(); cam.Refresh();
ubo_mvp=db->CreateUBO(sizeof(WorldMatrix),&cam.matrix); ubo_world_matrix=db->CreateUBO(sizeof(WorldMatrix),&cam.matrix);
if(!ubo_mvp) if(!ubo_world_matrix)
return(false); return(false);
return(true); return(true);
@ -132,7 +132,7 @@ public:
cam.Refresh(); cam.Refresh();
ubo_mvp->Write(&cam.matrix); ubo_world_matrix->Write(&cam.matrix);
BuildCommandBuffer(pipeline,material_instance,render_obj); BuildCommandBuffer(pipeline,material_instance,render_obj);
} }

View File

@ -32,7 +32,7 @@ private:
vulkan::Material * material =nullptr; vulkan::Material * material =nullptr;
vulkan::MaterialInstance * material_instance =nullptr; vulkan::MaterialInstance * material_instance =nullptr;
vulkan::Renderable * render_obj =nullptr; vulkan::Renderable * render_obj =nullptr;
vulkan::Buffer * ubo_mvp =nullptr; vulkan::Buffer * ubo_world_matrix =nullptr;
vulkan::Pipeline * pipeline =nullptr; vulkan::Pipeline * pipeline =nullptr;
@ -44,7 +44,7 @@ public:
{ {
SAFE_CLEAR(vertex_buffer); SAFE_CLEAR(vertex_buffer);
SAFE_CLEAR(pipeline); SAFE_CLEAR(pipeline);
SAFE_CLEAR(ubo_mvp); SAFE_CLEAR(ubo_world_matrix);
SAFE_CLEAR(render_obj); SAFE_CLEAR(render_obj);
SAFE_CLEAR(material_instance); SAFE_CLEAR(material_instance);
SAFE_CLEAR(material); SAFE_CLEAR(material);
@ -73,13 +73,13 @@ private:
cam.Refresh(); cam.Refresh();
ubo_mvp=device->CreateUBO(sizeof(WorldMatrix),&cam.matrix); ubo_world_matrix=device->CreateUBO(sizeof(WorldMatrix),&cam.matrix);
if(!ubo_mvp) if(!ubo_world_matrix)
return(false); return(false);
material_instance->BindUBO("world",ubo_mvp); material_instance->BindUBO("world",ubo_world_matrix);
material_instance->BindUBO("fragment_world",ubo_mvp); material_instance->BindUBO("fragment_world",ubo_world_matrix);
material_instance->Update(); material_instance->Update();
return(true); return(true);
@ -134,7 +134,7 @@ public:
cam.Refresh(); cam.Refresh();
ubo_mvp->Write(&cam.matrix); ubo_world_matrix->Write(&cam.matrix);
BuildCommandBuffer(pipeline,material_instance,render_obj); BuildCommandBuffer(pipeline,material_instance,render_obj);
} }

View File

@ -38,7 +38,7 @@ private:
*ro_circle =nullptr, *ro_circle =nullptr,
*ro_round_rectangle =nullptr; *ro_round_rectangle =nullptr;
vulkan::Buffer * ubo_mvp =nullptr; vulkan::Buffer * ubo_world_matrix =nullptr;
vulkan::Buffer * ubo_color_material =nullptr; vulkan::Buffer * ubo_color_material =nullptr;
vulkan::Pipeline * pipeline =nullptr; vulkan::Pipeline * pipeline =nullptr;
@ -119,7 +119,7 @@ private:
cam.Refresh(); cam.Refresh();
ubo_mvp =CreateUBO("world", sizeof(WorldMatrix),&cam.matrix); ubo_world_matrix =CreateUBO("world", sizeof(WorldMatrix),&cam.matrix);
ubo_color_material =CreateUBO("color_material",sizeof(Vector4f),&color); ubo_color_material =CreateUBO("color_material",sizeof(Vector4f),&color);
material_instance->Update(); material_instance->Update();
@ -182,7 +182,7 @@ public:
cam.Refresh(); cam.Refresh();
ubo_mvp->Write(&cam.matrix); ubo_world_matrix->Write(&cam.matrix);
BuildCommandBuffer(&render_list); BuildCommandBuffer(&render_list);
} }

View File

@ -41,7 +41,7 @@ private:
vulkan::Sampler * sampler =nullptr; vulkan::Sampler * sampler =nullptr;
vulkan::MaterialInstance * material_instance =nullptr; vulkan::MaterialInstance * material_instance =nullptr;
vulkan::Renderable * render_obj =nullptr; vulkan::Renderable * render_obj =nullptr;
vulkan::Buffer * ubo_mvp =nullptr; vulkan::Buffer * ubo_world_matrix =nullptr;
vulkan::Pipeline * pipeline =nullptr; vulkan::Pipeline * pipeline =nullptr;
@ -66,7 +66,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
material_instance->BindSampler("tex",texture,sampler); material_instance->BindSampler("tex",texture,sampler);
material_instance->BindUBO("world",ubo_mvp); material_instance->BindUBO("world",ubo_world_matrix);
material_instance->Update(); material_instance->Update();
db->Add(material); db->Add(material);
@ -85,9 +85,9 @@ private:
cam.Refresh(); cam.Refresh();
ubo_mvp=db->CreateUBO(sizeof(WorldMatrix),&cam.matrix); ubo_world_matrix=db->CreateUBO(sizeof(WorldMatrix),&cam.matrix);
if(!ubo_mvp) if(!ubo_world_matrix)
return(false); return(false);
return(true); return(true);
@ -145,7 +145,7 @@ public:
cam.Refresh(); cam.Refresh();
ubo_mvp->Write(&cam.matrix); ubo_world_matrix->Write(&cam.matrix);
BuildCommandBuffer(pipeline,material_instance,render_obj); BuildCommandBuffer(pipeline,material_instance,render_obj);
} }

View File

@ -38,7 +38,7 @@ private:
vulkan::Material * material =nullptr; vulkan::Material * material =nullptr;
vulkan::MaterialInstance * material_instance =nullptr; vulkan::MaterialInstance * material_instance =nullptr;
vulkan::Renderable * render_obj =nullptr; vulkan::Renderable * render_obj =nullptr;
vulkan::Buffer * ubo_mvp =nullptr; vulkan::Buffer * ubo_world_matrix =nullptr;
vulkan::Pipeline * pipeline =nullptr; vulkan::Pipeline * pipeline =nullptr;
@ -52,7 +52,7 @@ public:
SAFE_CLEAR(color_buffer); SAFE_CLEAR(color_buffer);
SAFE_CLEAR(vertex_buffer); SAFE_CLEAR(vertex_buffer);
SAFE_CLEAR(pipeline); SAFE_CLEAR(pipeline);
SAFE_CLEAR(ubo_mvp); SAFE_CLEAR(ubo_world_matrix);
SAFE_CLEAR(render_obj); SAFE_CLEAR(render_obj);
SAFE_CLEAR(material_instance); SAFE_CLEAR(material_instance);
SAFE_CLEAR(material); SAFE_CLEAR(material);
@ -81,12 +81,12 @@ private:
cam.Refresh(); cam.Refresh();
ubo_mvp=device->CreateUBO(sizeof(WorldMatrix),&cam.matrix); ubo_world_matrix=device->CreateUBO(sizeof(WorldMatrix),&cam.matrix);
if(!ubo_mvp) if(!ubo_world_matrix)
return(false); return(false);
material_instance->BindUBO("world",ubo_mvp); material_instance->BindUBO("world",ubo_world_matrix);
material_instance->Update(); material_instance->Update();
return(true); return(true);
} }
@ -158,7 +158,7 @@ public:
cam.Refresh(); cam.Refresh();
ubo_mvp->Write(&cam.matrix); ubo_world_matrix->Write(&cam.matrix);
BuildCommandBuffer(pipeline,material_instance,render_obj); BuildCommandBuffer(pipeline,material_instance,render_obj);
} }

View File

@ -12,7 +12,7 @@ constexpr uint32_t SCREEN_HEIGHT=128;
constexpr uint32_t VERTEX_COUNT=4; constexpr uint32_t VERTEX_COUNT=4;
static Vector4f color(1,1,0,1); static Vector4f color(1,1,1,1);
constexpr float SSP=0.25; constexpr float SSP=0.25;
constexpr float SSN=1-SSP; constexpr float SSN=1-SSP;
@ -42,12 +42,12 @@ private:
vulkan::Material * material =nullptr; vulkan::Material * material =nullptr;
vulkan::MaterialInstance * material_instance =nullptr; vulkan::MaterialInstance * material_instance =nullptr;
vulkan::Renderable * render_obj =nullptr; vulkan::Renderable * render_obj =nullptr;
vulkan::Buffer * ubo_mvp =nullptr; vulkan::Buffer * ubo_world_matrix =nullptr;
vulkan::Buffer * ubo_color_material =nullptr; vulkan::Buffer * ubo_color_material =nullptr;
vulkan::Pipeline * pipeline =nullptr; vulkan::Pipeline * pipeline =nullptr;
vulkan::VertexAttribBuffer * vertex_buffer =nullptr; vulkan::VertexAttribBuffer *vertex_buffer =nullptr;
vulkan::IndexBuffer * index_buffer =nullptr; vulkan::IndexBuffer * index_buffer =nullptr;
public: public:
@ -58,7 +58,7 @@ public:
SAFE_CLEAR(vertex_buffer); SAFE_CLEAR(vertex_buffer);
SAFE_CLEAR(pipeline); SAFE_CLEAR(pipeline);
SAFE_CLEAR(ubo_color_material); SAFE_CLEAR(ubo_color_material);
SAFE_CLEAR(ubo_mvp); SAFE_CLEAR(ubo_world_matrix);
SAFE_CLEAR(render_obj); SAFE_CLEAR(render_obj);
SAFE_CLEAR(material_instance); SAFE_CLEAR(material_instance);
SAFE_CLEAR(material); SAFE_CLEAR(material);
@ -69,7 +69,7 @@ private:
bool InitMaterial() bool InitMaterial()
{ {
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition.vert"), material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition.vert"),
OS_TEXT("res/shader/FlatColor.frag")); OS_TEXT("res/shader/XorColor.frag"));
if(!material) if(!material)
return(false); return(false);
@ -78,30 +78,20 @@ private:
return(true); return(true);
} }
vulkan::Buffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
{
vulkan::Buffer *ubo=device->CreateUBO(size,data);
if(!ubo)
return(nullptr);
if(!material_instance->BindUBO(name,ubo))
{
SAFE_CLEAR(ubo);
return(nullptr);
}
return ubo;
}
bool InitUBO() bool InitUBO()
{ {
const VkExtent2D extent=sc_render_target->GetExtent(); const VkExtent2D extent=sc_render_target->GetExtent();
wm.ortho=ortho(extent.width,extent.height); wm.ortho=ortho(extent.width,extent.height);
wm.canvas_resolution.x=extent.width;
wm.canvas_resolution.y=extent.height;
ubo_mvp =CreateUBO("world", sizeof(WorldMatrix),&wm); ubo_world_matrix =device->CreateUBO(sizeof(WorldMatrix),&wm);
ubo_color_material =CreateUBO("color_material",sizeof(Vector4f),&color); ubo_color_material =device->CreateUBO(sizeof(Vector4f),&color);
material_instance->BindUBO("world",ubo_world_matrix);
material_instance->BindUBO("fs_world",ubo_world_matrix);
material_instance->BindUBO("color_material",ubo_color_material);
material_instance->Update(); material_instance->Update();
return(true); return(true);

View File

@ -53,7 +53,7 @@ private:
vulkan::Sampler * sampler =nullptr; vulkan::Sampler * sampler =nullptr;
vulkan::MaterialInstance * material_instance =nullptr; vulkan::MaterialInstance * material_instance =nullptr;
vulkan::Renderable * render_obj =nullptr; vulkan::Renderable * render_obj =nullptr;
vulkan::Buffer * ubo_mvp =nullptr; vulkan::Buffer * ubo_world_matrix =nullptr;
vulkan::Pipeline * pipeline =nullptr; vulkan::Pipeline * pipeline =nullptr;
@ -69,7 +69,7 @@ public:
SAFE_CLEAR(tex_coord_buffer); SAFE_CLEAR(tex_coord_buffer);
SAFE_CLEAR(vertex_buffer); SAFE_CLEAR(vertex_buffer);
SAFE_CLEAR(pipeline); SAFE_CLEAR(pipeline);
SAFE_CLEAR(ubo_mvp); SAFE_CLEAR(ubo_world_matrix);
SAFE_CLEAR(render_obj); SAFE_CLEAR(render_obj);
SAFE_CLEAR(material_instance); SAFE_CLEAR(material_instance);
SAFE_CLEAR(sampler); SAFE_CLEAR(sampler);
@ -94,7 +94,7 @@ private:
sampler=device->CreateSampler(); sampler=device->CreateSampler();
material_instance->BindSampler("tex",texture,sampler); material_instance->BindSampler("tex",texture,sampler);
material_instance->BindUBO("world",ubo_mvp); material_instance->BindUBO("world",ubo_world_matrix);
material_instance->Update(); material_instance->Update();
return(true); return(true);
@ -109,9 +109,9 @@ private:
cam.Refresh(); cam.Refresh();
ubo_mvp=device->CreateUBO(sizeof(WorldMatrix),&cam.matrix); ubo_world_matrix=device->CreateUBO(sizeof(WorldMatrix),&cam.matrix);
if(!ubo_mvp) if(!ubo_world_matrix)
return(false); return(false);
return(true); return(true);
@ -170,7 +170,7 @@ public:
cam.Refresh(); cam.Refresh();
ubo_mvp->Write(&cam.matrix); ubo_world_matrix->Write(&cam.matrix);
BuildCommandBuffer(pipeline,material_instance,render_obj); BuildCommandBuffer(pipeline,material_instance,render_obj);
} }

2
res

@ -1 +1 @@
Subproject commit 9ce56221ff5907b041147f12fda367c226eba73f Subproject commit 3c8d4ba212c743feba2271743e560d32e9cb2e74