[Android] Remove Plugin_ForceGfxReset

This commit is contained in:
zilmar 2017-04-26 18:13:55 +10:00
parent c7f895737a
commit 9efae26d0c
15 changed files with 337 additions and 284 deletions

View File

@ -119,8 +119,6 @@
<string name="VerticalInterruptsPerSecond">Vertical interrupts per second</string> <string name="VerticalInterruptsPerSecond">Vertical interrupts per second</string>
<string name="RecordExecutionTimes_title">Record Execution Times</string> <string name="RecordExecutionTimes_title">Record Execution Times</string>
<string name="RecordExecutionTimes_summary">Record how long each block executes for</string> <string name="RecordExecutionTimes_summary">Record how long each block executes for</string>
<string name="ForceGfxReset_title">Reset GFX Plugin</string>
<string name="ForceGfxReset_summary">Always reload GFX plugin</string>
<string name="PreAllocSyncMem_title">Pre Alloc Sync Mem</string> <string name="PreAllocSyncMem_title">Pre Alloc Sync Mem</string>
<string name="PreAllocSyncMem_summary">Allocate sync memory at startup</string> <string name="PreAllocSyncMem_summary">Allocate sync memory at startup</string>
<string name="ReducedSyncMem_title">Reduced Sync Mem</string> <string name="ReducedSyncMem_title">Reduced Sync Mem</string>

View File

@ -26,10 +26,6 @@
android:key="Debugger_RecordExecutionTimes" android:key="Debugger_RecordExecutionTimes"
android:summary="@string/RecordExecutionTimes_summary" android:summary="@string/RecordExecutionTimes_summary"
android:title="@string/RecordExecutionTimes_title" /> android:title="@string/RecordExecutionTimes_title" />
<CheckBoxPreference
android:key="Plugin_ForceGfxReset"
android:summary="@string/ForceGfxReset_summary"
android:title="@string/ForceGfxReset_title" />
<CheckBoxPreference <CheckBoxPreference
android:key="PreAllocSyncMem" android:key="PreAllocSyncMem"
android:summary="@string/PreAllocSyncMem_summary" android:summary="@string/PreAllocSyncMem_summary"

View File

