Added GraphManager/TextureManager, moved few codes to they are.
This commit is contained in:
parent
983281f6ad
commit
2221e10750
@ -44,6 +44,12 @@ struct Swapchain;
|
||||
class RenderTarget;
|
||||
class RTSwapchain;
|
||||
|
||||
struct CopyBufferToImageInfo;
|
||||
struct TextureData;
|
||||
struct TextureCreateInfo;
|
||||
|
||||
struct Image2DRegion;
|
||||
|
||||
class Texture;
|
||||
class Texture1D;
|
||||
class Texture1DArray;
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/RectScope.h>
|
||||
#include<hgl/graph/ImageRegion.h>
|
||||
#include<hgl/platform/Window.h>
|
||||
#include<hgl/graph/BitmapData.h>
|
||||
#include<hgl/graph/font/Font.h>
|
||||
@ -43,9 +41,6 @@ private:
|
||||
|
||||
GPUDeviceAttribute *attr;
|
||||
|
||||
DeviceQueue *texture_queue;
|
||||
TextureCmdBuffer *texture_cmd_buf;
|
||||
|
||||
private:
|
||||
|
||||
DeviceRenderPassManage *render_pass_manage;
|
||||
@ -171,60 +166,6 @@ public: //间接绘制
|
||||
IndirectDrawIndexedBuffer * CreateIndirectDrawIndexedBuffer(const uint32_t cmd_count,SharingMode sm=SharingMode::Exclusive);
|
||||
IndirectDispatchBuffer * CreateIndirectDispatchBuffer( const uint32_t cmd_count,SharingMode sm=SharingMode::Exclusive);
|
||||
|
||||
public: //Image
|
||||
|
||||
VkImage CreateImage (VkImageCreateInfo *);
|
||||
void DestroyImage (VkImage);
|
||||
|
||||
private: //texture
|
||||
|
||||
bool CopyBufferToImage (const CopyBufferToImageInfo *info,VkPipelineStageFlags destinationStage);
|
||||
|
||||
bool CopyBufferToImage (Texture *,DeviceBuffer *buf,const VkBufferImageCopy *,const int count,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags);//=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
bool CopyBufferToImage2D (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic_list,const int bic_count, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic_list, bic_count, 0,1,dstStage);}
|
||||
bool CopyBufferToImage2D (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic, 1, 0,1,dstStage);}
|
||||
|
||||
bool CopyBufferToImageCube (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic_list,const int bic_count, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic_list, bic_count, 0,6,dstStage);}
|
||||
bool CopyBufferToImageCube (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic, 1, 0,6,dstStage);}
|
||||
|
||||
bool CommitTexture2D (Texture2D *,DeviceBuffer *buf,VkPipelineStageFlags stage);
|
||||
bool CommitTexture2DMipmaps (Texture2D *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool CommitTextureCube (TextureCube *,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags stage);
|
||||
bool CommitTextureCubeMipmaps (TextureCube *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool SubmitTexture (const VkCommandBuffer *cmd_bufs,const uint32_t count=1); ///<提交纹理处理到队列
|
||||
|
||||
public: //Texture
|
||||
|
||||
bool CheckFormatSupport(const VkFormat,const uint32_t bits,ImageTiling tiling=ImageTiling::Optimal)const;
|
||||
|
||||
bool CheckTextureFormatSupport(const VkFormat fmt,ImageTiling tiling=ImageTiling::Optimal)const{return CheckFormatSupport(fmt,VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT,tiling);}
|
||||
|
||||
bool CheckColorAttachmentFormatSupport(const VkFormat fmt)const{return CheckFormatSupport(fmt,VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT,ImageTiling::Optimal);}
|
||||
bool CheckDepthStencilAttachFormatSupport(const VkFormat fmt)const{return CheckFormatSupport(fmt,VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT,ImageTiling::Optimal);}
|
||||
|
||||
Texture2D *CreateTexture2D(TextureData *);
|
||||
Texture2D *CreateTexture2D(TextureCreateInfo *ci);
|
||||
|
||||
Texture2DArray *CreateTexture2DArray(TextureData *);
|
||||
Texture2DArray *CreateTexture2DArray(TextureCreateInfo *ci);
|
||||
Texture2DArray *CreateTexture2DArray(const uint32_t w,const uint32_t h,const uint32 l,const VkFormat fmt,const bool mipmaps);
|
||||
|
||||
TextureCube *CreateTextureCube(TextureData *);
|
||||
TextureCube *CreateTextureCube(TextureCreateInfo *ci);
|
||||
|
||||
void Clear(TextureCreateInfo *);
|
||||
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const List<Image2DRegion> &,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,void *data,const uint32_t size,const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
// bool ChangeTexture2DArray(Texture2DArray *,DeviceBuffer *buf, const List<Image2DRegion> &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2DArray(Texture2DArray *,DeviceBuffer *buf, const RectScope2ui &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2DArray(Texture2DArray *,void *data,const uint32_t size,const RectScope2ui &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
public: //
|
||||
|
||||
Sampler *CreateSampler(VkSamplerCreateInfo *sci=nullptr);
|
||||
|
@ -11,8 +11,6 @@ public:
|
||||
|
||||
VkDevice device =VK_NULL_HANDLE;
|
||||
|
||||
VkExtent2D extent;
|
||||
|
||||
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
||||
|
||||
uint32_t color_count =0;
|
||||
|
26
inc/hgl/graph/manager/GraphManager.h
Normal file
26
inc/hgl/graph/manager/GraphManager.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class GraphManager
|
||||
{
|
||||
GPUDevice *device;
|
||||
|
||||
public:
|
||||
|
||||
VkDevice GetVkDevice (); ///<取得Vulkan设备句柄
|
||||
GPUDevice * GetDevice ()noexcept{return device;} ///<取得GPU设备指针
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const; ///<取得GPU物理设备指针
|
||||
|
||||
|
||||
public:
|
||||
|
||||
GraphManager(GPUDevice *dev)
|
||||
{
|
||||
device=dev;
|
||||
}
|
||||
};//class GraphManager
|
||||
|
||||
VK_NAMESPACE_END
|
85
inc/hgl/graph/manager/TextureManager.h
Normal file
85
inc/hgl/graph/manager/TextureManager.h
Normal file
@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/manager/GraphManager.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/type/IDName.h>
|
||||
#include<hgl/type/RectScope.h>
|
||||
#include<hgl/graph/ImageRegion.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class TextureManager:public GraphManager
|
||||
{
|
||||
SortedSets<Texture *> texture_list;
|
||||
|
||||
DeviceQueue *texture_queue;
|
||||
TextureCmdBuffer *texture_cmd_buf;
|
||||
|
||||
protected:
|
||||
|
||||
DeviceBuffer *CreateTransferSourceBuffer(const VkDeviceSize,const void *data_ptr=nullptr);
|
||||
|
||||
public:
|
||||
|
||||
TextureManager();
|
||||
virtual ~TextureManager();
|
||||
|
||||
public: //Image
|
||||
|
||||
VkImage CreateImage (VkImageCreateInfo *);
|
||||
void DestroyImage (VkImage);
|
||||
|
||||
private: //texture
|
||||
|
||||
bool CopyBufferToImage (const CopyBufferToImageInfo *info,VkPipelineStageFlags destinationStage);
|
||||
|
||||
bool CopyBufferToImage (Texture *,DeviceBuffer *buf,const VkBufferImageCopy *,const int count,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags);//=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
bool CopyBufferToImage2D (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic_list,const int bic_count, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic_list, bic_count, 0,1,dstStage);}
|
||||
bool CopyBufferToImage2D (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic, 1, 0,1,dstStage);}
|
||||
|
||||
bool CopyBufferToImageCube (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic_list,const int bic_count, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic_list, bic_count, 0,6,dstStage);}
|
||||
bool CopyBufferToImageCube (Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *bic, VkPipelineStageFlags dstStage){return CopyBufferToImage(tex,buf,bic, 1, 0,6,dstStage);}
|
||||
|
||||
bool CommitTexture2D (Texture2D *,DeviceBuffer *buf,VkPipelineStageFlags stage);
|
||||
bool CommitTexture2DMipmaps (Texture2D *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool CommitTextureCube (TextureCube *,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags stage);
|
||||
bool CommitTextureCubeMipmaps (TextureCube *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool SubmitTexture (const VkCommandBuffer *cmd_bufs,const uint32_t count=1); ///<提交纹理处理到队列
|
||||
|
||||
public: //Format
|
||||
|
||||
bool CheckFormatSupport(const VkFormat,const uint32_t bits,ImageTiling tiling=ImageTiling::Optimal)const;
|
||||
|
||||
bool CheckTextureFormatSupport(const VkFormat fmt,ImageTiling tiling=ImageTiling::Optimal)const{return CheckFormatSupport(fmt,VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT,tiling);}
|
||||
|
||||
bool CheckColorAttachmentFormatSupport(const VkFormat fmt)const{return CheckFormatSupport(fmt,VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT,ImageTiling::Optimal);}
|
||||
bool CheckDepthStencilAttachFormatSupport(const VkFormat fmt)const{return CheckFormatSupport(fmt,VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT,ImageTiling::Optimal);}
|
||||
|
||||
public: //Create/Chagne
|
||||
|
||||
Texture2D *CreateTexture2D(TextureData *);
|
||||
Texture2D *CreateTexture2D(TextureCreateInfo *ci);
|
||||
|
||||
Texture2DArray *CreateTexture2DArray(TextureData *);
|
||||
Texture2DArray *CreateTexture2DArray(TextureCreateInfo *ci);
|
||||
Texture2DArray *CreateTexture2DArray(const uint32_t w,const uint32_t h,const uint32 l,const VkFormat fmt,const bool mipmaps);
|
||||
|
||||
TextureCube *CreateTextureCube(TextureData *);
|
||||
TextureCube *CreateTextureCube(TextureCreateInfo *ci);
|
||||
|
||||
void Clear(TextureCreateInfo *);
|
||||
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const List<Image2DRegion> &,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,const void *data,const VkDeviceSize size, const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
// bool ChangeTexture2DArray(Texture2DArray *,DeviceBuffer *buf, const List<Image2DRegion> &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2DArray(Texture2DArray *,DeviceBuffer *buf, const RectScope2ui &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2DArray(Texture2DArray *,const void *data,const VkDeviceSize size,const RectScope2ui &, const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
};//class TextureManager
|
||||
|
||||
VK_NAMESPACE_END
|
@ -19,7 +19,7 @@ public:
|
||||
GraphModuleManager(GPUDevice *dev){device=dev;}
|
||||
~GraphModuleManager();
|
||||
|
||||
GPUDevice *GetDevice(){return device;} ///<取得GPU设备
|
||||
GPUDevice *GetDevice()noexcept{return device;} ///<取得GPU设备
|
||||
|
||||
/**
|
||||
* 获取指定名称的模块
|
||||
|
@ -276,12 +276,12 @@ SOURCE_GROUP("Scene Graph\\Component" FILES ${SG_COMPONENT_HEADER} ${SG_COMPONEN
|
||||
|
||||
#-GraphModule,RenderFramework-------------------------------------------
|
||||
|
||||
SET(SGM_HEADER_PATH ${SG_INCLUDE_PATH}/module)
|
||||
SET(SG_MODULE_HEADER_PATH ${SG_INCLUDE_PATH}/module)
|
||||
|
||||
SET(GRAPH_MODULE_HEADER ${SGM_HEADER_PATH}/GraphModule.h
|
||||
${SGM_HEADER_PATH}/GraphModuleFactory.h
|
||||
${SGM_HEADER_PATH}/RenderModule.h
|
||||
${SGM_HEADER_PATH}/SwapchainModule.h)
|
||||
SET(GRAPH_MODULE_HEADER ${SG_MODULE_HEADER_PATH}/GraphModule.h
|
||||
${SG_MODULE_HEADER_PATH}/GraphModuleFactory.h
|
||||
${SG_MODULE_HEADER_PATH}/RenderModule.h
|
||||
${SG_MODULE_HEADER_PATH}/SwapchainModule.h)
|
||||
|
||||
SET(GRAPH_MODULE_SOURCE module/GraphModule.cpp
|
||||
module/GraphModuleManager.cpp
|
||||
@ -290,12 +290,22 @@ SET(GRAPH_MODULE_SOURCE module/GraphModule.cpp
|
||||
module/RegistryCommonModule.cpp
|
||||
module/SwapchainModule.cpp)
|
||||
|
||||
SOURCE_GROUP("Render Framework\\Module" FILES ${GRAPH_MODULE_HEADER}
|
||||
${GRAPH_MODULE_SOURCE})
|
||||
|
||||
SET(SG_MANAGER_HEADER_PATH ${SG_INCLUDE_PATH}/manager)
|
||||
|
||||
SET(GRAPH_MANAGER_HEADER ${SG_MANAGER_HEADER_PATH}/GraphManager.h
|
||||
${SG_MANAGER_HEADER_PATH}/TextureManager.h)
|
||||
SET(GRAPH_MANAGER_SOURCE manager/GraphManager.cpp
|
||||
manager/TextureManager.cpp)
|
||||
|
||||
SOURCE_GROUP("Render Framework\\Manager" FILES ${GRAPH_MANAGER_HEADER} ${GRAPH_MANAGER_SOURCE})
|
||||
|
||||
SET(RENDER_FRAMEWORK_FILES ${SG_INCLUDE_PATH}/RenderFramework.h
|
||||
RenderFramework.cpp)
|
||||
|
||||
SOURCE_GROUP("Render Framework" FILES ${GRAPH_MODULE_HEADER}
|
||||
${GRAPH_MODULE_SOURCE}
|
||||
${RENDER_FRAMEWORK_FILES})
|
||||
SOURCE_GROUP("Render Framework" FILES ${RENDER_FRAMEWORK_FILES})
|
||||
|
||||
SET(DEFERRED_RENDER_HEADER ${SG_INCLUDE_PATH}/deferred/GBufferFormat.h)
|
||||
SET(DEFERRED_RENDER_SOURCE deferred/GBufferFormat.cpp)
|
||||
@ -372,6 +382,9 @@ add_cm_library(ULRE.SceneGraph "ULRE" ${SCENE_GRAPH_HEADER} ${SCENE_GRAPH_SOUR
|
||||
${VULKAN_RENDER_SOURCE}
|
||||
${VULKAN_SURFACE_SOURCE}
|
||||
|
||||
${GRAPH_MODULE_HEADER} ${GRAPH_MODULE_SOURCE} ${RENDER_FRAMEWORK_FILES}
|
||||
${GRAPH_MODULE_HEADER} ${GRAPH_MODULE_SOURCE}
|
||||
${GRAPH_MANAGER_HEADER} ${GRAPH_MANAGER_SOURCE}
|
||||
${RENDER_FRAMEWORK_FILES}
|
||||
|
||||
${DEFERRED_RENDER_HEADER} ${DEFERRED_RENDER_SOURCE}
|
||||
)
|
||||
|
@ -67,4 +67,4 @@ void GenerateMipmaps(TextureCmdBuffer *texture_cmd_buf,VkImage image,VkImageAspe
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
subresourceRange);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
VK_NAMESPACE_END
|
||||
|
@ -1,12 +1,22 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/manager/TextureManager.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
#include"CopyBufferToImage.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
bool GPUDevice::CheckFormatSupport(const VkFormat format,const uint32_t bits,ImageTiling tiling) const
|
||||
|
||||
DeviceBuffer *TextureManager::CreateTransferSourceBuffer(const VkDeviceSize size,const void *data)
|
||||
{
|
||||
const VkFormatProperties fp=attr->physical_device->GetFormatProperties(format);
|
||||
if(size<=0)
|
||||
return(nullptr);
|
||||
|
||||
return GetDevice()->CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
|
||||
}
|
||||
|
||||
bool TextureManager::CheckFormatSupport(const VkFormat format,const uint32_t bits,ImageTiling tiling) const
|
||||
{
|
||||
const VkFormatProperties fp=GetPhysicalDevice()->GetFormatProperties(format);
|
||||
|
||||
if(tiling==ImageTiling::Optimal)
|
||||
return(fp.optimalTilingFeatures&bits);
|
||||
@ -14,7 +24,7 @@ bool GPUDevice::CheckFormatSupport(const VkFormat format,const uint32_t bits,Ima
|
||||
return(fp.linearTilingFeatures&bits);
|
||||
}
|
||||
|
||||
void GPUDevice::Clear(TextureCreateInfo *tci)
|
||||
void TextureManager::Clear(TextureCreateInfo *tci)
|
||||
{
|
||||
if(!tci)return;
|
||||
|
||||
@ -25,7 +35,7 @@ void GPUDevice::Clear(TextureCreateInfo *tci)
|
||||
delete tci;
|
||||
}
|
||||
|
||||
bool GPUDevice::CopyBufferToImage(const CopyBufferToImageInfo *info,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::CopyBufferToImage(const CopyBufferToImageInfo *info,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!info)
|
||||
return(false);
|
||||
@ -75,7 +85,7 @@ bool GPUDevice::CopyBufferToImage(const CopyBufferToImageInfo *info,VkPipelineSt
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool GPUDevice::CopyBufferToImage(Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *buffer_image_copy,const int count,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::CopyBufferToImage(Texture *tex,DeviceBuffer *buf,const VkBufferImageCopy *buffer_image_copy,const int count,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf)
|
||||
return(false);
|
||||
@ -97,7 +107,7 @@ bool GPUDevice::CopyBufferToImage(Texture *tex,DeviceBuffer *buf,const VkBufferI
|
||||
return CopyBufferToImage(&info,destinationStage);
|
||||
}
|
||||
|
||||
bool GPUDevice::SubmitTexture(const VkCommandBuffer *cmd_bufs,const uint32_t count)
|
||||
bool TextureManager::SubmitTexture(const VkCommandBuffer *cmd_bufs,const uint32_t count)
|
||||
{
|
||||
if(!cmd_bufs||count<=0)
|
||||
return(false);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/manager/TextureManager.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKImageCreateInfo.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
@ -7,15 +8,15 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
void GenerateMipmaps(TextureCmdBuffer *texture_cmd_buf,VkImage image,VkImageAspectFlags aspect_mask,VkExtent3D extent,const uint32_t mipLevels,const uint32_t layer_count);
|
||||
|
||||
Texture2D *GPUDevice::CreateTexture2D(TextureData *tex_data)
|
||||
Texture2D *TextureManager::CreateTexture2D(TextureData *tex_data)
|
||||
{
|
||||
if(!tex_data)
|
||||
return(nullptr);
|
||||
|
||||
return(new Texture2D(attr->device,tex_data));
|
||||
return(new Texture2D(GetVulkanDevice(),tex_data));
|
||||
}
|
||||
|
||||
Texture2D *GPUDevice::CreateTexture2D(TextureCreateInfo *tci)
|
||||
Texture2D *TextureManager::CreateTexture2D(TextureCreateInfo *tci)
|
||||
{
|
||||
if(!tci)return(nullptr);
|
||||
|
||||
@ -39,11 +40,11 @@ Texture2D *GPUDevice::CreateTexture2D(TextureCreateInfo *tci)
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
tci->memory=CreateMemory(tci->image);
|
||||
tci->memory=GetDevice()->CreateMemory(tci->image);
|
||||
}
|
||||
|
||||
if(!tci->image_view)
|
||||
tci->image_view=CreateImageView2D(attr->device,tci->format,tci->extent,tci->target_mipmaps,tci->aspect,tci->image);
|
||||
tci->image_view=CreateImageView2D(GetVulkanDevice(),tci->format,tci->extent,tci->target_mipmaps,tci->aspect,tci->image);
|
||||
|
||||
TextureData *tex_data=new TextureData(tci);
|
||||
|
||||
@ -56,7 +57,7 @@ Texture2D *GPUDevice::CreateTexture2D(TextureCreateInfo *tci)
|
||||
}
|
||||
|
||||
if((!tci->buffer)&&tci->pixels&&tci->total_bytes>0)
|
||||
tci->buffer=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,tci->total_bytes,tci->pixels);
|
||||
tci->buffer=CreateTransferSourceBuffer(tci->total_bytes,tci->pixels);
|
||||
|
||||
if(tci->buffer)
|
||||
{
|
||||
@ -89,7 +90,7 @@ Texture2D *GPUDevice::CreateTexture2D(TextureCreateInfo *tci)
|
||||
return tex;
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTexture2D(Texture2D *tex,DeviceBuffer *buf,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::CommitTexture2D(Texture2D *tex,DeviceBuffer *buf,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf)return(false);
|
||||
|
||||
@ -98,7 +99,7 @@ bool GPUDevice::CommitTexture2D(Texture2D *tex,DeviceBuffer *buf,VkPipelineStage
|
||||
return CopyBufferToImage2D(tex,buf,&buffer_image_copy,destinationStage);
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTexture2DMipmaps(Texture2D *tex,DeviceBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
bool TextureManager::CommitTexture2DMipmaps(Texture2D *tex,DeviceBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
{
|
||||
if(!tex||!buf
|
||||
||extent.width*extent.height<=0)
|
||||
@ -144,7 +145,7 @@ bool GPUDevice::CommitTexture2DMipmaps(Texture2D *tex,DeviceBuffer *buf,const Vk
|
||||
return CopyBufferToImage2D(tex,buf,buffer_image_copy,miplevel,VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
}
|
||||
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const List<Image2DRegion> &ir_list,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const List<Image2DRegion> &ir_list,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf||ir_list.GetCount()<=0)
|
||||
return(false);
|
||||
@ -184,7 +185,7 @@ bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const List<Imag
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const RectScope2ui &scope,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const RectScope2ui &scope,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf
|
||||
||scope.GetWidth()<=0
|
||||
@ -202,7 +203,7 @@ bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const RectScope
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,void *data,const uint32_t size,const RectScope2ui &scope,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::ChangeTexture2D(Texture2D *tex,const void *data,const VkDeviceSize size,const RectScope2ui &scope,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!data
|
||||
||size<=0
|
||||
@ -212,7 +213,7 @@ bool GPUDevice::ChangeTexture2D(Texture2D *tex,void *data,const uint32_t size,co
|
||||
||scope.GetBottom()>tex->GetHeight())
|
||||
return(false);
|
||||
|
||||
DeviceBuffer *buf=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
|
||||
DeviceBuffer *buf=CreateTransferSourceBuffer(size,data);
|
||||
|
||||
bool result=ChangeTexture2D(tex,buf,scope,destinationStage);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/manager/TextureManager.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKImageCreateInfo.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
@ -7,15 +8,15 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
void GenerateMipmaps(TextureCmdBuffer *texture_cmd_buf,VkImage image,VkImageAspectFlags aspect_mask,VkExtent3D extent,const uint32_t mipLevels,const uint32_t layer_count);
|
||||
|
||||
Texture2DArray *GPUDevice::CreateTexture2DArray(TextureData *tex_data)
|
||||
Texture2DArray *TextureManager::CreateTexture2DArray(TextureData *tex_data)
|
||||
{
|
||||
if(!tex_data)
|
||||
return(nullptr);
|
||||
|
||||
return(new Texture2DArray(attr->device,tex_data));
|
||||
return(new Texture2DArray(GetVkDevice(),tex_data));
|
||||
}
|
||||
|
||||
Texture2DArray *GPUDevice::CreateTexture2DArray(TextureCreateInfo *tci)
|
||||
Texture2DArray *TextureManager::CreateTexture2DArray(TextureCreateInfo *tci)
|
||||
{
|
||||
if(!tci)return(nullptr);
|
||||
|
||||
@ -39,11 +40,11 @@ Texture2DArray *GPUDevice::CreateTexture2DArray(TextureCreateInfo *tci)
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
tci->memory=CreateMemory(tci->image);
|
||||
tci->memory=GetDevice()->CreateMemory(tci->image);
|
||||
}
|
||||
|
||||
if(!tci->image_view)
|
||||
tci->image_view=CreateImageView2DArray(attr->device,tci->format,tci->extent,tci->target_mipmaps,tci->aspect,tci->image);
|
||||
tci->image_view=CreateImageView2DArray(GetVkDevice(),tci->format,tci->extent,tci->target_mipmaps,tci->aspect,tci->image);
|
||||
|
||||
TextureData *tex_data=new TextureData(tci);
|
||||
|
||||
@ -91,7 +92,7 @@ Texture2DArray *GPUDevice::CreateTexture2DArray(TextureCreateInfo *tci)
|
||||
return tex;
|
||||
}
|
||||
|
||||
Texture2DArray *GPUDevice::CreateTexture2DArray(const uint32_t w,const uint32_t h,const uint32 l,const VkFormat fmt,const bool mipmaps)
|
||||
Texture2DArray *TextureManager::CreateTexture2DArray(const uint32_t w,const uint32_t h,const uint32 l,const VkFormat fmt,const bool mipmaps)
|
||||
{
|
||||
if(w*h*l<=0)
|
||||
return(nullptr);
|
||||
@ -204,7 +205,7 @@ Texture2DArray *GPUDevice::CreateTexture2DArray(const uint32_t w,const uint32_t
|
||||
// return result;
|
||||
//}
|
||||
|
||||
bool GPUDevice::ChangeTexture2DArray(Texture2DArray *tex,DeviceBuffer *buf,const RectScope2ui &scope,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::ChangeTexture2DArray(Texture2DArray *tex,DeviceBuffer *buf,const RectScope2ui &scope,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf
|
||||
||base_layer<0
|
||||
@ -224,7 +225,7 @@ bool GPUDevice::ChangeTexture2DArray(Texture2DArray *tex,DeviceBuffer *buf,const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GPUDevice::ChangeTexture2DArray(Texture2DArray *tex,void *data,const uint32_t size,const RectScope2ui &scope,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::ChangeTexture2DArray(Texture2DArray *tex,const void *data,const VkDeviceSize size,const RectScope2ui &scope,const uint32_t base_layer,const uint32_t layer_count,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!data
|
||||
||size<=0
|
||||
@ -236,7 +237,7 @@ bool GPUDevice::ChangeTexture2DArray(Texture2DArray *tex,void *data,const uint32
|
||||
||scope.GetBottom()>tex->GetHeight())
|
||||
return(false);
|
||||
|
||||
DeviceBuffer *buf=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
|
||||
DeviceBuffer *buf=CreateTransferSourceBuffer(size,data);
|
||||
|
||||
bool result=ChangeTexture2DArray(tex,buf,scope,base_layer,layer_count,destinationStage);
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include<hgl/graph/manager/TextureManager.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKImageCreateInfo.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
@ -6,15 +7,15 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
void GenerateMipmaps(TextureCmdBuffer *texture_cmd_buf,VkImage image,VkImageAspectFlags aspect_mask,VkExtent3D extent,const uint32_t mipLevels,const uint32_t layer_count);
|
||||
|
||||
TextureCube *GPUDevice::CreateTextureCube(TextureData *tex_data)
|
||||
TextureCube *TextureManager::CreateTextureCube(TextureData *tex_data)
|
||||
{
|
||||
if(!tex_data)
|
||||
return(nullptr);
|
||||
|
||||
return(new TextureCube(attr->device,tex_data));
|
||||
return(new TextureCube(GetVkDevice(),tex_data));
|
||||
}
|
||||
|
||||
TextureCube *GPUDevice::CreateTextureCube(TextureCreateInfo *tci)
|
||||
TextureCube *TextureManager::CreateTextureCube(TextureCreateInfo *tci)
|
||||
{
|
||||
if(!tci)return(nullptr);
|
||||
|
||||
@ -34,11 +35,11 @@ TextureCube *GPUDevice::CreateTextureCube(TextureCreateInfo *tci)
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
tci->memory=CreateMemory(tci->image);
|
||||
tci->memory=GetDevice()->CreateMemory(tci->image);
|
||||
}
|
||||
|
||||
if(!tci->image_view)
|
||||
tci->image_view=CreateImageViewCube(attr->device,tci->format,tci->extent,tci->target_mipmaps,tci->aspect,tci->image);
|
||||
tci->image_view=CreateImageViewCube(GetVkDevice(),tci->format,tci->extent,tci->target_mipmaps,tci->aspect,tci->image);
|
||||
|
||||
TextureData *tex_data=new TextureData(tci);
|
||||
|
||||
@ -51,24 +52,24 @@ TextureCube *GPUDevice::CreateTextureCube(TextureCreateInfo *tci)
|
||||
}
|
||||
|
||||
if((!tci->buffer)&&tci->pixels&&tci->total_bytes>0)
|
||||
tci->buffer=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,tci->total_bytes,tci->pixels);
|
||||
tci->buffer=CreateTransferSourceBuffer(tci->total_bytes,tci->pixels);
|
||||
|
||||
if(tci->buffer)
|
||||
{
|
||||
texture_cmd_buf->Begin();
|
||||
if(tci->target_mipmaps==tci->origin_mipmaps)
|
||||
{
|
||||
if(tci->target_mipmaps<=1) //本身不含mipmaps,但也不要mipmaps
|
||||
if(tci->target_mipmaps<=1) //本身不含mipmaps,但也不要mipmaps
|
||||
{
|
||||
CommitTextureCube(tex,tci->buffer,tci->mipmap_zero_total_bytes,VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
}
|
||||
else //本身有mipmaps数据
|
||||
else //本身有mipmaps数据
|
||||
{
|
||||
CommitTextureCubeMipmaps(tex,tci->buffer,tci->extent,tci->mipmap_zero_total_bytes);
|
||||
}
|
||||
}
|
||||
else
|
||||
if(tci->origin_mipmaps<=1) //本身不含mipmaps数据,又想要mipmaps
|
||||
if(tci->origin_mipmaps<=1) //本身不含mipmaps数据,又想要mipmaps
|
||||
{
|
||||
CommitTextureCube(tex,tci->buffer,tci->mipmap_zero_total_bytes,VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
GenerateMipmaps(texture_cmd_buf,tex->GetImage(),tex->GetAspect(),tci->extent,tex_data->miplevel,6);
|
||||
@ -84,7 +85,7 @@ TextureCube *GPUDevice::CreateTextureCube(TextureCreateInfo *tci)
|
||||
return tex;
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTextureCube(TextureCube *tex,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags destinationStage)
|
||||
bool TextureManager::CommitTextureCube(TextureCube *tex,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags destinationStage)
|
||||
{
|
||||
if(!tex||!buf||!mipmaps_zero_bytes)return(false);
|
||||
|
||||
@ -93,7 +94,7 @@ bool GPUDevice::CommitTextureCube(TextureCube *tex,DeviceBuffer *buf,const uint3
|
||||
return CopyBufferToImageCube(tex,buf,&buffer_image_copy,destinationStage);
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTextureCubeMipmaps(TextureCube *tex,DeviceBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
bool TextureManager::CommitTextureCubeMipmaps(TextureCube *tex,DeviceBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
{
|
||||
if(!tex||!buf
|
||||
||extent.width*extent.height<=0)
|
||||
@ -216,4 +217,4 @@ bool GPUDevice::CommitTextureCubeMipmaps(TextureCube *tex,DeviceBuffer *buf,cons
|
||||
// delete buf;
|
||||
// return(result);
|
||||
//}
|
||||
VK_NAMESPACE_END
|
||||
VK_NAMESPACE_END
|
||||
|
14
src/SceneGraph/manager/GraphManager.cpp
Normal file
14
src/SceneGraph/manager/GraphManager.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include<hgl/graph/manager/GraphManager.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
VkDevice GraphManager::GetVulkanDevice()
|
||||
{
|
||||
return device->GetDevice();
|
||||
}
|
||||
|
||||
const GPUPhysicalDevice *GraphManager::GetPhysicalDevice()const
|
||||
{
|
||||
return device->GetPhysicalDevice();
|
||||
}
|
||||
VK_NAMESPACE_END
|
0
src/SceneGraph/manager/TextureManager.cpp
Normal file
0
src/SceneGraph/manager/TextureManager.cpp
Normal file
Loading…
x
Reference in New Issue
Block a user