1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-24 21:39:35 +00:00

Replace ShaderCombiner 2

This commit is contained in:
Sergey Lipskiy 2017-01-05 19:37:14 +07:00
parent 9725c527b9
commit 41d0a9ade5
15 changed files with 145 additions and 280 deletions

View File

@ -306,7 +306,6 @@
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramBuilder.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramImpl.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramUniformFactory.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_NoiseTexture.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_Utils.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_Attributes.cpp" />
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_BufferManipulationObjectFactory.cpp" />
@ -340,6 +339,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\N64.cpp" />
<ClCompile Include="..\..\src\NoiseTexture.cpp" />
<ClCompile Include="..\..\src\OGL3X\GLSLCombiner_ogl3x.cpp" />
<ClCompile Include="..\..\src\OpenGL.cpp" />
<ClCompile Include="..\..\src\Performance.cpp" />
@ -446,7 +446,6 @@
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramBuilder.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramImpl.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramUniformFactory.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_NoiseTexture.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_Utils.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_Attributes.h" />
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_BufferManipulationObjectFactory.h" />
@ -466,6 +465,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\..\src\N64.h" />
<ClInclude Include="..\..\src\NoiseTexture.h" />
<ClInclude Include="..\..\src\OGL3X\Shaders_ogl3x.h" />
<ClInclude Include="..\..\src\OpenGL.h" />
<ClInclude Include="..\..\src\Performance.h" />

View File

@ -326,8 +326,8 @@
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerInputs.cpp">
<Filter>Source Files\Graphics\OpenGL\GLSL</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_NoiseTexture.cpp">
<Filter>Source Files\Graphics\OpenGL\GLSL</Filter>
<ClCompile Include="..\..\src\NoiseTexture.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@ -595,11 +595,11 @@
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerProgramUniformFactory.h">
<Filter>Header Files\Graphics\OpenGL\GLSL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_NoiseTexture.h">
<Filter>Header Files\Graphics\OpenGL\GLSL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerInputs.h">
<Filter>Header Files\Graphics\OpenGL\GLSL</Filter>
</ClInclude>
<ClInclude Include="..\..\src\NoiseTexture.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -103,7 +103,6 @@ CombinerInfo & CombinerInfo::get()
void CombinerInfo::init()
{
m_pCurrent = nullptr;
m_pUniformCollection = createUniformCollection();
GLint numBinaryFormats = 0;
#ifdef GL_NUM_PROGRAM_BINARY_FORMATS
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &numBinaryFormats);
@ -122,8 +121,6 @@ void CombinerInfo::init()
void CombinerInfo::destroy()
{
delete m_pUniformCollection;
m_pUniformCollection = nullptr;
m_pCurrent = nullptr;
if (m_bShaderCacheSupported)
_saveShadersStorage();
@ -248,7 +245,6 @@ graphics::CombinerProgram * CombinerInfo::_compile(u64 mux) const
}
}
// return new ShaderCombiner( color, alpha, combine );
return gfxContext.createCombinerProgram(color, alpha, CombinerKey(combine.mux));
}
@ -271,87 +267,21 @@ void CombinerInfo::setCombine(u64 _mux )
const CombinerKey key(_mux);
if (m_pCurrent != nullptr && m_pCurrent->getKey() == key) {
m_bChanged = false;
// m_pCurrent->update(false);
return;
}
Combiners::const_iterator iter = m_combiners.find(key);
if (iter != m_combiners.end()) {
m_pCurrent = iter->second;
// m_pCurrent->update(false);
} else {
m_pCurrent = _compile(_mux);
m_pCurrent->update(true);
// m_pUniformCollection->bindWithShaderCombiner(m_pCurrent);
m_combiners[m_pCurrent->getKey()] = m_pCurrent;
}
m_bChanged = true;
}
void CombinerInfo::updatePrimColor()
void CombinerInfo::updateParameters()
{
return;
if (m_pUniformCollection != nullptr)
m_pUniformCollection->setColorData(UniformCollection::cuPrimColor, sizeof(f32)* 5, &gDP.primColor.r);
}
void CombinerInfo::updateEnvColor()
{
return;
if (m_pUniformCollection != nullptr)
m_pUniformCollection->setColorData(UniformCollection::cuEnvColor, sizeof(f32)* 4, &gDP.envColor.r);
}
void CombinerInfo::updateFogColor()
{
return;
if (m_pUniformCollection != nullptr)
m_pUniformCollection->setColorData(UniformCollection::cuFogColor, sizeof(f32)* 4, &gDP.fogColor.r);
}
void CombinerInfo::updateBlendColor()
{
return;
if (m_pUniformCollection != nullptr)
m_pUniformCollection->setColorData(UniformCollection::cuBlendColor, sizeof(f32)* 4, &gDP.blendColor.r);
}
void CombinerInfo::updateKeyColor()
{
return;
if (m_pUniformCollection != nullptr)
m_pUniformCollection->setColorData(UniformCollection::cuCenterColor, sizeof(f32)* 8, &gDP.key.center.r);
}
void CombinerInfo::updateConvertColor()
{
return;
if (m_pUniformCollection == nullptr)
return;
f32 convert[2] = { gDP.convert.k4*0.0039215689f, gDP.convert.k5*0.0039215689f };
m_pUniformCollection->setColorData(UniformCollection::cuK4, sizeof(convert), convert);
}
void CombinerInfo::updateTextureParameters()
{
return;
if (m_pUniformCollection != nullptr)
m_pUniformCollection->updateTextureParameters();
}
void CombinerInfo::updateLightParameters()
{
return;
if (config.generalEmulation.enableHWLighting != 0) {
if (m_pUniformCollection != nullptr)
m_pUniformCollection->updateLightParameters();
}
gSP.changed ^= CHANGED_HW_LIGHT;
}
void CombinerInfo::updateParameters(OGLRender::RENDER_STATE _renderState)
{
// if (m_pUniformCollection != nullptr)
// m_pUniformCollection->updateUniforms(m_pCurrent, _renderState);
m_pCurrent->update(false);
}