@ -550,7 +550,7 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
final Context finalContext = this; final Context finalContext = this;
AlertDialog.Builder GameMenu = new AlertDialog.Builder(finalContext); AlertDialog.Builder GameMenu = new AlertDialog.Builder(finalContext);
GameMenu.setTitle(NativeExports.SettingsLoadString(SettingsID.Game_GoodName.getValue())); GameMenu.setTitle(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue()));
GameMenu.setAdapter(adapter, new DialogInterface.OnClickListener() GameMenu.setAdapter(adapter, new DialogInterface.OnClickListener()
{ {
@Override @Override

View File

@ -42,34 +42,34 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
* assets are updated on disk. * assets are updated on disk.
*/ */
private static final int ASSET_VERSION = 2; private static final int ASSET_VERSION = 2;
/** The total number of assets to be extracted (for computing progress %). */ /** The total number of assets to be extracted (for computing progress %). */
private static final int TOTAL_ASSETS = 89; private static final int TOTAL_ASSETS = 89;
/** The minimum duration that the splash screen is shown, in milliseconds. */ /** The minimum duration that the splash screen is shown, in milliseconds. */
private static final int SPLASH_DELAY = 2000; private static final int SPLASH_DELAY = 2000;
/** /**
* The subdirectory within the assets directory to extract. A subdirectory is necessary to avoid * The subdirectory within the assets directory to extract. A subdirectory is necessary to avoid
* extracting all the default system assets in addition to ours. * extracting all the default system assets in addition to ours.
*/ */
private static final String SOURCE_DIR = "project64_data"; private static final String SOURCE_DIR = "project64_data";
private static boolean mInit = false; private static boolean mInit = false;
private static boolean mAppInit = false; private static boolean mAppInit = false;
/** The text view that displays extraction progress info. */ /** The text view that displays extraction progress info. */
private static TextView mTextView; private static TextView mTextView;
/** The running count of assets extracted. */ /** The running count of assets extracted. */
private int mAssetsExtracted; private int mAssetsExtracted;
@Override @Override
public void onCreate( Bundle savedInstanceState ) public void onCreate( Bundle savedInstanceState )
{ {
super.onCreate( savedInstanceState ); super.onCreate( savedInstanceState );
Window window = getWindow(); Window window = getWindow();
// Don't let the activity sleep in the middle of extraction // Don't let the activity sleep in the middle of extraction
window.setFlags( LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON ); window.setFlags( LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON );
@ -77,51 +77,51 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
setContentView( R.layout.splash_activity ); setContentView( R.layout.splash_activity );
((TextView) findViewById( R.id.versionText )).setText(NativeExports.appVersion()); ((TextView) findViewById( R.id.versionText )).setText(NativeExports.appVersion());
mTextView = (TextView) findViewById( R.id.mainText ); mTextView = (TextView) findViewById( R.id.mainText );
if (!mInit) if (!mInit)
{ {
mInit = true; mInit = true;
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
String ConfigFile = AndroidDevice.PACKAGE_DIRECTORY + "/Config/Project64.cfg"; String ConfigFile = AndroidDevice.PACKAGE_DIRECTORY + "/Config/Project64.cfg";
if(( new File( ConfigFile ) ).exists()) if(( new File( ConfigFile ) ).exists())
{ {
InitProject64(); InitProject64();
} }
// Extract the assets in a separate thread and launch the menu activity // Extract the assets in a separate thread and launch the menu activity
// Handler.postDelayed ensures this runs only after activity has resumed // Handler.postDelayed ensures this runs only after activity has resumed
Log.e( "Splash", "extractAssetsTaskLauncher - startup"); Log.e( "Splash", "extractAssetsTaskLauncher - startup");
final Handler handler = new Handler(); final Handler handler = new Handler();
if (!mAppInit || NativeExports.UISettingsLoadDword(UISettingID.Asserts_Version.getValue()) != ASSET_VERSION) if (!mAppInit || NativeExports.UISettingsLoadDword(UISettingID.Asserts_Version.getValue()) != ASSET_VERSION)
{ {
handler.post( extractAssetsTaskLauncher ); handler.post( extractAssetsTaskLauncher );
} }
else else
{ {
handler.postDelayed( startGalleryLauncher, SPLASH_DELAY ); handler.postDelayed( startGalleryLauncher, SPLASH_DELAY );
} }
} }
} }
@Override @Override
public void onBackPressed() public void onBackPressed()
{ {
moveTaskToBack(true); moveTaskToBack(true);
} }
static public void Reset () static public void Reset ()
{ {
mInit = false; mInit = false;
mAppInit = false; mAppInit = false;
} }
private void InitProject64() private void InitProject64()
{ {
String LibsDir = this.getFilesDir().getParentFile().getAbsolutePath() + "/lib/"; String LibsDir = this.getFilesDir().getParentFile().getAbsolutePath() + "/lib/";
if( !( new File( LibsDir ) ).exists() && AndroidDevice.IS_GINGERBREAD ) if( !( new File( LibsDir ) ).exists() && AndroidDevice.IS_GINGERBREAD )
{ {
LibsDir = this.getApplicationInfo().nativeLibraryDir; LibsDir = this.getApplicationInfo().nativeLibraryDir;
} }
String SyncDir = this.getFilesDir().getParentFile().getAbsolutePath() + "/lib-sync/"; String SyncDir = this.getFilesDir().getParentFile().getAbsolutePath() + "/lib-sync/";
NativeExports.appInit(AndroidDevice.PACKAGE_DIRECTORY); NativeExports.appInit(AndroidDevice.PACKAGE_DIRECTORY);
@ -135,13 +135,13 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
NativeExports.SettingsSaveString(SettingsID.Directory_NativeSaveSelected.getValue(), SaveDir); NativeExports.SettingsSaveString(SettingsID.Directory_NativeSaveSelected.getValue(), SaveDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_NativeSaveUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_NativeSaveUseSelected.getValue(), true);
} }
if (!NativeExports.IsSettingSet(SettingsID.Directory_InstantSave.getValue())) if (!NativeExports.IsSettingSet(SettingsID.Directory_InstantSave.getValue()))
{ {
NativeExports.SettingsSaveString(SettingsID.Directory_InstantSaveSelected.getValue(), SaveDir); NativeExports.SettingsSaveString(SettingsID.Directory_InstantSaveSelected.getValue(), SaveDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_InstantSaveUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_InstantSaveUseSelected.getValue(), true);
} }
if (!NativeExports.IsSettingSet(SettingsID.Directory_Log.getValue())) if (!NativeExports.IsSettingSet(SettingsID.Directory_Log.getValue()))
{ {
String LogDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Logs"; String LogDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Logs";
@ -157,7 +157,7 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
} }
mAppInit = true; mAppInit = true;
} }
/** Runnable that launches the non-UI thread from the UI thread after the activity has resumed. */ /** Runnable that launches the non-UI thread from the UI thread after the activity has resumed. */
private final Runnable startGalleryLauncher = new Runnable() private final Runnable startGalleryLauncher = new Runnable()
{ {
@ -167,12 +167,12 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
// Assets already extracted, just launch gallery activity // Assets already extracted, just launch gallery activity
Intent intent = new Intent( SplashActivity.this, GalleryActivity.class ); Intent intent = new Intent( SplashActivity.this, GalleryActivity.class );
SplashActivity.this.startActivity( intent ); SplashActivity.this.startActivity( intent );
// We never want to come back to this activity, so finish it // We never want to come back to this activity, so finish it
finish(); finish();
} }
}; };
private final Runnable extractAssetsTaskLauncher = new Runnable() private final Runnable extractAssetsTaskLauncher = new Runnable()
{ {
@Override @Override
@ -183,16 +183,16 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
new ExtractAssetsTask( getAssets(), SOURCE_DIR, AndroidDevice.PACKAGE_DIRECTORY, SplashActivity.this ).execute(); new ExtractAssetsTask( getAssets(), SOURCE_DIR, AndroidDevice.PACKAGE_DIRECTORY, SplashActivity.this ).execute();
} }
}; };
@Override @Override
public void onExtractAssetsProgress( String nextFileToExtract ) public void onExtractAssetsProgress( String nextFileToExtract )
{ {
final float percent = ( 100f * mAssetsExtracted ) / (float) TOTAL_ASSETS; final float percent = ( 100f * mAssetsExtracted ) / (float) TOTAL_ASSETS;
final String text = getString( R.string.assetExtractor_progress, percent, nextFileToExtract ); final String text = getString( R.string.assetExtractor_progress, percent, nextFileToExtract );
mTextView.setText(text); mTextView.setText(text);
mAssetsExtracted++; mAssetsExtracted++;
} }
@Override @Override
public void onExtractAssetsFinished( List<Failure> failures ) public void onExtractAssetsFinished( List<Failure> failures )
{ {
@ -202,7 +202,7 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
{ {
InitProject64(); InitProject64();
} }
// Extraction succeeded, record new asset version and merge cheats // Extraction succeeded, record new asset version and merge cheats
mTextView.setText( R.string.assetExtractor_finished ); mTextView.setText( R.string.assetExtractor_finished );
NativeExports.UISettingsSaveDword(UISettingID.Asserts_Version.getValue(), ASSET_VERSION); NativeExports.UISettingsSaveDword(UISettingID.Asserts_Version.getValue(), ASSET_VERSION);
@ -210,7 +210,7 @@ public class SplashActivity extends Activity implements ExtractAssetsListener
// Launch gallery activity // Launch gallery activity
Intent intent = new Intent( this, GalleryActivity.class ); Intent intent = new Intent( this, GalleryActivity.class );
this.startActivity( intent ); this.startActivity( intent );
// We never want to come back to this activity, so finish it // We never want to come back to this activity, so finish it
finish(); finish();
} }

View File

