Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Tegra 4 'support.' This brings up the OpenGL backend to sup…
…port Tegra 4 to the point where it will run games but it doesn't have any video output for some reason. This is a large change that doesn't actually change much functionally. Walking through the changes.

It changes the string in the Android backend select to just OpenGL ES.
Adds a check in the Android code to check for Tegra 4 and to enable the option to select the OpenGL ES backend.
Adds a DriverDetails bug under BUG_ISTEGRA as a blanket case of Tegra 4 support.
The changes that effects most lines in this change. Removing all float suffixes in the pixel/vertex/util shaders since OpenGL ES 2 doesn't support float suffixes.
Disables the shaders for reinterpreting the EFB format since Tegra 4 doesn't support integers.
Changes GLFunctions.cpp to grab the correct Tegra extension functions.
Readds the GLSL 1.2 'hacks' as GLSLES2 'hacks' since they are required for GLSL ES 2
Adds a GLSLES2 to the GLSL_VERSION enum.
Disable the SamplerCache on Tegra since Tegra doesn't support samplers...
Enable glBufferSubData on Tegra since it is the only mobile GPU to correctly work with it.
Disable glDrawRangeElements on Tegra since it doesn't support it, This uses glDrawElements instead.
  • Loading branch information
Sonicadvance1 committed Oct 6, 2013
1 parent 2b08172 commit 6bdcde9
Show file tree
Hide file tree
Showing 20 changed files with 404 additions and 285 deletions.
2 changes: 1 addition & 1 deletion Source/Android/res/values/strings.xml
Expand Up @@ -78,7 +78,7 @@
<string name="fastmem_desc">Uses potentially unsafe optimizations for memory access.</string>
<string name="video_settings">Video</string>
<string name="software_renderer">Software Renderer</string>
<string name="opengl_es3">OpenGL ES 3</string>
<string name="opengl_es3">OpenGL ES</string>
<string name="video_backend">Video Backend</string>
<string name="video_backend_to_use">Video backend to use</string>
<string name="show_fps">Show FPS</string>
Expand Down
Expand Up @@ -76,7 +76,6 @@ public void onCreate(Bundle savedInstanceState)
NativeLibrary.SetDimensions((int)screenHeight, (int)screenWidth);
else
NativeLibrary.SetDimensions((int)screenWidth, (int)screenHeight);

NativeLibrary.SetFilename(gameToEmulate.getStringExtra("SelectedGame"));
Running = true;

Expand Down
Expand Up @@ -27,6 +27,7 @@ public final class VideoSettingsFragment extends PreferenceFragment
public static String m_GLVersion;
public static String m_GLVendor;
public static String m_GLRenderer;
public static String m_GLExtensions;
private Activity m_activity;

/**
Expand Down Expand Up @@ -104,6 +105,16 @@ public String getRenderer()
return mGL.glGetString(GL10.GL_RENDERER);
}

/**
* Gets the extension that the device supports
*
* @return String containing the extensions
*/
public String getExtensions()
{
return mGL.glGetString(GL10.GL_EXTENSIONS);
}

private EGLConfig chooseConfig()
{
int[] attribList = new int[] {
Expand Down Expand Up @@ -139,6 +150,7 @@ public static boolean SupportsGLES3()
m_GLVersion = mbuffer.getVersion();
m_GLVendor = mbuffer.getVendor();
m_GLRenderer = mbuffer.getRenderer();
m_GLExtensions = mbuffer.getExtensions();

boolean mSupportsGLES3 = false;

Expand Down Expand Up @@ -170,6 +182,14 @@ public static boolean SupportsGLES3()
mSupportsGLES3 = true;
}
}
if (!mSupportsGLES3 &&
m_GLVendor != null && m_GLVendor.equals("NVIDIA Corporation") &&
m_GLRenderer != null && m_GLRenderer.equals("NVIDIA Tegra") &&
m_GLExtensions != null && m_GLExtensions.contains("GL_OES_depth24"))
{
// Is a Tegra 4 since it supports 24bit depth
mSupportsGLES3 = true;
}
return mSupportsGLES3;
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoCommon/Src/DriverDetails.cpp
Expand Up @@ -37,7 +37,8 @@ namespace DriverDetails
{VENDOR_MESA, DRIVER_I965, BUG_BROKENUBO, 900, 920, true},
{VENDOR_ATI, DRIVER_ATI, BUG_BROKENHACKEDBUFFER, -1.0, -1.0, true},
{VENDOR_MESA, DRIVER_NOUVEAU, BUG_BROKENHACKEDBUFFER, -1.0, -1.0, true},
{VENDOR_ATI, DRIVER_ATI, BUG_BROKENPINNEDMEMORY, -1.0, -1.0, true}
{VENDOR_ATI, DRIVER_ATI, BUG_BROKENPINNEDMEMORY, -1.0, -1.0, true},
{VENDOR_TEGRA, DRIVER_NVIDIA, BUG_ISTEGRA, -1.0, -1.0, true},
};

std::map<Bug, BugInfo> m_bugs;
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/VideoCommon/Src/DriverDetails.h
Expand Up @@ -115,6 +115,13 @@ namespace DriverDetails
// Drawing on screen text causes the whole screen to swizzle in a terrible fashion
// Clearing the framebuffer causes one to never see a frame.
BUG_BROKENSWAP,
// Bug: Running on a Tegra 4 device
// Affected devices: Nvidia Tegra
// Started Version: 4
// Ended Version: 5
// Tegra 4 hardware limitations don't allow it to support OpenGL ES 3
// This is fixed in Tegra 5
BUG_ISTEGRA,
};

