Move BGRA conversion out of upload in GEVulkanTexture
This commit is contained in:
parent
661a57b5fc
commit
3fe53751c4
@ -40,6 +40,7 @@ GEVulkanTexture::GEVulkanTexture(video::IImage* img, const std::string& name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_size = m_orig_size = img->getDimension();
|
m_size = m_orig_size = img->getDimension();
|
||||||
|
convertBGRA(img);
|
||||||
uint8_t* data = (uint8_t*)img->lock();
|
uint8_t* data = (uint8_t*)img->lock();
|
||||||
upload(data);
|
upload(data);
|
||||||
img->unlock();
|
img->unlock();
|
||||||
@ -337,6 +338,8 @@ void GEVulkanTexture::reloadInternal()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_size = texture_image->getDimension();
|
m_size = texture_image->getDimension();
|
||||||
|
|
||||||
|
convertBGRA(texture_image);
|
||||||
if (m_image_mani)
|
if (m_image_mani)
|
||||||
m_image_mani(texture_image);
|
m_image_mani(texture_image);
|
||||||
|
|
||||||
@ -349,15 +352,6 @@ void GEVulkanTexture::reloadInternal()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void GEVulkanTexture::upload(uint8_t* data)
|
void GEVulkanTexture::upload(uint8_t* data)
|
||||||
{
|
{
|
||||||
if (!m_single_channel)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < m_size.Width * m_size.Height; i++)
|
|
||||||
{
|
|
||||||
uint8_t tmp_val = data[i * 4];
|
|
||||||
data[i * 4] = data[i * 4 + 2];
|
|
||||||
data[i * 4 + 2] = tmp_val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!createTextureImage(data))
|
if (!createTextureImage(data))
|
||||||
return;
|
return;
|
||||||
if (!createImageView(VK_IMAGE_ASPECT_COLOR_BIT))
|
if (!createImageView(VK_IMAGE_ASPECT_COLOR_BIT))
|
||||||
@ -457,4 +451,16 @@ void GEVulkanTexture::updateTexture(void* data, video::ECOLOR_FORMAT format,
|
|||||||
vkFreeMemory(m_vulkan_device, staging_buffer_memory, NULL);
|
vkFreeMemory(m_vulkan_device, staging_buffer_memory, NULL);
|
||||||
} // updateTexture
|
} // updateTexture
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void GEVulkanTexture::convertBGRA(video::IImage* img)
|
||||||
|
{
|
||||||
|
uint8_t* data = (uint8_t*)img->lock();
|
||||||
|
for (unsigned int i = 0; i < m_size.Width * m_size.Height; i++)
|
||||||
|
{
|
||||||
|
uint8_t tmp_val = data[i * 4];
|
||||||
|
data[i * 4] = data[i * 4 + 2];
|
||||||
|
data[i * 4 + 2] = tmp_val;
|
||||||
|
}
|
||||||
|
} // convertBGRA
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ private:
|
|||||||
|
|
||||||
const bool m_disable_reload;
|
const bool m_disable_reload;
|
||||||
|
|
||||||
bool m_single_channel;
|
const bool m_single_channel;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool createTextureImage(uint8_t* texture_data);
|
bool createTextureImage(uint8_t* texture_data);
|
||||||
@ -54,6 +54,8 @@ private:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void reloadInternal();
|
void reloadInternal();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
void convertBGRA(video::IImage* img);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
public:
|
public:
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
GEVulkanTexture(const std::string& path,
|
GEVulkanTexture(const std::string& path,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user