MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / CompileAndAddProgram

Method CompileAndAddProgram

pcsx2/GS/Renderers/OpenGL/GLShaderCache.cpp:409–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409std::optional<GLProgram> GLShaderCache::CompileAndAddProgram(const CacheIndexKey& key,
410 const std::string_view vertex_shader, const std::string_view fragment_shader, const PreLinkCallback& callback)
411{
412#ifdef PCSX2_DEVBUILD
413 Common::Timer timer;
414#endif
415
416 std::optional<GLProgram> prog = CompileProgram(vertex_shader, fragment_shader, callback, true);
417 if (!prog)
418 return std::nullopt;
419
420#ifdef PCSX2_DEVBUILD
421 const float compile_time = timer.GetTimeMilliseconds();
422 timer.Reset();
423#endif
424
425 std::vector<u8> prog_data;
426 u32 prog_format = 0;
427 if (!prog->GetBinary(&prog_data, &prog_format))
428 return std::nullopt;
429
430#ifdef PCSX2_DEVBUILD
431 const float binary_time = timer.GetTimeMilliseconds();
432 timer.Reset();
433#endif
434
435 WriteToBlobFile(key, prog_data, prog_format);
436
437#ifdef PCSX2_DEVBUILD
438 const float write_time = timer.GetTimeMilliseconds();
439 Console.WriteLn("Compiled and cached shader: Compile: %.2fms, Binary: %.2fms, Write: %.2fms", compile_time,
440 binary_time, write_time);
441#endif
442
443 return prog;
444}
445
446std::optional<GLProgram> GLShaderCache::GetComputeProgram(const std::string_view glsl, const PreLinkCallback& callback)
447{

Callers

nothing calls this directly

Calls 4

GetTimeMillisecondsMethod · 0.80
GetBinaryMethod · 0.80
ResetMethod · 0.45
WriteLnMethod · 0.45

Tested by

no test coverage detected