ShaderProgram::ShaderProgram(const std::string& vertex_shader, const std::string& fragment_shader) : m_program_id(0), m_vertex_shader_id(0), m_fragment_shader_id(0), m_link_succeeded(false), m_program_log(), m_program_validity_log(), m_vertex_shader_log(), m_fragment_shader_log() { glGetError(); m_program_id = glCreateProgram(); CHECK_ERROR("ShaderProgram::ShaderProgram", "glCreateProgram()"); const char* strings[1] = { 0 }; if (!vertex_shader.empty()) { m_vertex_shader_id = glCreateShader(GL_VERTEX_SHADER); CHECK_ERROR("ShaderProgram::ShaderProgram", "glCreateShader(GL_VERTEX_SHADER)"); strings[0] = vertex_shader.c_str(); glShaderSource(m_vertex_shader_id, 1, strings, 0); CHECK_ERROR("ShaderProgram::ShaderProgram", "glShaderSource(vertex_shader)"); glCompileShader(m_vertex_shader_id); CHECK_ERROR("ShaderProgram::ShaderProgram", "glCompileShader(m_vertex_shader_id)"); GetShaderLog(m_vertex_shader_id, m_vertex_shader_log); glAttachShader(m_program_id, m_vertex_shader_id); CHECK_ERROR("ShaderProgram::ShaderProgram", "glAttachShader(m_vertex_shader_id)"); } if (!fragment_shader.empty()) { m_fragment_shader_id = glCreateShader(GL_FRAGMENT_SHADER); CHECK_ERROR("ShaderProgram::ShaderProgram", "glCreateShader(GL_FRAGMENT_SHADER)"); strings[0] = fragment_shader.c_str(); glShaderSource(m_fragment_shader_id, 1, strings, 0); CHECK_ERROR("ShaderProgram::ShaderProgram", "glShaderSource(fragment_shader)"); glCompileShader(m_fragment_shader_id); CHECK_ERROR("ShaderProgram::ShaderProgram", "glCompileShader(m_fragment_shader_id)"); GetShaderLog(m_fragment_shader_id, m_fragment_shader_log); glAttachShader(m_program_id, m_fragment_shader_id); CHECK_ERROR("ShaderProgram::ShaderProgram", "glAttachShader(m_fragment_shader_id)"); } GLint status; glLinkProgram(m_program_id); CHECK_ERROR("ShaderProgram::ShaderProgram", "glLinkProgram()"); glGetProgramiv(m_program_id, GL_LINK_STATUS, &status); CHECK_ERROR("ShaderProgram::ShaderProgram", "glGetProgramiv(GL_LINK_STATUS)"); m_link_succeeded = status; GetProgramLog(m_program_id, m_program_log); }
bool ShaderProgram::AllValuesBound() { bool retval = false; glGetError(); glValidateProgram(m_program_id); CHECK_ERROR("ShaderProgram::AllValuesBound", "glValidateProgram()"); GLint status; glGetProgramiv(m_program_id, GL_VALIDATE_STATUS, &status); CHECK_ERROR("ShaderProgram::AllValuesBound", "glGetProgramiv(GL_VALIDATE_STATUS)"); retval = status; GetProgramLog(m_program_id, m_program_validity_log); return retval; }
// Used to disable the emuLog disk logger, typically used when disabling or re-initializing the // emuLog file handle. Call SetConsoleLogging to re-enable the disk logger when finished. void Pcsx2App::DisableDiskLogging() const { AffinityAssert_AllowFrom_MainUI(); const bool logBoxOpen = (GetProgramLog() != NULL); Console_SetActiveHandler( logBoxOpen ? (IConsoleWriter&)ConsoleWriter_Window : (IConsoleWriter&)ConsoleWriter_Stdout ); // Semi-hack: It's possible, however very unlikely, that a secondary thread could attempt // to write to the logfile just before we disable logging, and would thus have a pending write // operation to emuLog file handle at the same time we're trying to re-initialize it. The CRT // has some guards of its own, and PCSX2 itself typically suspends the "log happy" threads // when changing settings, so the chance for problems is low. We minimize it further here // by sleeping off 5ms, which should allow any pending log-to-disk events to finish up. // // (the most correct solution would be a mutex lock in the Disk logger itself, but for now I // am going to try and keep the logger lock-free and use this semi-hack instead). Threading::Sleep( 5 ); }
void Pcsx2App::ProgramLog_PostEvent( wxEvent& evt ) { if( ConsoleLogFrame* proglog = GetProgramLog() ) proglog->GetEventHandler()->AddPendingEvent( evt ); }