View File

@ -118,8 +118,6 @@ namespace graphics {
class CombinerProgram;
}
class ShaderCombiner;
class UniformCollection;
class CombinerInfo
{
public:
@ -127,8 +125,8 @@ public:
void destroy();
void update();
void setCombine(u64 _mux);
void updateParameters();
// ShaderCombiner * getCurrent() const {return m_pCurrent;}
graphics::CombinerProgram * getCurrent() const { return m_pCurrent; }
bool isChanged() const {return m_bChanged;}
bool isShaderCacheSupported() const { return m_bShaderCacheSupported; }
@ -136,18 +134,6 @@ public:
static CombinerInfo & get();
void updatePrimColor();
void updateEnvColor();
void updateFogColor();
void updateBlendColor();
void updateKeyColor();
void updateConvertColor();
void updateTextureParameters();
void updateLightParameters();
// Update uniforms for GL without UniformBlock support
void updateParameters(OGLRender::RENDER_STATE _renderState);
void setPolygonMode(OGLRender::RENDER_STATE _renderState);
bool isRectMode() const { return m_rectMode; }
@ -164,7 +150,6 @@ private:
void _saveShadersStorage() const;
bool _loadShadersStorage();
u32 _getConfigOptionsBitSet() const;
//ShaderCombiner * _compile(u64 mux) const;
graphics::CombinerProgram * _compile(u64 mux) const;
bool m_bChanged;
@ -173,16 +158,12 @@ private:
u32 m_shadersLoaded;
u32 m_configOptionsBitSet;
// ShaderCombiner * m_pCurrent;
// typedef std::map<CombinerKey, ShaderCombiner *> Combiners;
graphics::CombinerProgram * m_pCurrent;
typedef std::map<CombinerKey, graphics::CombinerProgram *> Combiners;
Combiners m_combiners;
UniformCollection * m_pUniformCollection;
};
inline
//ShaderCombiner * currentCombiner() {
graphics::CombinerProgram * currentCombiner() {
return CombinerInfo::get().getCurrent();
}

