renamed to DynamicBufferAccess instead of UBODynamicAccess

This commit is contained in:
2023-04-25 11:43:15 +08:00
parent d163f914c7
commit ba6af7a596
5 changed files with 24 additions and 25 deletions

View File

@@ -2,7 +2,7 @@
#define HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
#include<hgl/graph/VK.h>
#include<hgl/graph/VKUBODynamic.h>
#include<hgl/graph/VKDynamicBufferAccess.h>
namespace hgl
{
class Collection;
@@ -50,26 +50,26 @@ namespace hgl
void Clear();
template<typename T>
bool Start(UBODynamicAccess<T> *ubo_access,const uint32 start,const uint32 count)
bool Start(DynamicBufferAccess<T> *dba,const uint32 start,const uint32 count)
{
if(!ubo_access)return(false);
if(!dba)return(false);
void *ptr=Map(start,count);
if(!ptr)return(false);
ubo_access->Start((uchar *)ptr,align_size,count);
dba->Start((uchar *)ptr,align_size,count);
return(true);
}
template<typename T>
void End(UBODynamicAccess<T> *ubo_access)
void End(DynamicBufferAccess<T> *dba)
{
if(!ubo_access)return;
if(!dba)return;
Flush(ubo_access->GetCount());
Flush(dba->GetCount());
ubo_access->Restart();
dba->Restart();
}
};//class GPUArrayBuffer
}//namespace graph

View File

@@ -1,22 +1,21 @@
#ifndef HGL_GRAPH_UBO_DYNAMIC_INCLUDE
#define HGL_GRAPH_UBO_DYNAMIC_INCLUDE
#ifndef HGL_GRAPH_DYNAMIC_BUFFER_ACCESS_INCLUDE
#define HGL_GRAPH_DYNAMIC_BUFFER_ACCESS_INCLUDE
#include<hgl/graph/VKArrayBuffer.h>
VK_NAMESPACE_BEGIN
template<typename T> class UBODynamicAccess
template<typename T> class DynamicBufferAccess
{
uchar *pointer;
uchar *current;
uint unit_size;
uint align_size;
uint count;
uint index;
private:
UBODynamicAccess()
DynamicBufferAccess()
{
Restart();
}
@@ -25,15 +24,15 @@ private:
{
pointer=nullptr;
current=nullptr;
unit_size=0;
align_size=0;
count=0;
index=0;
}
void Start(uchar *buf,const uint us,const uint c)
void Start(uchar *buf,const uint as,const uint c)
{
current=pointer=buf;
unit_size=us;
align_size=as;
count=c;
index=0;
}
@@ -44,7 +43,7 @@ public:
const uint GetCount()const{return count;}
const uint GetCurrentIndex()const{return index;}
const uint GetOffsetBytes()const{return index*unit_size;}
const uint GetOffsetBytes()const{return index*align_size;}
bool Write(uchar *src)
{
@@ -52,7 +51,7 @@ public:
if(index>=count)return(false);
memcpy(current,src,sizeof(T));
current+=unit_size;
current+=align_size;
++index;
return(true);
@@ -67,7 +66,7 @@ public:
for(uint i=0;i<c;i++)
{
memcpy(current,src,sizeof(T));
current+=unit_size;
current+=align_size;
src+=sizeof(T);
}
@@ -75,6 +74,6 @@ public:
return(true);
}
};//template<typename T> class UBODynamicAccess
};//template<typename T> class DynamicBufferAccess
VK_NAMESPACE_END
#endif//HGL_GRAPH_UBO_DYNAMIC_INCLUDE
#endif//HGL_GRAPH_DYNAMIC_BUFFER_ACCESS_INCLUDE