use "VertexAttribData" instead "VertexAttribBufferCreater"

This commit is contained in:
hyzboy 2020-07-16 17:08:13 +08:00
parent 1ebaedb350
commit 770ab4d1d9
8 changed files with 29 additions and 24 deletions

View File

@ -9,7 +9,7 @@
#include<hgl/graph/vulkan/VKSampler.h> #include<hgl/graph/vulkan/VKSampler.h>
#include<hgl/graph/vulkan/VKTexture.h> #include<hgl/graph/vulkan/VKTexture.h>
#include<hgl/graph/vulkan/VKMaterialInstance.h> #include<hgl/graph/vulkan/VKMaterialInstance.h>
#include<hgl/graph/VertexAttribBufferCreater.h> #include<hgl/graph/VertexAttribData.h>
#include<hgl/graph/RenderableInstance.h> #include<hgl/graph/RenderableInstance.h>
#include<hgl/type/ResManage.h> #include<hgl/type/ResManage.h>
namespace hgl namespace hgl
@ -26,7 +26,7 @@ namespace hgl
using SamplerID =int; using SamplerID =int;
using TextureID =int; using TextureID =int;
class VertexAttribBufferCreater; class VertexAttribData;
/** /**
* DB * DB
@ -66,7 +66,7 @@ namespace hgl
vulkan::VertexAttribBuffer *CreateVAB(VkFormat format,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); vulkan::VertexAttribBuffer *CreateVAB(VkFormat format,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
vulkan::VertexAttribBuffer *CreateVAB(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(format,count,nullptr,sharing_mode);} vulkan::VertexAttribBuffer *CreateVAB(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(format,count,nullptr,sharing_mode);}
vulkan::VertexAttribBuffer *CreateVAB(const VertexAttribBufferCreater *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);} vulkan::VertexAttribBuffer *CreateVAB(const VertexAttribData *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);}
#define SCENE_DB_CREATE_FUNC(name) vulkan::Buffer *Create##name(VkDeviceSize size,void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); \ #define SCENE_DB_CREATE_FUNC(name) vulkan::Buffer *Create##name(VkDeviceSize size,void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); \
vulkan::Buffer *Create##name(VkDeviceSize size,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); vulkan::Buffer *Create##name(VkDeviceSize size,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);

View File

@ -5,7 +5,7 @@
#include<hgl/type/Color4f.h> #include<hgl/type/Color4f.h>
#include<hgl/type/RectScope.h> #include<hgl/type/RectScope.h>
#include<hgl/type/BaseString.h> #include<hgl/type/BaseString.h>
#include<hgl/graph/VertexAttribBufferCreater.h> #include<hgl/graph/VertexAttribData.h>
#include<hgl/log/LogInfo.h> #include<hgl/log/LogInfo.h>
namespace hgl namespace hgl
{ {
@ -14,7 +14,7 @@ namespace hgl
/** /**
* *
*/ */
template<typename T,int C> class VertexAttribBufferBase:public VertexAttribBufferCreater template<typename T,int C> class VertexAttribBufferBase:public VertexAttribData
{ {
protected: protected:
@ -25,7 +25,7 @@ namespace hgl
public: public:
VertexAttribBufferBase(uint32_t _size,const T *_data=nullptr):VertexAttribBufferCreater(_size,C,sizeof(T)) VertexAttribBufferBase(uint32_t _size,const T *_data=nullptr):VertexAttribData(_size,C,sizeof(T))
{ {
mem_type=(T *)GetData(); mem_type=(T *)GetData();
access=0; access=0;
@ -1135,7 +1135,7 @@ namespace hgl
* @param vecsize vec数量 * @param vecsize vec数量
* @param vertex_count * @param vertex_count
*/ */
VertexAttribBufferCreater *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count); VertexAttribData *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count);
}//namespace graph }//namespace graph
}//namespace hgl }//namespace hgl
#endif//HGL_GRAPH_VERTEX_ATTRIB_BUFFER_INCLUDE #endif//HGL_GRAPH_VERTEX_ATTRIB_BUFFER_INCLUDE

View File