View File

@ -2,7 +2,6 @@
#include <Log.h>
#include <Config.h>
#include "glsl_Utils.h"
#include "glsl_NoiseTexture.h"
#include "glsl_CombinerInputs.h"
#include "glsl_CombinerProgramImpl.h"
#include "glsl_CombinerProgramBuilder.h"
@ -1914,9 +1913,7 @@ CombinerProgramBuilder::CombinerProgramBuilder(const opengl::GLInfo & _glinfo)
m_vertexShaderTriangle = _createVertexShader(m_vertexHeader.get(), m_vertexTriangle.get());
m_vertexShaderTexturedRect = _createVertexShader(m_vertexHeader.get(), m_vertexTexturedRect.get());
m_vertexShaderTexturedTriangle = _createVertexShader(m_vertexHeader.get(), m_vertexTexturedTriangle.get());
if (config.generalEmulation.enableNoise != 0)
m_noiseTexture.reset(new NoiseTexture);
m_uniformFactory.reset(new CombinerProgramUniformFactory(_glinfo, m_noiseTexture.get()));
m_uniformFactory.reset(new CombinerProgramUniformFactory(_glinfo));
}
CombinerProgramBuilder::~CombinerProgramBuilder()

View File

@ -11,7 +11,6 @@ namespace graphics {
namespace glsl {
class NoiseTexture;
class CombinerProgramUniformFactory;
class ShaderPart
@ -83,7 +82,6 @@ namespace glsl {
ShaderPartPtr m_shaderN64DepthCompare;
ShaderPartPtr m_shaderN64DepthRender;
std::unique_ptr<NoiseTexture> m_noiseTexture;
std::unique_ptr<CombinerProgramUniformFactory> m_uniformFactory;
GLuint m_vertexShaderRect;

View File

@ -1,8 +1,8 @@
#include <Config.h>
#include "glsl_CombinerProgramUniformFactory.h"
#include "glsl_NoiseTexture.h"
#include <Textures.h>
#include <NoiseTexture.h>
#include <FrameBuffer.h>
#include <GBI.h>
#include <RSP.h>
@ -327,18 +327,13 @@ private:
class UDitherMode : public UniformGroup
{
public:
UDitherMode(GLuint _program, bool _usesNoise, NoiseTexture * _noiseTexture)
UDitherMode(GLuint _program, bool _usesNoise)
: m_usesNoise(m_usesNoise)
, m_noiseTexture(_noiseTexture)
{
LocateUniform(uAlphaCompareMode);
LocateUniform(uAlphaDitherMode);
LocateUniform(uColorDitherMode);
}
~UDitherMode()
{
m_noiseTexture = nullptr;
}
void update(bool _force) override
{
@ -355,8 +350,8 @@ public:
bool updateNoiseTex = m_usesNoise;
updateNoiseTex |= (gDP.otherMode.cycleType < G_CYC_COPY) && (gDP.otherMode.colorDither == G_CD_NOISE || gDP.otherMode.alphaDither == G_AD_NOISE || gDP.otherMode.alphaCompare == G_AC_DITHER);
if (updateNoiseTex && m_noiseTexture != nullptr)
m_noiseTexture->update();
if (updateNoiseTex)
g_noiseTexture.update();
}
private:
@ -364,7 +359,6 @@ private:
iUniform uAlphaDitherMode;
iUniform uColorDitherMode;
bool m_usesNoise;
NoiseTexture * m_noiseTexture;
};
class UScreenScale : public UniformGroup
@ -806,7 +800,7 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
}
}
_uniforms.emplace_back(new UDitherMode(_program, _inputs.usesNoise(), m_noiseTexture));
_uniforms.emplace_back(new UDitherMode(_program, _inputs.usesNoise()));
_uniforms.emplace_back(new UScreenScale(_program));
@ -846,16 +840,13 @@ void CombinerProgramUniformFactory::buildUniforms(GLuint _program,
_uniforms.emplace_back(new ULights(_program));
}
CombinerProgramUniformFactory::CombinerProgramUniformFactory(const opengl::GLInfo & _glInfo,
NoiseTexture * _noiseTexture)
CombinerProgramUniformFactory::CombinerProgramUniformFactory(const opengl::GLInfo & _glInfo)
: m_glInfo(_glInfo)
, m_noiseTexture(_noiseTexture)
{
}
CombinerProgramUniformFactory::~CombinerProgramUniformFactory()
{
m_noiseTexture = nullptr;
}
}

