mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
Fixed crash on start if config does not exists
Cleanup OpenGL renerer
This commit is contained in:
parent
e4631f93bd
commit
7416fe91fc
@ -1,267 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "GLBuffers.h"
|
||||
|
||||
GLBufferObject::GLBufferObject()
|
||||
{
|
||||
}
|
||||
|
||||
GLBufferObject::GLBufferObject(u32 type)
|
||||
{
|
||||
Create(type);
|
||||
}
|
||||
|
||||
GLBufferObject::~GLBufferObject()
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
|
||||
void GLBufferObject::Create(GLuint type, u32 count)
|
||||
{
|
||||
if(IsCreated()) return;
|
||||
|
||||
m_id.resize(count);
|
||||
glGenBuffers(count, &m_id[0]);
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
void GLBufferObject::Delete()
|
||||
{
|
||||
if(!IsCreated()) return;
|
||||
|
||||
glDeleteBuffers(m_id.size(), &m_id[0]);
|
||||
m_id.clear();
|
||||
m_type = 0;
|
||||
}
|
||||
|
||||
void GLBufferObject::Bind(u32 type, u32 num)
|
||||
{
|
||||
assert(num < m_id.size());
|
||||
glBindBuffer(type, m_id[num]);
|
||||
}
|
||||
|
||||
void GLBufferObject::UnBind(u32 type)
|
||||
{
|
||||
glBindBuffer(type, 0);
|
||||
}
|
||||
|
||||
void GLBufferObject::Bind(u32 num)
|
||||
{
|
||||
Bind(m_type, num);
|
||||
}
|
||||
|
||||
void GLBufferObject::UnBind()
|
||||
{
|
||||
UnBind(m_type);
|
||||
}
|
||||
|
||||
void GLBufferObject::SetData(u32 type, const void* data, u32 size, u32 usage)
|
||||
{
|
||||
glBufferData(type, size, data, usage);
|
||||
}
|
||||
|
||||
void GLBufferObject::SetData(const void* data, u32 size, u32 usage)
|
||||
{
|
||||
SetData(m_type, data, size, usage);
|
||||
}
|
||||
|
||||
void GLBufferObject::SetAttribPointer(int location, int size, int type, GLvoid* pointer, int stride, bool normalized)
|
||||
{
|
||||
if(location < 0) return;
|
||||
|
||||
glVertexAttribPointer(location, size, type, normalized ? GL_TRUE : GL_FALSE, stride, pointer);
|
||||
glEnableVertexAttribArray(location);
|
||||
}
|
||||
|
||||
bool GLBufferObject::IsCreated() const
|
||||
{
|
||||
return m_id.size() != 0;
|
||||
}
|
||||
|
||||
GLvbo::GLvbo()
|
||||
{
|
||||
}
|
||||
|
||||
void GLvbo::Create(u32 count)
|
||||
{
|
||||
GLBufferObject::Create(GL_ARRAY_BUFFER, count);
|
||||
}
|
||||
|
||||
GLvao::GLvao() : m_id(0)
|
||||
{
|
||||
}
|
||||
|
||||
GLvao::~GLvao()
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
|
||||
void GLvao::Create()
|
||||
{
|
||||
if(!IsCreated()) glGenVertexArrays(1, &m_id);
|
||||
}
|
||||
|
||||
void GLvao::Bind() const
|
||||
{
|
||||
glBindVertexArray(m_id);
|
||||
}
|
||||
|
||||
void GLvao::Unbind()
|
||||
{
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void GLvao::Delete()
|
||||
{
|
||||
if(!IsCreated()) return;
|
||||
|
||||
Unbind();
|
||||
glDeleteVertexArrays(1, &m_id);
|
||||
m_id = 0;
|
||||
}
|
||||
|
||||
bool GLvao::IsCreated() const
|
||||
{
|
||||
return m_id != 0;
|
||||
}
|
||||
|
||||
GLrbo::GLrbo()
|
||||
{
|
||||
}
|
||||
|
||||
GLrbo::~GLrbo()
|
||||
{
|
||||
}
|
||||
|
||||
void GLrbo::Create(u32 count)
|
||||
{
|
||||
if(m_id.size() == count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Delete();
|
||||
|
||||
m_id.resize(count);
|
||||
glGenRenderbuffers(count, m_id.data());
|
||||
}
|
||||
|
||||
void GLrbo::Bind(u32 num) const
|
||||
{
|
||||
assert(num < m_id.size());
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_id[num]);
|
||||
}
|
||||
|
||||
void GLrbo::Storage(u32 format, u32 width, u32 height)
|
||||
{
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, format, width, height);
|
||||
}
|
||||
|
||||
void GLrbo::Unbind()
|
||||
{
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
|
||||
void GLrbo::Delete()
|
||||
{
|
||||
if(!IsCreated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
glDeleteRenderbuffers(m_id.size(), m_id.data());
|
||||
m_id.clear();
|
||||
}
|
||||
|
||||
bool GLrbo::IsCreated() const
|
||||
{
|
||||
return m_id.size();
|
||||
}
|
||||
|
||||
u32 GLrbo::GetId(u32 num) const
|
||||
{
|
||||
assert(num < m_id.size());
|
||||
return m_id[num];
|
||||
}
|
||||
|
||||
GLfbo::GLfbo() : m_id(0)
|
||||
{
|
||||
}
|
||||
|
||||
GLfbo::~GLfbo()
|
||||
{
|
||||
}
|
||||
|
||||
void GLfbo::Create()
|
||||
{
|
||||
if(IsCreated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
glGenFramebuffers(1, &m_id);
|
||||
}
|
||||
|
||||
void GLfbo::Bind(u32 type, int id)
|
||||
{
|
||||
glBindFramebuffer(type, id);
|
||||
}
|
||||
|
||||
void GLfbo::Bind(u32 type)
|
||||
{
|
||||
assert(IsCreated());
|
||||
|
||||
m_type = type;
|
||||
Bind(type, m_id);
|
||||
}
|
||||
|
||||
void GLfbo::Texture1D(u32 attachment, u32 texture, int level)
|
||||
{
|
||||
glFramebufferTexture1D(m_type, attachment, GL_TEXTURE_1D, texture, level);
|
||||
}
|
||||
|
||||
void GLfbo::Texture2D(u32 attachment, u32 texture, int level)
|
||||
{
|
||||
glFramebufferTexture2D(m_type, attachment, GL_TEXTURE_2D, texture, level);
|
||||
}
|
||||
|
||||
void GLfbo::Texture3D(u32 attachment, u32 texture, int zoffset, int level)
|
||||
{
|
||||
glFramebufferTexture3D(m_type, attachment, GL_TEXTURE_3D, texture, level, zoffset);
|
||||
}
|
||||
|
||||
void GLfbo::Renderbuffer(u32 attachment, u32 renderbuffer)
|
||||
{
|
||||
glFramebufferRenderbuffer(m_type, attachment, GL_RENDERBUFFER, renderbuffer);
|
||||
}
|
||||
|
||||
void GLfbo::Blit(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, u32 mask, u32 filter)
|
||||
{
|
||||
glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||
}
|
||||
|
||||
void GLfbo::Unbind()
|
||||
{
|
||||
Unbind(m_type);
|
||||
}
|
||||
|
||||
void GLfbo::Unbind(u32 type)
|
||||
{
|
||||
glBindFramebuffer(type, 0);
|
||||
}
|
||||
|
||||
void GLfbo::Delete()
|
||||
{
|
||||
if(!IsCreated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
glDeleteFramebuffers(1, &m_id);
|
||||
m_id = 0;
|
||||
}
|
||||
|
||||
bool GLfbo::IsCreated() const
|
||||
{
|
||||
return m_id != 0;
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
#pragma once
|
||||
#include "OpenGL.h"
|
||||
|
||||
struct GLBufferObject
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> m_id;
|
||||
GLuint m_type;
|
||||
|
||||
public:
|
||||
GLBufferObject();
|
||||
GLBufferObject(u32 type);
|
||||
|
||||
~GLBufferObject();
|
||||
|
||||
void Create(GLuint type, u32 count = 1);
|
||||
void Delete();
|
||||
void Bind(u32 type, u32 num);
|
||||
void UnBind(u32 type);
|
||||
void Bind(u32 num = 0);
|
||||
void UnBind();
|
||||
void SetData(u32 type, const void* data, u32 size, u32 usage = GL_DYNAMIC_DRAW);
|
||||
void SetData(const void* data, u32 size, u32 usage = GL_DYNAMIC_DRAW);
|
||||
void SetAttribPointer(int location, int size, int type, GLvoid* pointer, int stride, bool normalized = false);
|
||||
bool IsCreated() const;
|
||||
};
|
||||
|
||||
struct GLvbo : public GLBufferObject
|
||||
{
|
||||
GLvbo();
|
||||
|
||||
void Create(u32 count = 1);
|
||||
};
|
||||
|
||||
class GLvao
|
||||
{
|
||||
protected:
|
||||
GLuint m_id;
|
||||
|
||||
public:
|
||||
GLvao();
|
||||
~GLvao();
|
||||
|
||||
void Create();
|
||||
void Bind() const;
|
||||
static void Unbind();
|
||||
void Delete();
|
||||
bool IsCreated() const;
|
||||
};
|
||||
|
||||
class GLrbo
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> m_id;
|
||||
|
||||
public:
|
||||
GLrbo();
|
||||
~GLrbo();
|
||||
|
||||
void Create(u32 count = 1);
|
||||
void Bind(u32 num = 0) const;
|
||||
void Storage(u32 format, u32 width, u32 height);
|
||||
static void Unbind();
|
||||
void Delete();
|
||||
bool IsCreated() const;
|
||||
u32 GetId(u32 num = 0) const;
|
||||
};
|
||||
|
||||
class GLfbo
|
||||
{
|
||||
protected:
|
||||
GLuint m_id;
|
||||
GLuint m_type;
|
||||
|
||||
public:
|
||||
GLfbo();
|
||||
~GLfbo();
|
||||
|
||||
void Create();
|
||||
static void Bind(u32 type, int id);
|
||||
void Bind(u32 type = GL_FRAMEBUFFER);
|
||||
void Texture1D(u32 attachment, u32 texture, int level = 0);
|
||||
void Texture2D(u32 attachment, u32 texture, int level = 0);
|
||||
void Texture3D(u32 attachment, u32 texture, int zoffset = 0, int level = 0);
|
||||
void Renderbuffer(u32 attachment, u32 renderbuffer);
|
||||
static void Blit(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, u32 mask, u32 filter);
|
||||
void Unbind();
|
||||
static void Unbind(u32 type);
|
||||
void Delete();
|
||||
bool IsCreated() const;
|
||||
};
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "Emu/RSX/GSRender.h"
|
||||
#include "GLBuffers.h"
|
||||
#include "gl_helpers.h"
|
||||
|
||||
#define RSX_DEBUG 1
|
||||
|
@ -1,119 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "Utilities/Log.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "GLProgram.h"
|
||||
#include "GLGSRender.h"
|
||||
/*
|
||||
GLProgram::GLProgram() : id(0)
|
||||
{
|
||||
}
|
||||
|
||||
int GLProgram::GetLocation(const std::string& name)
|
||||
{
|
||||
for (u32 i=0; i < m_locations.size(); ++i)
|
||||
{
|
||||
if (!m_locations[i].name.compare(name))
|
||||
{
|
||||
return m_locations[i].loc;
|
||||
}
|
||||
}
|
||||
|
||||
m_locations.emplace_back();
|
||||
u32 pos = m_locations.size()-1;
|
||||
m_locations[pos].name = name;
|
||||
|
||||
m_locations[pos].loc = glGetUniformLocation(id, name.c_str());
|
||||
checkForGlError(fmt::format("glGetUniformLocation(0x%x, %s)", id, name.c_str()));
|
||||
return m_locations[pos].loc;
|
||||
}
|
||||
|
||||
bool GLProgram::IsCreated() const
|
||||
{
|
||||
return id > 0;
|
||||
}
|
||||
|
||||
void GLProgram::Create(const u32 vp, const u32 fp)
|
||||
{
|
||||
if (IsCreated())
|
||||
Delete();
|
||||
|
||||
id = glCreateProgram();
|
||||
glAttachShader(id, vp);
|
||||
glAttachShader(id, fp);
|
||||
|
||||
glLinkProgram(id);
|
||||
|
||||
GLint linkStatus = GL_FALSE;
|
||||
glGetProgramiv(id, GL_LINK_STATUS, &linkStatus);
|
||||
if (linkStatus != GL_TRUE)
|
||||
{
|
||||
GLint bufLength = 0;
|
||||
glGetProgramiv(id, GL_INFO_LOG_LENGTH, &bufLength);
|
||||
|
||||
if (bufLength)
|
||||
{
|
||||
char* buf = new char[bufLength + 1]();
|
||||
glGetProgramInfoLog(id, bufLength, NULL, buf);
|
||||
LOG_ERROR(RSX, "Could not link program: %s", buf);
|
||||
delete[] buf;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
//else LOG_NOTICE(HLE, "Program linked!");
|
||||
|
||||
glGetProgramiv(id, GL_VALIDATE_STATUS, &linkStatus);
|
||||
if (linkStatus != GL_TRUE)
|
||||
{
|
||||
GLint bufLength = 0;
|
||||
glGetProgramiv(id, GL_INFO_LOG_LENGTH, &bufLength);
|
||||
|
||||
if (bufLength)
|
||||
{
|
||||
char* buf = new char[bufLength]();
|
||||
glGetProgramInfoLog(id, bufLength, NULL, buf);
|
||||
LOG_ERROR(RSX, "Could not link program: %s", buf);
|
||||
delete[] buf;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLProgram::UnUse()
|
||||
{
|
||||
id = 0;
|
||||
m_locations.clear();
|
||||
}
|
||||
|
||||
void GLProgram::Use()
|
||||
{
|
||||
if (id != 0)
|
||||
glUseProgram(id);
|
||||
checkForGlError("glUseProgram");
|
||||
}
|
||||
|
||||
void GLProgram::SetTex(u32 index)
|
||||
{
|
||||
int loc = GetLocation(fmt::format("tex%u", index));
|
||||
glProgramUniform1i(id, loc, index);
|
||||
checkForGlError(fmt::format("SetTex(%u - %d - %d)", id, index, loc));
|
||||
}
|
||||
|
||||
void GLProgram::SetVTex(u32 index)
|
||||
{
|
||||
int loc = GetLocation(fmt::format("vtex%u", index));
|
||||
glProgramUniform1i(id, loc, index);
|
||||
checkForGlError(fmt::format("SetVTex(%u - %d - %d)", id, index, loc));
|
||||
}
|
||||
|
||||
void GLProgram::Delete()
|
||||
{
|
||||
if (!IsCreated())
|
||||
return;
|
||||
|
||||
glDeleteProgram(id);
|
||||
id = 0;
|
||||
m_locations.clear();
|
||||
}
|
||||
*/
|
@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "GLVertexProgram.h"
|
||||
#include "GLFragmentProgram.h"
|
||||
/*
|
||||
struct GLProgram
|
||||
{
|
||||
private:
|
||||
struct Location
|
||||
{
|
||||
int loc;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
std::vector<Location> m_locations;
|
||||
|
||||
public:
|
||||
u32 id;
|
||||
|
||||
GLProgram();
|
||||
|
||||
int GetLocation(const std::string& name);
|
||||
bool IsCreated() const;
|
||||
void Create(const u32 vp, const u32 fp);
|
||||
void Use();
|
||||
void UnUse();
|
||||
void SetTex(u32 index);
|
||||
void SetVTex(u32 index);
|
||||
void Delete();
|
||||
};
|
||||
*/
|
@ -1,5 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "Utilities/Log.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
|
||||
//#include "GLProgramBuffer.h"
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "GLProgram.h"
|
||||
#include "GLVertexProgram.h"
|
||||
#include "GLFragmentProgram.h"
|
||||
#include "../Common/ProgramStateCache.h"
|
||||
#include "Utilities/File.h"
|
||||
|
||||
|
@ -67,24 +67,19 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Emu\RSX\GL\GLBuffers.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLCommonDecompiler.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLFragmentProgram.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLGSRender.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLProcTable.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLProgram.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLProgramBuffer.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLVertexProgram.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\gl_helpers.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\OpenGL.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Emu\RSX\GL\GLBuffers.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\GLCommonDecompiler.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\GLFragmentProgram.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\GLGSRender.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\GLProgram.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\GLProgramBuffer.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\GLVertexProgram.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\gl_helpers.cpp" />
|
||||
<ClCompile Include="Emu\RSX\GL\OpenGL.cpp" />
|
||||
|
@ -4,9 +4,6 @@
|
||||
<ClCompile Include="Emu\RSX\GL\gl_helpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\RSX\GL\GLBuffers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\RSX\GL\GLCommonDecompiler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -16,12 +13,6 @@
|
||||
<ClCompile Include="Emu\RSX\GL\GLGSRender.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\RSX\GL\GLProgram.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\RSX\GL\GLProgramBuffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\RSX\GL\GLVertexProgram.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -33,9 +24,6 @@
|
||||
<ClInclude Include="Emu\RSX\GL\gl_helpers.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\GL\GLBuffers.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\GL\GLCommonDecompiler.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
@ -48,9 +36,6 @@
|
||||
<ClInclude Include="Emu\RSX\GL\GLProcTable.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\GL\GLProgram.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\GL\GLProgramBuffer.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -33,7 +33,10 @@ namespace rpcs3
|
||||
|
||||
void config_t::load()
|
||||
{
|
||||
from_string(fs::file(m_path));
|
||||
fs::file file(m_path);
|
||||
|
||||
if (file)
|
||||
from_string((const std::string)file);
|
||||
}
|
||||
|
||||
void config_t::save() const
|
||||
|
Loading…
Reference in New Issue
Block a user