From 7416fe91fc5a97deab4561a9fbdcdca049f27830 Mon Sep 17 00:00:00 2001 From: DHrpcs3 Date: Mon, 21 Dec 2015 03:28:07 +0200 Subject: [PATCH] Fixed crash on start if config does not exists Cleanup OpenGL renerer --- rpcs3/Emu/RSX/GL/GLBuffers.cpp | 267 --------------------------- rpcs3/Emu/RSX/GL/GLBuffers.h | 91 --------- rpcs3/Emu/RSX/GL/GLGSRender.h | 1 - rpcs3/Emu/RSX/GL/GLProgram.cpp | 119 ------------ rpcs3/Emu/RSX/GL/GLProgram.h | 31 ---- rpcs3/Emu/RSX/GL/GLProgramBuffer.cpp | 5 - rpcs3/Emu/RSX/GL/GLProgramBuffer.h | 3 +- rpcs3/GLGSRender.vcxproj | 5 - rpcs3/GLGSRender.vcxproj.filters | 15 -- rpcs3/config.cpp | 5 +- 10 files changed, 6 insertions(+), 536 deletions(-) delete mode 100644 rpcs3/Emu/RSX/GL/GLBuffers.cpp delete mode 100644 rpcs3/Emu/RSX/GL/GLBuffers.h delete mode 100644 rpcs3/Emu/RSX/GL/GLProgram.cpp delete mode 100644 rpcs3/Emu/RSX/GL/GLProgram.h delete mode 100644 rpcs3/Emu/RSX/GL/GLProgramBuffer.cpp diff --git a/rpcs3/Emu/RSX/GL/GLBuffers.cpp b/rpcs3/Emu/RSX/GL/GLBuffers.cpp deleted file mode 100644 index c2fbd354b2..0000000000 --- a/rpcs3/Emu/RSX/GL/GLBuffers.cpp +++ /dev/null @@ -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; -} diff --git a/rpcs3/Emu/RSX/GL/GLBuffers.h b/rpcs3/Emu/RSX/GL/GLBuffers.h deleted file mode 100644 index 659365d29b..0000000000 --- a/rpcs3/Emu/RSX/GL/GLBuffers.h +++ /dev/null @@ -1,91 +0,0 @@ -#pragma once -#include "OpenGL.h" - -struct GLBufferObject -{ -protected: - std::vector 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 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; -}; diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.h b/rpcs3/Emu/RSX/GL/GLGSRender.h index 06ffd034c6..3dbf1fd678 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.h +++ b/rpcs3/Emu/RSX/GL/GLGSRender.h @@ -1,6 +1,5 @@ #pragma once #include "Emu/RSX/GSRender.h" -#include "GLBuffers.h" #include "gl_helpers.h" #define RSX_DEBUG 1 diff --git a/rpcs3/Emu/RSX/GL/GLProgram.cpp b/rpcs3/Emu/RSX/GL/GLProgram.cpp deleted file mode 100644 index 033d1608b5..0000000000 --- a/rpcs3/Emu/RSX/GL/GLProgram.cpp +++ /dev/null @@ -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(); -} -*/ \ No newline at end of file diff --git a/rpcs3/Emu/RSX/GL/GLProgram.h b/rpcs3/Emu/RSX/GL/GLProgram.h deleted file mode 100644 index 024c05b8a1..0000000000 --- a/rpcs3/Emu/RSX/GL/GLProgram.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "GLVertexProgram.h" -#include "GLFragmentProgram.h" -/* -struct GLProgram -{ -private: - struct Location - { - int loc; - std::string name; - }; - - std::vector 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(); -}; -*/ diff --git a/rpcs3/Emu/RSX/GL/GLProgramBuffer.cpp b/rpcs3/Emu/RSX/GL/GLProgramBuffer.cpp deleted file mode 100644 index 3df737bd0c..0000000000 --- a/rpcs3/Emu/RSX/GL/GLProgramBuffer.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "stdafx.h" -#include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" - -//#include "GLProgramBuffer.h" \ No newline at end of file diff --git a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h b/rpcs3/Emu/RSX/GL/GLProgramBuffer.h index 5ee69f5e9a..fad18c583d 100644 --- a/rpcs3/Emu/RSX/GL/GLProgramBuffer.h +++ b/rpcs3/Emu/RSX/GL/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" diff --git a/rpcs3/GLGSRender.vcxproj b/rpcs3/GLGSRender.vcxproj index bc4738bede..d57e706603 100644 --- a/rpcs3/GLGSRender.vcxproj +++ b/rpcs3/GLGSRender.vcxproj @@ -67,24 +67,19 @@ - - - - - diff --git a/rpcs3/GLGSRender.vcxproj.filters b/rpcs3/GLGSRender.vcxproj.filters index f3ee493441..83c53a7b4e 100644 --- a/rpcs3/GLGSRender.vcxproj.filters +++ b/rpcs3/GLGSRender.vcxproj.filters @@ -4,9 +4,6 @@ Source Files - - Source Files - Source Files @@ -16,12 +13,6 @@ Source Files - - Source Files - - - Source Files - Source Files @@ -33,9 +24,6 @@ Source Files - - Source Files - Source Files @@ -48,9 +36,6 @@ Source Files - - Source Files - Source Files diff --git a/rpcs3/config.cpp b/rpcs3/config.cpp index 62488558eb..14424d228b 100644 --- a/rpcs3/config.cpp +++ b/rpcs3/config.cpp @@ -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