fixed draw_triangle_in_NDC sample and other about codes.
This commit is contained in:
parent
90152ca74e
commit
611a9fe61d
@ -6,7 +6,7 @@
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/SceneInfo.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/VKRenderablePrimitiveCreater.h>
|
||||
#include<hgl/graph/PrimitiveCreater.h>
|
||||
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||
|
||||
using namespace hgl;
|
||||
@ -108,16 +108,18 @@ private:
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
RenderablePrimitiveCreater rpc(db,"Triangle",VERTEX_COUNT);
|
||||
PrimitiveCreater rpc(device,material_instance->GetVIL());
|
||||
|
||||
rpc.Init("Triangle",VERTEX_COUNT);
|
||||
|
||||
#ifdef USE_HALF_FLOAT_POSITION
|
||||
Float32toFloat16(position_data_hf,position_data_float,VERTEX_COUNT*2);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
if(!rpc.SetVAB(VAN::Position, PositionFormat, position_data))return(false);
|
||||
if(!rpc.SetVAB(VAN::Color, ColorFormat, color_data ))return(false);
|
||||
if(!rpc.WriteVAB(VAN::Position, PositionFormat, position_data))return(false);
|
||||
if(!rpc.WriteVAB(VAN::Color, ColorFormat, color_data ))return(false);
|
||||
|
||||
render_obj=rpc.Create(material_instance,pipeline);
|
||||
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ constexpr const COLOR AxisColor[4]=
|
||||
//COLOR::Green, //Y轴颜色
|
||||
//COLOR::Blue, //Z轴颜色
|
||||
COLOR::White, //全局颜色
|
||||
COLOR::White, //全局颜色
|
||||
COLOR::White, //全局颜色
|
||||
COLOR::White //全局颜色
|
||||
COLOR::GhostWhite,
|
||||
COLOR::BlanchedAlmond,
|
||||
COLOR::AntiqueWhite
|
||||
|
||||
};
|
||||
|
||||
|
@ -222,7 +222,7 @@ public:
|
||||
cb->BeginRenderPass();
|
||||
cb->BindPipeline(ri->GetPipeline());
|
||||
cb->BindDescriptorSets(ri->GetMaterial());
|
||||
cb->BindRenderBuffer(ri->GetDataBuffer());
|
||||
cb->BindDataBuffer(ri->GetDataBuffer());
|
||||
cb->Draw(ri->GetDataBuffer(),ri->GetRenderData());
|
||||
cb->EndRenderPass();
|
||||
cb->End();
|
||||
|
@ -176,7 +176,7 @@ public:
|
||||
|
||||
void BindIBO(IndexBuffer *,const VkDeviceSize byte_offset=0);
|
||||
|
||||
bool BindRenderBuffer(const PrimitiveDataBuffer *);
|
||||
bool BindDataBuffer(const PrimitiveDataBuffer *);
|
||||
|
||||
void SetViewport (uint32_t first,uint32_t count,const VkViewport *vp) {vkCmdSetViewport(cmd_buf,first,count,vp);}
|
||||
void SetScissor (uint32_t first,uint32_t count,const VkRect2D *sci) {vkCmdSetScissor(cmd_buf,first,count,sci);}
|
||||
|
@ -22,7 +22,7 @@ struct PrimitiveDataBuffer
|
||||
// 另一种是使用VDM,为了批量渲染,所有的VAB又必须对齐,所以每个VAB单独指定offset也不可行。
|
||||
// 所以干脆不支持VAB的offset,只支持vertexOffset。
|
||||
|
||||
// uint32_t * vab_offset; //注意:这里的offset是相对于vertex的,代表第几个顶点,不是字节偏移
|
||||
VkDeviceSize * vab_offset; //注意:这里的offset是相对于vertex的,代表第几个顶点,不是字节偏移
|
||||
|
||||
// IndexBuffer 同理也不再支持buffer的offset
|
||||
|
||||
|
@ -140,7 +140,7 @@ void RenderCmdBuffer::BindIBO(IndexBuffer *ibo,const VkDeviceSize byte_offset)
|
||||
VkIndexType(ibo->GetType()));
|
||||
}
|
||||
|
||||
bool RenderCmdBuffer::BindRenderBuffer(const PrimitiveDataBuffer *pdb)
|
||||
bool RenderCmdBuffer::BindDataBuffer(const PrimitiveDataBuffer *pdb)
|
||||
{
|
||||
if(!pdb)
|
||||
return(false);
|
||||
@ -152,7 +152,7 @@ bool RenderCmdBuffer::BindRenderBuffer(const PrimitiveDataBuffer *pdb)
|
||||
0, //first binding
|
||||
pdb->vab_count,
|
||||
pdb->vab_list,
|
||||
nullptr); //vab byte offsets
|
||||
pdb->vab_offset); //vab byte offsets
|
||||
|
||||
if(pdb->ibo)
|
||||
BindIBO(pdb->ibo);
|
||||
|
@ -12,6 +12,7 @@ PrimitiveDataBuffer::PrimitiveDataBuffer(const uint32_t c,IndexBuffer *ib,Vertex
|
||||
vab_count=c;
|
||||
|
||||
vab_list=hgl_zero_new<VkBuffer>(vab_count);
|
||||
vab_offset=hgl_zero_new<VkDeviceSize>(vab_count);
|
||||
ibo=ib;
|
||||
|
||||
vdm=_vdm;
|
||||
@ -19,6 +20,7 @@ PrimitiveDataBuffer::PrimitiveDataBuffer(const uint32_t c,IndexBuffer *ib,Vertex
|
||||
|
||||
PrimitiveDataBuffer::~PrimitiveDataBuffer()
|
||||
{
|
||||
delete[] vab_offset;
|
||||
delete[] vab_list;
|
||||
}
|
||||
|
||||
@ -34,6 +36,7 @@ const bool PrimitiveDataBuffer::Comp(const PrimitiveDataBuffer *pdb)const
|
||||
for(uint32_t i=0;i<vab_count;i++)
|
||||
{
|
||||
if(vab_list[i]!=pdb->vab_list[i])return(false);
|
||||
if(vab_offset[i]!=pdb->vab_offset[i])return(false);
|
||||
}
|
||||
|
||||
if(ibo!=pdb->ibo)
|
||||
@ -108,6 +111,7 @@ Renderable *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
|
||||
}
|
||||
|
||||
pdb->vab_list[i]=vab->GetBuffer();
|
||||
pdb->vab_offset[i]=0;
|
||||
++vif;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user