@ -210,7 +210,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
{ {
item.setChecked(true); item.setChecked(true);
} }
String SaveFileName = SaveDirectory + "/" + NativeExports.SettingsLoadString(SettingsID.Game_GoodName.getValue()) + ".pj"; String SaveFileName = SaveDirectory + "/" + NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue()) + ".pj";
String Timestamp = ""; String Timestamp = "";
if (SaveSlot != 0) if (SaveSlot != 0)
{ {
@ -228,7 +228,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
Timestamp = new SimpleDateFormat(" [yyyy/MM/dd HH:mm]").format(new Date(LastModified)); Timestamp = new SimpleDateFormat(" [yyyy/MM/dd HH:mm]").format(new Date(LastModified));
} }
String SlotName = SaveSlot == 0 ? Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVEAUTO) : String SlotName = SaveSlot == 0 ? Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVEAUTO) :
Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVESLOT) + " " + SaveSlot; Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVESLOT) + " " + SaveSlot;
item.setTitle(SlotName + Timestamp); item.setTitle(SlotName + Timestamp);
} }

View File

@ -97,7 +97,7 @@ public enum SettingsID
Game_File, Game_File,
Game_UniqueSaveDir, Game_UniqueSaveDir,
Game_GameName, Game_GameName,
Game_GoodName, Cfg_GoodName,
Game_TempLoaded, Game_TempLoaded,
Game_SystemType, Game_SystemType,
Game_EditPlugin_Gfx, Game_EditPlugin_Gfx,
@ -255,7 +255,6 @@ public enum SettingsID
Plugin_UseHleGfx, Plugin_UseHleGfx,
Plugin_UseHleAudio, Plugin_UseHleAudio,
Plugin_EnableAudio, Plugin_EnableAudio,
Plugin_ForceGfxReset,
Logging_GenerateLog, Logging_GenerateLog,
Logging_LogRDRamRegisters, Logging_LogRDRamRegisters,

View File

@ -60,7 +60,6 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
.putBoolean("audio_Enabled",NativeExports.SettingsLoadBool(SettingsID.Plugin_EnableAudio.getValue())) .putBoolean("audio_Enabled",NativeExports.SettingsLoadBool(SettingsID.Plugin_EnableAudio.getValue()))
.putBoolean("PreAllocSyncMem",NativeExports.SettingsLoadBool(SettingsID.Setting_PreAllocSyncMem.getValue())) .putBoolean("PreAllocSyncMem",NativeExports.SettingsLoadBool(SettingsID.Setting_PreAllocSyncMem.getValue()))
.putBoolean("ReducedSyncMem",NativeExports.SettingsLoadBool(SettingsID.Setting_ReducedSyncMem.getValue())) .putBoolean("ReducedSyncMem",NativeExports.SettingsLoadBool(SettingsID.Setting_ReducedSyncMem.getValue()))
.putBoolean("Plugin_ForceGfxReset",NativeExports.SettingsLoadBool(SettingsID.Plugin_ForceGfxReset.getValue()))
.putBoolean("UserInterface_BasicMode",NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue())) .putBoolean("UserInterface_BasicMode",NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue()))
.putBoolean("Debugger_Enabled",NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue())) .putBoolean("Debugger_Enabled",NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue()))
.putBoolean("Debugger_RecordRecompilerAsm",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordRecompilerAsm.getValue())) .putBoolean("Debugger_RecordRecompilerAsm",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordRecompilerAsm.getValue()))
@ -145,7 +144,6 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
else if (key.equals("touchscreenLayout")) { NativeExports.UISettingsSaveString(UISettingID.TouchScreen_Layout.getValue(), sharedPreferences.getString(key, "Analog")); } else if (key.equals("touchscreenLayout")) { NativeExports.UISettingsSaveString(UISettingID.TouchScreen_Layout.getValue(), sharedPreferences.getString(key, "Analog")); }
else if (key.equals("Patreon_email")) { NativeExports.UISettingsSaveString(UISettingID.SupportWindow_PatreonEmail.getValue(), sharedPreferences.getString(key, "")); } else if (key.equals("Patreon_email")) { NativeExports.UISettingsSaveString(UISettingID.SupportWindow_PatreonEmail.getValue(), sharedPreferences.getString(key, "")); }
else if (key.equals("audio_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Plugin_EnableAudio.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("audio_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Plugin_EnableAudio.getValue(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Plugin_ForceGfxReset")) { NativeExports.SettingsSaveBool(SettingsID.Plugin_ForceGfxReset.getValue(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("PreAllocSyncMem")) { NativeExports.SettingsSaveBool(SettingsID.Setting_PreAllocSyncMem.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("PreAllocSyncMem")) { NativeExports.SettingsSaveBool(SettingsID.Setting_PreAllocSyncMem.getValue(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("ReducedSyncMem")) { NativeExports.SettingsSaveBool(SettingsID.Setting_ReducedSyncMem.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("ReducedSyncMem")) { NativeExports.SettingsSaveBool(SettingsID.Setting_ReducedSyncMem.getValue(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Debugger_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_Enabled.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Debugger_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_Enabled.getValue(), sharedPreferences.getBoolean(key,false)); }

View File

@ -106,15 +106,15 @@ public final class Notifier
GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay); GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay);
overlay.SetDisplayMessage2(message); overlay.SetDisplayMessage2(message);
} }
public static void EmulationStarted (Activity activity) public static void EmulationStarted (Activity activity)
{ {
((Project64Application) activity.getApplication()).getDefaultTracker().send(new HitBuilders.EventBuilder() ((Project64Application) activity.getApplication()).getDefaultTracker().send(new HitBuilders.EventBuilder()
.setCategory("mobile") .setCategory("mobile")
.setAction("game") .setAction("game")
.setLabel(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue())) .setLabel(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue()))
.build()); .build());
} }
private static Runnable runEmulationStopped = null; private static Runnable runEmulationStopped = null;
public static void EmulationStopped (Activity activity) public static void EmulationStopped (Activity activity)

View File