// Initializes our internal vendor, device family, and driver version
Expand Down
26 changes: 13 additions & 13 deletions Source/Core/VideoCommon/Src/LightingShaderGen.h
Expand Up @@ -63,7 +63,7 @@ static void GenerateLightShader(T& object, LightingUidData& uid_data, int index,
case LIGHTDIF_CLAMP:
object.Write("ldir = normalize(" LIGHT_POS".xyz - pos.xyz);\n", LIGHT_POS_PARAMS(lightsName, index));
object.Write("lacc.%s += %sdot(ldir, _norm0)) * " LIGHT_COL";\n",
swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", LIGHT_COL_PARAMS(lightsName, index, swizzle));
swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0," :"(", LIGHT_COL_PARAMS(lightsName, index, swizzle));
break;
default: _assert_(0);
}
Expand All @@ -76,18 +76,18 @@ static void GenerateLightShader(T& object, LightingUidData& uid_data, int index,
object.Write("dist2 = dot(ldir, ldir);\n"
"dist = sqrt(dist2);\n"
"ldir = ldir / dist;\n"
"attn = max(0.0f, dot(ldir, " LIGHT_DIR".xyz));\n",
"attn = max(0.0, dot(ldir, " LIGHT_DIR".xyz));\n",
LIGHT_DIR_PARAMS(lightsName, index));
// attn*attn may overflow
object.Write("attn = max(0.0f, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / dot(" LIGHT_DISTATT".xyz, float3(1.0f,dist,dist2));\n",
object.Write("attn = max(0.0, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / dot(" LIGHT_DISTATT".xyz, float3(1.0,dist,dist2));\n",
LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index));
}
else if (chan.attnfunc == 1)
{ // specular
object.Write("ldir = normalize(" LIGHT_POS".xyz);\n", LIGHT_POS_PARAMS(lightsName, index));
object.Write("attn = (dot(_norm0,ldir) >= 0.0f) ? max(0.0f, dot(_norm0, " LIGHT_DIR".xyz)) : 0.0f;\n", LIGHT_DIR_PARAMS(lightsName, index));
object.Write("attn = (dot(_norm0,ldir) >= 0.0) ? max(0.0, dot(_norm0, " LIGHT_DIR".xyz)) : 0.0;\n", LIGHT_DIR_PARAMS(lightsName, index));
// attn*attn may overflow
object.Write("attn = max(0.0f, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / (" LIGHT_DISTATT".x + " LIGHT_DISTATT".y*attn + " LIGHT_DISTATT".z*attn*attn);\n",
object.Write("attn = max(0.0, " LIGHT_COSATT".x + " LIGHT_COSATT".y*attn + " LIGHT_COSATT".z*attn*attn) / (" LIGHT_DISTATT".x + " LIGHT_DISTATT".y*attn + " LIGHT_DISTATT".z*attn*attn);\n",
LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index), LIGHT_COSATT_PARAMS(lightsName, index),
LIGHT_DISTATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index), LIGHT_DISTATT_PARAMS(lightsName, index));
}
Expand All @@ -101,7 +101,7 @@ static void GenerateLightShader(T& object, LightingUidData& uid_data, int index,
case LIGHTDIF_CLAMP:
object.Write("lacc.%s += attn * %sdot(ldir, _norm0)) * " LIGHT_COL";\n",
swizzle,
chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(",
chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0," :"(",
LIGHT_COL_PARAMS(lightsName, index, swizzle));
break;
default: _assert_(0);
Expand Down Expand Up @@ -133,7 +133,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
else if (components & VB_HAS_COL0)
object.Write("mat = %s0;\n", inColorName);
else
object.Write("mat = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
object.Write("mat = float4(1.0, 1.0, 1.0, 1.0);\n");
}
else // from color
{
Expand All @@ -154,7 +154,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
// TODO: this isn't verified. Here we want to read the ambient from the vertex,
// but the vertex itself has no color. So we don't know which value to read.
// Returing 1.0 is the same as disabled lightning, so this could be fine
object.Write("lacc = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
object.Write("lacc = float4(1.0, 1.0, 1.0, 1.0);\n");
}
else // from color
{
Expand All @@ -163,7 +163,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
}
else
{
object.Write("lacc = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
object.Write("lacc = float4(1.0, 1.0, 1.0, 1.0);\n");
}

// check if alpha is different
Expand All @@ -176,7 +176,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
object.Write("mat.w = %s%d.w;\n", inColorName, j);
else if (components & VB_HAS_COL0)
object.Write("mat.w = %s0.w;\n", inColorName);
else object.Write("mat.w = 1.0f;\n");
else object.Write("mat.w = 1.0;\n");
}
else // from color
{
Expand All @@ -196,7 +196,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
object.Write("lacc.w = %s0.w;\n", inColorName);
else
// TODO: The same for alpha: We want to read from vertex, but the vertex has no color
object.Write("lacc.w = 1.0f;\n");
object.Write("lacc.w = 1.0;\n");
}
else // from color
{
Expand All @@ -205,7 +205,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
}
else
{
object.Write("lacc.w = 1.0f;\n");
object.Write("lacc.w = 1.0;\n");
}

if(color.enablelighting && alpha.enablelighting)
Expand Down Expand Up @@ -256,7 +256,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
GenerateLightShader<T>(object, uid_data, i, lit_index, lightsName, coloralpha);
}
}
object.Write("%s%d = mat * clamp(lacc, 0.0f, 1.0f);\n", dest, j);
object.Write("%s%d = mat * clamp(lacc, 0.0, 1.0);\n", dest, j);
object.Write("}\n");
}
}
Expand Down

0 comments on commit 6bdcde9

Please sign in to comment.