Avoid unneeded copying in sky box and SH

This commit is contained in:
Benau
2017-01-03 11:08:33 +08:00
parent 19ac8a0d3c
commit 57e16dcb73
6 changed files with 10 additions and 25 deletions

View File

@@ -514,10 +514,12 @@ void Material::install(bool srgb, bool premul_alpha)
// now set the name to the basename, so that all tests work as expected
m_texname = StringUtils::getBasename(m_texname);
#ifndef SERVER_ONLY
if (!CVS->isGLSL() && m_mask.size() > 0)
{
irr_driver->applyMask(m_texture, m_mask);
}
#endif
m_texture->grab();
} // install

View File

@@ -20,6 +20,7 @@
#include "graphics/skybox.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/stk_texture.hpp"
#include "graphics/texture_shader.hpp"
#include <algorithm>
@@ -160,15 +161,8 @@ void Skybox::generateCubeMapFromTextures()
for (unsigned i = 0; i < 6; i++)
{
unsigned idx = texture_permutation[i];
video::IImage* image = irr_driver->getVideoDriver()
->createImageFromData(m_skybox_textures[idx]->getColorFormat(),
m_skybox_textures[idx]->getSize(),
m_skybox_textures[idx]->lock(), false );
m_skybox_textures[idx]->unlock();
image->copyToScaling(rgba[i], size, size);
image->drop();
static_cast<STKTexture*>(m_skybox_textures[idx])->getTextureImage()
->copyToScaling(rgba[i], size, size);
#if defined(USE_GLES2)
for (unsigned int j = 0; j < size * size; j++)

View File

@@ -19,6 +19,7 @@
#include "graphics/irr_driver.hpp"
#include "graphics/spherical_harmonics.hpp"
#include "graphics/stk_texture.hpp"
#include "utils/log.hpp"
#include <algorithm>
@@ -405,17 +406,8 @@ void SphericalHarmonics::setTextures(const std::vector<video::ITexture *> &spher
for (unsigned i = 0; i < 6; i++)
{
unsigned idx = texture_permutation[i];
video::IImage* image = irr_driver->getVideoDriver()->createImageFromData(
m_spherical_harmonics_textures[idx]->getColorFormat(),
m_spherical_harmonics_textures[idx]->getSize(),
m_spherical_harmonics_textures[idx]->lock(),
false
);
m_spherical_harmonics_textures[idx]->unlock();
image->copyToScaling(sh_rgba[i], sh_w, sh_h);
delete image;
static_cast<STKTexture*>(m_spherical_harmonics_textures[idx])
->getTextureImage()->copyToScaling(sh_rgba[i], sh_w, sh_h);
} //for (unsigned i = 0; i < 6; i++)
Color *float_tex_cube[6];

View File

@@ -22,9 +22,6 @@
#include "utils/string_utils.hpp"
#include "utils/log.hpp"
#include <fstream>
#include <sstream>
// ----------------------------------------------------------------------------
STKTexManager::~STKTexManager()
{

View File

@@ -20,8 +20,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "io/file_manager.hpp"
#include "utils/string_utils.hpp"
#include "utils/log.hpp"
#include <fstream>

View File

@@ -110,6 +110,8 @@ public:
unsigned int getTextureSize() const { return m_texture_size; }
// ------------------------------------------------------------------------
void reload(bool no_upload = false, video::IImage* pre_loaded_tex = NULL);
// ------------------------------------------------------------------------
video::IImage* getTextureImage() { return m_texture_image; }
}; // STKTexture