View File

@ -4,19 +4,16 @@
namespace glsl {
class NoiseTexture;
class CombinerProgramUniformFactory
{
public:
CombinerProgramUniformFactory(const opengl::GLInfo & _glInfo, NoiseTexture * _noiseTexture);
CombinerProgramUniformFactory(const opengl::GLInfo & _glInfo);
~CombinerProgramUniformFactory();
void buildUniforms(GLuint _program, const CombinerInputs & _inputs, bool _rect, UniformGroups & _uniforms);
private:
const opengl::GLInfo & m_glInfo;
NoiseTexture * m_noiseTexture;
};
}

View File

@ -1,116 +0,0 @@
#include "glsl_NoiseTexture.h"
#include <Graphics/Context.h>
#include <Graphics/Parameters.h>
#include <Config.h>
#include <GBI.h>
#include <VI.h>
#include <Textures.h>
namespace glsl {
struct PBOBinder {
PBOBinder(GLenum _target, GLuint _PBO) : m_target(_target)
{
glBindBuffer(m_target, _PBO);
}
~PBOBinder() {
glBindBuffer(m_target, 0);
}
GLenum m_target;
};
NoiseTexture::NoiseTexture()
: m_pTexture(nullptr)
, m_PBO(0)
, m_DList(0)
{
init();
}
NoiseTexture::~NoiseTexture()
{
destroy();
}
void NoiseTexture::init()
{
if (config.generalEmulation.enableNoise == 0)
return;
m_pTexture = textureCache().addFrameBufferTexture(false);
m_pTexture->format = G_IM_FMT_RGBA;
m_pTexture->clampS = 1;
m_pTexture->clampT = 1;
m_pTexture->frameBufferTexture = CachedTexture::fbOneSample;
m_pTexture->maskS = 0;
m_pTexture->maskT = 0;
m_pTexture->mirrorS = 0;
m_pTexture->mirrorT = 0;
m_pTexture->realWidth = 640;
m_pTexture->realHeight = 580;
m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight;
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
{
graphics::Context::InitTextureParams params;
params.handle = graphics::ObjectHandle(m_pTexture->glName);
params.width = m_pTexture->realWidth;
params.height = m_pTexture->realHeight;
params.internalFormat = graphics::internalcolor::RED;
params.format = graphics::color::RED;
params.dataType = graphics::datatype::UNSIGNED_BYTE;
gfxContext.init2DTexture(params);
}
{
graphics::Context::TexParameters params;
params.handle = graphics::ObjectHandle(m_pTexture->glName);
params.target = graphics::target::TEXTURE_2D;
params.textureUnitIndex = 0;
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
gfxContext.setTextureParameters(params);
}
// TODO rewrite in GL independent way
// Generate Pixel Buffer Object. Initialize it with max buffer size.
glGenBuffers(1, &m_PBO);
PBOBinder binder(GL_PIXEL_UNPACK_BUFFER, m_PBO);
glBufferData(GL_PIXEL_UNPACK_BUFFER, 640 * 580, nullptr, GL_DYNAMIC_DRAW);
}
void NoiseTexture::destroy()
{
if (m_pTexture != nullptr) {
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = nullptr;
}
glDeleteBuffers(1, &m_PBO);
m_PBO = 0;
}
void NoiseTexture::update()
{
if (m_PBO == 0 || m_pTexture == nullptr)
return;
if (m_DList == video().getBuffersSwapCount() || config.generalEmulation.enableNoise == 0)
return;
const u32 dataSize = VI.width*VI.height;
if (dataSize == 0)
return;
PBOBinder binder(GL_PIXEL_UNPACK_BUFFER, m_PBO);
GLubyte* ptr = (GLubyte*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, dataSize, GL_MAP_WRITE_BIT);
if (ptr == nullptr)
return;
for (u32 y = 0; y < VI.height; ++y) {
for (u32 x = 0; x < VI.width; ++x)
ptr[x + y*VI.width] = rand() & 0xFF;
}
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); // release the mapped buffer
glActiveTexture(GL_TEXTURE0 + g_noiseTexIndex);
glBindTexture(GL_TEXTURE_2D, m_pTexture->glName);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VI.width, VI.height, GL_RED, GL_UNSIGNED_BYTE, 0);
m_DList = video().getBuffersSwapCount();
}
}

