VertexInput/CommandBuffer支持IBO
This commit is contained in:
parent
34ae77c8fc
commit
df149ee988
@ -3,6 +3,7 @@
|
|||||||
#include"VKFramebuffer.h"
|
#include"VKFramebuffer.h"
|
||||||
#include"VKPipeline.h"
|
#include"VKPipeline.h"
|
||||||
#include"VKPipelineLayout.h"
|
#include"VKPipelineLayout.h"
|
||||||
|
#include"VKBuffer.h"
|
||||||
#include"VKVertexInput.h"
|
#include"VKVertexInput.h"
|
||||||
#include"VKDescriptorSets.h"
|
#include"VKDescriptorSets.h"
|
||||||
|
|
||||||
@ -94,6 +95,12 @@ bool CommandBuffer::Bind(VertexInput *vi)
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
vkCmdBindVertexBuffers(cmd_buf,0,count,vi->GetBuffer(),vi->GetOffset());
|
vkCmdBindVertexBuffers(cmd_buf,0,count,vi->GetBuffer(),vi->GetOffset());
|
||||||
|
|
||||||
|
IndexBuffer *indices_buffer=vi->GetIndexBuffer();
|
||||||
|
|
||||||
|
if(indices_buffer)
|
||||||
|
vkCmdBindIndexBuffer(cmd_buf,*indices_buffer,vi->GetIndexOffset(),indices_buffer->GetType());
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
void CommandBuffer::SetDepthBias(float constant_factor,float clamp,float slope_factor)
|
void CommandBuffer::SetDepthBias(float constant_factor,float clamp,float slope_factor)
|
||||||
@ -141,6 +148,16 @@ void CommandBuffer::Draw(const uint32_t vertex_count,const uint32_t instance_cou
|
|||||||
vkCmdDraw(cmd_buf,vertex_count,instance_count,first_vertex,first_instance);
|
vkCmdDraw(cmd_buf,vertex_count,instance_count,first_vertex,first_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommandBuffer::DrawIndexed(const uint32_t index_count)
|
||||||
|
{
|
||||||
|
vkCmdDrawIndexed(cmd_buf,index_count,1,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandBuffer::DrawIndexed(const uint32_t index_count,const uint32_t instance_count,const uint32_t first_index,const uint32_t vertex_offset,const uint32_t first_instance)
|
||||||
|
{
|
||||||
|
vkCmdDrawIndexed(cmd_buf,index_count,instance_count,first_index,vertex_offset,first_instance);
|
||||||
|
}
|
||||||
|
|
||||||
bool CommandBuffer::End()
|
bool CommandBuffer::End()
|
||||||
{
|
{
|
||||||
vkCmdEndRenderPass(cmd_buf);
|
vkCmdEndRenderPass(cmd_buf);
|
||||||
|
@ -65,6 +65,8 @@ public:
|
|||||||
|
|
||||||
void Draw(const uint32_t vertex_count);
|
void Draw(const uint32_t vertex_count);
|
||||||
void Draw(const uint32_t vertex_count,const uint32_t instance_count,const uint32_t first_vertex=0,const uint32_t first_instance=0);
|
void Draw(const uint32_t vertex_count,const uint32_t instance_count,const uint32_t first_vertex=0,const uint32_t first_instance=0);
|
||||||
|
void DrawIndexed(const uint32_t index_count);
|
||||||
|
void DrawIndexed(const uint32_t index_count,const uint32_t instance_count,const uint32_t first_index=0,const uint32_t vertex_offset=0,const uint32_t first_instance=0);
|
||||||
};//class CommandBuffer
|
};//class CommandBuffer
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include"VK.h"
|
#include"VK.h"
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
class VertexBuffer;
|
class VertexBuffer;
|
||||||
|
class IndexBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顶点输入配置,类似于OpenGL的VAB<br>
|
* 顶点输入配置,类似于OpenGL的VAB<br>
|
||||||
@ -36,12 +37,22 @@ class VertexInput
|
|||||||
List<VkVertexInputBindingDescription> binding_list;
|
List<VkVertexInputBindingDescription> binding_list;
|
||||||
List<VkVertexInputAttributeDescription> attribute_list;
|
List<VkVertexInputAttributeDescription> attribute_list;
|
||||||
|
|
||||||
|
IndexBuffer *indices_buffer=nullptr;
|
||||||
|
VkDeviceSize indices_offset=0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VertexInput()=default;
|
VertexInput()=default;
|
||||||
virtual ~VertexInput()=default;
|
virtual ~VertexInput()=default;
|
||||||
|
|
||||||
bool Add(uint32_t location,VertexBuffer *,bool instance=false,VkDeviceSize offset=0);
|
bool Add(uint32_t location,VertexBuffer *,bool instance=false,VkDeviceSize offset=0);
|
||||||
|
bool AddIndices(IndexBuffer *ib,VkDeviceSize offset=0)
|
||||||
|
{
|
||||||
|
if(!ib)return(false);
|
||||||
|
|
||||||
|
indices_buffer=ib;
|
||||||
|
indices_offset=offset;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -49,6 +60,9 @@ public:
|
|||||||
const VkBuffer * GetBuffer ()const{return buf_list.GetData();}
|
const VkBuffer * GetBuffer ()const{return buf_list.GetData();}
|
||||||
const VkDeviceSize * GetOffset ()const{return buf_offset.GetData();}
|
const VkDeviceSize * GetOffset ()const{return buf_offset.GetData();}
|
||||||
|
|
||||||
|
IndexBuffer * GetIndexBuffer()const{return indices_buffer;}
|
||||||
|
const VkDeviceSize GetIndexOffset()const{return indices_offset;}
|
||||||
|
|
||||||
const VkPipelineVertexInputStateCreateInfo GetPipelineVertexInputStateCreateInfo()const;
|
const VkPipelineVertexInputStateCreateInfo GetPipelineVertexInputStateCreateInfo()const;
|
||||||
};//class VertexInput
|
};//class VertexInput
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user