@ -356,6 +356,8 @@ FX_ENTRY GrContext_t FX_CALL grSstWinOpen(GrColorFormat_t color_format, GrOrigin
{ {
static int show_warning = 1; static int show_warning = 1;
GLCache::ResetCache();
// ZIGGY // ZIGGY
// allocate static texture names // allocate static texture names
// the initial value should be big enough to support the maximal resolution // the initial value should be big enough to support the maximal resolution

View File

@ -42,313 +42,351 @@
void vbo_draw(); void vbo_draw();
void cache_glActiveTexture (GLenum texture) GLenum GLCache::m_cached_texture;
{ GLenum GLCache::m_cached_mode;
static GLenum cached_texture; GLenum GLCache::m_cached_modeRGB;
GLenum GLCache::m_cached_modeAlpha;
GLenum GLCache::m_cached_sfactor;
GLenum GLCache::m_cached_dfactor;
GLenum GLCache::m_cached_BlendFuncSeparate_srcRGB;
GLenum GLCache::m_cached_BlendFuncSeparate_dstRGB;
GLenum GLCache::m_cached_BlendFuncSeparate_srcAlpha;
GLenum GLCache::m_cached_BlendFuncSeparate_dstAlpha;
GLclampf GLCache::m_cached_depth;
GLenum GLCache::m_cached_CullFace_mode;
GLenum GLCache::m_cached_func;
GLboolean GLCache::m_cached_DepthMask_flag;
GLclampf GLCache::m_cached_zNear;
GLclampf GLCache::m_cached_zFar;
bool GLCache::m_cached_BLEND = false;
bool GLCache::m_cached_CULL_FACE = false;
bool GLCache::m_cached_DEPTH_TEST = false;
bool GLCache::m_cached_DITHER = false;
bool GLCache::m_cached_POLYGON_OFFSET_FILL = false;
bool GLCache::m_cached_SAMPLE_ALPHA_TO_COVERAGE = false;
bool GLCache::m_cached_SAMPLE_COVERAGE = false;
bool GLCache::m_cached_SCISSOR_TEST = false;
bool GLCache::m_cached_STENCIL_TEST = false;
GLenum GLCache::m_cached_FrontFace_mode;
GLfloat GLCache::m_cached_factor;
GLfloat GLCache::m_cached_units;
GLclampf GLCache::m_cached_red, GLCache::m_cached_green, GLCache::m_cached_blue, GLCache::m_cached_alpha;
GLint GLCache::m_cached_x, GLCache::m_cached_y;
GLsizei GLCache::m_cached_width, GLCache::m_cached_height;
GLuint GLCache::m_cached_program;
GLint GLCache::m_Viewport_cached_x = 0, GLCache::m_Viewport_cached_y = 0;
GLsizei GLCache::m_Viewport_cached_width = 0, GLCache::m_Viewport_cached_height = 0;
if(texture != cached_texture) void GLCache::ResetCache(void)
{
m_cached_texture = 0;
m_cached_mode = 0;
m_cached_modeRGB = 0;
m_cached_modeAlpha = 0;
m_cached_sfactor = 0;
m_cached_dfactor = 0;
m_cached_BlendFuncSeparate_srcRGB = 0;
m_cached_BlendFuncSeparate_dstRGB = 0;
m_cached_BlendFuncSeparate_srcAlpha = 0;
m_cached_BlendFuncSeparate_dstAlpha = 0;
m_cached_depth = 0;
m_cached_CullFace_mode = 0;
m_cached_func = 0;
m_cached_DepthMask_flag = 0;
m_cached_zNear = 0;
m_cached_zFar = 0;
m_cached_BLEND = false;
m_cached_CULL_FACE = false;
m_cached_DEPTH_TEST = false;
m_cached_DITHER = false;
m_cached_POLYGON_OFFSET_FILL = false;
m_cached_SAMPLE_ALPHA_TO_COVERAGE = false;
m_cached_SAMPLE_COVERAGE = false;
m_cached_SCISSOR_TEST = false;
m_cached_STENCIL_TEST = false;
m_cached_FrontFace_mode = 0;
m_cached_factor = 0;
m_cached_units = 0;
m_cached_red = 0;
m_cached_green = 0;
m_cached_blue = 0;
m_cached_alpha = 0;
m_cached_x = 0;
m_cached_y = 0;
m_cached_width = 0;
m_cached_height = 0;
m_cached_program = 0;
m_Viewport_cached_x = 0;
m_Viewport_cached_y = 0;
m_Viewport_cached_width = 0;
m_Viewport_cached_height = 0;
}
void GLCache::glActiveTexture(GLenum texture)
{
if (texture != m_cached_texture)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "texture: %d",texture); WriteTrace(TraceOGLWrapper, TraceDebug, "texture: %d", texture);
vbo_draw(); vbo_draw();
glActiveTexture(texture); ::glActiveTexture(texture);
cached_texture = texture; m_cached_texture = texture;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - texture: %d",texture); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - texture: %d", texture);
} }
} }
void cache_glBindTexture (GLenum target, GLuint texture) void GLCache::glBindTexture(GLenum target, GLuint texture)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "target: %d texture: %d",target, texture); WriteTrace(TraceOGLWrapper, TraceDebug, "target: %d texture: %d", target, texture);
vbo_draw(); vbo_draw();
glBindTexture(target, texture); ::glBindTexture(target, texture);
} }
void cache_glBlendEquation ( GLenum mode ) void GLCache::glBlendEquation(GLenum mode)
{ {
static GLenum cached_mode; if (mode != m_cached_mode)
if(mode != cached_mode)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d",mode); WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode);
vbo_draw(); vbo_draw();
glBlendEquation(mode); ::glBlendEquation(mode);
cached_mode = mode; m_cached_mode = mode;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d",mode); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d", mode);
} }
} }
void cache_glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha) void GLCache::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
{ {
static GLenum cached_modeRGB; if (modeRGB != m_cached_modeRGB || modeAlpha != m_cached_modeAlpha)
static GLenum cached_modeAlpha;
if(modeRGB != cached_modeRGB || modeAlpha != cached_modeAlpha)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "modeRGB: %d cached_modeAlpha: %d",modeRGB, cached_modeAlpha); WriteTrace(TraceOGLWrapper, TraceDebug, "modeRGB: %d cached_modeAlpha: %d", modeRGB, m_cached_modeAlpha);
vbo_draw(); vbo_draw();
glBlendEquationSeparate(modeRGB, modeAlpha); ::glBlendEquationSeparate(modeRGB, modeAlpha);
cached_modeRGB = modeRGB; m_cached_modeRGB = modeRGB;
cached_modeAlpha = modeAlpha; m_cached_modeAlpha = modeAlpha;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - modeRGB: %d cached_modeAlpha: %d",modeRGB, cached_modeAlpha); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - modeRGB: %d cached_modeAlpha: %d", modeRGB, m_cached_modeAlpha);
} }
} }
void cache_glBlendFunc (GLenum sfactor, GLenum dfactor) void GLCache::glBlendFunc(GLenum sfactor, GLenum dfactor)
{ {
static GLenum cached_sfactor; if (sfactor != m_cached_sfactor || dfactor != m_cached_dfactor)
static GLenum cached_dfactor;
if(sfactor != cached_sfactor || dfactor != cached_dfactor)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "sfactor: %d dfactor: %d",sfactor, dfactor); WriteTrace(TraceOGLWrapper, TraceDebug, "sfactor: %d dfactor: %d", sfactor, dfactor);
vbo_draw(); vbo_draw();
glBlendFunc(sfactor, dfactor); ::glBlendFunc(sfactor, dfactor);
cached_sfactor = sfactor; m_cached_sfactor = sfactor;
cached_dfactor = dfactor; m_cached_dfactor = dfactor;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - sfactor: %d dfactor: %d",sfactor, dfactor); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - sfactor: %d dfactor: %d", sfactor, dfactor);
} }
} }
void cache_glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) void GLCache::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
{ {
static GLenum cached_BlendFuncSeparate_srcRGB; if (srcRGB != m_cached_BlendFuncSeparate_srcRGB || dstRGB != m_cached_BlendFuncSeparate_dstRGB || srcAlpha != m_cached_BlendFuncSeparate_srcAlpha || dstAlpha != m_cached_BlendFuncSeparate_dstAlpha)
static GLenum cached_BlendFuncSeparate_dstRGB;
static GLenum cached_BlendFuncSeparate_srcAlpha;
static GLenum cached_BlendFuncSeparate_dstAlpha;
if(srcRGB != cached_BlendFuncSeparate_srcRGB || dstRGB != cached_BlendFuncSeparate_dstRGB || srcAlpha != cached_BlendFuncSeparate_srcAlpha || dstAlpha != cached_BlendFuncSeparate_dstAlpha)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d",srcRGB, dstRGB, srcAlpha, dstAlpha); WriteTrace(TraceOGLWrapper, TraceDebug, "srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d", srcRGB, dstRGB, srcAlpha, dstAlpha);
vbo_draw(); vbo_draw();
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
cached_BlendFuncSeparate_srcRGB = srcRGB; m_cached_BlendFuncSeparate_srcRGB = srcRGB;
cached_BlendFuncSeparate_dstRGB = dstRGB; m_cached_BlendFuncSeparate_dstRGB = dstRGB;
cached_BlendFuncSeparate_srcAlpha = srcAlpha; m_cached_BlendFuncSeparate_srcAlpha = srcAlpha;
cached_BlendFuncSeparate_dstAlpha = dstAlpha; m_cached_BlendFuncSeparate_dstAlpha = dstAlpha;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d",srcRGB, dstRGB, srcAlpha, dstAlpha); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d", srcRGB, dstRGB, srcAlpha, dstAlpha);
} }
} }
void cache_glClearDepthf (GLclampf depth) void GLCache::glClearDepthf(GLclampf depth)
{ {
static GLclampf cached_depth; if (depth != m_cached_depth)
if(depth != cached_depth)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "depth: %d",depth); WriteTrace(TraceOGLWrapper, TraceDebug, "depth: %d", depth);
vbo_draw(); vbo_draw();
glClearDepthf(depth); ::glClearDepthf(depth);
cached_depth = depth; m_cached_depth = depth;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - depth: %d",depth); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - depth: %d", depth);
} }
} }
void cache_glCullFace (GLenum mode) void GLCache::glCullFace(GLenum mode)
{ {
static GLenum cached_CullFace_mode; if (mode != m_cached_CullFace_mode)
if(mode != cached_CullFace_mode)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d",mode); WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode);
vbo_draw(); vbo_draw();
glCullFace(mode); ::glCullFace(mode);
cached_CullFace_mode = mode; m_cached_CullFace_mode = mode;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d",mode); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d", mode);
} }
} }
void cache_glDepthFunc (GLenum func) void GLCache::glDepthFunc(GLenum func)
{ {
static GLenum cached_func; if (func != m_cached_func)
if(func != cached_func)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "func: %d",func); WriteTrace(TraceOGLWrapper, TraceDebug, "func: %d", func);
vbo_draw(); vbo_draw();
glDepthFunc(func); ::glDepthFunc(func);
cached_func = func; m_cached_func = func;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - func: %d",func); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - func: %d", func);
} }
} }
void cache_glDepthMask (GLboolean flag) void GLCache::glDepthMask(GLboolean flag)
{ {
static GLboolean cached_DepthMask_flag; if (flag != m_cached_DepthMask_flag)
if(flag != cached_DepthMask_flag)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "flag: %d",(int)flag); WriteTrace(TraceOGLWrapper, TraceDebug, "flag: %d", (int)flag);
vbo_draw(); vbo_draw();
glDepthMask(flag); ::glDepthMask(flag);
cached_DepthMask_flag = flag; m_cached_DepthMask_flag = flag;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - flag: %d",(int)flag); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - flag: %d", (int)flag);
} }
} }
void cache_glDepthRangef (GLclampf zNear, GLclampf zFar) void GLCache::glDepthRangef(GLclampf zNear, GLclampf zFar)
{ {
static GLclampf cached_zNear; if (zNear != m_cached_zNear || zFar != m_cached_zFar)
static GLclampf cached_zFar;
if(zNear != cached_zNear || zFar != cached_zFar)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "zNear: %d zFar: %d",zNear, zFar); WriteTrace(TraceOGLWrapper, TraceDebug, "zNear: %d zFar: %d", zNear, zFar);
vbo_draw(); vbo_draw();
glDepthRangef(zNear, zFar); ::glDepthRangef(zNear, zFar);
cached_zNear = zNear; m_cached_zNear = zNear;
cached_zFar = zFar; m_cached_zFar = zFar;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - zNear: %d zFar: %d",zNear, zFar); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - zNear: %d zFar: %d", zNear, zFar);
} }
} }
void GLCache::glEnableDisableItem(GLenum cap, bool enable, bool & cached_state, const char * StateName)
void cache_glEnableDisableItem (GLenum cap, bool enable, bool & cached_state, const char * StateName)
{ {
if (enable) if (enable)
{ {
if(!cached_state) if (!cached_state)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%s)",StateName); WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%s)", StateName);
vbo_draw(); vbo_draw();
glEnable(cap); ::glEnable(cap);
cached_state = true; cached_state = true;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)",StateName); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)", StateName);
} }
} }
else else
{ {
if (cached_state) if (cached_state)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%s)",StateName); WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%s)", StateName);
vbo_draw(); vbo_draw();
glDisable(cap); ::glDisable(cap);
cached_state = false; cached_state = false;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)",StateName); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)", StateName);
} }
} }
} }
void cache_glEnableDisable (GLenum cap, bool enable) void GLCache::glEnableDisable(GLenum cap, bool enable)
{ {
static bool cached_BLEND = false; if (cap == GL_BLEND) { GLCache::glEnableDisableItem(cap, enable, m_cached_BLEND, "GL_BLEND"); }
static bool cached_CULL_FACE = false; else if (cap == GL_CULL_FACE) { GLCache::glEnableDisableItem(cap, enable, m_cached_CULL_FACE, "GL_CULL_FACE"); }
static bool cached_DEPTH_TEST = false; else if (cap == GL_DEPTH_TEST) { GLCache::glEnableDisableItem(cap, enable, m_cached_DEPTH_TEST, "GL_DEPTH_TEST"); }
static bool cached_DITHER = false; else if (cap == GL_DITHER) { GLCache::glEnableDisableItem(cap, enable, m_cached_DITHER, "GL_DITHER"); }
static bool cached_POLYGON_OFFSET_FILL = false; else if (cap == GL_POLYGON_OFFSET_FILL) { GLCache::glEnableDisableItem(cap, enable, m_cached_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL"); }
static bool cached_SAMPLE_ALPHA_TO_COVERAGE = false; else if (cap == GL_SAMPLE_ALPHA_TO_COVERAGE) { GLCache::glEnableDisableItem(cap, enable, m_cached_SAMPLE_ALPHA_TO_COVERAGE, "GL_SAMPLE_ALPHA_TO_COVERAGE"); }
static bool cached_SAMPLE_COVERAGE = false; else if (cap == GL_SAMPLE_COVERAGE) { GLCache::glEnableDisableItem(cap, enable, m_cached_SAMPLE_COVERAGE, "GL_SAMPLE_COVERAGE"); }
static bool cached_SCISSOR_TEST = false; else if (cap == GL_SCISSOR_TEST) { GLCache::glEnableDisableItem(cap, enable, m_cached_SCISSOR_TEST, "GL_SCISSOR_TEST"); }
static bool cached_STENCIL_TEST = false; else if (cap == GL_STENCIL_TEST) { GLCache::glEnableDisableItem(cap, enable, m_cached_STENCIL_TEST, "GL_STENCIL_TEST"); }
if(cap == GL_BLEND) { cache_glEnableDisableItem(cap, enable, cached_BLEND, "GL_BLEND"); }
else if(cap == GL_CULL_FACE) { cache_glEnableDisableItem(cap, enable, cached_CULL_FACE, "GL_CULL_FACE"); }
else if(cap == GL_DEPTH_TEST) { cache_glEnableDisableItem(cap, enable, cached_DEPTH_TEST, "GL_DEPTH_TEST"); }
else if(cap == GL_DITHER) { cache_glEnableDisableItem(cap, enable, cached_DITHER, "GL_DITHER"); }
else if(cap == GL_POLYGON_OFFSET_FILL) { cache_glEnableDisableItem(cap, enable, cached_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL"); }
else if(cap == GL_SAMPLE_ALPHA_TO_COVERAGE) { cache_glEnableDisableItem(cap, enable, cached_SAMPLE_ALPHA_TO_COVERAGE, "GL_SAMPLE_ALPHA_TO_COVERAGE"); }
else if(cap == GL_SAMPLE_COVERAGE) { cache_glEnableDisableItem(cap, enable, cached_SAMPLE_COVERAGE, "GL_SAMPLE_COVERAGE"); }
else if(cap == GL_SCISSOR_TEST) { cache_glEnableDisableItem(cap, enable, cached_SCISSOR_TEST, "GL_SCISSOR_TEST"); }
else if(cap == GL_STENCIL_TEST) { cache_glEnableDisableItem(cap, enable, cached_STENCIL_TEST, "GL_STENCIL_TEST"); }
else else
{ {
if (enable) if (enable)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%d)",cap); WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%d)", cap);
vbo_draw(); vbo_draw();
glEnable(cap); ::glEnable(cap);
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%d)",cap); WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%d)", cap);
vbo_draw(); vbo_draw();
glDisable(cap); ::glDisable(cap);
} }
} }
} }
void cache_glFrontFace (GLenum mode) void GLCache::glFrontFace(GLenum mode)
{ {
static GLenum cached_FrontFace_mode; if (mode != m_cached_FrontFace_mode)
if(mode != cached_FrontFace_mode)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d",mode); WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode);
vbo_draw(); vbo_draw();
glFrontFace(mode); ::glFrontFace(mode);
cached_FrontFace_mode = mode; m_cached_FrontFace_mode = mode;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d",mode); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d", mode);
} }
} }
void cache_glPolygonOffset (GLfloat factor, GLfloat units) void GLCache::glPolygonOffset(GLfloat factor, GLfloat units)
{ {
static GLfloat cached_factor; if (factor != m_cached_factor || units != m_cached_units)
static GLfloat cached_units;
if(factor != cached_factor || units != cached_units)
{ {
vbo_draw(); vbo_draw();
WriteTrace(TraceOGLWrapper, TraceDebug, "factor: %f units: %f",factor, units); WriteTrace(TraceOGLWrapper, TraceDebug, "factor: %f units: %f", factor, units);
glPolygonOffset(factor, units); ::glPolygonOffset(factor, units);
cached_factor = factor; m_cached_factor = factor;
cached_units = units; m_cached_units = units;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - factor: %f units: %f",factor, units); WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - factor: %f units: %f", factor, units);
} }
} }
void cache_glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) void GLCache::glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{ {
static GLclampf cached_red, cached_green, cached_blue, cached_alpha; if (red != m_cached_red || green != m_cached_green || blue != m_cached_blue || alpha != m_cached_alpha)
if(red != cached_red || green != cached_green || blue != cached_blue || alpha != cached_alpha)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "red: %f, green: %f, blue: %f, alpha: %f", red, green, blue, alpha); WriteTrace(TraceOGLWrapper, TraceDebug, "red: %f, green: %f, blue: %f, alpha: %f", red, green, blue, alpha);
vbo_draw(); vbo_draw();
glClearColor(red, green, blue, alpha); ::glClearColor(red, green, blue, alpha);
cached_red = red; m_cached_red = red;
cached_green = green; m_cached_green = green;
cached_blue = blue; m_cached_blue = blue;
cached_alpha = alpha; m_cached_alpha = alpha;
} }
else else
{ {
@ -356,20 +394,17 @@ void cache_glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf a
} }
} }
void cache_glScissor (GLint x, GLint y, GLsizei width, GLsizei height) void GLCache::glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
{ {
static GLint cached_x, cached_y; if (x != m_cached_x || y != m_cached_y || width != m_cached_width || height != m_cached_height)
static GLsizei cached_width, cached_height;
if(x != cached_x || y != cached_y || width != cached_width || height != cached_height)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height); WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height);
vbo_draw(); vbo_draw();
glScissor(x, y, width, height); ::glScissor(x, y, width, height);
cached_x = x; m_cached_x = x;
cached_y = y; m_cached_y = y;
cached_width = width; m_cached_width = width;
cached_height = height; m_cached_height = height;
} }
else else
{ {
@ -377,15 +412,14 @@ void cache_glScissor (GLint x, GLint y, GLsizei width, GLsizei height)
} }
} }
void cache_glUseProgram (GLuint program) void GLCache::glUseProgram(GLuint program)
{ {
static GLuint cached_program; if (program != m_cached_program)
if(program != cached_program)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "program: %d", program); WriteTrace(TraceOGLWrapper, TraceDebug, "program: %d", program);
vbo_draw(); vbo_draw();
glUseProgram(program); ::glUseProgram(program);
cached_program = program; m_cached_program = program;
} }
else else
{ {
@ -393,24 +427,20 @@ void cache_glUseProgram (GLuint program)
} }
} }
void cache_glViewport (GLint x, GLint y, GLsizei width, GLsizei height) void GLCache::glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{ {
static GLint cached_x = 0, cached_y = 0; if (x != m_Viewport_cached_x || y != m_Viewport_cached_y || width != m_Viewport_cached_width || height != m_Viewport_cached_height)
static GLsizei cached_width = 0, cached_height = 0;
if(x != cached_x || y != cached_y || width != cached_width || height != cached_height)
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height); WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height);
vbo_draw(); vbo_draw();
glViewport(x, y, width, height); ::glViewport(x, y, width, height);
cached_x = x; m_Viewport_cached_x = x;
cached_y = y; m_Viewport_cached_y = y;
cached_width = width; m_Viewport_cached_width = width;
cached_height = height; m_Viewport_cached_height = height;
} }
else else
{ {
WriteTrace(TraceOGLWrapper, TraceDebug, "ignored x: %d, y: %d, width: %d, height: %d", x, y, width, height); WriteTrace(TraceOGLWrapper, TraceDebug, "ignored x: %d, y: %d, width: %d, height: %d", x, y, width, height);
} }
} }

