[Android] Tegra 4 'support.' This brings up the OpenGL backend to support 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.
This commit is contained in:
Ryan Houdek
2013-10-06 03:12:13 -05:00
parent 2b08172a45
commit 6bdcde9dd6
20 changed files with 404 additions and 285 deletions

View File

@ -142,7 +142,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
if (ApiType != API_OPENGL)
{
WRITE(p, " sampleUv = sampleUv + float2(0.0f,1.0f);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv + float2(0.0,1.0);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n");
}
}
@ -204,14 +204,14 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
WRITE(p, " float yb = yl * %f;\n", blkH);
WRITE(p, " float yoff = uv1.y - yb;\n");
WRITE(p, " float xp = uv1.x + (yoff * " I_COLORS"[1].x);\n");
WRITE(p, " float xel = floor(xp / 2.0f);\n");
WRITE(p, " float xel = floor(xp / 2.0);\n");
WRITE(p, " float xb = floor(xel / %f);\n", blkH);
WRITE(p, " float xoff = xel - (xb * %f);\n", blkH);
WRITE(p, " float x2 = uv1.x * 2.0f;\n");
WRITE(p, " float x2 = uv1.x * 2.0;\n");
WRITE(p, " float xl = floor(x2 / %f);\n", blkW);
WRITE(p, " float xib = x2 - (xl * %f);\n", blkW);
WRITE(p, " float halfxb = floor(xb / 2.0f);\n");
WRITE(p, " float halfxb = floor(xb / 2.0);\n");
WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW);
WRITE(p, " sampleUv.y = yb + xoff;\n");
@ -224,7 +224,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
if (ApiType != API_OPENGL)
{
WRITE(p, " sampleUv = sampleUv + float2(0.0f,1.0f);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv + float2(0.0,1.0);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n");
}
}
@ -246,7 +246,7 @@ void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYP
else
texSampleIncrementUnit = I_COLORS"[0].x";
WRITE(p, " %s = %s(samp0, sampleUv + float2(%d.0f * (%s), 0.0f)).%s;\n",
WRITE(p, " %s = %s(samp0, sampleUv + float2(%d.0 * (%s), 0.0)).%s;\n",
dest, texSampleOpName, s_incrementSampleXCount, texSampleIncrementUnit, colorComp);
}
@ -282,7 +282,7 @@ void WriteIncrementSampleX(char*& p,API_TYPE ApiType)
void WriteToBitDepth(char*& p, u8 depth, const char* src, const char* dest)
{
float result = 255 / pow(2.0f, (8 - depth));
float result = 255 / pow(2.0, (8 - depth));
WRITE(p, " %s = floor(%s * %ff);\n", dest, src, result);
}
@ -362,7 +362,7 @@ void WriteI4Encoder(char* p, API_TYPE ApiType)
WriteToBitDepth(p, 4, "color0", "color0");
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -416,7 +416,7 @@ void WriteIA4Encoder(char* p,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color0", "color0");
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -432,15 +432,15 @@ void WriteRGB565Encoder(char* p,API_TYPE ApiType)
WRITE(p, " float2 texBs = float2(texSample0.b, texSample1.b);\n");
WriteToBitDepth(p, 6, "texGs", "float2 gInt");
WRITE(p, " float2 gUpper = floor(gInt / 8.0f);\n");
WRITE(p, " float2 gLower = gInt - gUpper * 8.0f;\n");
WRITE(p, " float2 gUpper = floor(gInt / 8.0);\n");
WRITE(p, " float2 gLower = gInt - gUpper * 8.0;\n");
WriteToBitDepth(p, 5, "texRs", "ocol0.br");
WRITE(p, " ocol0.br = ocol0.br * 8.0f + gUpper;\n");
WRITE(p, " ocol0.br = ocol0.br * 8.0 + gUpper;\n");
WriteToBitDepth(p, 5, "texBs", "ocol0.ga");
WRITE(p, " ocol0.ga = ocol0.ga + gLower * 32.0f;\n");
WRITE(p, " ocol0.ga = ocol0.ga + gLower * 32.0;\n");
WRITE(p, " ocol0 = ocol0 / 255.0f;\n");
WRITE(p, " ocol0 = ocol0 / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -459,13 +459,13 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WRITE(p, "if(texSample.a > 0.878f) {\n");
WriteToBitDepth(p, 5, "texSample.g", "color0");
WRITE(p, " gUpper = floor(color0 / 8.0f);\n");
WRITE(p, " gLower = color0 - gUpper * 8.0f;\n");
WRITE(p, " gUpper = floor(color0 / 8.0);\n");
WRITE(p, " gLower = color0 - gUpper * 8.0;\n");
WriteToBitDepth(p, 5, "texSample.r", "ocol0.b");
WRITE(p, " ocol0.b = ocol0.b * 4.0f + gUpper + 128.0f;\n");
WRITE(p, " ocol0.b = ocol0.b * 4.0 + gUpper + 128.0;\n");
WriteToBitDepth(p, 5, "texSample.b", "ocol0.g");
WRITE(p, " ocol0.g = ocol0.g + gLower * 32.0f;\n");
WRITE(p, " ocol0.g = ocol0.g + gLower * 32.0;\n");
WRITE(p, "} else {\n");
@ -473,9 +473,9 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WriteToBitDepth(p, 4, "texSample.b", "ocol0.g");
WriteToBitDepth(p, 3, "texSample.a", "color0");
WRITE(p, "ocol0.b = ocol0.b + color0 * 16.0f;\n");
WRITE(p, "ocol0.b = ocol0.b + color0 * 16.0;\n");
WriteToBitDepth(p, 4, "texSample.g", "color0");
WRITE(p, "ocol0.g = ocol0.g + color0 * 16.0f;\n");
WRITE(p, "ocol0.g = ocol0.g + color0 * 16.0;\n");
WRITE(p, "}\n");
@ -487,13 +487,13 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WRITE(p, "if(texSample.a > 0.878f) {\n");
WriteToBitDepth(p, 5, "texSample.g", "color0");
WRITE(p, " gUpper = floor(color0 / 8.0f);\n");
WRITE(p, " gLower = color0 - gUpper * 8.0f;\n");
WRITE(p, " gUpper = floor(color0 / 8.0);\n");
WRITE(p, " gLower = color0 - gUpper * 8.0;\n");
WriteToBitDepth(p, 5, "texSample.r", "ocol0.r");
WRITE(p, " ocol0.r = ocol0.r * 4.0f + gUpper + 128.0f;\n");
WRITE(p, " ocol0.r = ocol0.r * 4.0 + gUpper + 128.0;\n");
WriteToBitDepth(p, 5, "texSample.b", "ocol0.a");
WRITE(p, " ocol0.a = ocol0.a + gLower * 32.0f;\n");
WRITE(p, " ocol0.a = ocol0.a + gLower * 32.0;\n");
WRITE(p, "} else {\n");
@ -501,13 +501,13 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WriteToBitDepth(p, 4, "texSample.b", "ocol0.a");
WriteToBitDepth(p, 3, "texSample.a", "color0");
WRITE(p, "ocol0.r = ocol0.r + color0 * 16.0f;\n");
WRITE(p, "ocol0.r = ocol0.r + color0 * 16.0;\n");
WriteToBitDepth(p, 4, "texSample.g", "color0");
WRITE(p, "ocol0.a = ocol0.a + color0 * 16.0f;\n");
WRITE(p, "ocol0.a = ocol0.a + color0 * 16.0;\n");
WRITE(p, "}\n");
WRITE(p, " ocol0 = ocol0 / 255.0f;\n");
WRITE(p, " ocol0 = ocol0 / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -533,7 +533,7 @@ void WriteRGBA4443Encoder(char* p,API_TYPE ApiType)
WriteToBitDepth(p, 4, "texSample.g", "color0.a");
WriteToBitDepth(p, 4, "texSample.b", "color1.a");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -541,8 +541,8 @@ void WriteRGBA8Encoder(char* p,API_TYPE ApiType)
{
Write32BitSwizzler(p, GX_TF_RGBA8, ApiType);
WRITE(p, " float cl1 = xb - (halfxb * 2.0f);\n");
WRITE(p, " float cl0 = 1.0f - cl1;\n");
WRITE(p, " float cl1 = xb - (halfxb * 2.0);\n");
WRITE(p, " float cl0 = 1.0 - cl1;\n");
WRITE(p, " float4 texSample;\n");
WRITE(p, " float4 color0;\n");
@ -599,7 +599,7 @@ void WriteC4Encoder(char* p, const char* comp,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color0", "color0");
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -650,7 +650,7 @@ void WriteCC4Encoder(char* p, const char* comp,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color0", "color0");
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -701,25 +701,25 @@ void WriteZ16Encoder(char* p,API_TYPE ApiType)
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
WRITE(p, " depth -= expanded.r * 256.0f * 256.0f;\n");
WRITE(p, " expanded.g = floor(depth / 256.0f);\n");
WRITE(p, " depth *= 16777215.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
WRITE(p, " ocol0.b = expanded.g / 255.0f;\n");
WRITE(p, " ocol0.g = expanded.r / 255.0f;\n");
WRITE(p, " ocol0.b = expanded.g / 255.0;\n");
WRITE(p, " ocol0.g = expanded.r / 255.0;\n");
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
WRITE(p, " depth -= expanded.r * 256.0f * 256.0f;\n");
WRITE(p, " expanded.g = floor(depth / 256.0f);\n");
WRITE(p, " depth *= 16777215.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
WRITE(p, " ocol0.r = expanded.g / 255.0f;\n");
WRITE(p, " ocol0.a = expanded.r / 255.0f;\n");
WRITE(p, " ocol0.r = expanded.g / 255.0;\n");
WRITE(p, " ocol0.a = expanded.r / 255.0;\n");
WriteEncoderEnd(p, ApiType);
}
@ -735,25 +735,25 @@ void WriteZ16LEncoder(char* p,API_TYPE ApiType)
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
WRITE(p, " depth -= expanded.r * 256.0f * 256.0f;\n");
WRITE(p, " expanded.g = floor(depth / 256.0f);\n");
WRITE(p, " depth -= expanded.g * 256.0f;\n");
WRITE(p, " depth *= 16777215.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
WRITE(p, " depth -= expanded.g * 256.0;\n");
WRITE(p, " expanded.b = depth;\n");
WRITE(p, " ocol0.b = expanded.b / 255.0f;\n");
WRITE(p, " ocol0.g = expanded.g / 255.0f;\n");
WRITE(p, " ocol0.b = expanded.b / 255.0;\n");
WRITE(p, " ocol0.g = expanded.g / 255.0;\n");
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
WRITE(p, " depth -= expanded.r * 256.0f * 256.0f;\n");
WRITE(p, " expanded.g = floor(depth / 256.0f);\n");
WRITE(p, " depth -= expanded.g * 256.0f;\n");
WRITE(p, " depth *= 16777215.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
WRITE(p, " depth -= expanded.g * 256.0;\n");
WRITE(p, " expanded.b = depth;\n");
WRITE(p, " ocol0.r = expanded.b;\n");
@ -766,7 +766,7 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType)
{
Write32BitSwizzler(p, GX_TF_Z24X8, ApiType);
WRITE(p, " float cl = xb - (halfxb * 2.0f);\n");
WRITE(p, " float cl = xb - (halfxb * 2.0);\n");
WRITE(p, " float depth0;\n");
WRITE(p, " float depth1;\n");
@ -779,27 +779,27 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType)
for (int i = 0; i < 2; i++)
{
WRITE(p, " depth%i *= 16777215.0f;\n", i);
WRITE(p, " depth%i *= 16777215.0;\n", i);
WRITE(p, " expanded%i.r = floor(depth%i / (256.0f * 256.0f));\n", i, i);
WRITE(p, " depth%i -= expanded%i.r * 256.0f * 256.0f;\n", i, i);
WRITE(p, " expanded%i.g = floor(depth%i / 256.0f);\n", i, i);
WRITE(p, " depth%i -= expanded%i.g * 256.0f;\n", i, i);
WRITE(p, " expanded%i.r = floor(depth%i / (256.0 * 256.0));\n", i, i);
WRITE(p, " depth%i -= expanded%i.r * 256.0 * 256.0;\n", i, i);
WRITE(p, " expanded%i.g = floor(depth%i / 256.0);\n", i, i);
WRITE(p, " depth%i -= expanded%i.g * 256.0;\n", i, i);
WRITE(p, " expanded%i.b = depth%i;\n", i, i);
}
WRITE(p, " if(cl > 0.5f) {\n");
WRITE(p, " if(cl > 0.5) {\n");
// upper 16
WRITE(p, " ocol0.b = expanded0.g / 255.0f;\n");
WRITE(p, " ocol0.g = expanded0.b / 255.0f;\n");
WRITE(p, " ocol0.r = expanded1.g / 255.0f;\n");
WRITE(p, " ocol0.a = expanded1.b / 255.0f;\n");
WRITE(p, " ocol0.b = expanded0.g / 255.0;\n");
WRITE(p, " ocol0.g = expanded0.b / 255.0;\n");
WRITE(p, " ocol0.r = expanded1.g / 255.0;\n");
WRITE(p, " ocol0.a = expanded1.b / 255.0;\n");
WRITE(p, " } else {\n");
// lower 8
WRITE(p, " ocol0.b = 1.0f;\n");
WRITE(p, " ocol0.g = expanded0.r / 255.0f;\n");
WRITE(p, " ocol0.r = 1.0f;\n");
WRITE(p, " ocol0.a = expanded1.r / 255.0f;\n");
WRITE(p, " ocol0.b = 1.0;\n");
WRITE(p, " ocol0.g = expanded0.r / 255.0;\n");
WRITE(p, " ocol0.r = 1.0;\n");
WRITE(p, " ocol0.a = expanded1.r / 255.0;\n");
WRITE(p, " }\n");
WriteEncoderEnd(p, ApiType);
@ -878,10 +878,10 @@ const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
WriteC4Encoder(p, "b", ApiType);
break;
case GX_CTF_Z8M:
WriteZ8Encoder(p, "256.0f", ApiType);
WriteZ8Encoder(p, "256.0", ApiType);
break;
case GX_CTF_Z8L:
WriteZ8Encoder(p, "65536.0f" , ApiType);
WriteZ8Encoder(p, "65536.0" , ApiType);
break;
case GX_CTF_Z16L:
WriteZ16LEncoder(p, ApiType);