OK???? 3rd_draw_triangle_use_RenderList run OK!.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include<hgl/graph/RenderNode.h>
|
||||
#include<hgl/graph/VKVBOList.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct RenderExtraBuffer;
|
||||
@@ -42,9 +43,7 @@ private:
|
||||
|
||||
protected:
|
||||
|
||||
uint32_t binding_count;
|
||||
VkBuffer *buffer_list;
|
||||
VkDeviceSize *buffer_offset;
|
||||
VBOList * vbo_list;
|
||||
|
||||
MaterialInstance * last_mi;
|
||||
Pipeline * last_pipeline;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#define HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKVBOList.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
@@ -140,7 +141,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool BindDescriptorSets(Renderable *ri);
|
||||
bool BindDescriptorSets(Material *);
|
||||
|
||||
bool PushDescriptorSet(VkPipelineLayout pipeline_layout,uint32_t set,uint32_t count,const VkWriteDescriptorSet *write_desc_set)
|
||||
{
|
||||
@@ -160,6 +161,17 @@ public:
|
||||
vkCmdBindVertexBuffers(cmd_buf,first,count,vbo,offsets);
|
||||
}
|
||||
|
||||
bool BindVBO(VBOList *vbo_list)
|
||||
{
|
||||
if(!vbo_list)return(false);
|
||||
|
||||
if(!vbo_list->IsFull())return(false);
|
||||
|
||||
vkCmdBindVertexBuffers(cmd_buf,0,vbo_list->binding_count,vbo_list->buffer_list,vbo_list->buffer_offset);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void BindIBO(const IndexBufferData *);
|
||||
|
||||
bool BindVBO(Renderable *);
|
||||
|
57
inc/hgl/graph/VKVBOList.h
Normal file
57
inc/hgl/graph/VKVBOList.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class VBOList
|
||||
{
|
||||
uint32_t binding_count;
|
||||
VkBuffer *buffer_list;
|
||||
VkDeviceSize *buffer_offset;
|
||||
|
||||
uint32_t write_count;
|
||||
|
||||
friend class RenderCmdBuffer;
|
||||
|
||||
public:
|
||||
|
||||
VBOList(const uint32 bc)
|
||||
{
|
||||
binding_count=bc;
|
||||
buffer_list=new VkBuffer[binding_count];
|
||||
buffer_offset=new VkDeviceSize[binding_count];
|
||||
|
||||
write_count=0;
|
||||
}
|
||||
|
||||
~VBOList()
|
||||
{
|
||||
delete[] buffer_offset;
|
||||
delete[] buffer_list;
|
||||
}
|
||||
|
||||
void Restart()
|
||||
{
|
||||
write_count=0;
|
||||
}
|
||||
|
||||
const bool IsFull()const
|
||||
{
|
||||
return write_count>=binding_count;
|
||||
}
|
||||
|
||||
void Add(const VkBuffer buf,const VkDeviceSize offset)
|
||||
{
|
||||
buffer_list[write_count]=buf;
|
||||
buffer_offset[write_count]=offset;
|
||||
|
||||
++write_count;
|
||||
}
|
||||
|
||||
void Add(const VkBuffer *buf,const VkDeviceSize *offset,const uint32_t count)
|
||||
{
|
||||
hgl_cpy(buffer_list +write_count,buf, count);
|
||||
hgl_cpy(buffer_offset+write_count,offset,count);
|
||||
|
||||
write_count+=count;
|
||||
}
|
||||
};//class VBOList
|
||||
VK_NAMESPACE_END
|
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/graph/mtl/ShaderBuffer.h>
|
||||
@@ -42,6 +42,18 @@ constexpr const ShaderBufferSource SBS_CameraInfo=
|
||||
float znear,zfar;)"
|
||||
};
|
||||
|
||||
// UBO必须严格指定数组的大小
|
||||
// SSBO则不需要,使用[]方式指定为动态大小数组
|
||||
|
||||
constexpr const ShaderBufferSource SBS_LocalToWorld=
|
||||
{
|
||||
"LocalToWorldData",
|
||||
"l2w",
|
||||
|
||||
R"(
|
||||
mat4 mats[L2W_MAX_COUNT];)"
|
||||
};
|
||||
|
||||
constexpr const char MaterialInstanceStruct[]="MaterialInstance";
|
||||
|
||||
constexpr const ShaderBufferSource SBS_MaterialInstanceData=
|
||||
|
Reference in New Issue
Block a user