mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 05:49:34 +00:00
Add cycle type to combiner's key. If the same combiner is used with different cycle types, it must be compiled separately for each cycle type.
This commit is contained in:
parent
f5310c4ba7
commit
f2ebb7d1d4
|
@ -253,12 +253,13 @@ void CombinerInfo::update()
|
|||
|
||||
void CombinerInfo::setCombine(u64 _mux )
|
||||
{
|
||||
if (m_pCurrent != NULL && m_pCurrent->getMux() == _mux) {
|
||||
const u64 key = getCombinerKey(_mux);
|
||||
if (m_pCurrent != NULL && m_pCurrent->getKey() == key) {
|
||||
m_bChanged = false;
|
||||
m_pCurrent->update(false);
|
||||
return;
|
||||
}
|
||||
Combiners::const_iterator iter = m_combiners.find(_mux);
|
||||
Combiners::const_iterator iter = m_combiners.find(key);
|
||||
if (iter != m_combiners.end()) {
|
||||
m_pCurrent = iter->second;
|
||||
m_pCurrent->update(false);
|
||||
|
@ -266,7 +267,7 @@ void CombinerInfo::setCombine(u64 _mux )
|
|||
m_pCurrent = _compile(_mux);
|
||||
m_pCurrent->update(true);
|
||||
m_pUniformCollection->bindWithShaderCombiner(m_pCurrent);
|
||||
m_combiners[_mux] = m_pCurrent;
|
||||
m_combiners[m_pCurrent->getKey()] = m_pCurrent;
|
||||
}
|
||||
m_bChanged = true;
|
||||
}
|
||||
|
@ -455,7 +456,7 @@ bool CombinerInfo::_loadShadersStorage()
|
|||
fin >> *m_pCurrent;
|
||||
m_pCurrent->update(true);
|
||||
m_pUniformCollection->bindWithShaderCombiner(m_pCurrent);
|
||||
m_combiners[m_pCurrent->getMux()] = m_pCurrent;
|
||||
m_combiners[m_pCurrent->getKey()] = m_pCurrent;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -175,5 +175,14 @@ ShaderCombiner * currentCombiner() {
|
|||
void Combiner_Init();
|
||||
void Combiner_Destroy();
|
||||
|
||||
inline
|
||||
u64 getCombinerKey(u64 _mux)
|
||||
{
|
||||
gDPCombine cmb;
|
||||
cmb.mux = _mux;
|
||||
cmb.muxs0 |= (gDP.otherMode.cycleType<<24);
|
||||
return cmb.mux;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ void DestroyShaderCombiner() {
|
|||
noiseTex.destroy();
|
||||
}
|
||||
|
||||
ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCombine & _combine) : m_combine(_combine)
|
||||
ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCombine & _combine) : m_key(getCombinerKey(_combine.mux))
|
||||
{
|
||||
std::string strCombiner;
|
||||
m_nInputs = compileCombiner(_color, _alpha, strCombiner);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
void UniformSet::bindWithShaderCombiner(ShaderCombiner * _pCombiner)
|
||||
{
|
||||
const u64 mux = _pCombiner->getMux();
|
||||
const u64 mux = _pCombiner->getKey();
|
||||
const GLuint program = _pCombiner->m_program;
|
||||
m_uniforms.emplace(mux, program);
|
||||
UniformSetLocation & location = m_uniforms.at(mux);
|
||||
|
@ -129,7 +129,7 @@ void UniformSet::_updateLightUniforms(UniformSetLocation & _location, bool _bFor
|
|||
|
||||
void UniformSet::updateUniforms(ShaderCombiner * _pCombiner, OGLRender::RENDER_STATE _renderState)
|
||||
{
|
||||
UniformSetLocation & location = m_uniforms.at(_pCombiner->getMux());
|
||||
UniformSetLocation & location = m_uniforms.at(_pCombiner->getKey());
|
||||
|
||||
_updateColorUniforms(location, false);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
void updateRenderState(bool _bForce = false);
|
||||
void updateScreenCoordsScale(bool _bForce = false);
|
||||
|
||||
u64 getMux() const {return m_combine.mux;}
|
||||
u64 getKey() const {return m_key;}
|
||||
|
||||
bool usesTile(u32 _t) const {
|
||||
if (_t == 0)
|
||||
|
@ -119,7 +119,7 @@ private:
|
|||
void _locate_attributes() const;
|
||||
void _locateUniforms();
|
||||
|
||||
gDPCombine m_combine;
|
||||
u64 m_key;
|
||||
UniformLocation m_uniforms;
|
||||
GLuint m_program;
|
||||
int m_nInputs;
|
||||
|
|
|
@ -301,7 +301,7 @@ ShaderCombiner::ShaderCombiner() : m_bNeedUpdate(true)
|
|||
_locate_attributes();
|
||||
}
|
||||
|
||||
ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCombine & _combine) : m_combine(_combine), m_bNeedUpdate(true)
|
||||
ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCombine & _combine) : m_key(getCombinerKey(_combine.mux)), m_bNeedUpdate(true)
|
||||
{
|
||||
std::string strCombiner;
|
||||
m_nInputs = compileCombiner(_color, _alpha, strCombiner);
|
||||
|
@ -838,7 +838,7 @@ std::ostream & operator<< (std::ostream & _os, const ShaderCombiner & _combiner)
|
|||
if (isGLError())
|
||||
return _os;
|
||||
|
||||
_os.write((char*)&_combiner.m_combine.mux, sizeof(_combiner.m_combine.mux));
|
||||
_os.write((char*)&_combiner.m_key, sizeof(_combiner.m_key));
|
||||
_os.write((char*)&_combiner.m_nInputs, sizeof(_combiner.m_nInputs));
|
||||
_os.write((char*)&binaryFormat, sizeof(binaryFormat));
|
||||
_os.write((char*)&binaryLength, sizeof(binaryLength));
|
||||
|
@ -848,7 +848,7 @@ std::ostream & operator<< (std::ostream & _os, const ShaderCombiner & _combiner)
|
|||
|
||||
std::istream & operator>> (std::istream & _is, ShaderCombiner & _combiner)
|
||||
{
|
||||
_is.read((char*)&_combiner.m_combine.mux, sizeof(_combiner.m_combine.mux));
|
||||
_is.read((char*)&_combiner.m_key, sizeof(_combiner.m_key));
|
||||
_is.read((char*)&_combiner.m_nInputs, sizeof(_combiner.m_nInputs));
|
||||
GLenum binaryFormat;
|
||||
GLint binaryLength;
|
||||
|
|
|
@ -1120,7 +1120,7 @@ void OGLRender::drawTexturedRect(const TexturedRectParams & _params)
|
|||
GLfloat alpha = 0.0f;
|
||||
if (currentCombiner()->usesShade()) {
|
||||
gDPCombine combine;
|
||||
combine.mux = currentCombiner()->getMux();
|
||||
combine.mux = currentCombiner()->getKey();
|
||||
if (combine.mA0 == G_ACMUX_0 && combine.aA0 == G_ACMUX_SHADE)
|
||||
alpha = 1.0f;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user