2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
|
|
|
// Copyright (C) 2021-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2021-02-02 21:25:06 +00:00
|
|
|
|
|
|
|
#include "gfx-lut.hpp"
|
|
|
|
#include "obs/gs/gs-helper.hpp"
|
|
|
|
#include "plugin.hpp"
|
2021-09-07 02:29:41 +00:00
|
|
|
#include "util/util-logging.hpp"
|
2021-02-02 21:25:06 +00:00
|
|
|
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-disable.hpp"
|
|
|
|
#include <mutex>
|
|
|
|
#include "warning-enable.hpp"
|
|
|
|
|
2021-09-07 02:29:41 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
#define ST_PREFIX "<%s> "
|
|
|
|
#define D_LOG_ERROR(x, ...) P_LOG_ERROR(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
|
|
#define D_LOG_WARNING(x, ...) P_LOG_WARN(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
|
|
#define D_LOG_INFO(x, ...) P_LOG_INFO(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
|
|
#define D_LOG_DEBUG(x, ...) P_LOG_DEBUG(ST_PREFIX##x, __FUNCTION_SIG__, __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define ST_PREFIX "<transition::shader> "
|
|
|
|
#define D_LOG_ERROR(...) P_LOG_ERROR(ST_PREFIX __VA_ARGS__)
|
|
|
|
#define D_LOG_WARNING(...) P_LOG_WARN(ST_PREFIX __VA_ARGS__)
|
|
|
|
#define D_LOG_INFO(...) P_LOG_INFO(ST_PREFIX __VA_ARGS__)
|
|
|
|
#define D_LOG_DEBUG(...) P_LOG_DEBUG(ST_PREFIX __VA_ARGS__)
|
|
|
|
#endif
|
2021-02-02 21:25:06 +00:00
|
|
|
|
2021-09-07 02:29:41 +00:00
|
|
|
using namespace streamfx;
|
2021-02-02 21:25:06 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
std::shared_ptr<streamfx::gfx::lut::data> streamfx::gfx::lut::data::instance()
|
2021-02-02 21:25:06 +00:00
|
|
|
{
|
2021-06-08 02:47:04 +00:00
|
|
|
static std::weak_ptr<streamfx::gfx::lut::data> _instance;
|
|
|
|
static std::mutex _mutex;
|
2021-02-02 21:25:06 +00:00
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
|
|
|
|
auto reference = _instance.lock();
|
|
|
|
if (!reference) {
|
2021-06-08 02:47:04 +00:00
|
|
|
reference = std::shared_ptr<streamfx::gfx::lut::data>(new streamfx::gfx::lut::data());
|
2021-02-02 21:25:06 +00:00
|
|
|
_instance = reference;
|
|
|
|
}
|
|
|
|
return reference;
|
|
|
|
}
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
streamfx::gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
2021-02-02 21:25:06 +00:00
|
|
|
{
|
2021-06-08 02:38:24 +00:00
|
|
|
auto gctx = streamfx::obs::gs::context();
|
2021-02-02 21:25:06 +00:00
|
|
|
|
|
|
|
std::filesystem::path lut_producer_path = streamfx::data_file_path("effects/lut-producer.effect");
|
|
|
|
if (std::filesystem::exists(lut_producer_path)) {
|
|
|
|
try {
|
2021-06-08 02:38:24 +00:00
|
|
|
_producer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_producer_path);
|
2021-02-02 21:25:06 +00:00
|
|
|
} catch (std::exception const& ex) {
|
2021-09-07 02:29:41 +00:00
|
|
|
D_LOG_ERROR("Loading LUT Producer effect failed: %s", ex.what());
|
2021-02-02 21:25:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::filesystem::path lut_consumer_path = streamfx::data_file_path("effects/lut-consumer.effect");
|
|
|
|
if (std::filesystem::exists(lut_consumer_path)) {
|
|
|
|
try {
|
2021-06-08 02:38:24 +00:00
|
|
|
_consumer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_consumer_path);
|
2021-02-02 21:25:06 +00:00
|
|
|
} catch (std::exception const& ex) {
|
2021-09-07 02:29:41 +00:00
|
|
|
D_LOG_ERROR("Loading LUT Consumer effect failed: %s", ex.what());
|
2021-02-02 21:25:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
streamfx::gfx::lut::data::~data()
|
2021-02-02 21:25:06 +00:00
|
|
|
{
|
2021-06-08 02:38:24 +00:00
|
|
|
auto gctx = streamfx::obs::gs::context();
|
2021-02-02 21:25:06 +00:00
|
|
|
_producer_effect.reset();
|
|
|
|
_consumer_effect.reset();
|
|
|
|
}
|