mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Fill noise textures data only once on plugin's start.
This commit is contained in:
parent
f6b0f3446b
commit
1cdb1754a6
|
@ -1,4 +1,5 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "GLideNHQ/Ext_TxFilter.h"
|
||||
#include <Graphics/Context.h>
|
||||
#include <Graphics/Parameters.h>
|
||||
|
@ -38,7 +39,8 @@ void displayLoadProgress(const wchar_t *format, ...)
|
|||
|
||||
GraphicsDrawer & drawer = dwnd().getDrawer();
|
||||
drawer.clearColorBuffer(nullptr);
|
||||
drawer.drawText(buf, -0.9f, 0);
|
||||
if (strlen(buf) > 0)
|
||||
drawer.drawText(buf, -0.9f, 0);
|
||||
dwnd().swapBuffers();
|
||||
|
||||
if (pBuffer != nullptr)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#endif
|
||||
|
||||
#include <thread>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
#include <functional>
|
||||
|
@ -31,8 +30,6 @@ NoiseTexture::NoiseTexture()
|
|||
{
|
||||
}
|
||||
|
||||
typedef std::array<std::vector<u8>, NOISE_TEX_NUM> NoiseTexturesData;
|
||||
|
||||
static
|
||||
u32 Rand(u32 rand_value)
|
||||
{
|
||||
|
@ -59,15 +56,12 @@ void FillTextureData(u32 _seed, NoiseTexturesData * _pData, u32 _start, u32 _sto
|
|||
}
|
||||
}
|
||||
|
||||
void NoiseTexture::init()
|
||||
{
|
||||
if (config.generalEmulation.enableNoise == 0)
|
||||
return;
|
||||
|
||||
void NoiseTexture::_fillTextureData()
|
||||
{
|
||||
displayLoadProgress(L"INIT NOISE TEXTURES. PLEASE WAIT...");
|
||||
|
||||
NoiseTexturesData texData;
|
||||
for (auto& vec : texData)
|
||||
for (auto& vec : m_texData)
|
||||
vec.resize(NOISE_TEX_WIDTH * NOISE_TEX_HEIGHT);
|
||||
|
||||
const u32 concurentThreadsSupported = std::thread::hardware_concurrency();
|
||||
|
@ -88,20 +82,32 @@ void NoiseTexture::init()
|
|||
threads.emplace_back(
|
||||
FillTextureData,
|
||||
generator(),
|
||||
&texData,
|
||||
&m_texData,
|
||||
start,
|
||||
std::min(start + chunk, static_cast<u32>(texData.size())));
|
||||
std::min(start + chunk, static_cast<u32>(m_texData.size())));
|
||||
start += chunk;
|
||||
} while (start < NOISE_TEX_NUM - chunk);
|
||||
|
||||
FillTextureData(generator(), &texData, start, texData.size());
|
||||
FillTextureData(generator(), &m_texData, start, m_texData.size());
|
||||
|
||||
for (auto& t : threads)
|
||||
t.join();
|
||||
} else {
|
||||
FillTextureData(static_cast<u32>(time(nullptr)), &texData, 0, texData.size());
|
||||
FillTextureData(static_cast<u32>(time(nullptr)), &m_texData, 0, m_texData.size());
|
||||
}
|
||||
|
||||
displayLoadProgress(L"");
|
||||
}
|
||||
|
||||
|
||||
void NoiseTexture::init()
|
||||
{
|
||||
if (config.generalEmulation.enableNoise == 0)
|
||||
return;
|
||||
|
||||
if (m_texData[0].empty())
|
||||
_fillTextureData();
|
||||
|
||||
for (u32 i = 0; i < NOISE_TEX_NUM; ++i) {
|
||||
m_pTexture[i] = textureCache().addFrameBufferTexture(false);
|
||||
m_pTexture[i]->format = G_IM_FMT_RGBA;
|
||||
|
@ -145,7 +151,7 @@ void NoiseTexture::init()
|
|||
params.height = m_pTexture[i]->realHeight;
|
||||
params.format = fbTexFormats.noiseFormat;
|
||||
params.dataType = fbTexFormats.noiseType;
|
||||
params.data = texData[i].data();
|
||||
params.data = m_texData[i].data();
|
||||
gfxContext.update2DTexture(params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "Types.h"
|
||||
|
||||
#define NOISE_TEX_NUM 30
|
||||
|
||||
struct CachedTexture;
|
||||
typedef std::array<std::vector<u8>, NOISE_TEX_NUM> NoiseTexturesData;
|
||||
|
||||
class NoiseTexture
|
||||
{
|
||||
|
@ -16,9 +19,12 @@ public:
|
|||
void update();
|
||||
|
||||
private:
|
||||
void _fillTextureData();
|
||||
|
||||
CachedTexture * m_pTexture[NOISE_TEX_NUM];
|
||||
u32 m_DList;
|
||||
u32 m_currTex, m_prevTex;
|
||||
NoiseTexturesData m_texData;
|
||||
};
|
||||
|
||||
extern NoiseTexture g_noiseTexture;
|
||||
|
|
Loading…
Reference in New Issue
Block a user