View File

@ -1,24 +0,0 @@
#pragma once
#include <Types.h>
#include <Graphics/OpenGLContext/GLFunctions.h>
struct CachedTexture;
namespace glsl {
class NoiseTexture
{
public:
NoiseTexture();
~NoiseTexture();
void init();
void destroy();
void update();
private:
CachedTexture * m_pTexture;
GLuint m_PBO;
u32 m_DList;
};
}

97
src/NoiseTexture.cpp Normal file
View File

@ -0,0 +1,97 @@
#include <Graphics/Context.h>
#include <Graphics/Parameters.h>
#include "FrameBuffer.h"
#include "Config.h""
#include "GBI.h"
#include "VI.h""
#include "Textures.h"
#include "NoiseTexture.h"
NoiseTexture g_noiseTexture;
NoiseTexture::NoiseTexture()
: m_pTexture(nullptr)
, m_PBO(0)
, m_DList(0)
{
}
void NoiseTexture::init()
{
if (config.generalEmulation.enableNoise == 0)
return;
m_pTexture = textureCache().addFrameBufferTexture(false);
m_pTexture->format = G_IM_FMT_RGBA;
m_pTexture->clampS = 1;
m_pTexture->clampT = 1;
m_pTexture->frameBufferTexture = CachedTexture::fbOneSample;
m_pTexture->maskS = 0;
m_pTexture->maskT = 0;
m_pTexture->mirrorS = 0;
m_pTexture->mirrorT = 0;
m_pTexture->realWidth = 640;
m_pTexture->realHeight = 580;
m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight;
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
{
graphics::Context::InitTextureParams params;
params.handle = graphics::ObjectHandle(m_pTexture->glName);
params.width = m_pTexture->realWidth;
params.height = m_pTexture->realHeight;
params.internalFormat = graphics::internalcolor::RED;
params.format = graphics::color::RED;
params.dataType = graphics::datatype::UNSIGNED_BYTE;
gfxContext.init2DTexture(params);
}
{
graphics::Context::TexParameters params;
params.handle = graphics::ObjectHandle(m_pTexture->glName);
params.target = graphics::target::TEXTURE_2D;
params.textureUnitIndex = 0;
params.minFilter = graphics::textureParameters::FILTER_NEAREST;
params.magFilter = graphics::textureParameters::FILTER_NEAREST;
gfxContext.setTextureParameters(params);
}
// TODO rewrite in GL independent way
// Generate Pixel Buffer Object. Initialize it with max buffer size.
glGenBuffers(1, &m_PBO);
PBOBinder binder(GL_PIXEL_UNPACK_BUFFER, m_PBO);
glBufferData(GL_PIXEL_UNPACK_BUFFER, 640 * 580, nullptr, GL_DYNAMIC_DRAW);
}
void NoiseTexture::destroy()
{
if (m_pTexture != nullptr) {
textureCache().removeFrameBufferTexture(m_pTexture);
m_pTexture = nullptr;
}
glDeleteBuffers(1, &m_PBO);
m_PBO = 0;
}
void NoiseTexture::update()
{
if (m_PBO == 0 || m_pTexture == nullptr)
return;
if (m_DList == video().getBuffersSwapCount() || config.generalEmulation.enableNoise == 0)
return;
const u32 dataSize = VI.width*VI.height;
if (dataSize == 0)
return;
PBOBinder binder(GL_PIXEL_UNPACK_BUFFER, m_PBO);
GLubyte* ptr = (GLubyte*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, dataSize, GL_MAP_WRITE_BIT);
if (ptr == nullptr)
return;
for (u32 y = 0; y < VI.height; ++y) {
for (u32 x = 0; x < VI.width; ++x)
ptr[x + y*VI.width] = rand() & 0xFF;
}
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); // release the mapped buffer
glActiveTexture(GL_TEXTURE0 + g_noiseTexIndex);
glBindTexture(GL_TEXTURE_2D, m_pTexture->glName);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VI.width, VI.height, GL_RED, GL_UNSIGNED_BYTE, 0);
m_DList = video().getBuffersSwapCount();
}

