[Android] Start of *working* GLES3 support. Needs to be able to compile in Windows still.

This commit is contained in:
Ryan Houdek
2013-06-11 08:33:56 -05:00
parent 1bea76a6e0
commit 703a51e4c0
12 changed files with 563 additions and 222 deletions

View File

@ -4,6 +4,7 @@ set(SRCS Src/BPFunctions.cpp
Src/CPMemory.cpp
Src/CommandProcessor.cpp
Src/Debugger.cpp
Src/DriverDetails.cpp
Src/Fifo.cpp
Src/FPSCounter.cpp
Src/FramebufferManagerBase.cpp

View File

@ -0,0 +1,69 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <map>
#include "LogManager.h"
#include "DriverDetails.h"
namespace DriverDetails
{
struct BugInfo
{
Bug m_bug; // Which bug it is
u32 m_devfamily; // Which device(family) has the error
double m_versionstart; // When it started
double m_versionend; // When it ended
bool m_hasbug; // Does it have it?
};
// Local members
Vendor m_vendor = VENDOR_UNKNOWN;
u32 m_devfamily = 0;
double m_version = 0.0;
// This is a list of all known bugs for each vendor
// We use this to check if the device and driver has a issue
BugInfo m_qualcommbugs[] = {
{BUG_NODYNUBOACCESS, 300, 14.0, -1.0},
{BUG_BROKENCENTROID, 300, 14.0, -1.0},
};
std::map<std::pair<Vendor, Bug>, BugInfo> m_bugs;
// Private function
void InitBugMap()
{
switch(m_vendor)
{
case VENDOR_QUALCOMM:
for (int a = 0; a < (sizeof(m_qualcommbugs) / sizeof(BugInfo)); ++a)
m_bugs[std::make_pair(m_vendor, m_qualcommbugs[a].m_bug)] = m_qualcommbugs[a];
break;
default:
break;
}
}
void Init(Vendor vendor, const u32 devfamily, const double version)
{
m_vendor = vendor;
m_devfamily = devfamily;
m_version = version;
InitBugMap();
for (auto it = m_bugs.begin(); it != m_bugs.end(); ++it)
if (it->second.m_devfamily == m_devfamily)
if (it->second.m_versionend == -1.0 || (it->second.m_versionstart <= m_version && it->second.m_versionend > m_version))
it->second.m_hasbug = true;
}
const bool HasBug(Bug bug)
{
auto it = m_bugs.find(std::make_pair(m_vendor, bug));
if (it == m_bugs.end())
return false;
return it->second.m_hasbug;
}
}

View File

@ -0,0 +1,52 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include "CommonTypes.h"
namespace DriverDetails
{
// Enum of known vendors
// Tegra and Nvidia are separated out due to such substantial differences
enum Vendor
{
VENDOR_NVIDIA = 0,
VENDOR_ATI,
VENDOR_INTEL,
VENDOR_ARM,
VENDOR_QUALCOMM,
VENDOR_IMGTEC,
VENDOR_TEGRA,
VENDOR_VIVANTE,
VENDOR_UNKNOWN
};
// Enum of known bugs
// These can be vendor specific, but we put them all in here
// For putting a new bug in here, make sure to put a detailed comment above the enum
// This'll ensure we know exactly what the issue is.
enum Bug
{
// Bug: No Dynamic UBO array object access
// Affected Devices: Qualcomm/Adreno
// Started Version: 14
// Ended Version: -1
// Accessing UBO array members dynamically causes the Adreno shader compiler to crash
// Errors out with "Internal Error"
BUG_NODYNUBOACCESS = 0,
// Bug: Centroid is broken in shaders
// Affected devices: Qualcomm/Adreno
// Started Version: 14
// Ended Version: -1
// Centroid in/out, used in the shaders, is used for multisample buffers to get the texel correctly
// When MSAA is disabled, it acts like a regular in/out
// Tends to cause the driver to render full white or black
BUG_BROKENCENTROID,
};
// Initializes our internal vendor, device family, and driver version
void Init(Vendor vendor, const u32 devfamily, const double version);
// Once Vendor and driver version is set, this will return if it has the applicable bug passed to it.
const bool HasBug(Bug bug);
}

View File

@ -9,6 +9,7 @@
#include "BPMemory.h"
#include "CPMemory.h"
#include "DriverDetails.h"
#include "LightingShaderGen.h"
#include "VertexShaderGen.h"
#include "VideoConfig.h"
@ -322,13 +323,22 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "int posmtx = int(fposmtx);\n");
}
WRITE(p, "float4 pos = float4(dot(" I_TRANSFORMMATRICES"[posmtx], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+1], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+2], rawpos), 1);\n");
if (components & VB_HAS_NRMALL) {
WRITE(p, "int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
WRITE(p, "float3 N0 = " I_NORMALMATRICES"[normidx].xyz, N1 = " I_NORMALMATRICES"[normidx+1].xyz, N2 = " I_NORMALMATRICES"[normidx+2].xyz;\n");
if (DriverDetails::HasBug(BUG_NODYNUBOACCESS))
{
// This'll cause issues, but it can't be helped
WRITE(p, "float4 pos = float4(dot(" I_TRANSFORMMATRICES"[0], rawpos), dot(" I_TRANSFORMMATRICES"[1], rawpos), dot(" I_TRANSFORMMATRICES"[2], rawpos), 1);\n");
if (components & VB_HAS_NRMALL)
WRITE(p, "float3 N0 = " I_NORMALMATRICES"[0].xyz, N1 = " I_NORMALMATRICES"[1].xyz, N2 = " I_NORMALMATRICES"[2].xyz;\n");
}
else
{
WRITE(p, "float4 pos = float4(dot(" I_TRANSFORMMATRICES"[posmtx], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+1], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+2], rawpos), 1);\n");
if (components & VB_HAS_NRMALL) {
WRITE(p, "int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
WRITE(p, "float3 N0 = " I_NORMALMATRICES"[normidx].xyz, N1 = " I_NORMALMATRICES"[normidx+1].xyz, N2 = " I_NORMALMATRICES"[normidx+2].xyz;\n");
}
}
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n");
if (components & VB_HAS_NRM1)