Fix GEVulkanTexture::getTextureData for compressed internal format
This commit is contained in:
parent
b4b0ddc620
commit
93dc6ed770
@ -16,6 +16,9 @@ irr::video::ITexture* createTexture(irr::video::IImage* img,
|
|||||||
irr::video::IImage* getResizedImage(const std::string& path,
|
irr::video::IImage* getResizedImage(const std::string& path,
|
||||||
const irr::core::dimension2d<irr::u32>& max_size,
|
const irr::core::dimension2d<irr::u32>& max_size,
|
||||||
irr::core::dimension2d<irr::u32>* orig_size = NULL);
|
irr::core::dimension2d<irr::u32>* orig_size = NULL);
|
||||||
|
irr::video::IImage* getResizedImageFullPath(const irr::io::path& fullpath,
|
||||||
|
const irr::core::dimension2d<irr::u32>& max_size,
|
||||||
|
irr::core::dimension2d<irr::u32>* orig_size = NULL);
|
||||||
irr::video::IImage* getResizedImage(irr::io::IReadFile* file,
|
irr::video::IImage* getResizedImage(irr::io::IReadFile* file,
|
||||||
const irr::core::dimension2d<irr::u32>& max_size,
|
const irr::core::dimension2d<irr::u32>& max_size,
|
||||||
irr::core::dimension2d<irr::u32>* orig_size = NULL);
|
irr::core::dimension2d<irr::u32>* orig_size = NULL);
|
||||||
|
@ -23,6 +23,19 @@ video::IImage* getResizedImage(const std::string& path,
|
|||||||
return image;
|
return image;
|
||||||
} // getResizedImage
|
} // getResizedImage
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
video::IImage* getResizedImageFullPath(const io::path& fullpath,
|
||||||
|
const core::dimension2d<u32>& max_size,
|
||||||
|
core::dimension2d<u32>* orig_size)
|
||||||
|
{
|
||||||
|
io::IReadFile* file = io::createReadFile(fullpath);
|
||||||
|
if (file == NULL)
|
||||||
|
return NULL;
|
||||||
|
video::IImage* texture_image = getResizedImage(file, max_size, orig_size);
|
||||||
|
file->drop();
|
||||||
|
return texture_image;
|
||||||
|
} // getResizedImageFullPath
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
video::IImage* getResizedImage(irr::io::IReadFile* file,
|
video::IImage* getResizedImage(irr::io::IReadFile* file,
|
||||||
const core::dimension2du& max_size,
|
const core::dimension2du& max_size,
|
||||||
|
@ -413,17 +413,13 @@ void GEVulkanTexture::reloadInternal()
|
|||||||
|
|
||||||
clearVulkanData();
|
clearVulkanData();
|
||||||
|
|
||||||
io::IReadFile* file = io::createReadFile(m_full_path);
|
video::IImage* texture_image = getResizedImageFullPath(m_full_path,
|
||||||
if (file == NULL)
|
m_max_size, &m_orig_size);
|
||||||
{
|
|
||||||
// We checked for file existence so we should always get a file
|
|
||||||
throw std::runtime_error("File missing in getResizedImage");
|
|
||||||
}
|
|
||||||
video::IImage* texture_image = getResizedImage(file, m_max_size,
|
|
||||||
&m_orig_size);
|
|
||||||
if (texture_image == NULL)
|
if (texture_image == NULL)
|
||||||
throw std::runtime_error("Missing texture_image in getResizedImage");
|
{
|
||||||
file->drop();
|
throw std::runtime_error(
|
||||||
|
"Missing texture_image in getResizedImageFullPath");
|
||||||
|
}
|
||||||
|
|
||||||
m_size = texture_image->getDimension();
|
m_size = texture_image->getDimension();
|
||||||
if (m_size.Width < 4 || m_size.Height < 4)
|
if (m_size.Width < 4 || m_size.Height < 4)
|
||||||
@ -480,6 +476,22 @@ void* GEVulkanTexture::lock(video::E_TEXTURE_LOCK_MODE mode, u32 mipmap_level)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
uint8_t* GEVulkanTexture::getTextureData()
|
uint8_t* GEVulkanTexture::getTextureData()
|
||||||
{
|
{
|
||||||
|
if (m_internal_format != VK_FORMAT_R8G8B8A8_UNORM ||
|
||||||
|
m_internal_format != VK_FORMAT_R8_UNORM)
|
||||||
|
{
|
||||||
|
if (m_full_path.empty())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
video::IImage* texture_image = getResizedImageFullPath(m_full_path,
|
||||||
|
m_max_size, &m_orig_size);
|
||||||
|
if (texture_image == NULL)
|
||||||
|
return NULL;
|
||||||
|
texture_image->setDeleteMemory(false);
|
||||||
|
uint8_t* data = (uint8_t*)texture_image->lock();
|
||||||
|
texture_image->drop();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
m_image_view_lock.lock();
|
m_image_view_lock.lock();
|
||||||
m_image_view_lock.unlock();
|
m_image_view_lock.unlock();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user