mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-13 02:08:49 +12:00
gl: Refactor shader compilation
This commit is contained in:
parent
661636efef
commit
3db2f23e02
10 changed files with 43 additions and 138 deletions
|
@ -2,7 +2,6 @@
|
|||
#include "GLFragmentProgram.h"
|
||||
|
||||
#include "Emu/System.h"
|
||||
#include "GLHelpers.h"
|
||||
#include "GLFragmentProgram.h"
|
||||
#include "GLCommonDecompiler.h"
|
||||
#include "../GCM.h"
|
||||
|
@ -341,7 +340,8 @@ GLFragmentProgram::~GLFragmentProgram()
|
|||
void GLFragmentProgram::Decompile(const RSXFragmentProgram& prog)
|
||||
{
|
||||
u32 size;
|
||||
GLFragmentDecompilerThread decompiler(shader, parr, prog, size);
|
||||
std::string source;
|
||||
GLFragmentDecompilerThread decompiler(source, parr, prog, size);
|
||||
|
||||
if (!g_cfg.video.disable_native_float16)
|
||||
{
|
||||
|
@ -365,55 +365,18 @@ void GLFragmentProgram::Decompile(const RSXFragmentProgram& prog)
|
|||
FragmentConstantOffsetCache.push_back(offset);
|
||||
}
|
||||
}
|
||||
|
||||
shader.create(gl::glsl::shader::type::fragment, source);
|
||||
}
|
||||
|
||||
void GLFragmentProgram::Compile()
|
||||
{
|
||||
if (id)
|
||||
{
|
||||
glDeleteShader(id);
|
||||
}
|
||||
|
||||
id = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
const char* str = shader.c_str();
|
||||
const int strlen = ::narrow<int>(shader.length());
|
||||
|
||||
fs::file(fs::get_cache_dir() + "shaderlog/FragmentProgram" + std::to_string(id) + ".glsl", fs::rewrite).write(str);
|
||||
|
||||
glShaderSource(id, 1, &str, &strlen);
|
||||
glCompileShader(id);
|
||||
|
||||
GLint compileStatus = GL_FALSE;
|
||||
glGetShaderiv(id, GL_COMPILE_STATUS, &compileStatus); // Determine the result of the glCompileShader call
|
||||
if (compileStatus != GL_TRUE) // If the shader failed to compile...
|
||||
{
|
||||
GLint infoLength;
|
||||
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &infoLength); // Retrieve the length in bytes (including trailing NULL) of the shader info log
|
||||
|
||||
if (infoLength > 0)
|
||||
{
|
||||
GLsizei len;
|
||||
char* buf = new char[infoLength]; // Buffer to store infoLog
|
||||
|
||||
glGetShaderInfoLog(id, infoLength, &len, buf); // Retrieve the shader info log into our buffer
|
||||
rsx_log.error("Failed to compile shader: %s", buf); // Write log to the console
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
rsx_log.notice("%s", shader); // Log the text of the shader that failed to compile
|
||||
Emu.Pause(); // Pause the emulator, we can't really continue from here
|
||||
}
|
||||
shader.compile();
|
||||
id = shader.id();
|
||||
}
|
||||
|
||||
void GLFragmentProgram::Delete()
|
||||
{
|
||||
shader.clear();
|
||||
|
||||
if (id)
|
||||
{
|
||||
glDeleteShader(id);
|
||||
id = 0;
|
||||
}
|
||||
shader.remove();
|
||||
id = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue