added CopyBufferToImage.h
This commit is contained in:
parent
7805494ca9
commit
2487cb1f36
84
inc/hgl/graph/RenderResourceType.h
Normal file
84
inc/hgl/graph/RenderResourceType.h
Normal file
@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
enum class ResourceType
|
||||
{
|
||||
Unknown=0,
|
||||
|
||||
VkInstance,
|
||||
VkPhysicalDevice,
|
||||
VkDevice,
|
||||
|
||||
VertexInputLayout,
|
||||
Material,
|
||||
MaterialInstance,
|
||||
|
||||
FrameBuffer,
|
||||
|
||||
Texture,
|
||||
Sampler,
|
||||
|
||||
VertexBuffer,
|
||||
IndexBuffer,
|
||||
IndirectBuffer,
|
||||
UniformBuffer,
|
||||
StorageBuffer,
|
||||
|
||||
Skeleton, ///<骨骼信息
|
||||
SkeletonAnime, ///<骨骼动画信息
|
||||
|
||||
Primitive, ///<原始的单个模型数据,由多个VBO+Index组成
|
||||
RawMesh, ///<原始的静态模型数据,由一个Primitive和一个MaterialInstance组成
|
||||
StaticMesh, ///<静态模型数据,由一个或多个RawMesh组成
|
||||
SkeletonMesh, ///<骨骼模型数据,由一个或多个StaticMesh组成
|
||||
|
||||
Font,
|
||||
|
||||
Scene,
|
||||
Animation,
|
||||
Audio,
|
||||
Other,
|
||||
|
||||
ENUM_CLASS_RANGE(Unknown,Other)
|
||||
};
|
||||
|
||||
enum class ResourcePlace
|
||||
{
|
||||
Unknown=0,
|
||||
|
||||
Memory, ///<内存
|
||||
Device, ///<设备(如显存)
|
||||
Disk, ///<硬盘
|
||||
LAN, ///<局域网
|
||||
WAN, ///<广域网
|
||||
Other,
|
||||
|
||||
ENUM_CLASS_RANGE(Device,Other)
|
||||
};
|
||||
|
||||
struct RenderResourceID
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint device:1; ///<在设备
|
||||
uint memory:1; ///<在内存
|
||||
|
||||
uint disk:1; ///<在硬盘
|
||||
uint network:1; ///<在网络
|
||||
};
|
||||
|
||||
uint8 place; ///<数据所在位置
|
||||
};
|
||||
|
||||
uint16 resource_type; ///<资源类型,对应ResourceType枚举
|
||||
|
||||
uint16 thread_id; ///<线程ID
|
||||
|
||||
uint32 id; ///<资源ID
|
||||
};
|
||||
VK_NAMESPACE_END
|
@ -24,16 +24,7 @@ class TileFont;
|
||||
class FontSource;
|
||||
class GPUArrayBuffer;
|
||||
|
||||
struct CopyBufferToImageInfo
|
||||
{
|
||||
VkImage image;
|
||||
VkBuffer buffer;
|
||||
|
||||
VkImageSubresourceRange isr;
|
||||
|
||||
const VkBufferImageCopy * bic_list;
|
||||
uint32_t bic_count;
|
||||
};
|
||||
struct CopyBufferToImageInfo;
|
||||
|
||||
class GPUDevice
|
||||
{
|
||||
|
60
src/SceneGraph/Vulkan/Texture/CopyBufferToImage.h
Normal file
60
src/SceneGraph/Vulkan/Texture/CopyBufferToImage.h
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
#include"BufferImageCopy2D.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct CopyBufferToImageInfo
|
||||
{
|
||||
VkImage image;
|
||||
VkBuffer buffer;
|
||||
|
||||
VkImageSubresourceRange isr;
|
||||
|
||||
const VkBufferImageCopy * bic_list;
|
||||
uint32_t bic_count;
|
||||
|
||||
public:
|
||||
|
||||
CopyBufferToImageInfo()
|
||||
{
|
||||
hgl_zero(*this);
|
||||
}
|
||||
|
||||
CopyBufferToImageInfo(Texture *tex,VkBuffer buf,const VkBufferImageCopy *bic)
|
||||
{
|
||||
image =tex->GetImage();
|
||||
buffer =buf;
|
||||
|
||||
isr.aspectMask =tex->GetAspect();
|
||||
|
||||
isr.baseMipLevel =0;
|
||||
isr.levelCount =tex->GetMipLevel();
|
||||
|
||||
isr.baseArrayLayer =0;
|
||||
isr.layerCount =1;
|
||||
|
||||
bic_list =bic;
|
||||
bic_count =1;
|
||||
}
|
||||
};
|
||||
|
||||
struct CopyBufferToImageMipmapsInfo:public CopyBufferToImageInfo
|
||||
{
|
||||
CopyBufferToImageMipmapsInfo(Texture2D *tex,VkBuffer buf,const VkBufferImageCopy *bic,const uint32_t miplevel)
|
||||
{
|
||||
image =tex->GetImage();
|
||||
buffer =buf;
|
||||
|
||||
isr.aspectMask =tex->GetAspect();
|
||||
|
||||
isr.baseMipLevel =0;
|
||||
isr.levelCount =tex->GetMipLevel();
|
||||
|
||||
isr.baseArrayLayer =0;
|
||||
isr.layerCount =1;
|
||||
|
||||
bic_list =bic;
|
||||
bic_count =miplevel;
|
||||
}
|
||||
};
|
||||
|
||||
VK_NAMESPACE_END
|
@ -1,6 +1,7 @@
|
||||
#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
|
||||
@ -94,52 +95,6 @@ bool GPUDevice::CopyBufferToImage(Texture *tex,DeviceBuffer *buf,const VkBufferI
|
||||
info.bic_count =count;
|
||||
|
||||
return CopyBufferToImage(&info,destinationStage);
|
||||
|
||||
//下面这段是原始能跑的,上面的是走新的接口的,本质一样,待完全测试后,删掉下面的。
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
//ImageSubresourceRange subresourceRange(tex->GetAspect(),tex->GetMipLevel(),layer_count);
|
||||
|
||||
//texture_cmd_buf->ImageMemoryBarrier(tex->GetImage(),
|
||||
// VK_PIPELINE_STAGE_HOST_BIT,
|
||||
// VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
// 0,
|
||||
// VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
// VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
// VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
// subresourceRange);
|
||||
|
||||
//texture_cmd_buf->CopyBufferToImage(
|
||||
// buf->GetBuffer(),
|
||||
// tex->GetImage(),
|
||||
// VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
// count,
|
||||
// buffer_image_copy);
|
||||
|
||||
//if(destinationStage==VK_PIPELINE_STAGE_TRANSFER_BIT) //接下来还有,一般是给自动生成mipmaps
|
||||
//{
|
||||
// //texture_cmd_buf->ImageMemoryBarrier(tex->GetImage(),
|
||||
// // VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
// // VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
// // VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
// // VK_ACCESS_TRANSFER_READ_BIT,
|
||||
// // VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
// // VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
// // subresourceRange);
|
||||
//}
|
||||
//else// if(destinationStage==VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT) //接下来就给fragment shader用了,证明是最后一步
|
||||
//{
|
||||
// texture_cmd_buf->ImageMemoryBarrier(tex->GetImage(),
|
||||
// VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
// VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
// VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
// VK_ACCESS_SHADER_READ_BIT,
|
||||
// VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
// VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
// subresourceRange);
|
||||
//}
|
||||
|
||||
//return(true);
|
||||
}
|
||||
|
||||
bool GPUDevice::SubmitTexture(const VkCommandBuffer *cmd_bufs,const uint32_t count)
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include<hgl/graph/VKImageCreateInfo.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
#include"BufferImageCopy2D.h"
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include"CopyBufferToImage.h"
|
||||
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);
|
||||
|
||||
@ -94,7 +95,9 @@ bool GPUDevice::CommitTexture2D(Texture2D *tex,DeviceBuffer *buf,VkPipelineStage
|
||||
|
||||
BufferImageCopy buffer_image_copy(tex);
|
||||
|
||||
return CopyBufferToImage(tex,buf,&buffer_image_copy,1,1,destinationStage);
|
||||
CopyBufferToImageInfo info(tex,buf->GetBuffer(),&buffer_image_copy);
|
||||
|
||||
return CopyBufferToImage(&info,destinationStage);
|
||||
}
|
||||
|
||||
bool GPUDevice::CommitTexture2DMipmaps(Texture2D *tex,DeviceBuffer *buf,const VkExtent3D &extent,uint32_t total_bytes)
|
||||
@ -140,7 +143,9 @@ bool GPUDevice::CommitTexture2DMipmaps(Texture2D *tex,DeviceBuffer *buf,const Vk
|
||||
if(height>1){height>>=1;total_bytes>>=1;}
|
||||
}
|
||||
|
||||
return CopyBufferToImage(tex,buf,buffer_image_copy,miplevel,1,VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
CopyBufferToImageMipmapsInfo info(tex,buf->GetBuffer(),buffer_image_copy,miplevel);
|
||||
|
||||
return CopyBufferToImage(&info,VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
}
|
||||
|
||||
bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const List<Image2DRegion> &ir_list,VkPipelineStageFlags destinationStage)
|
||||
|
Loading…
x
Reference in New Issue
Block a user