@ -1,5 +1,5 @@
#ifndef HGL_GRAPH_VERTEX_ATTRIB_BUFFER_CREATER_INCLUDE #ifndef HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE
#define HGL_GRAPH_VERTEX_ATTRIB_BUFFER_CREATER_INCLUDE #define HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE
#include<hgl/graph/vulkan/VK.h> #include<hgl/graph/vulkan/VK.h>
namespace hgl namespace hgl
@ -7,7 +7,7 @@ namespace hgl
namespace graph namespace graph
{ {
/** /**
* *
*/ */
class VertexAttribData ///顶点属性缓冲区创建者 class VertexAttribData ///顶点属性缓冲区创建者
{ {
@ -50,4 +50,4 @@ namespace hgl
using VAD=VertexAttribData; using VAD=VertexAttribData;
}//namespace graph }//namespace graph
}//namespace hgl }//namespace hgl
#endif//HGL_GRAPH_VERTEX_ATTRIB_BUFFER_CREATER_INCLUDE #endif//HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE

View File

@ -9,7 +9,7 @@
#include<hgl/graph/vulkan/VKDeviceAttribute.h> #include<hgl/graph/vulkan/VKDeviceAttribute.h>
#include<hgl/graph/vulkan/VKSwapchain.h> #include<hgl/graph/vulkan/VKSwapchain.h>
#include<hgl/graph/vulkan/VKRenderTarget.h> #include<hgl/graph/vulkan/VKRenderTarget.h>
#include<hgl/graph/VertexAttribBufferCreater.h> #include<hgl/graph/VertexAttribData.h>
namespace hgl namespace hgl
{ {
@ -89,7 +89,7 @@ public: //Buffer相关
VertexAttribBuffer * CreateVAB(VkFormat format,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); VertexAttribBuffer * CreateVAB(VkFormat format,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
VertexAttribBuffer * CreateVAB(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(format,count,nullptr,sharing_mode);} VertexAttribBuffer * CreateVAB(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(format,count,nullptr,sharing_mode);}
VertexAttribBuffer * CreateVAB(const VertexAttribBufferCreater *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);} VertexAttribBuffer * CreateVAB(const VertexAttribData *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);}
IndexBuffer * CreateIBO(VkIndexType index_type,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); IndexBuffer * CreateIBO(VkIndexType index_type,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
IndexBuffer * CreateIBO16(uint32_t count,const uint16 *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateIBO(VK_INDEX_TYPE_UINT16,count,(void *)data,sharing_mode);} IndexBuffer * CreateIBO16(uint32_t count,const uint16 *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateIBO(VK_INDEX_TYPE_UINT16,count,(void *)data,sharing_mode);}

View File

@ -9,7 +9,7 @@ Buffer::~Buffer()
vkDestroyBuffer(device,buf.buffer,nullptr); vkDestroyBuffer(device,buf.buffer,nullptr);
} }
VertexAttribBufferCreater *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count) VertexAttribData *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count)
{ {
if(base_type==spirv_cross::SPIRType::SByte) if(base_type==spirv_cross::SPIRType::SByte)
{ {

View File

@ -12,10 +12,10 @@ SOURCE_GROUP("Material" FILES ${SG_MATERIAL_HEADER}
SOURCE_GROUP("Material\\Shader" FILES ${SHADER_RESOURCE_FILES}) SOURCE_GROUP("Material\\Shader" FILES ${SHADER_RESOURCE_FILES})
SET(SG_VERTEX_SOURCE ${ROOT_INCLUDE_PATH}/hgl/graph/VertexAttribBufferCreater.h SET(SG_VAB_SOURCE ${ROOT_INCLUDE_PATH}/hgl/graph/VertexAttribData.h
${ROOT_INCLUDE_PATH}/hgl/graph/VertexAttribBuffer.h) ${ROOT_INCLUDE_PATH}/hgl/graph/VertexAttribBuffer.h)
SOURCE_GROUP("VertexBuffer" FILES ${SG_VERTEX_SOURCE}) SOURCE_GROUP("VertexAttribBuffer" FILES ${SG_VAB_SOURCE})
SET(SCENE_GRAPH_HEADER ${ROOT_INCLUDE_PATH}/hgl/graph/Light.h SET(SCENE_GRAPH_HEADER ${ROOT_INCLUDE_PATH}/hgl/graph/Light.h
${ROOT_INCLUDE_PATH}/hgl/graph/SceneDB.h ${ROOT_INCLUDE_PATH}/hgl/graph/SceneDB.h
@ -78,7 +78,7 @@ add_cm_library(ULRE.SceneGraph "ULRE" ${SCENE_GRAPH_HEADER}
${SG_MATERIAL_HEADER} ${SG_MATERIAL_HEADER}
${SG_MATERIAL_SOURCE} ${SG_MATERIAL_SOURCE}
${SG_VERTEX_SOURCE} ${SG_VAB_SOURCE}
${RENDERABLE_FILES} ${RENDERABLE_FILES}

View File

@ -6,11 +6,13 @@
#include<hgl/graph/vulkan/VKDevice.h> #include<hgl/graph/vulkan/VKDevice.h>
#include<hgl/graph/vulkan/VKShaderModule.h> #include<hgl/graph/vulkan/VKShaderModule.h>
#include<hgl/graph/SceneDB.h> #include<hgl/graph/SceneDB.h>
#include<hgl/graph/RenderableCreater.h>
namespace hgl namespace hgl
{ {
namespace graph namespace graph
{ {
namespace /* namespace
{ {
template<typename VERTEX_VB_FORMAT> template<typename VERTEX_VB_FORMAT>
struct GeometryCreater struct GeometryCreater
@ -103,7 +105,7 @@ namespace hgl
private: private:
void Finish(int binding,VertexAttribBufferCreater *vb) void Finish(int binding,VertexAttribData *vb)
{ {
render_obj->Set(binding,db->CreateVAB(vb)); render_obj->Set(binding,db->CreateVAB(vb));
delete vb; delete vb;
@ -141,15 +143,18 @@ namespace hgl
using GeometryCreater3D=GeometryCreater<VB3f>; using GeometryCreater3D=GeometryCreater<VB3f>;
using GeometryCreater2D=GeometryCreater<VB2f>; using GeometryCreater2D=GeometryCreater<VB2f>;
}//namespace }//namespace
*/
vulkan::Renderable *CreateRenderableRectangle(SceneDB *db,vulkan::Material *mtl,const RectangleCreateInfo *rci) vulkan::Renderable *CreateRenderableRectangle(SceneDB *db,vulkan::Material *mtl,const RectangleCreateInfo *rci)
{ {
GeometryCreater2D gc(db,mtl); RenderableCreater rc(db,mtl);
if(!gc.Init(4)) if(!rc.Init(4))
return(nullptr); return(nullptr);
VB2f *vertex=gc.GetVertex(); VAD *vertex=rc.CreateVAB(VAN::Vertex);
if(vertex->GetComponent()!=2)
return(nullptr);
vertex->WriteRectFan(rci->scope); vertex->WriteRectFan(rci->scope);

View File

@ -24,7 +24,7 @@ namespace hgl
return(true); return(true);
} }
VertexAttribBufferCreater *RenderableCreater::CreateVAB(const AnsiString &name) VertexAttribData *RenderableCreater::CreateVAB(const AnsiString &name)
{ {
if(!vsm)return(false); if(!vsm)return(false);