21
src/NoiseTexture.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include "Types.h"
struct CachedTexture;
class NoiseTexture
{
public:
NoiseTexture();
void init();
void destroy();
void update();
private:
CachedTexture * m_pTexture;
GLuint m_PBO;
u32 m_DList;
};
extern NoiseTexture g_noiseTexture;

View File

@ -45,6 +45,7 @@ static u32 g_paletteCRC256 = 0;
static std::string strFragmentShader;
#if 0
class NoiseTexture
{
public:
@ -144,7 +145,7 @@ void NoiseTexture::update()
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VI.width, VI.height, GL_RED, GL_UNSIGNED_BYTE, 0);
m_DList = video().getBuffersSwapCount();
}
#endif
#ifdef GL_IMAGE_TEXTURES_SUPPORT
static
@ -329,7 +330,7 @@ void DestroyShaderCombiner() {
glDeleteProgram(g_monochrome_image_program);
g_monochrome_image_program = 0;
noiseTex.destroy();
// noiseTex.destroy();
#ifdef GL_IMAGE_TEXTURES_SUPPORT
DestroyZlutTexture();
@ -765,7 +766,7 @@ void ShaderCombiner::updateDitherMode(bool _bForce)
m_uniforms.uScreenScale.set(video().getScaleX(), video().getScaleY(), _bForce);
else
m_uniforms.uScreenScale.set(float(config.frameBufferEmulation.nativeResFactor), float(config.frameBufferEmulation.nativeResFactor), _bForce);
noiseTex.update();
// noiseTex.update();
}
}

View File

