<commit_before>#include "shader_program.h"
#include "pathos/engine.h"
#include "pathos/console.h"
#include "pathos/render/render_device.h"
#include "pathos/util/log.h"
#include "pathos/util/resource_finder.h"

#include "badger/assertion/assertion.h"

#include <fstream>
#include <sstream>

#define IGNORE_SAME_SHADERS_ON_RECOMPILE 1

namespace pathos {

	// Turn this on EngineConfig.ini as shaders are compiled on startup and you don't have a chance to change this through console.
	static ConsoleVariable<int32> cvar_dumpShaders("r.dumpShaderSources", 0, "Dump shader sources to log/shader_dump");

	static struct InitRecompileShaders {
		InitRecompileShaders() {
			Engine::internal_registerGlobalRenderRoutine(InitRecompileShaders::recompileShaders, nullptr);
		}
		// Dirty but works anyway
		// #todo-shader: Suddenly this doesn't work? Fails at glLinkProgram().
		static void recompileShaders(OpenGLDevice* device, RenderCommandList& cmdList) {
			gEngine->registerExec("recompile_shaders", [](const std::string& command) -> void {
				LOG(LogInfo, "Begin reloading shaders...");
				ShaderDB::get().forEach([](ShaderProgram* program) -> void {
					program->reload();
				});
				LOG(LogInfo, "End reloading shaders.");
			});
		}
	} internal_recompileShaders;

	ShaderProgram::ShaderProgram(const char* inDebugName, uint32 inProgramHash)
		: debugName(inDebugName)<commit_msg>Fix runtime shader recompilation<commit_after>#include "shader_program.h"
#include "pathos/engine.h"
#include "pathos/console.h"
#include "pathos/render/render_device.h"
#include "pathos/util/log.h"
#include "pathos/util/resource_finder.h"

#include "badger/assertion/assertion.h"

#include <fstream>
#include <sstream>

#define IGNORE_SAME_SHADERS_ON_RECOMPILE 1

namespace pathos {

	// Turn this on EngineConfig.ini as shaders are compiled on startup and you don't have a chance to change this through console.
	static ConsoleVariable<int32> cvar_dumpShaders("r.dumpShaderSources", 0, "Dump shader sources to log/shader_dump");

	static struct InitRecompileShaders {
		InitRecompileShaders() {
			Engine::internal_registerGlobalRenderRoutine(InitRecompileShaders::recompileShaders, nullptr);
		}
		// Dirty but works anyway
		static void recompileShaders(OpenGLDevice* device, RenderCommandList& cmdList) {
			gEngine->registerExec("recompile_shaders", [](const std::string& command) -> void {
				LOG(LogInfo, "Begin reloading shaders...");
				ENQUEUE_RENDER_COMMAND([](RenderCommandList& cmdList) {
					ShaderDB::get().forEach([](ShaderProgram* program) -> void {
						program->reload();
					});
				});
				FLUSH_RENDER_COMMAND();
				LOG(LogInfo, "End reloading shaders.");
			});
		}
	} internal_recompileShaders;

	ShaderProgram::ShaderProgram(const char* inDebugName, uint32 inProgramHash)
		: debugName(inDebugName)
{'fraction_non_alphanumeric': 0.1197158081705151, 'fraction_numerical': 0.004262877442273535, 'mean_word_length': 5.533642691415313, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2139982', 'n_tokens_mistral': 980, 'n_tokens_neox': 898, 'n_words': 199}