View File

@ -1,42 +1,87 @@
#pragma once #pragma once
#include "opengl.h" #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
void vbo_draw(); void vbo_draw();
void cache_glActiveTexture (GLenum texture); class GLCache
void cache_glBindTexture (GLenum target, GLuint texture); {
void cache_glBlendEquation ( GLenum mode ); public:
void cache_glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); static void ResetCache(void);
void cache_glBlendFunc (GLenum sfactor, GLenum dfactor);
void cache_glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
void cache_glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void cache_glClearDepthf (GLclampf depth);
void cache_glCullFace (GLenum mode);
void cache_glDepthFunc (GLenum func);
void cache_glDepthMask (GLboolean flag);
void cache_glDepthRangef (GLclampf zNear, GLclampf zFar);
void cache_glEnableDisable (GLenum cap, bool enable);
void cache_glPolygonOffset (GLfloat factor, GLfloat units);
void cache_glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
void cache_glUseProgram (GLuint program);
void cache_glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
#define glActiveTexture(texture) cache_glActiveTexture(texture) static void glActiveTexture(GLenum texture);
#define glBindTexture(target, texture) cache_glBindTexture(target, texture) static void glBindTexture(GLenum target, GLuint texture);
#define glBlendEquation(mode) cache_glBlendEquation(mode) static void glBlendEquation(GLenum mode);
#define glBlendEquationSeparate(modeRGB, modeAlpha) cache_glBlendEquationSeparate(modeRGB, modeAlpha) static void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
#define glBlendFunc(sfactor, dfactor) cache_glBlendFunc(sfactor, dfactor) static void glBlendFunc(GLenum sfactor, GLenum dfactor);
#define glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha) cache_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha) static void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
#define glClearColor(red, green, blue, alpha) cache_glClearColor(red, green, blue, alpha) static void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
#define glClearDepthf(depth) cache_glClearDepthf(depth) static void glClearDepthf(GLclampf depth);
#define glCullFace(mode) cache_glCullFace(mode) static void glCullFace(GLenum mode);
#define glDepthFunc(func) cache_glDepthFunc(func) static void glDepthFunc(GLenum func);
#define glDepthMask(flag) cache_glDepthMask(flag) static void glDepthMask(GLboolean flag);
#define glDepthRangef(zNear, zFar) cache_glDepthRangef(zNear, zFar) static void glDepthRangef(GLclampf zNear, GLclampf zFar);
#define glDisable(cap) cache_glEnableDisable(cap, false) static void glEnableDisable(GLenum cap, bool enable);
#define glEnable(cap) cache_glEnableDisable(cap, true) static void glPolygonOffset(GLfloat factor, GLfloat units);
#define glFrontFace(mode) cache_glFrontFace(mode) static void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
#define glPolygonOffset(factor, units) cache_glPolygonOffset(factor, units) static void glUseProgram(GLuint program);
#define glScissor(x, y, width, height) cache_glScissor(x, y, width, height) static void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
#define glUseProgram(program) cache_glUseProgram(program) static void glFrontFace(GLenum mode);
#define glViewport(x, y, width, height) cache_glViewport(x, y, width, height)
private:
static void glEnableDisableItem(GLenum cap, bool enable, bool & cached_state, const char * StateName);
static GLenum m_cached_texture;
static GLenum m_cached_mode;
static GLenum m_cached_modeRGB;
static GLenum m_cached_modeAlpha;
static GLenum m_cached_sfactor;
static GLenum m_cached_dfactor;
static GLenum m_cached_BlendFuncSeparate_srcRGB;
static GLenum m_cached_BlendFuncSeparate_dstRGB;
static GLenum m_cached_BlendFuncSeparate_srcAlpha;
static GLenum m_cached_BlendFuncSeparate_dstAlpha;
static GLclampf m_cached_depth;
static GLenum m_cached_CullFace_mode;
static GLenum m_cached_func;
static GLboolean m_cached_DepthMask_flag;
static GLclampf m_cached_zNear;
static GLclampf m_cached_zFar;
static bool m_cached_BLEND;
static bool m_cached_CULL_FACE;
static bool m_cached_DEPTH_TEST;
static bool m_cached_DITHER;
static bool m_cached_POLYGON_OFFSET_FILL;
static bool m_cached_SAMPLE_ALPHA_TO_COVERAGE;
static bool m_cached_SAMPLE_COVERAGE;
static bool m_cached_SCISSOR_TEST;
static bool m_cached_STENCIL_TEST;
static GLenum m_cached_FrontFace_mode;
static GLfloat m_cached_factor;
static GLfloat m_cached_units;
static GLclampf m_cached_red, m_cached_green, m_cached_blue, m_cached_alpha;
static GLint m_cached_x, m_cached_y;
static GLsizei m_cached_width, m_cached_height;
static GLuint m_cached_program;
static GLint m_Viewport_cached_x, m_Viewport_cached_y;
static GLsizei m_Viewport_cached_width, m_Viewport_cached_height;
};
#define glActiveTexture(texture) GLCache::glActiveTexture(texture)
#define glBindTexture(target, texture) GLCache::glBindTexture(target, texture)
#define glBlendEquation(mode) GLCache::glBlendEquation(mode)
#define glBlendEquationSeparate(modeRGB, modeAlpha) GLCache::glBlendEquationSeparate(modeRGB, modeAlpha)
#define glBlendFunc(sfactor, dfactor) GLCache::glBlendFunc(sfactor, dfactor)
#define glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha) GLCache::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha)
#define glClearColor(red, green, blue, alpha) GLCache::glClearColor(red, green, blue, alpha)
#define glClearDepthf(depth) GLCache::glClearDepthf(depth)
#define glCullFace(mode) GLCache::glCullFace(mode)
#define glDepthFunc(func) GLCache::glDepthFunc(func)
#define glDepthMask(flag) GLCache::glDepthMask(flag)
#define glDepthRangef(zNear, zFar) GLCache::glDepthRangef(zNear, zFar)
#define glDisable(cap) GLCache::glEnableDisable(cap, false)
#define glEnable(cap) GLCache::glEnableDisable(cap, true)
#define glFrontFace(mode) GLCache::glFrontFace(mode)
#define glPolygonOffset(factor, units) GLCache::glPolygonOffset(factor, units)
#define glScissor(x, y, width, height) GLCache::glScissor(x, y, width, height)
#define glUseProgram(program) GLCache::glUseProgram(program)
#define glViewport(x, y, width, height) GLCache::glViewport(x, y, width, height)

