void Combiner_Init() { CombinerInfo & cmbInfo = CombinerInfo::get(); cmbInfo.init(); InitShaderCombiner(); gDP.otherMode.cycleType = G_CYC_1CYCLE; if (cmbInfo.getCombinersNumber() == 0) { cmbInfo.setCombine(EncodeCombineMode(0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0)); cmbInfo.setCombine(EncodeCombineMode(0, 0, 0, TEXEL0, 0, 0, 0, 1, 0, 0, 0, TEXEL0, 0, 0, 0, 1)); } }
void Combiner_Init() { CombinerInfo & cmbInfo = CombinerInfo::get(); cmbInfo.init(); InitShaderCombiner(); if (cmbInfo.getCombinersNumber() == 0) { gDP.otherMode.cycleType = G_CYC_COPY; cmbInfo.setCombine(EncodeCombineMode(0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0)); gDP.otherMode.cycleType = G_CYC_FILL; cmbInfo.setCombine(EncodeCombineMode(0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE)); } gDP.otherMode.cycleType = G_CYC_1CYCLE; }
void CombinerInfo::update() { // TODO: find, why gDP.changed & CHANGED_COMBINE not always works (e.g. Mario Tennis). // if (gDP.changed & CHANGED_COMBINE) { if (gDP.otherMode.cycleType == G_CYC_COPY) setCombine(EncodeCombineMode(0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0)); else if (gDP.otherMode.cycleType == G_CYC_FILL) setCombine(EncodeCombineMode(0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE, 0, 0, 0, SHADE)); else setCombine(gDP.combine.mux); gDP.changed &= ~CHANGED_COMBINE; // } }
void Combiner_SelectCombine( u64 mux ) { // Hack for the Banjo-Tooie shadow (framebuffer textures must be enabled too) if ((gDP.otherMode.cycleType == G_CYC_1CYCLE) && (mux == 0x00ffe7ffffcf9fcfLL) && (cache.current[0]->frameBufferTexture)) { mux = EncodeCombineMode( 0, 0, 0, 0, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, 0, TEXEL0, 0, PRIMITIVE, 0 ); } CachedCombiner *current = combiner.root; CachedCombiner *parent = current; while (current) { parent = current; if (mux == current->combine.mux) break; else if (mux < current->combine.mux) current = current->left; else current = current->right; } if (current == NULL) { current = Combiner_Compile( mux ); if (parent == NULL) combiner.root = current; else if (parent->combine.mux > current->combine.mux) parent->left = current; else parent->right = current; } combiner.current = current; gDP.changed |= CHANGED_COMBINE_COLORS; }
bool OGL_Start(void) { float f; OGL_InitStates(); #ifdef USE_SDL /////// paulscode, graphics bug-fixes float depth = gDP.fillColor.z ; glDisable( GL_SCISSOR_TEST ); glDepthMask( GL_TRUE ); // fixes side-bar graphics glitches glClearDepth( 1.0f ); // fixes missing graphics on Qualcomm Adreno glClearColor( 0, 0, 0, 1 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glFinish(); Android_JNI_SwapWindow(); // paulscode, fix for black-screen bug glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glFinish(); OGL_UpdateDepthUpdate(); glEnable( GL_SCISSOR_TEST ); //////// #endif //check extensions if ((config.texture.maxAnisotropy>0) && !OGL_IsExtSupported("GL_EXT_texture_filter_anistropic")) { LOG(LOG_WARNING, "Anistropic Filtering is not supported.\n"); config.texture.maxAnisotropy = 0; } f = 0; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &f); if (config.texture.maxAnisotropy > ((int)f)) { LOG(LOG_WARNING, "Clamping max anistropy to %ix.\n", (int)f); config.texture.maxAnisotropy = (int)f; } //Print some info LOG(LOG_VERBOSE, "[gles2n64]: Enable Runfast... \n"); OGL_EnableRunfast(); //We must have a shader bound before binding any textures: ShaderCombiner_Init(); ShaderCombiner_Set(EncodeCombineMode(0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0), -1); ShaderCombiner_Set(EncodeCombineMode(0, 0, 0, SHADE, 0, 0, 0, 1, 0, 0, 0, SHADE, 0, 0, 0, 1), -1); TextureCache_Init(); memset(OGL.triangles.vertices, 0, VERTBUFF_SIZE * sizeof(SPVertex)); memset(OGL.triangles.elements, 0, ELEMBUFF_SIZE * sizeof(GLubyte)); OGL.triangles.num = 0; #ifdef __TRIBUFFER_OPT __indexmap_init(); #endif OGL.renderingToTexture = false; OGL.renderState = RS_NONE; gSP.changed = gDP.changed = 0xFFFFFFFF; VI.displayNum = 0; glGetError(); return TRUE; }
void ShaderCombiner_Set(u64 mux, int flags) { //banjo tooie hack if ((gDP.otherMode.cycleType == G_CYC_1CYCLE) && (mux == 0x00ffe7ffffcf9fcfLL)) { mux = EncodeCombineMode( 0, 0, 0, 0, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, 0, TEXEL0, 0, PRIMITIVE, 0 ); } //determine flags if (flags == -1) { flags = 0; if ((config.enableFog) && (gSP.geometryMode & G_FOG)) flags |= SC_FOGENABLED; if (config.enableAlphaTest) { if ((gDP.otherMode.alphaCompare == G_AC_THRESHOLD) && !(gDP.otherMode.alphaCvgSel)){ flags |= SC_ALPHAENABLED; if (gDP.blendColor.a > 0.0f) flags |= SC_ALPHAGREATER; } else if (gDP.otherMode.cvgXAlpha){ flags |= SC_ALPHAENABLED; flags |= SC_ALPHAGREATER; } } if (gDP.otherMode.cycleType == G_CYC_2CYCLE) flags |= SC_2CYCLE; } DecodedMux dmux(mux, flags&SC_2CYCLE); dmux.hack(); //if already bound: if (scProgramCurrent) { if (_program_compare(scProgramCurrent, &dmux, flags)) { scProgramChanged = 0; return; } } //traverse binary tree for cached programs scProgramChanged = 1; ShaderProgram *root = scProgramRoot; ShaderProgram *prog = root; while(!_program_compare(prog, &dmux, flags)) { root = prog; if (prog->combine.mux < dmux.combine.mux) prog = prog->right; else prog = prog->left; } //build new program if (!prog) { scProgramCount++; prog = ShaderCombiner_Compile(&dmux, flags); if (!root) scProgramRoot = prog; else if (root->combine.mux < dmux.combine.mux) root->right = prog; else root->left = prog; } prog->lastUsed = OGL.frame_dl; scProgramCurrent = prog; glUseProgram(prog->program); _force_uniforms(); }