@ -27,6 +27,7 @@
#include "SoftwareRender.h"
#include "FBOTextureFormats.h"
#include "TextureFilterHandler.h"
#include "NoiseTexture.h"
#include "Graphics/Context.h"
#include <Graphics/Parameters.h>
@ -521,7 +522,7 @@ void OGLRender::TexrectDrawer::add()
draw();
memcpy(pRect, rect, sizeof(rect));
render._updateTextures(rsTexRect);
CombinerInfo::get().updateParameters(rsTexRect);
CombinerInfo::get().updateParameters();
}
}
@ -1186,8 +1187,6 @@ void OGLRender::_updateTextures(RENDER_STATE _renderState) const
textureCache().activateDummy(t);
}
pCurrentCombiner->updateFrameBufferInfo();
if (pCurrentCombiner->usesTexture() && (_renderState == rsTriangle || _renderState == rsLine))
cmbInfo.updateTextureParameters();
}
gDP.changed &= ~(CHANGED_TILE | CHANGED_TMEM);
gSP.changed &= ~(CHANGED_TEXTURE);
@ -1215,9 +1214,6 @@ void OGLRender::_updateStates(RENDER_STATE _renderState) const
if (gSP.changed & CHANGED_VIEWPORT)
_updateViewport();
if (gSP.changed & CHANGED_HW_LIGHT)
cmbInfo.updateLightParameters();
if ((gSP.changed & CHANGED_TEXTURE) ||
(gDP.changed & (CHANGED_TILE|CHANGED_TMEM)) ||
cmbInfo.isChanged() ||
@ -1230,7 +1226,7 @@ void OGLRender::_updateStates(RENDER_STATE _renderState) const
gDP.changed &= ~(CHANGED_RENDERMODE | CHANGED_CYCLETYPE);
}
cmbInfo.updateParameters(_renderState);
cmbInfo.updateParameters();
#ifndef GLES2
if (gDP.colorImage.address == gDP.depthImageAddress &&
@ -1767,7 +1763,7 @@ void OGLRender::drawTexturedRect(const TexturedRectParams & _params)
cmbInfo.update();
// currentCombiner()->updateRenderState();
_updateTextures(rsTexRect);
cmbInfo.updateParameters(rsTexRect);
cmbInfo.updateParameters();
if (CombinerInfo::get().isChanged())
_setTexCoordArrays();
} else {
@ -2220,6 +2216,7 @@ void OGLRender::_initData()
TextDrawer::get().init();
TFH.init();
PostProcessor::get().init();
g_noiseTexture.init();
perf.reset();
FBInfo::fbInfo.reset();
m_texrectDrawer.init();
@ -2253,6 +2250,7 @@ void OGLRender::_destroyData()
m_renderState = rsNone;
m_texrectDrawer.destroy();
g_noiseTexture.destroy();
PostProcessor::get().destroy();
if (TFH.optionsChanged())
TFH.shutdown();

View File

@ -212,7 +212,6 @@ void gDPSetEnvColor( u32 r, u32 g, u32 b, u32 a )
gDP.envColor.g = g * 0.0039215689f;
gDP.envColor.b = b * 0.0039215689f;
gDP.envColor.a = a * 0.0039215689f;
CombinerInfo::get().updateEnvColor();
#ifdef DEBUG
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_COMBINE, "gDPSetEnvColor( %i, %i, %i, %i );\n",
@ -226,7 +225,6 @@ void gDPSetBlendColor( u32 r, u32 g, u32 b, u32 a )
gDP.blendColor.g = g * 0.0039215689f;
gDP.blendColor.b = b * 0.0039215689f;
gDP.blendColor.a = a * 0.0039215689f;
CombinerInfo::get().updateBlendColor();
gDP.changed |= CHANGED_BLENDCOLOR;
#ifdef DEBUG
@ -241,7 +239,6 @@ void gDPSetFogColor( u32 r, u32 g, u32 b, u32 a )
gDP.fogColor.g = g * 0.0039215689f;
gDP.fogColor.b = b * 0.0039215689f;
gDP.fogColor.a = a * 0.0039215689f;
CombinerInfo::get().updateFogColor();
gDP.changed |= CHANGED_FOGCOLOR;
@ -286,7 +283,6 @@ void gDPSetPrimColor( u32 m, u32 l, u32 r, u32 g, u32 b, u32 a )
gDP.primColor.g = g * 0.0039215689f;
gDP.primColor.b = b * 0.0039215689f;
gDP.primColor.a = a * 0.0039215689f;
CombinerInfo::get().updatePrimColor();
#ifdef DEBUG
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_COMBINE, "gDPSetPrimColor( %i, %i, %i, %i, %i, %i );\n",
@ -814,7 +810,6 @@ void gDPSetConvert( s32 k0, s32 k1, s32 k2, s32 k3, s32 k4, s32 k5 )
gDP.convert.k3 = SIGN(k3, 9);
gDP.convert.k4 = SIGN(k4, 9);
gDP.convert.k5 = SIGN(k5, 9);
CombinerInfo::get().updateConvertColor();
}
void gDPSetKeyR( u32 cR, u32 sR, u32 wR )
@ -832,7 +827,6 @@ void gDPSetKeyGB(u32 cG, u32 sG, u32 wG, u32 cB, u32 sB, u32 wB )
gDP.key.center.b = cB * 0.0039215689f;
gDP.key.scale.b = sB * 0.0039215689f;
gDP.key.width.b = wB * 0.0039215689f;
CombinerInfo::get().updateKeyColor();
}
void gDPTextureRectangle(f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, f32 s, f32 t, f32 dsdx, f32 dtdy , bool flip)