commit
15a3b30e27
|
@ -42,7 +42,8 @@
|
||||||
// There may be multiple XFBs in GameCube RAM. This is the maximum number to
|
// There may be multiple XFBs in GameCube RAM. This is the maximum number to
|
||||||
// virtualize.
|
// virtualize.
|
||||||
|
|
||||||
namespace OGL {
|
namespace OGL
|
||||||
|
{
|
||||||
|
|
||||||
struct XFBSource : public XFBSourceBase
|
struct XFBSource : public XFBSourceBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,13 +54,20 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
|
||||||
GLsizei stringBufferUsage = 0;
|
GLsizei stringBufferUsage = 0;
|
||||||
glGetShaderiv(vertexShaderID, GL_COMPILE_STATUS, &Result);
|
glGetShaderiv(vertexShaderID, GL_COMPILE_STATUS, &Result);
|
||||||
glGetShaderInfoLog(vertexShaderID, 1024, &stringBufferUsage, stringBuffer);
|
glGetShaderInfoLog(vertexShaderID, 1024, &stringBufferUsage, stringBuffer);
|
||||||
if (Result && stringBufferUsage) {
|
|
||||||
|
if (Result && stringBufferUsage)
|
||||||
|
{
|
||||||
ERROR_LOG(VIDEO, "GLSL vertex shader warnings:\n%s%s", stringBuffer, vertexShader);
|
ERROR_LOG(VIDEO, "GLSL vertex shader warnings:\n%s%s", stringBuffer, vertexShader);
|
||||||
} else if (!Result) {
|
}
|
||||||
|
else if (!Result)
|
||||||
|
{
|
||||||
ERROR_LOG(VIDEO, "GLSL vertex shader error:\n%s%s", stringBuffer, vertexShader);
|
ERROR_LOG(VIDEO, "GLSL vertex shader error:\n%s%s", stringBuffer, vertexShader);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DEBUG_LOG(VIDEO, "GLSL vertex shader compiled:\n%s", vertexShader);
|
DEBUG_LOG(VIDEO, "GLSL vertex shader compiled:\n%s", vertexShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shader_errors = !Result;
|
bool shader_errors = !Result;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -70,13 +77,20 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST) || defined(DEBUG_GLSL)
|
#if defined(_DEBUG) || defined(DEBUGFAST) || defined(DEBUG_GLSL)
|
||||||
glGetShaderiv(fragmentShaderID, GL_COMPILE_STATUS, &Result);
|
glGetShaderiv(fragmentShaderID, GL_COMPILE_STATUS, &Result);
|
||||||
glGetShaderInfoLog(fragmentShaderID, 1024, &stringBufferUsage, stringBuffer);
|
glGetShaderInfoLog(fragmentShaderID, 1024, &stringBufferUsage, stringBuffer);
|
||||||
if (Result && stringBufferUsage) {
|
|
||||||
|
if (Result && stringBufferUsage)
|
||||||
|
{
|
||||||
ERROR_LOG(VIDEO, "GLSL fragment shader warnings:\n%s%s", stringBuffer, fragmentShader);
|
ERROR_LOG(VIDEO, "GLSL fragment shader warnings:\n%s%s", stringBuffer, fragmentShader);
|
||||||
} else if (!Result) {
|
}
|
||||||
|
else if (!Result)
|
||||||
|
{
|
||||||
ERROR_LOG(VIDEO, "GLSL fragment shader error:\n%s%s", stringBuffer, fragmentShader);
|
ERROR_LOG(VIDEO, "GLSL fragment shader error:\n%s%s", stringBuffer, fragmentShader);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DEBUG_LOG(VIDEO, "GLSL fragment shader compiled:\n%s", fragmentShader);
|
DEBUG_LOG(VIDEO, "GLSL fragment shader compiled:\n%s", fragmentShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
shader_errors |= !Result;
|
shader_errors |= !Result;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -87,9 +101,13 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST) || defined(DEBUG_GLSL)
|
#if defined(_DEBUG) || defined(DEBUGFAST) || defined(DEBUG_GLSL)
|
||||||
glGetProgramiv(programID, GL_LINK_STATUS, &Result);
|
glGetProgramiv(programID, GL_LINK_STATUS, &Result);
|
||||||
glGetProgramInfoLog(programID, 1024, &stringBufferUsage, stringBuffer);
|
glGetProgramInfoLog(programID, 1024, &stringBufferUsage, stringBuffer);
|
||||||
if (Result && stringBufferUsage) {
|
|
||||||
|
if (Result && stringBufferUsage)
|
||||||
|
{
|
||||||
ERROR_LOG(VIDEO, "GLSL linker warnings:\n%s%s%s", stringBuffer, vertexShader, fragmentShader);
|
ERROR_LOG(VIDEO, "GLSL linker warnings:\n%s%s%s", stringBuffer, vertexShader, fragmentShader);
|
||||||
} else if (!Result && !shader_errors) {
|
}
|
||||||
|
else if (!Result && !shader_errors)
|
||||||
|
{
|
||||||
ERROR_LOG(VIDEO, "GLSL linker error:\n%s%s%s", stringBuffer, vertexShader, fragmentShader);
|
ERROR_LOG(VIDEO, "GLSL linker error:\n%s%s%s", stringBuffer, vertexShader, fragmentShader);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,7 @@ GLVertexFormat::~GLVertexFormat()
|
||||||
glDeleteVertexArrays(1, &VAO);
|
glDeleteVertexArrays(1, &VAO);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline GLuint VarToGL(VarType t)
|
static inline GLuint VarToGL(VarType t)
|
||||||
{
|
{
|
||||||
static const GLuint lookup[5] = {
|
static const GLuint lookup[5] = {
|
||||||
GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_FLOAT
|
GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_FLOAT
|
||||||
|
@ -75,24 +75,22 @@ void GLVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
|
||||||
|
|
||||||
SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position);
|
SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position);
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++)
|
||||||
SetPointer(SHADER_NORM0_ATTRIB+i, vertex_stride, vtx_decl.normals[i]);
|
SetPointer(SHADER_NORM0_ATTRIB+i, vertex_stride, vtx_decl.normals[i]);
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++)
|
||||||
SetPointer(SHADER_COLOR0_ATTRIB+i, vertex_stride, vtx_decl.colors[i]);
|
SetPointer(SHADER_COLOR0_ATTRIB+i, vertex_stride, vtx_decl.colors[i]);
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++)
|
||||||
SetPointer(SHADER_TEXTURE0_ATTRIB+i, vertex_stride, vtx_decl.texcoords[i]);
|
SetPointer(SHADER_TEXTURE0_ATTRIB+i, vertex_stride, vtx_decl.texcoords[i]);
|
||||||
}
|
|
||||||
|
|
||||||
SetPointer(SHADER_POSMTX_ATTRIB, vertex_stride, vtx_decl.posmtx);
|
SetPointer(SHADER_POSMTX_ATTRIB, vertex_stride, vtx_decl.posmtx);
|
||||||
|
|
||||||
vm->m_last_vao = VAO;
|
vm->m_last_vao = VAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLVertexFormat::SetupVertexPointers() {
|
void GLVertexFormat::SetupVertexPointers()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "VideoCommon/PerfQueryBase.h"
|
#include "VideoCommon/PerfQueryBase.h"
|
||||||
|
|
||||||
namespace OGL {
|
namespace OGL
|
||||||
|
{
|
||||||
|
|
||||||
class PerfQuery : public PerfQueryBase
|
class PerfQuery : public PerfQueryBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,24 +164,28 @@ void OpenGLPostProcessing::Update(u32 width, u32 height)
|
||||||
void OpenGLPostProcessing::ApplyShader()
|
void OpenGLPostProcessing::ApplyShader()
|
||||||
{
|
{
|
||||||
// shader didn't changed
|
// shader didn't changed
|
||||||
if (m_config.GetShader() == g_ActiveConfig.sPostProcessingShader) return;
|
if (m_config.GetShader() == g_ActiveConfig.sPostProcessingShader)
|
||||||
|
return;
|
||||||
|
|
||||||
m_enable = false;
|
m_enable = false;
|
||||||
m_shader.Destroy();
|
m_shader.Destroy();
|
||||||
m_uniform_bindings.clear();
|
m_uniform_bindings.clear();
|
||||||
|
|
||||||
// shader disabled
|
// shader disabled
|
||||||
if (g_ActiveConfig.sPostProcessingShader == "") return;
|
if (g_ActiveConfig.sPostProcessingShader == "")
|
||||||
|
return;
|
||||||
|
|
||||||
// so need to compile shader
|
// so need to compile shader
|
||||||
std::string code = m_config.LoadShader();
|
std::string code = m_config.LoadShader();
|
||||||
|
|
||||||
if (code == "") return;
|
if (code == "")
|
||||||
|
return;
|
||||||
|
|
||||||
code = LoadShaderOptions(code);
|
code = LoadShaderOptions(code);
|
||||||
|
|
||||||
// and compile it
|
// and compile it
|
||||||
if (!ProgramShaderCache::CompileShader(m_shader, s_vertex_shader, code.c_str())) {
|
if (!ProgramShaderCache::CompileShader(m_shader, s_vertex_shader, code.c_str()))
|
||||||
|
{
|
||||||
ERROR_LOG(VIDEO, "Failed to compile post-processing shader %s", m_config.GetShader().c_str());
|
ERROR_LOG(VIDEO, "Failed to compile post-processing shader %s", m_config.GetShader().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,8 @@ void SHADER::SetProgramBindings()
|
||||||
glBindAttribLocation(glprogid, SHADER_NORM1_ATTRIB, "rawnorm1");
|
glBindAttribLocation(glprogid, SHADER_NORM1_ATTRIB, "rawnorm1");
|
||||||
glBindAttribLocation(glprogid, SHADER_NORM2_ATTRIB, "rawnorm2");
|
glBindAttribLocation(glprogid, SHADER_NORM2_ATTRIB, "rawnorm2");
|
||||||
|
|
||||||
for (int i=0; i<8; i++) {
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
char attrib_name[8];
|
char attrib_name[8];
|
||||||
snprintf(attrib_name, 8, "tex%d", i);
|
snprintf(attrib_name, 8, "tex%d", i);
|
||||||
glBindAttribLocation(glprogid, SHADER_TEXTURE0_ATTRIB+i, attrib_name);
|
glBindAttribLocation(glprogid, SHADER_TEXTURE0_ATTRIB+i, attrib_name);
|
||||||
|
@ -153,7 +154,7 @@ void ProgramShaderCache::UploadConstants()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint ProgramShaderCache::GetCurrentProgram(void)
|
GLuint ProgramShaderCache::GetCurrentProgram()
|
||||||
{
|
{
|
||||||
return CurrentProgram;
|
return CurrentProgram;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +217,8 @@ SHADER* ProgramShaderCache::SetShader ( DSTALPHA_MODE dstAlphaMode, u32 componen
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!CompileShader(newentry.shader, vcode.GetBuffer(), pcode.GetBuffer())) {
|
if (!CompileShader(newentry.shader, vcode.GetBuffer(), pcode.GetBuffer()))
|
||||||
|
{
|
||||||
GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
|
GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -275,12 +277,14 @@ bool ProgramShaderCache::CompileShader ( SHADER& shader, const char* vcode, cons
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if (linkStatus != GL_TRUE)
|
if (linkStatus != GL_TRUE)
|
||||||
|
{
|
||||||
PanicAlert("Failed to link shaders!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s, %s, %s):\n%s",
|
PanicAlert("Failed to link shaders!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s, %s, %s):\n%s",
|
||||||
filename.c_str(),
|
filename.c_str(),
|
||||||
g_ogl_config.gl_vendor,
|
g_ogl_config.gl_vendor,
|
||||||
g_ogl_config.gl_renderer,
|
g_ogl_config.gl_renderer,
|
||||||
g_ogl_config.gl_version,
|
g_ogl_config.gl_version,
|
||||||
infoLog);
|
infoLog);
|
||||||
|
}
|
||||||
|
|
||||||
delete [] infoLog;
|
delete [] infoLog;
|
||||||
}
|
}
|
||||||
|
@ -332,6 +336,7 @@ GLuint ProgramShaderCache::CompileSingleShader (GLuint type, const char* code )
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if (compileStatus != GL_TRUE)
|
if (compileStatus != GL_TRUE)
|
||||||
|
{
|
||||||
PanicAlert("Failed to compile %s shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s, %s, %s):\n%s",
|
PanicAlert("Failed to compile %s shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s, %s, %s):\n%s",
|
||||||
type == GL_VERTEX_SHADER ? "vertex" : "pixel",
|
type == GL_VERTEX_SHADER ? "vertex" : "pixel",
|
||||||
filename.c_str(),
|
filename.c_str(),
|
||||||
|
@ -339,6 +344,7 @@ GLuint ProgramShaderCache::CompileSingleShader (GLuint type, const char* code )
|
||||||
g_ogl_config.gl_renderer,
|
g_ogl_config.gl_renderer,
|
||||||
g_ogl_config.gl_version,
|
g_ogl_config.gl_version,
|
||||||
infoLog);
|
infoLog);
|
||||||
|
}
|
||||||
|
|
||||||
delete[] infoLog;
|
delete[] infoLog;
|
||||||
}
|
}
|
||||||
|
@ -372,12 +378,12 @@ void ProgramShaderCache::GetShaderId(SHADERUID* uid, DSTALPHA_MODE dstAlphaMode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramShaderCache::PCacheEntry ProgramShaderCache::GetShaderProgram(void)
|
ProgramShaderCache::PCacheEntry ProgramShaderCache::GetShaderProgram()
|
||||||
{
|
{
|
||||||
return *last_entry;
|
return *last_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramShaderCache::Init(void)
|
void ProgramShaderCache::Init()
|
||||||
{
|
{
|
||||||
// We have to get the UBO alignment here because
|
// We have to get the UBO alignment here because
|
||||||
// if we generate a buffer that isn't aligned
|
// if we generate a buffer that isn't aligned
|
||||||
|
@ -421,7 +427,7 @@ void ProgramShaderCache::Init(void)
|
||||||
last_entry = nullptr;
|
last_entry = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramShaderCache::Shutdown(void)
|
void ProgramShaderCache::Shutdown()
|
||||||
{
|
{
|
||||||
// store all shaders in cache on disk
|
// store all shaders in cache on disk
|
||||||
if (g_ogl_config.bSupportsGLSLCache && !g_Config.bEnableShaderDebugging)
|
if (g_ogl_config.bSupportsGLSLCache && !g_Config.bEnableShaderDebugging)
|
||||||
|
@ -468,7 +474,7 @@ void ProgramShaderCache::Shutdown(void)
|
||||||
s_buffer = nullptr;
|
s_buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramShaderCache::CreateHeader ( void )
|
void ProgramShaderCache::CreateHeader()
|
||||||
{
|
{
|
||||||
GLSL_VERSION v = g_ogl_config.eSupportedGLSLVersion;
|
GLSL_VERSION v = g_ogl_config.eSupportedGLSLVersion;
|
||||||
snprintf(s_glsl_header, sizeof(s_glsl_header),
|
snprintf(s_glsl_header, sizeof(s_glsl_header),
|
||||||
|
@ -540,8 +546,10 @@ void ProgramShaderCache::ProgramShaderCacheInserter::Read ( const SHADERUID& key
|
||||||
entry.shader.SetProgramVariables();
|
entry.shader.SetProgramVariables();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
glDeleteProgram(entry.shader.glprogid);
|
glDeleteProgram(entry.shader.glprogid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace OGL
|
} // namespace OGL
|
||||||
|
|
|
@ -25,9 +25,15 @@ public:
|
||||||
|
|
||||||
bool operator <(const SHADERUID& r) const
|
bool operator <(const SHADERUID& r) const
|
||||||
{
|
{
|
||||||
if (puid < r.puid) return true;
|
if (puid < r.puid)
|
||||||
if (r.puid < puid) return false;
|
return true;
|
||||||
if (vuid < r.vuid) return true;
|
|
||||||
|
if (r.puid < puid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (vuid < r.vuid)
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +78,8 @@ public:
|
||||||
|
|
||||||
typedef std::map<SHADERUID, PCacheEntry> PCache;
|
typedef std::map<SHADERUID, PCacheEntry> PCache;
|
||||||
|
|
||||||
static PCacheEntry GetShaderProgram(void);
|
static PCacheEntry GetShaderProgram();
|
||||||
static GLuint GetCurrentProgram(void);
|
static GLuint GetCurrentProgram();
|
||||||
static SHADER* SetShader(DSTALPHA_MODE dstAlphaMode, u32 components);
|
static SHADER* SetShader(DSTALPHA_MODE dstAlphaMode, u32 components);
|
||||||
static void GetShaderId(SHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 components);
|
static void GetShaderId(SHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 components);
|
||||||
|
|
||||||
|
@ -81,9 +87,9 @@ public:
|
||||||
static GLuint CompileSingleShader(GLuint type, const char *code);
|
static GLuint CompileSingleShader(GLuint type, const char *code);
|
||||||
static void UploadConstants();
|
static void UploadConstants();
|
||||||
|
|
||||||
static void Init(void);
|
static void Init();
|
||||||
static void Shutdown(void);
|
static void Shutdown();
|
||||||
static void CreateHeader(void);
|
static void CreateHeader();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ProgramShaderCacheInserter : public LinearDiskCacheReader<SHADERUID, u8>
|
class ProgramShaderCacheInserter : public LinearDiskCacheReader<SHADERUID, u8>
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
// globals
|
// globals
|
||||||
|
|
||||||
namespace OGL {
|
namespace OGL
|
||||||
|
{
|
||||||
|
|
||||||
static const int char_width = 8;
|
static const int char_width = 8;
|
||||||
static const int char_height = 13;
|
static const int char_height = 13;
|
||||||
|
|
|
@ -13,7 +13,7 @@ class RasterFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RasterFont();
|
RasterFont();
|
||||||
~RasterFont(void);
|
~RasterFont();
|
||||||
static int debug;
|
static int debug;
|
||||||
|
|
||||||
void printMultilineText(const std::string& text, double x, double y, double z, int bbWidth, int bbHeight, u32 color);
|
void printMultilineText(const std::string& text, double x, double y, double z, int bbWidth, int bbHeight, u32 color);
|
||||||
|
|
|
@ -64,7 +64,8 @@ static int OSDInternalW, OSDInternalH;
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
|
|
||||||
enum MultisampleMode {
|
enum MultisampleMode
|
||||||
|
{
|
||||||
MULTISAMPLE_OFF,
|
MULTISAMPLE_OFF,
|
||||||
MULTISAMPLE_2X,
|
MULTISAMPLE_2X,
|
||||||
MULTISAMPLE_4X,
|
MULTISAMPLE_4X,
|
||||||
|
@ -125,26 +126,34 @@ static int GetNumMSAASamples(int MSAAMode)
|
||||||
samples = 1;
|
samples = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (samples <= g_ogl_config.max_samples) return samples;
|
if (samples <= g_ogl_config.max_samples)
|
||||||
|
return samples;
|
||||||
|
|
||||||
// TODO: move this to InitBackendInfo
|
// TODO: move this to InitBackendInfo
|
||||||
OSD::AddMessage(StringFromFormat("%d Anti Aliasing samples selected, but only %d supported by your GPU.", samples, g_ogl_config.max_samples), 10000);
|
OSD::AddMessage(StringFromFormat("%d Anti Aliasing samples selected, but only %d supported by your GPU.", samples, g_ogl_config.max_samples), 10000);
|
||||||
return g_ogl_config.max_samples;
|
return g_ogl_config.max_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ApplySSAASettings() {
|
static void ApplySSAASettings()
|
||||||
|
{
|
||||||
// GLES3 doesn't support SSAA
|
// GLES3 doesn't support SSAA
|
||||||
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
|
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
|
||||||
{
|
{
|
||||||
if (g_ActiveConfig.iMultisampleMode == MULTISAMPLE_SSAA_4X) {
|
if (g_ActiveConfig.iMultisampleMode == MULTISAMPLE_SSAA_4X)
|
||||||
if (g_ogl_config.bSupportSampleShading) {
|
{
|
||||||
|
if (g_ogl_config.bSupportSampleShading)
|
||||||
|
{
|
||||||
glEnable(GL_SAMPLE_SHADING_ARB);
|
glEnable(GL_SAMPLE_SHADING_ARB);
|
||||||
glMinSampleShadingARB(s_MSAASamples);
|
glMinSampleShadingARB(s_MSAASamples);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// TODO: move this to InitBackendInfo
|
// TODO: move this to InitBackendInfo
|
||||||
OSD::AddMessage("SSAA Anti Aliasing isn't supported by your GPU.", 10000);
|
OSD::AddMessage("SSAA Anti Aliasing isn't supported by your GPU.", 10000);
|
||||||
}
|
}
|
||||||
} else if (g_ogl_config.bSupportSampleShading) {
|
}
|
||||||
|
else if (g_ogl_config.bSupportSampleShading)
|
||||||
|
{
|
||||||
glDisable(GL_SAMPLE_SHADING_ARB);
|
glDisable(GL_SAMPLE_SHADING_ARB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,28 +217,46 @@ static void InitDriverInfo()
|
||||||
|
|
||||||
// Get the vendor first
|
// Get the vendor first
|
||||||
if (svendor == "NVIDIA Corporation" && srenderer != "NVIDIA Tegra")
|
if (svendor == "NVIDIA Corporation" && srenderer != "NVIDIA Tegra")
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_NVIDIA;
|
vendor = DriverDetails::VENDOR_NVIDIA;
|
||||||
|
}
|
||||||
else if (svendor == "ATI Technologies Inc." || svendor == "Advanced Micro Devices, Inc.")
|
else if (svendor == "ATI Technologies Inc." || svendor == "Advanced Micro Devices, Inc.")
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_ATI;
|
vendor = DriverDetails::VENDOR_ATI;
|
||||||
|
}
|
||||||
else if (std::string::npos != sversion.find("Mesa"))
|
else if (std::string::npos != sversion.find("Mesa"))
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_MESA;
|
vendor = DriverDetails::VENDOR_MESA;
|
||||||
|
}
|
||||||
else if (std::string::npos != svendor.find("Intel"))
|
else if (std::string::npos != svendor.find("Intel"))
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_INTEL;
|
vendor = DriverDetails::VENDOR_INTEL;
|
||||||
|
}
|
||||||
else if (svendor == "ARM")
|
else if (svendor == "ARM")
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_ARM;
|
vendor = DriverDetails::VENDOR_ARM;
|
||||||
|
}
|
||||||
else if (svendor == "http://limadriver.org/")
|
else if (svendor == "http://limadriver.org/")
|
||||||
{
|
{
|
||||||
vendor = DriverDetails::VENDOR_ARM;
|
vendor = DriverDetails::VENDOR_ARM;
|
||||||
driver = DriverDetails::DRIVER_LIMA;
|
driver = DriverDetails::DRIVER_LIMA;
|
||||||
}
|
}
|
||||||
else if (svendor == "Qualcomm")
|
else if (svendor == "Qualcomm")
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_QUALCOMM;
|
vendor = DriverDetails::VENDOR_QUALCOMM;
|
||||||
|
}
|
||||||
else if (svendor == "Imagination Technologies")
|
else if (svendor == "Imagination Technologies")
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_IMGTEC;
|
vendor = DriverDetails::VENDOR_IMGTEC;
|
||||||
|
}
|
||||||
else if (svendor == "NVIDIA Corporation" && srenderer == "NVIDIA Tegra")
|
else if (svendor == "NVIDIA Corporation" && srenderer == "NVIDIA Tegra")
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_TEGRA;
|
vendor = DriverDetails::VENDOR_TEGRA;
|
||||||
|
}
|
||||||
else if (svendor == "Vivante Corporation")
|
else if (svendor == "Vivante Corporation")
|
||||||
|
{
|
||||||
vendor = DriverDetails::VENDOR_VIVANTE;
|
vendor = DriverDetails::VENDOR_VIVANTE;
|
||||||
|
}
|
||||||
|
|
||||||
// Get device family and driver version...if we care about it
|
// Get device family and driver version...if we care about it
|
||||||
switch (vendor)
|
switch (vendor)
|
||||||
|
@ -588,8 +615,11 @@ Renderer::Renderer()
|
||||||
if (g_ActiveConfig.backend_info.bSupportsPrimitiveRestart)
|
if (g_ActiveConfig.backend_info.bSupportsPrimitiveRestart)
|
||||||
{
|
{
|
||||||
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
|
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
|
||||||
|
{
|
||||||
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if (g_ogl_config.bSupportOGL31)
|
if (g_ogl_config.bSupportOGL31)
|
||||||
{
|
{
|
||||||
glEnable(GL_PRIMITIVE_RESTART);
|
glEnable(GL_PRIMITIVE_RESTART);
|
||||||
|
@ -601,6 +631,7 @@ Renderer::Renderer()
|
||||||
glPrimitiveRestartIndexNV(65535);
|
glPrimitiveRestartIndexNV(65535);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
ClearEFBCache();
|
ClearEFBCache();
|
||||||
}
|
}
|
||||||
|
@ -1045,9 +1076,21 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||||
{
|
{
|
||||||
color |= 0xFF000000;
|
color |= 0xFF000000;
|
||||||
}
|
}
|
||||||
if (alpha_read_mode.ReadMode == 2) return color; // GX_READ_NONE
|
if (alpha_read_mode.ReadMode == 2)
|
||||||
else if (alpha_read_mode.ReadMode == 1) return (color | 0xFF000000); // GX_READ_FF
|
{
|
||||||
else /*if(alpha_read_mode.ReadMode == 0)*/ return (color & 0x00FFFFFF); // GX_READ_00
|
// GX_READ_NONE
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
else if (alpha_read_mode.ReadMode == 1)
|
||||||
|
{
|
||||||
|
// GX_READ_FF
|
||||||
|
return (color | 0xFF000000);
|
||||||
|
}
|
||||||
|
else /*if(alpha_read_mode.ReadMode == 0)*/
|
||||||
|
{
|
||||||
|
// GX_READ_00
|
||||||
|
return (color & 0x00FFFFFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case POKE_COLOR:
|
case POKE_COLOR:
|
||||||
|
@ -1232,7 +1275,9 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
newval |= bpmem.blendmode.subtract << 2;
|
newval |= bpmem.blendmode.subtract << 2;
|
||||||
|
|
||||||
if (bpmem.blendmode.subtract)
|
if (bpmem.blendmode.subtract)
|
||||||
|
{
|
||||||
newval |= 0x0049; // enable blending src 1 dst 1
|
newval |= 0x0049; // enable blending src 1 dst 1
|
||||||
|
}
|
||||||
else if (bpmem.blendmode.blendenable)
|
else if (bpmem.blendmode.blendenable)
|
||||||
{
|
{
|
||||||
newval |= 1; // enable blending
|
newval |= 1; // enable blending
|
||||||
|
@ -1243,8 +1288,10 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
|
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
|
||||||
|
|
||||||
if (changes & 1)
|
if (changes & 1)
|
||||||
|
{
|
||||||
// blend enable change
|
// blend enable change
|
||||||
(newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
(newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
|
|
||||||
if (changes & 4)
|
if (changes & 4)
|
||||||
{
|
{
|
||||||
|
@ -1271,12 +1318,16 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we can't use GL_DST_COLOR or GL_ONE_MINUS_DST_COLOR for source in alpha channel so use their alpha equivalent instead
|
// we can't use GL_DST_COLOR or GL_ONE_MINUS_DST_COLOR for source in alpha channel so use their alpha equivalent instead
|
||||||
if (srcidx == BlendMode::DSTCLR) srcidx = BlendMode::DSTALPHA;
|
if (srcidx == BlendMode::DSTCLR)
|
||||||
if (srcidx == BlendMode::INVDSTCLR) srcidx = BlendMode::INVDSTALPHA;
|
srcidx = BlendMode::DSTALPHA;
|
||||||
|
else if (srcidx == BlendMode::INVDSTCLR)
|
||||||
|
srcidx = BlendMode::INVDSTALPHA;
|
||||||
|
|
||||||
// we can't use GL_SRC_COLOR or GL_ONE_MINUS_SRC_COLOR for destination in alpha channel so use their alpha equivalent instead
|
// we can't use GL_SRC_COLOR or GL_ONE_MINUS_SRC_COLOR for destination in alpha channel so use their alpha equivalent instead
|
||||||
if (dstidx == BlendMode::SRCCLR) dstidx = BlendMode::SRCALPHA;
|
if (dstidx == BlendMode::SRCCLR)
|
||||||
if (dstidx == BlendMode::INVSRCCLR) dstidx = BlendMode::INVSRCALPHA;
|
dstidx = BlendMode::SRCALPHA;
|
||||||
|
else if (dstidx == BlendMode::INVSRCCLR)
|
||||||
|
dstidx = BlendMode::INVSRCALPHA;
|
||||||
}
|
}
|
||||||
GLenum srcFactorAlpha = glSrcFactors[srcidx];
|
GLenum srcFactorAlpha = glSrcFactors[srcidx];
|
||||||
GLenum dstFactorAlpha = glDestFactors[dstidx];
|
GLenum dstFactorAlpha = glDestFactors[dstidx];
|
||||||
|
@ -1452,7 +1503,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||||
bAVIDumping = AVIDump::Start(w, h);
|
bAVIDumping = AVIDump::Start(w, h);
|
||||||
#endif
|
#endif
|
||||||
if (!bAVIDumping)
|
if (!bAVIDumping)
|
||||||
|
{
|
||||||
OSD::AddMessage("AVIDump Start failed", 2000);
|
OSD::AddMessage("AVIDump Start failed", 2000);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OSD::AddMessage(StringFromFormat(
|
OSD::AddMessage(StringFromFormat(
|
||||||
|
@ -1472,8 +1525,10 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||||
bLastFrameDumped = true;
|
bLastFrameDumped = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
NOTICE_LOG(VIDEO, "Error reading framebuffer");
|
NOTICE_LOG(VIDEO, "Error reading framebuffer");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bLastFrameDumped && bAVIDumping)
|
if (bLastFrameDumped && bAVIDumping)
|
||||||
|
@ -1503,7 +1558,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||||
movie_file_name = File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump.raw";
|
movie_file_name = File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump.raw";
|
||||||
pFrameDump.Open(movie_file_name, "wb");
|
pFrameDump.Open(movie_file_name, "wb");
|
||||||
if (!pFrameDump)
|
if (!pFrameDump)
|
||||||
|
{
|
||||||
OSD::AddMessage("Error opening framedump.raw for writing.", 2000);
|
OSD::AddMessage("Error opening framedump.raw for writing.", 2000);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000);
|
OSD::AddMessage(StringFromFormat("Dumping Frames to \"%s\" (%dx%d RGB24)", movie_file_name.c_str(), w, h), 2000);
|
||||||
|
@ -1679,8 +1736,10 @@ void Renderer::SetGenerationMode()
|
||||||
glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
|
glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::SetDepthMode()
|
void Renderer::SetDepthMode()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,8 @@ namespace OGL
|
||||||
|
|
||||||
void ClearEFBCache();
|
void ClearEFBCache();
|
||||||
|
|
||||||
enum GLSL_VERSION {
|
enum GLSL_VERSION
|
||||||
|
{
|
||||||
GLSL_130,
|
GLSL_130,
|
||||||
GLSL_140,
|
GLSL_140,
|
||||||
GLSL_150, // and above
|
GLSL_150, // and above
|
||||||
|
@ -17,7 +18,8 @@ enum GLSL_VERSION {
|
||||||
};
|
};
|
||||||
|
|
||||||
// ogl-only config, so not in VideoConfig.h
|
// ogl-only config, so not in VideoConfig.h
|
||||||
struct VideoConfig {
|
struct VideoConfig
|
||||||
|
{
|
||||||
bool bSupportsGLSLCache;
|
bool bSupportsGLSLCache;
|
||||||
bool bSupportsGLPinnedMemory;
|
bool bSupportsGLPinnedMemory;
|
||||||
bool bSupportsGLSync;
|
bool bSupportsGLSync;
|
||||||
|
|
|
@ -95,8 +95,8 @@ void StreamBuffer::AllocMemory(u32 size)
|
||||||
m_free_iterator = m_iterator + size;
|
m_free_iterator = m_iterator + size;
|
||||||
|
|
||||||
// if buffer is full
|
// if buffer is full
|
||||||
if (m_iterator + size >= m_size) {
|
if (m_iterator + size >= m_size)
|
||||||
|
{
|
||||||
// insert waiting slots in unused space at the end of the buffer
|
// insert waiting slots in unused space at the end of the buffer
|
||||||
for (int i = SLOT(m_used_iterator); i < SYNC_POINTS; i++)
|
for (int i = SLOT(m_used_iterator); i < SYNC_POINTS; i++)
|
||||||
{
|
{
|
||||||
|
@ -126,16 +126,20 @@ void StreamBuffer::AllocMemory(u32 size)
|
||||||
class MapAndOrphan : public StreamBuffer
|
class MapAndOrphan : public StreamBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MapAndOrphan(u32 type, u32 size) : StreamBuffer(type, size) {
|
MapAndOrphan(u32 type, u32 size) : StreamBuffer(type, size)
|
||||||
|
{
|
||||||
glBindBuffer(m_buffertype, m_buffer);
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW);
|
glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
~MapAndOrphan() {
|
~MapAndOrphan()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<u8*, u32> Map(u32 size) override {
|
std::pair<u8*, u32> Map(u32 size) override
|
||||||
if (m_iterator + size >= m_size) {
|
{
|
||||||
|
if (m_iterator + size >= m_size)
|
||||||
|
{
|
||||||
glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW);
|
glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW);
|
||||||
m_iterator = 0;
|
m_iterator = 0;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +148,8 @@ public:
|
||||||
return std::make_pair(pointer, m_iterator);
|
return std::make_pair(pointer, m_iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(u32 used_size) override {
|
void Unmap(u32 used_size) override
|
||||||
|
{
|
||||||
glFlushMappedBufferRange(m_buffertype, 0, used_size);
|
glFlushMappedBufferRange(m_buffertype, 0, used_size);
|
||||||
glUnmapBuffer(m_buffertype);
|
glUnmapBuffer(m_buffertype);
|
||||||
m_iterator += used_size;
|
m_iterator += used_size;
|
||||||
|
@ -161,24 +166,28 @@ public:
|
||||||
class MapAndSync : public StreamBuffer
|
class MapAndSync : public StreamBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MapAndSync(u32 type, u32 size) : StreamBuffer(type, size) {
|
MapAndSync(u32 type, u32 size) : StreamBuffer(type, size)
|
||||||
|
{
|
||||||
CreateFences();
|
CreateFences();
|
||||||
glBindBuffer(m_buffertype, m_buffer);
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW);
|
glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
~MapAndSync() {
|
~MapAndSync()
|
||||||
|
{
|
||||||
DeleteFences();
|
DeleteFences();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<u8*, u32> Map(u32 size) override {
|
std::pair<u8*, u32> Map(u32 size) override
|
||||||
|
{
|
||||||
AllocMemory(size);
|
AllocMemory(size);
|
||||||
u8* pointer = (u8*)glMapBufferRange(m_buffertype, m_iterator, size,
|
u8* pointer = (u8*)glMapBufferRange(m_buffertype, m_iterator, size,
|
||||||
GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||||
return std::make_pair(pointer, m_iterator);
|
return std::make_pair(pointer, m_iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(u32 used_size) override {
|
void Unmap(u32 used_size) override
|
||||||
|
{
|
||||||
glFlushMappedBufferRange(m_buffertype, 0, used_size);
|
glFlushMappedBufferRange(m_buffertype, 0, used_size);
|
||||||
glUnmapBuffer(m_buffertype);
|
glUnmapBuffer(m_buffertype);
|
||||||
m_iterator += used_size;
|
m_iterator += used_size;
|
||||||
|
@ -201,7 +210,8 @@ public:
|
||||||
class BufferStorage : public StreamBuffer
|
class BufferStorage : public StreamBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferStorage(u32 type, u32 size) : StreamBuffer(type, size) {
|
BufferStorage(u32 type, u32 size) : StreamBuffer(type, size)
|
||||||
|
{
|
||||||
CreateFences();
|
CreateFences();
|
||||||
glBindBuffer(m_buffertype, m_buffer);
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
|
|
||||||
|
@ -214,18 +224,21 @@ public:
|
||||||
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
|
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
~BufferStorage() {
|
~BufferStorage()
|
||||||
|
{
|
||||||
DeleteFences();
|
DeleteFences();
|
||||||
glUnmapBuffer(m_buffertype);
|
glUnmapBuffer(m_buffertype);
|
||||||
glBindBuffer(m_buffertype, 0);
|
glBindBuffer(m_buffertype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<u8*, u32> Map(u32 size) override {
|
std::pair<u8*, u32> Map(u32 size) override
|
||||||
|
{
|
||||||
AllocMemory(size);
|
AllocMemory(size);
|
||||||
return std::make_pair(m_pointer + m_iterator, m_iterator);
|
return std::make_pair(m_pointer + m_iterator, m_iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(u32 used_size) override {
|
void Unmap(u32 used_size) override
|
||||||
|
{
|
||||||
glFlushMappedBufferRange(m_buffertype, m_iterator, used_size);
|
glFlushMappedBufferRange(m_buffertype, m_iterator, used_size);
|
||||||
m_iterator += used_size;
|
m_iterator += used_size;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +256,8 @@ public:
|
||||||
class PinnedMemory : public StreamBuffer
|
class PinnedMemory : public StreamBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PinnedMemory(u32 type, u32 size) : StreamBuffer(type, size) {
|
PinnedMemory(u32 type, u32 size) : StreamBuffer(type, size)
|
||||||
|
{
|
||||||
CreateFences();
|
CreateFences();
|
||||||
m_pointer = (u8*)AllocateAlignedMemory(ROUND_UP(m_size,ALIGN_PINNED_MEMORY), ALIGN_PINNED_MEMORY );
|
m_pointer = (u8*)AllocateAlignedMemory(ROUND_UP(m_size,ALIGN_PINNED_MEMORY), ALIGN_PINNED_MEMORY );
|
||||||
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_buffer);
|
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_buffer);
|
||||||
|
@ -252,7 +266,8 @@ public:
|
||||||
glBindBuffer(m_buffertype, m_buffer);
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
~PinnedMemory() {
|
~PinnedMemory()
|
||||||
|
{
|
||||||
DeleteFences();
|
DeleteFences();
|
||||||
glBindBuffer(m_buffertype, 0);
|
glBindBuffer(m_buffertype, 0);
|
||||||
glFinish(); // ogl pipeline must be flushed, else this buffer can be in use
|
glFinish(); // ogl pipeline must be flushed, else this buffer can be in use
|
||||||
|
@ -260,12 +275,14 @@ public:
|
||||||
m_pointer = nullptr;
|
m_pointer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<u8*, u32> Map(u32 size) override {
|
std::pair<u8*, u32> Map(u32 size) override
|
||||||
|
{
|
||||||
AllocMemory(size);
|
AllocMemory(size);
|
||||||
return std::make_pair(m_pointer + m_iterator, m_iterator);
|
return std::make_pair(m_pointer + m_iterator, m_iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(u32 used_size) override {
|
void Unmap(u32 used_size) override
|
||||||
|
{
|
||||||
m_iterator += used_size;
|
m_iterator += used_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,21 +298,25 @@ public:
|
||||||
class BufferSubData : public StreamBuffer
|
class BufferSubData : public StreamBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferSubData(u32 type, u32 size) : StreamBuffer(type, size) {
|
BufferSubData(u32 type, u32 size) : StreamBuffer(type, size)
|
||||||
|
{
|
||||||
glBindBuffer(m_buffertype, m_buffer);
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
glBufferData(m_buffertype, size, nullptr, GL_STATIC_DRAW);
|
glBufferData(m_buffertype, size, nullptr, GL_STATIC_DRAW);
|
||||||
m_pointer = new u8[m_size];
|
m_pointer = new u8[m_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
~BufferSubData() {
|
~BufferSubData()
|
||||||
|
{
|
||||||
delete [] m_pointer;
|
delete [] m_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<u8*, u32> Map(u32 size) override {
|
std::pair<u8*, u32> Map(u32 size) override
|
||||||
|
{
|
||||||
return std::make_pair(m_pointer, 0);
|
return std::make_pair(m_pointer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(u32 used_size) override {
|
void Unmap(u32 used_size) override
|
||||||
|
{
|
||||||
glBufferSubData(m_buffertype, 0, used_size, m_pointer);
|
glBufferSubData(m_buffertype, 0, used_size, m_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,20 +331,24 @@ public:
|
||||||
class BufferData : public StreamBuffer
|
class BufferData : public StreamBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferData(u32 type, u32 size) : StreamBuffer(type, size) {
|
BufferData(u32 type, u32 size) : StreamBuffer(type, size)
|
||||||
|
{
|
||||||
glBindBuffer(m_buffertype, m_buffer);
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
m_pointer = new u8[m_size];
|
m_pointer = new u8[m_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
~BufferData() {
|
~BufferData()
|
||||||
|
{
|
||||||
delete [] m_pointer;
|
delete [] m_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<u8*, u32> Map(u32 size) override {
|
std::pair<u8*, u32> Map(u32 size) override
|
||||||
|
{
|
||||||
return std::make_pair(m_pointer, 0);
|
return std::make_pair(m_pointer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(u32 used_size) override {
|
void Unmap(u32 used_size) override
|
||||||
|
{
|
||||||
glBufferData(m_buffertype, used_size, m_pointer, GL_STREAM_DRAW);
|
glBufferData(m_buffertype, used_size, m_pointer, GL_STREAM_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
|
|
||||||
class StreamBuffer {
|
class StreamBuffer
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static StreamBuffer* Create(u32 type, u32 size);
|
static StreamBuffer* Create(u32 type, u32 size);
|
||||||
|
|
|
@ -298,8 +298,10 @@ int EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer,
|
||||||
format |= _GX_TF_CTF;
|
format |= _GX_TF_CTF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !bIsIntensityFmt))
|
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !bIsIntensityFmt))
|
||||||
format |= _GX_TF_CTF;
|
format |= _GX_TF_CTF;
|
||||||
|
}
|
||||||
|
|
||||||
SHADER& texconv_shader = GetOrCreateEncodingShader(format);
|
SHADER& texconv_shader = GetOrCreateEncodingShader(format);
|
||||||
|
|
||||||
|
|
|
@ -116,11 +116,15 @@ void VertexManager::Draw(u32 stride)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ogl_config.bSupportsGLBaseVertex) {
|
if (g_ogl_config.bSupportsGLBaseVertex)
|
||||||
|
{
|
||||||
glDrawRangeElementsBaseVertex(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr+s_index_offset, (GLint)s_baseVertex);
|
glDrawRangeElementsBaseVertex(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr+s_index_offset, (GLint)s_baseVertex);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
glDrawRangeElements(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr+s_index_offset);
|
glDrawRangeElements(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr+s_index_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
INCSTAT(stats.thisFrame.numDrawCalls);
|
INCSTAT(stats.thisFrame.numDrawCalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +133,8 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||||
GLVertexFormat *nativeVertexFmt = (GLVertexFormat*)VertexLoaderManager::GetCurrentVertexFormat();
|
GLVertexFormat *nativeVertexFmt = (GLVertexFormat*)VertexLoaderManager::GetCurrentVertexFormat();
|
||||||
u32 stride = nativeVertexFmt->GetVertexStride();
|
u32 stride = nativeVertexFmt->GetVertexStride();
|
||||||
|
|
||||||
if (m_last_vao != nativeVertexFmt->VAO) {
|
if (m_last_vao != nativeVertexFmt->VAO)
|
||||||
|
{
|
||||||
glBindVertexArray(nativeVertexFmt->VAO);
|
glBindVertexArray(nativeVertexFmt->VAO);
|
||||||
m_last_vao = nativeVertexFmt->VAO;
|
m_last_vao = nativeVertexFmt->VAO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,8 +226,8 @@ void VideoBackend::Shutdown()
|
||||||
GLInterface->Shutdown();
|
GLInterface->Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoBackend::Video_Cleanup() {
|
void VideoBackend::Video_Cleanup()
|
||||||
|
{
|
||||||
if (g_renderer)
|
if (g_renderer)
|
||||||
{
|
{
|
||||||
s_efbAccessRequested = false;
|
s_efbAccessRequested = false;
|
||||||
|
|
Loading…
Reference in New Issue