include整理
This commit is contained in:
parent
08e353b07a
commit
89369484da
@ -1,9 +1,62 @@
|
||||
#include"VKCommandBuffer.h"
|
||||
#include"VKRenderPass.h"
|
||||
#include"VKFramebuffer.h"
|
||||
#include"VKPipeline.h"
|
||||
#include"VKVertexInput.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
CommandBuffer::CommandBuffer(VkDevice dev,VkCommandPool cp,VkCommandBuffer cb)
|
||||
{
|
||||
device=dev;
|
||||
pool=cp;
|
||||
cmd_buf=cb;
|
||||
|
||||
clear_values[0].color.float32[0] = 0.2f;
|
||||
clear_values[0].color.float32[1] = 0.2f;
|
||||
clear_values[0].color.float32[2] = 0.2f;
|
||||
clear_values[0].color.float32[3] = 0.2f;
|
||||
clear_values[1].depthStencil.depth = 1.0f;
|
||||
clear_values[1].depthStencil.stencil = 0;
|
||||
}
|
||||
|
||||
CommandBuffer::~CommandBuffer()
|
||||
{
|
||||
VkCommandBuffer cmd_bufs[1] = {buf};
|
||||
VkCommandBuffer cmd_bufs[1] = {cmd_buf};
|
||||
vkFreeCommandBuffers(device, pool, 1, cmd_bufs);
|
||||
}
|
||||
|
||||
bool CommandBuffer::Bind(RenderPass *rp,Framebuffer *fb,Pipeline *p)
|
||||
{
|
||||
VkRenderPassBeginInfo rp_begin;
|
||||
|
||||
rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||
rp_begin.pNext = nullptr;
|
||||
rp_begin.renderPass = *rp;
|
||||
rp_begin.framebuffer = *fb;
|
||||
rp_begin.renderArea = render_area;
|
||||
rp_begin.clearValueCount = 2;
|
||||
rp_begin.pClearValues = clear_values;
|
||||
|
||||
vkCmdBeginRenderPass(cmd_buf, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
|
||||
vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS, *p);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool CommandBuffer::Bind(VertexInput *vi)
|
||||
{
|
||||
if(!vi)
|
||||
return(false);
|
||||
|
||||
const List<VkBuffer> &buf_list=vi->GetBufferList();
|
||||
|
||||
if(buf_list.GetCount()<=0)
|
||||
return(false);
|
||||
|
||||
constexpr VkDeviceSize zero_offsets[1]={0};
|
||||
|
||||
vkCmdBindVertexBuffers(cmd_buf,0,buf_list.GetCount(),buf_list.GetData(),zero_offsets);
|
||||
|
||||
return(true);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -2,37 +2,30 @@
|
||||
#define HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
#include"VKVertexInput.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class RenderPass;
|
||||
class Framebuffer;
|
||||
class Pipeline;
|
||||
class VertexInput;
|
||||
|
||||
class CommandBuffer
|
||||
{
|
||||
VkDevice device;
|
||||
VkCommandPool pool;
|
||||
VkCommandBuffer buf;
|
||||
class CommandBuffer
|
||||
{
|
||||
VkDevice device;
|
||||
VkCommandPool pool;
|
||||
VkCommandBuffer cmd_buf;
|
||||
|
||||
public:
|
||||
VkClearValue clear_values[2];
|
||||
VkRect2D render_area;
|
||||
|
||||
CommandBuffer(VkDevice dev,VkCommandPool cp,VkCommandBuffer cb){device=dev;pool=cp;buf=cb;}
|
||||
~CommandBuffer();
|
||||
public:
|
||||
|
||||
bool Bind(VertexInput *vi)
|
||||
{
|
||||
if(!vi)
|
||||
return(false);
|
||||
CommandBuffer(VkDevice dev,VkCommandPool cp,VkCommandBuffer cb);
|
||||
~CommandBuffer();
|
||||
|
||||
const List<VkBuffer> &buf_list=vi->GetBufferList();
|
||||
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
||||
|
||||
if(buf_list.GetCount()<=0)
|
||||
return(false);
|
||||
|
||||
constexpr VkDeviceSize zero_offsets[1]={0};
|
||||
|
||||
vkCmdBindVertexBuffers(buf,0,buf_list.GetCount(),buf_list.GetData(),zero_offsets);
|
||||
|
||||
return(true);
|
||||
}
|
||||
};//class CommandBuffer
|
||||
bool Bind(RenderPass *rp,Framebuffer *fb,Pipeline *p);
|
||||
bool Bind(VertexInput *vi);
|
||||
};//class CommandBuffer
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||
|
@ -1,5 +1,9 @@
|
||||
#include"VKDevice.h"
|
||||
#include<hgl/type/Pair.h>
|
||||
#include"VKBuffer.h"
|
||||
#include"VKCommandBuffer.h"
|
||||
//#include"VKDescriptorSet.h"
|
||||
#include"VKRenderPass.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -5,12 +5,13 @@
|
||||
#include"VK.h"
|
||||
#include"Window.h"
|
||||
#include"VKDeviceAttribute.h"
|
||||
#include"VKBuffer.h"
|
||||
#include"VKCommandBuffer.h"
|
||||
//#include"VKDescriptorSet.h"
|
||||
#include"VKRenderPass.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct PhysicalDevice;
|
||||
class Buffer;
|
||||
class VertexBuffer;
|
||||
class CommandBuffer;
|
||||
class RenderPass;
|
||||
|
||||
using RefDeviceAttribute=SharedPtr<DeviceAttribute>;
|
||||
|
||||
@ -41,7 +42,7 @@ public:
|
||||
Buffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize size,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
|
||||
VertexBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
|
||||
|
||||
#define CREATE_FORMAT_BUFFER_OBJECT(LargeName,type) Buffer *Create##LargeName(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,format,count,sharing_mode);}
|
||||
#define CREATE_FORMAT_BUFFER_OBJECT(LargeName,type) VertexBuffer *Create##LargeName(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,format,count,sharing_mode);}
|
||||
CREATE_FORMAT_BUFFER_OBJECT(VBO,VERTEX)
|
||||
CREATE_FORMAT_BUFFER_OBJECT(IBO,INDEX)
|
||||
#undef CREATE_FORMAT_BUFFER_OBJECT
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include"VKDeviceAttribute.h"
|
||||
#include"VKPhysicalDevice.h"
|
||||
#include<iostream>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
@ -169,4 +170,9 @@ DeviceAttribute::~DeviceAttribute()
|
||||
if(surface)
|
||||
vkDestroySurfaceKHR(instance,surface,nullptr);
|
||||
}
|
||||
|
||||
bool DeviceAttribute::CheckMemoryType(uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex) const
|
||||
{
|
||||
return physical_device->CheckMemoryType(typeBits,requirements_mask,typeIndex);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include"VK.h"
|
||||
#include"VKPhysicalDevice.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
constexpr uint32_t ERROR_FAMILY_INDEX=UINT32_MAX;
|
||||
|
||||
struct PhysicalDevice;
|
||||
|
||||
struct DeviceAttribute
|
||||
{
|
||||
VkInstance instance =nullptr;
|
||||
@ -52,9 +53,6 @@ public:
|
||||
DeviceAttribute(VkInstance inst,const PhysicalDevice *pd,VkSurfaceKHR s);
|
||||
~DeviceAttribute();
|
||||
|
||||
bool CheckMemoryType(uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex) const
|
||||
{
|
||||
return physical_device->CheckMemoryType(typeBits,requirements_mask,typeIndex);
|
||||
}
|
||||
bool CheckMemoryType(uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex) const;
|
||||
};//class DeviceAttribute
|
||||
VK_NAMESPACE_END
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include"VKDevice.h"
|
||||
#include"VKInstance.h"
|
||||
#include"VKPhysicalDevice.h"
|
||||
#include<hgl/type/Smart.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include"VKFramebuffer.h"
|
||||
#include"VKDevice.h"
|
||||
#include"VKRenderPass.h"
|
||||
VK_NAMESPACE_BEGIN
|
||||
Framebuffer::~Framebuffer()
|
||||
{
|
||||
|
@ -2,9 +2,10 @@
|
||||
#define HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
#include"VKDevice.h"
|
||||
#include"VKRenderPass.h"
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Device;
|
||||
class RenderPass;
|
||||
|
||||
class Framebuffer
|
||||
{
|
||||
VkDevice device;
|
||||
@ -23,6 +24,8 @@ private:
|
||||
public:
|
||||
|
||||
~Framebuffer();
|
||||
|
||||
operator VkFramebuffer(){return frame_buffer;}
|
||||
};//class Framebuffer
|
||||
|
||||
Framebuffer *CreateFramebuffer(Device *,RenderPass *,VkImageView color,VkImageView depth);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include"VKInstance.h"
|
||||
#include"VKSurfaceExtensionName.h"
|
||||
#include<hgl/type/DataType.h>
|
||||
#include"VKPhysicalDevice.h"
|
||||
#include<iostream>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
@ -5,9 +5,11 @@
|
||||
#include<hgl/type/List.h>
|
||||
#include"Window.h"
|
||||
#include"VK.h"
|
||||
#include"VKDevice.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct PhysicalDevice;
|
||||
class Device;
|
||||
|
||||
class Instance
|
||||
{
|
||||
VkInstance inst;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include"VKPipeline.h"
|
||||
#include"VKDevice.h"
|
||||
#include"VKShader.h"
|
||||
#include"VKVertexInput.h"
|
||||
#include"VKRenderPass.h"
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define HGL_GRAPH_VULKAN_PIPELINE_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
#include"VKDevice.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Device;
|
||||
class RenderPass;
|
||||
|
||||
class Pipeline
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include"VKPipelineLayout.h"
|
||||
#include"VKDescriptorSetLayout.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
PipelineLayout::~PipelineLayout()
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define HGL_GRAPH_VULKAN_PIPELINE_LAYOUT_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
#include"VKDescriptorSetLayout.h"
|
||||
VK_NAMESPACE_BEGIN
|
||||
class DescriptorSetLayout;
|
||||
class PipelineLayout
|
||||
{
|
||||
VkDevice device;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include"VKVertexInput.h"
|
||||
#include"VKBuffer.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
bool VertexInput::Add(VertexBuffer *buf,bool instance)
|
||||
|
@ -2,8 +2,9 @@
|
||||
#define HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
|
||||
|
||||
#include"VK.h"
|
||||
#include"VKBuffer.h"
|
||||
VK_NAMESPACE_BEGIN
|
||||
class VertexBuffer;
|
||||
|
||||
/**
|
||||
* 顶点输入配置,类似于OpenGL的VAB<br>
|
||||
* 注:本引擎不支持一个BUFFER中包括多种数据
|
||||
|
@ -1,11 +1,15 @@
|
||||
#include"Window.h"
|
||||
#include"VKInstance.h"
|
||||
#include"VKPhysicalDevice.h"
|
||||
#include"VKDevice.h"
|
||||
#include"VKBuffer.h"
|
||||
#include"VKShader.h"
|
||||
#include"VKVertexInput.h"
|
||||
#include"VKDescriptorSetLayout.h"
|
||||
#include"VKRenderPass.h"
|
||||
#include"VKPipelineLayout.h"
|
||||
#include"VKPipeline.h"
|
||||
#include"VKCommandBuffer.h"
|
||||
|
||||
#include<io.h>
|
||||
#include<fcntl.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user