View File

@ -675,10 +675,6 @@ void CN64System::Reset(bool bInitReg, bool ClearMenory)
} }
if (m_Plugins && g_Settings->LoadBool(GameRunning_CPU_Running)) if (m_Plugins && g_Settings->LoadBool(GameRunning_CPU_Running))
{ {
if (g_Settings->LoadBool(Plugin_ForceGfxReset))
{
m_Plugins->Reset(this);
}
m_Plugins->RomClosed(); m_Plugins->RomClosed();
m_Plugins->RomOpened(); m_Plugins->RomOpened();
} }

View File

@ -326,12 +326,6 @@ bool CPlugins::Reset(CN64System * System)
bool bRspChange = _stricmp(m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; bool bRspChange = _stricmp(m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0;
bool bContChange = _stricmp(m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; bool bContChange = _stricmp(m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0;
if (g_Settings->LoadBool(Plugin_ForceGfxReset))
{
//this is a hack and should not be here, glide64 is not correctly freeing something on restart, this needs to be fixed but this is a short term workaround
bGfxChange = true;
}
//if GFX and Audio has changed we also need to force reset of RSP //if GFX and Audio has changed we also need to force reset of RSP
if (bGfxChange || bAudioChange) if (bGfxChange || bAudioChange)
{ {

View File

@ -260,7 +260,6 @@ enum SettingID
Plugin_UseHleGfx, Plugin_UseHleGfx,
Plugin_UseHleAudio, Plugin_UseHleAudio,
Plugin_EnableAudio, Plugin_EnableAudio,
Plugin_ForceGfxReset,
Logging_GenerateLog, Logging_GenerateLog,
Logging_LogRDRamRegisters, Logging_LogRDRamRegisters,

View File

@ -357,11 +357,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", true)); AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", true));
AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio", false)); AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio", false));
AddHandler(Plugin_EnableAudio, new CSettingTypeApplication("Audio", "Enable Audio", true)); AddHandler(Plugin_EnableAudio, new CSettingTypeApplication("Audio", "Enable Audio", true));
#ifdef ANDROID
AddHandler(Plugin_ForceGfxReset, new CSettingTypeApplication("Plugin", "Force Gfx Reset", true));
#else
AddHandler(Plugin_ForceGfxReset, new CSettingTypeApplication("Plugin", "Force Gfx Reset", false));
#endif
//Logging //Logging
AddHandler(Logging_GenerateLog, new CSettingTypeApplication("Logging", "Generate Log Files", false)); AddHandler(Logging_GenerateLog, new CSettingTypeApplication("Logging", "Generate Log Files", false));
AddHandler(Logging_LogRDRamRegisters, new CSettingTypeApplication("Logging", "Log RDRam Registers", false)); AddHandler(Logging_LogRDRamRegisters, new CSettingTypeApplication("Logging", "Log RDRam Registers", false));