fixed bug at GPUDevice::ChangeTexture2D

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-06-07 20:25:32 +08:00
parent 18850b0e27
commit 8f6260f440
3 changed files with 17 additions and 38 deletions

2
CMCore

@ -1 +1 @@
Subproject commit 97422170df154a9e3067c6e129b01d196e7fa265
Subproject commit 72fcbb18ab3bbd8971777f62ee9fcb967ab25e9e

View File

@ -175,32 +175,9 @@ public: //Texture
void Clear(TextureCreateInfo *);
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const List<Image2DRegion> &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, uint32_t left,uint32_t top,uint32_t width,uint32_t height, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
bool ChangeTexture2D(Texture2D *,void *data, uint32_t left,uint32_t top,uint32_t width,uint32_t height,uint32_t size,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
template<typename T>
bool ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const RectScope2<T> &rs)
{
return ChangeTexture2D( tex,
buf,
rs.GetLeft(),
rs.GetTop(),
rs.GetWidth(),
rs.GetHeight());
}
template<typename T>
bool ChangeTexture2D(Texture2D *tex,void *data,const RectScope2<T> &rs,uint32_t size)
{
return ChangeTexture2D( tex,
data,
rs.GetLeft(),
rs.GetTop(),
rs.GetWidth(),
rs.GetHeight(),
size);
}
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);
public: //

View File

@ -183,15 +183,16 @@ bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const List<Imag
return result;
}
bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height,VkPipelineStageFlags destinationStage)
bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const RectScope2ui &scope,VkPipelineStageFlags destinationStage)
{
if(!tex||!buf
||left<0||left+width>tex->GetWidth()
||top<0||top+height>tex->GetHeight()
||width<=0||height<=0)
||scope.GetWidth()<=0
||scope.GetHeight()<=0
||scope.GetRight()>tex->GetWidth()
||scope.GetBottom()>tex->GetHeight())
return(false);
BufferImageCopy buffer_image_copy(tex);
BufferImageCopy buffer_image_copy(tex,scope);
texture_cmd_buf->Begin();
bool result=CommitTexture(tex,buf,&buffer_image_copy,1,1,destinationStage);
@ -200,18 +201,19 @@ bool GPUDevice::ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,uint32_t left,u
return result;
}
bool GPUDevice::ChangeTexture2D(Texture2D *tex,void *data,uint32_t left,uint32_t top,uint32_t width,uint32_t height,uint32_t size,VkPipelineStageFlags destinationStage)
bool GPUDevice::ChangeTexture2D(Texture2D *tex,void *data,const uint32_t size,const RectScope2ui &scope,VkPipelineStageFlags destinationStage)
{
if(!tex||!data
||left<0||left+width>tex->GetWidth()
||top<0||top+height>tex->GetHeight()
||width<=0||height<=0
||size<=0)
||size<=0
||scope.GetWidth()<=0
||scope.GetHeight()<=0
||scope.GetRight()>tex->GetWidth()
||scope.GetBottom()>tex->GetHeight())
return(false);
DeviceBuffer *buf=CreateBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT,size,data);
bool result=ChangeTexture2D(tex,buf,left,top,width,height,destinationStage);
bool result=ChangeTexture2D(tex,buf,scope,destinationStage);
delete buf;
return(result);