mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +00:00
obs/gs: Apply coding guidelines
This commit is contained in:
parent
015fac588b
commit
c84c301d49
74 changed files with 810 additions and 773 deletions
|
@ -113,7 +113,7 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
if (gs_get_device_type() == GS_DEVICE_DIRECT3D_11) {
|
if (gs_get_device_type() == GS_DEVICE_DIRECT3D_11) {
|
||||||
_hwapi = std::make_shared<::streamfx::ffmpeg::hwapi::d3d11>();
|
_hwapi = std::make_shared<::streamfx::ffmpeg::hwapi::d3d11>();
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool
|
||||||
update(settings);
|
update(settings);
|
||||||
|
|
||||||
// Initialize Encoder
|
// Initialize Encoder
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
int res = avcodec_open2(_context, _codec, NULL);
|
int res = avcodec_open2(_context, _codec, NULL);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
throw std::runtime_error(::streamfx::ffmpeg::tools::get_error_description(res));
|
throw std::runtime_error(::streamfx::ffmpeg::tools::get_error_description(res));
|
||||||
|
@ -156,7 +156,7 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool
|
||||||
|
|
||||||
ffmpeg_instance::~ffmpeg_instance()
|
ffmpeg_instance::~ffmpeg_instance()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
if (_context) {
|
if (_context) {
|
||||||
// Flush encoders that require it.
|
// Flush encoders that require it.
|
||||||
if ((_codec->capabilities & AV_CODEC_CAP_DELAY) != 0) {
|
if ((_codec->capabilities & AV_CODEC_CAP_DELAY) != 0) {
|
||||||
|
@ -615,7 +615,7 @@ int ffmpeg_instance::receive_packet(bool* received_packet, struct encoder_packet
|
||||||
av_packet_unref(&_packet);
|
av_packet_unref(&_packet);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
res = avcodec_receive_packet(_context, &_packet);
|
res = avcodec_receive_packet(_context, &_packet);
|
||||||
}
|
}
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
|
@ -680,7 +680,7 @@ int ffmpeg_instance::send_frame(std::shared_ptr<AVFrame> const frame)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
res = avcodec_send_frame(_context, frame.get());
|
res = avcodec_send_frame(_context, frame.get());
|
||||||
}
|
}
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ std::shared_ptr<instance> d3d11::create(device target)
|
||||||
|
|
||||||
std::shared_ptr<instance> d3d11::create_from_obs()
|
std::shared_ptr<instance> d3d11::create_from_obs()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
if (GS_DEVICE_DIRECT3D_11 != gs_get_device_type()) {
|
if (GS_DEVICE_DIRECT3D_11 != gs_get_device_type()) {
|
||||||
throw std::runtime_error("OBS Device is not a D3D11 Device.");
|
throw std::runtime_error("OBS Device is not a D3D11 Device.");
|
||||||
|
@ -189,7 +189,7 @@ AVBufferRef* d3d11_instance::create_device_context()
|
||||||
|
|
||||||
std::shared_ptr<AVFrame> d3d11_instance::allocate_frame(AVBufferRef* frames)
|
std::shared_ptr<AVFrame> d3d11_instance::allocate_frame(AVBufferRef* frames)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
// Allocate a frame.
|
// Allocate a frame.
|
||||||
auto frame = std::shared_ptr<AVFrame>(av_frame_alloc(), [](AVFrame* frame) {
|
auto frame = std::shared_ptr<AVFrame>(av_frame_alloc(), [](AVFrame* frame) {
|
||||||
|
@ -211,7 +211,7 @@ std::shared_ptr<AVFrame> d3d11_instance::allocate_frame(AVBufferRef* frames)
|
||||||
void d3d11_instance::copy_from_obs(AVBufferRef*, uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key,
|
void d3d11_instance::copy_from_obs(AVBufferRef*, uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key,
|
||||||
std::shared_ptr<AVFrame> frame)
|
std::shared_ptr<AVFrame> frame)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
// Attempt to acquire shared texture.
|
// Attempt to acquire shared texture.
|
||||||
ATL::CComPtr<ID3D11Texture2D> input;
|
ATL::CComPtr<ID3D11Texture2D> input;
|
||||||
|
@ -254,7 +254,7 @@ void d3d11_instance::copy_from_obs(AVBufferRef*, uint32_t handle, uint64_t lock_
|
||||||
std::shared_ptr<AVFrame> d3d11_instance::avframe_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key,
|
std::shared_ptr<AVFrame> d3d11_instance::avframe_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key,
|
||||||
uint64_t* next_lock_key)
|
uint64_t* next_lock_key)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
auto frame = this->allocate_frame(frames);
|
auto frame = this->allocate_frame(frames);
|
||||||
this->copy_from_obs(frames, handle, lock_key, next_lock_key, frame);
|
this->copy_from_obs(frames, handle, lock_key, next_lock_key, frame);
|
||||||
|
|
|
@ -107,17 +107,17 @@ blur_instance::blur_instance(obs_data_t* settings, obs_source_t* self)
|
||||||
: obs::source_instance(settings, self), _source_rendered(false), _output_rendered(false)
|
: obs::source_instance(settings, self), _source_rendered(false), _output_rendered(false)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
// Create RenderTargets
|
// Create RenderTargets
|
||||||
this->_source_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
this->_source_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
this->_output_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
this->_output_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
|
|
||||||
// Load Effects
|
// Load Effects
|
||||||
{
|
{
|
||||||
auto file = streamfx::data_file_path("effects/mask.effect").string();
|
auto file = streamfx::data_file_path("effects/mask.effect").string();
|
||||||
try {
|
try {
|
||||||
_effect_mask = gs::effect::create(file);
|
_effect_mask = streamfx::obs::gs::effect::create(file);
|
||||||
} catch (std::runtime_error& ex) {
|
} catch (std::runtime_error& ex) {
|
||||||
DLOG_ERROR("<filter-blur> Loading effect '%s' failed with error(s): %s", file.c_str(), ex.what());
|
DLOG_ERROR("<filter-blur> Loading effect '%s' failed with error(s): %s", file.c_str(), ex.what());
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ blur_instance::blur_instance(obs_data_t* settings, obs_source_t* self)
|
||||||
|
|
||||||
blur_instance::~blur_instance() {}
|
blur_instance::~blur_instance() {}
|
||||||
|
|
||||||
bool blur_instance::apply_mask_parameters(gs::effect effect, gs_texture_t* original_texture,
|
bool blur_instance::apply_mask_parameters(streamfx::obs::gs::effect effect, gs_texture_t* original_texture,
|
||||||
gs_texture_t* blurred_texture)
|
gs_texture_t* blurred_texture)
|
||||||
{
|
{
|
||||||
if (effect.has_parameter("image_orig")) {
|
if (effect.has_parameter("image_orig")) {
|
||||||
|
@ -328,7 +328,7 @@ void blur_instance::video_tick(float)
|
||||||
if (_mask.type == mask_type::Image) {
|
if (_mask.type == mask_type::Image) {
|
||||||
if (_mask.image.path_old != _mask.image.path) {
|
if (_mask.image.path_old != _mask.image.path) {
|
||||||
try {
|
try {
|
||||||
_mask.image.texture = std::make_shared<gs::texture>(_mask.image.path);
|
_mask.image.texture = std::make_shared<streamfx::obs::gs::texture>(_mask.image.path);
|
||||||
_mask.image.path_old = _mask.image.path;
|
_mask.image.path_old = _mask.image.path;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
DLOG_ERROR("<filter-blur> Instance '%s' failed to load image '%s'.", obs_source_get_name(_self),
|
DLOG_ERROR("<filter-blur> Instance '%s' failed to load image '%s'.", obs_source_get_name(_self),
|
||||||
|
@ -367,14 +367,15 @@ void blur_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Blur '%s'", obs_source_get_name(_self)};
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Blur '%s'",
|
||||||
|
obs_source_get_name(_self)};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!_source_rendered) {
|
if (!_source_rendered) {
|
||||||
// Source To Texture
|
// Source To Texture
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_cache, "Cache"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache, "Cache"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (obs_source_process_filter_begin(this->_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {
|
if (obs_source_process_filter_begin(this->_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {
|
||||||
|
@ -424,7 +425,7 @@ void blur_instance::video_render(gs_effect_t* effect)
|
||||||
if (!_output_rendered) {
|
if (!_output_rendered) {
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Blur"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Blur"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_blur->set_input(_source_texture);
|
_blur->set_input(_source_texture);
|
||||||
|
@ -434,7 +435,7 @@ void blur_instance::video_render(gs_effect_t* effect)
|
||||||
// Mask
|
// Mask
|
||||||
if (_mask.enabled) {
|
if (_mask.enabled) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Mask"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Mask"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs_blend_state_push();
|
gs_blend_state_push();
|
||||||
|
@ -492,7 +493,7 @@ void blur_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_capture, "Capture '%s'",
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_capture, "Capture '%s'",
|
||||||
obs_source_get_name(_mask.source.source_texture->get_object())};
|
obs_source_get_name(_mask.source.source_texture->get_object())};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -528,7 +529,7 @@ void blur_instance::video_render(gs_effect_t* effect)
|
||||||
// Draw source
|
// Draw source
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_render, "Render"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// It is important that we do not modify the blend state here, as it is set correctly by OBS
|
// It is important that we do not modify the blend state here, as it is set correctly by OBS
|
||||||
|
|
|
@ -40,16 +40,16 @@ namespace streamfx::filter::blur {
|
||||||
|
|
||||||
class blur_instance : public obs::source_instance {
|
class blur_instance : public obs::source_instance {
|
||||||
// Effects
|
// Effects
|
||||||
gs::effect _effect_mask;
|
streamfx::obs::gs::effect _effect_mask;
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
std::shared_ptr<gs::rendertarget> _source_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _source_rt;
|
||||||
std::shared_ptr<gs::texture> _source_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _source_texture;
|
||||||
bool _source_rendered;
|
bool _source_rendered;
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
std::shared_ptr<gs::texture> _output_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _output_texture;
|
||||||
std::shared_ptr<gs::rendertarget> _output_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _output_rt;
|
||||||
bool _output_rendered;
|
bool _output_rendered;
|
||||||
|
|
||||||
// Blur
|
// Blur
|
||||||
|
@ -76,14 +76,14 @@ namespace streamfx::filter::blur {
|
||||||
struct {
|
struct {
|
||||||
std::string path;
|
std::string path;
|
||||||
std::string path_old;
|
std::string path_old;
|
||||||
std::shared_ptr<gs::texture> texture;
|
std::shared_ptr<streamfx::obs::gs::texture> texture;
|
||||||
} image;
|
} image;
|
||||||
struct {
|
struct {
|
||||||
std::string name_old;
|
std::string name_old;
|
||||||
std::string name;
|
std::string name;
|
||||||
bool is_scene;
|
bool is_scene;
|
||||||
std::shared_ptr<gfx::source_texture> source_texture;
|
std::shared_ptr<gfx::source_texture> source_texture;
|
||||||
std::shared_ptr<gs::texture> texture;
|
std::shared_ptr<streamfx::obs::gs::texture> texture;
|
||||||
} source;
|
} source;
|
||||||
struct {
|
struct {
|
||||||
float_t r;
|
float_t r;
|
||||||
|
@ -107,7 +107,8 @@ namespace streamfx::filter::blur {
|
||||||
virtual void video_render(gs_effect_t* effect) override;
|
virtual void video_render(gs_effect_t* effect) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool apply_mask_parameters(gs::effect effect, gs_texture_t* original_texture, gs_texture_t* blurred_texture);
|
bool apply_mask_parameters(streamfx::obs::gs::effect effect, gs_texture_t* original_texture,
|
||||||
|
gs_texture_t* blurred_texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
class blur_factory : public obs::source_factory<filter::blur::blur_factory, filter::blur::blur_instance> {
|
class blur_factory : public obs::source_factory<filter::blur::blur_factory, filter::blur::blur_instance> {
|
||||||
|
|
|
@ -131,7 +131,7 @@ color_grade_instance::color_grade_instance(obs_data_t* data, obs_source_t* self)
|
||||||
throw std::runtime_error("Failed to load color grade effect.");
|
throw std::runtime_error("Failed to load color grade effect.");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
_effect = gs::effect::create(path.u8string());
|
_effect = streamfx::obs::gs::effect::create(path.u8string());
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Failed to load effect '%s': %s", path.u8string().c_str(), ex.what());
|
DLOG_ERROR(LOCAL_PREFIX "Failed to load effect '%s': %s", path.u8string().c_str(), ex.what());
|
||||||
throw;
|
throw;
|
||||||
|
@ -162,7 +162,7 @@ color_grade_instance::color_grade_instance(obs_data_t* data, obs_source_t* self)
|
||||||
|
|
||||||
void color_grade_instance::allocate_rendertarget(gs_color_format format)
|
void color_grade_instance::allocate_rendertarget(gs_color_format format)
|
||||||
{
|
{
|
||||||
_cache_rt = std::make_unique<gs::rendertarget>(format, GS_ZS_NONE);
|
_cache_rt = std::make_unique<streamfx::obs::gs::rendertarget>(format, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
float_t fix_gamma_value(double_t v)
|
float_t fix_gamma_value(double_t v)
|
||||||
|
@ -287,7 +287,7 @@ void color_grade_instance::prepare_effect()
|
||||||
void color_grade_instance::rebuild_lut()
|
void color_grade_instance::rebuild_lut()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_cache, "Rebuild LUT"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache, "Rebuild LUT"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Generate a fresh LUT texture.
|
// Generate a fresh LUT texture.
|
||||||
|
@ -298,7 +298,7 @@ void color_grade_instance::rebuild_lut()
|
||||||
// Check if we have a render target to work with and if it's the correct format.
|
// Check if we have a render target to work with and if it's the correct format.
|
||||||
if (!_lut_rt || (lut_texture->get_color_format() != _lut_rt->get_color_format())) {
|
if (!_lut_rt || (lut_texture->get_color_format() != _lut_rt->get_color_format())) {
|
||||||
// Create a new render target with new format.
|
// Create a new render target with new format.
|
||||||
_lut_rt = std::make_unique<gs::rendertarget>(lut_texture->get_color_format(), GS_ZS_NONE);
|
_lut_rt = std::make_unique<streamfx::obs::gs::rendertarget>(lut_texture->get_color_format(), GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare our color grade effect.
|
// Prepare our color grade effect.
|
||||||
|
@ -361,7 +361,8 @@ void color_grade_instance::video_render(gs_effect_t* shader)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Color Grading '%s'", obs_source_get_name(_self)};
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Color Grading '%s'",
|
||||||
|
obs_source_get_name(_self)};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: Optimize this once (https://github.com/obsproject/obs-studio/pull/4199) is merged.
|
// TODO: Optimize this once (https://github.com/obsproject/obs-studio/pull/4199) is merged.
|
||||||
|
@ -370,11 +371,12 @@ void color_grade_instance::video_render(gs_effect_t* shader)
|
||||||
// 1. Capture the filter/source rendered above this.
|
// 1. Capture the filter/source rendered above this.
|
||||||
if (!_ccache_fresh || !_ccache_texture) {
|
if (!_ccache_fresh || !_ccache_texture) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_cache, "Cache '%s'", obs_source_get_name(target)};
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_cache, "Cache '%s'",
|
||||||
|
obs_source_get_name(target)};
|
||||||
#endif
|
#endif
|
||||||
// If the input cache render target doesn't exist, create it.
|
// If the input cache render target doesn't exist, create it.
|
||||||
if (!_ccache_rt) {
|
if (!_ccache_rt) {
|
||||||
_ccache_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_ccache_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -425,7 +427,7 @@ void color_grade_instance::video_render(gs_effect_t* shader)
|
||||||
if (_lut_initialized && _lut_enabled) { // Try to apply with the LUT based method.
|
if (_lut_initialized && _lut_enabled) { // Try to apply with the LUT based method.
|
||||||
try {
|
try {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "LUT Rendering"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "LUT Rendering"};
|
||||||
#endif
|
#endif
|
||||||
// If the LUT was changed, rebuild the LUT first.
|
// If the LUT was changed, rebuild the LUT first.
|
||||||
if (_lut_dirty) {
|
if (_lut_dirty) {
|
||||||
|
@ -491,7 +493,7 @@ void color_grade_instance::video_render(gs_effect_t* shader)
|
||||||
}
|
}
|
||||||
if ((!_lut_initialized || !_lut_enabled) && !_cache_fresh) {
|
if ((!_lut_initialized || !_lut_enabled) && !_cache_fresh) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Direct Rendering"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Direct Rendering"};
|
||||||
#endif
|
#endif
|
||||||
// Reallocate the rendertarget if necessary.
|
// Reallocate the rendertarget if necessary.
|
||||||
if (_cache_rt->get_color_format() != GS_RGBA) {
|
if (_cache_rt->get_color_format() != GS_RGBA) {
|
||||||
|
@ -547,7 +549,7 @@ void color_grade_instance::video_render(gs_effect_t* shader)
|
||||||
// 3. Render the output cache.
|
// 3. Render the output cache.
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_cache_render, "Draw Cache"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache_render, "Draw Cache"};
|
||||||
#endif
|
#endif
|
||||||
// Revert GPU status to what OBS Studio expects.
|
// Revert GPU status to what OBS Studio expects.
|
||||||
gs_enable_depth_test(false);
|
gs_enable_depth_test(false);
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace streamfx::filter::color_grade {
|
||||||
};
|
};
|
||||||
|
|
||||||
class color_grade_instance : public obs::source_instance {
|
class color_grade_instance : public obs::source_instance {
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
|
||||||
// User Configuration
|
// User Configuration
|
||||||
vec4 _lift;
|
vec4 _lift;
|
||||||
|
@ -63,8 +63,8 @@ namespace streamfx::filter::color_grade {
|
||||||
gfx::lut::color_depth _lut_depth;
|
gfx::lut::color_depth _lut_depth;
|
||||||
|
|
||||||
// Capture Cache
|
// Capture Cache
|
||||||
std::shared_ptr<gs::rendertarget> _ccache_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _ccache_rt;
|
||||||
std::shared_ptr<gs::texture> _ccache_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _ccache_texture;
|
||||||
bool _ccache_fresh;
|
bool _ccache_fresh;
|
||||||
|
|
||||||
// LUT work flow
|
// LUT work flow
|
||||||
|
@ -72,12 +72,12 @@ namespace streamfx::filter::color_grade {
|
||||||
bool _lut_dirty;
|
bool _lut_dirty;
|
||||||
std::shared_ptr<gfx::lut::producer> _lut_producer;
|
std::shared_ptr<gfx::lut::producer> _lut_producer;
|
||||||
std::shared_ptr<gfx::lut::consumer> _lut_consumer;
|
std::shared_ptr<gfx::lut::consumer> _lut_consumer;
|
||||||
std::shared_ptr<gs::rendertarget> _lut_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _lut_rt;
|
||||||
std::shared_ptr<gs::texture> _lut_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _lut_texture;
|
||||||
|
|
||||||
// Render Cache
|
// Render Cache
|
||||||
std::shared_ptr<gs::rendertarget> _cache_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _cache_rt;
|
||||||
std::shared_ptr<gs::texture> _cache_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _cache_texture;
|
||||||
bool _cache_fresh;
|
bool _cache_fresh;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -33,7 +33,7 @@ using namespace streamfx::filter::displacement;
|
||||||
displacement_instance::displacement_instance(obs_data_t* data, obs_source_t* context)
|
displacement_instance::displacement_instance(obs_data_t* data, obs_source_t* context)
|
||||||
: obs::source_instance(data, context)
|
: obs::source_instance(data, context)
|
||||||
{
|
{
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/displace.effect").u8string());
|
_effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/displace.effect").u8string());
|
||||||
|
|
||||||
update(data);
|
update(data);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ void displacement_instance::update(obs_data_t* settings)
|
||||||
std::string new_file = obs_data_get_string(settings, ST_FILE);
|
std::string new_file = obs_data_get_string(settings, ST_FILE);
|
||||||
if (new_file != _texture_file) {
|
if (new_file != _texture_file) {
|
||||||
try {
|
try {
|
||||||
_texture = std::make_shared<gs::texture>(new_file);
|
_texture = std::make_shared<streamfx::obs::gs::texture>(new_file);
|
||||||
_texture_file = new_file;
|
_texture_file = new_file;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
_texture.reset();
|
_texture.reset();
|
||||||
|
@ -90,8 +90,8 @@ void displacement_instance::video_render(gs_effect_t*)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Displacement Mapping '%s' on '%s'", obs_source_get_name(_self),
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Displacement Mapping '%s' on '%s'",
|
||||||
obs_source_get_name(obs_filter_get_parent(_self))};
|
obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {
|
if (!obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
|
|
||||||
namespace streamfx::filter::displacement {
|
namespace streamfx::filter::displacement {
|
||||||
class displacement_instance : public obs::source_instance {
|
class displacement_instance : public obs::source_instance {
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
|
||||||
// Displacement Map
|
// Displacement Map
|
||||||
std::shared_ptr<gs::texture> _texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _texture;
|
||||||
std::string _texture_file;
|
std::string _texture_file;
|
||||||
float_t _scale[2];
|
float_t _scale[2];
|
||||||
float_t _scale_type;
|
float_t _scale_type;
|
||||||
|
|
|
@ -57,11 +57,11 @@ dynamic_mask_instance::dynamic_mask_instance(obs_data_t* settings, obs_source_t*
|
||||||
_filter_texture(), _have_input_texture(false), _input(), _input_capture(), _input_texture(),
|
_filter_texture(), _have_input_texture(false), _input(), _input_capture(), _input_texture(),
|
||||||
_have_final_texture(false), _final_rt(), _final_texture(), _channels(), _precalc()
|
_have_final_texture(false), _final_rt(), _final_texture(), _channels(), _precalc()
|
||||||
{
|
{
|
||||||
_filter_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_filter_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_final_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_final_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/channel-mask.effect").u8string());
|
_effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/channel-mask.effect").u8string());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
DLOG_ERROR("Loading channel mask effect failed with error(s):\n%s", ex.what());
|
DLOG_ERROR("Loading channel mask effect failed with error(s):\n%s", ex.what());
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ void dynamic_mask_instance::update(obs_data_t* settings)
|
||||||
// Update source.
|
// Update source.
|
||||||
try {
|
try {
|
||||||
auto input = std::make_shared<obs::deprecated_source>(obs_data_get_string(settings, ST_INPUT));
|
auto input = std::make_shared<obs::deprecated_source>(obs_data_get_string(settings, ST_INPUT));
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
auto capture = std::make_shared<gfx::source_texture>(input, _self);
|
auto capture = std::make_shared<gfx::source_texture>(input, _self);
|
||||||
|
|
||||||
input->events.rename += std::bind(&dynamic_mask_instance::input_renamed, this, std::placeholders::_1,
|
input->events.rename += std::bind(&dynamic_mask_instance::input_renamed, this, std::placeholders::_1,
|
||||||
|
@ -212,8 +212,8 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Dynamic Mask '%s' on '%s'", obs_source_get_name(_self),
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Dynamic Mask '%s' on '%s'",
|
||||||
obs_source_get_name(obs_filter_get_parent(_self))};
|
obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs_effect_t* default_effect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
gs_effect_t* default_effect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
||||||
|
@ -221,7 +221,7 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect)
|
||||||
try { // Capture filter and input
|
try { // Capture filter and input
|
||||||
if (!_have_filter_texture) {
|
if (!_have_filter_texture) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_cache, "Cache"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache, "Cache"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {
|
if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {
|
||||||
|
@ -257,7 +257,7 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect)
|
||||||
|
|
||||||
if (!_have_input_texture) {
|
if (!_have_input_texture) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_capture, "Capture '%s'",
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_capture, "Capture '%s'",
|
||||||
obs_source_get_name(_input_capture->get_object())};
|
obs_source_get_name(_input_capture->get_object())};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect)
|
||||||
// Draw source
|
// Draw source
|
||||||
if (!_have_final_texture) {
|
if (!_have_final_texture) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Masking"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Masking"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -325,7 +325,7 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect)
|
||||||
// Draw source
|
// Draw source
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_render, "Render"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// It is important that we do not modify the blend state here, as it is set correctly by OBS
|
// It is important that we do not modify the blend state here, as it is set correctly by OBS
|
||||||
|
|
|
@ -34,22 +34,22 @@ namespace streamfx::filter::dynamic_mask {
|
||||||
class dynamic_mask_instance : public obs::source_instance {
|
class dynamic_mask_instance : public obs::source_instance {
|
||||||
std::map<std::tuple<channel, channel, std::string>, std::string> _translation_map;
|
std::map<std::tuple<channel, channel, std::string>, std::string> _translation_map;
|
||||||
|
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
|
||||||
bool _have_filter_texture;
|
bool _have_filter_texture;
|
||||||
std::shared_ptr<gs::rendertarget> _filter_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _filter_rt;
|
||||||
std::shared_ptr<gs::texture> _filter_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _filter_texture;
|
||||||
|
|
||||||
bool _have_input_texture;
|
bool _have_input_texture;
|
||||||
std::shared_ptr<obs::deprecated_source> _input;
|
std::shared_ptr<obs::deprecated_source> _input;
|
||||||
std::shared_ptr<gfx::source_texture> _input_capture;
|
std::shared_ptr<gfx::source_texture> _input_capture;
|
||||||
std::shared_ptr<gs::texture> _input_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _input_texture;
|
||||||
std::shared_ptr<obs::tools::visible_source> _input_vs;
|
std::shared_ptr<obs::tools::visible_source> _input_vs;
|
||||||
std::shared_ptr<obs::tools::active_source> _input_ac;
|
std::shared_ptr<obs::tools::active_source> _input_ac;
|
||||||
|
|
||||||
bool _have_final_texture;
|
bool _have_final_texture;
|
||||||
std::shared_ptr<gs::rendertarget> _final_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _final_rt;
|
||||||
std::shared_ptr<gs::texture> _final_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _final_texture;
|
||||||
|
|
||||||
struct channel_data {
|
struct channel_data {
|
||||||
float_t value = 0.0;
|
float_t value = 0.0;
|
||||||
|
|
|
@ -73,9 +73,9 @@ face_tracking_instance::face_tracking_instance(obs_data_t* settings, obs_source_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ // Create render target, vertex buffer, and CUDA stream.
|
{ // Create render target, vertex buffer, and CUDA stream.
|
||||||
auto gctx = gs::context{};
|
auto gctx = streamfx::obs::gs::context{};
|
||||||
_rt = std::make_shared<gs::rendertarget>(GS_RGBA_UNORM, GS_ZS_NONE);
|
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA_UNORM, GS_ZS_NONE);
|
||||||
_geometry = std::make_shared<gs::vertex_buffer>(uint32_t(4), uint8_t(1));
|
_geometry = std::make_shared<streamfx::obs::gs::vertex_buffer>(uint32_t(4), uint8_t(1));
|
||||||
auto cctx = _cuda->get_context()->enter();
|
auto cctx = _cuda->get_context()->enter();
|
||||||
_cuda_stream = std::make_shared<::nvidia::cuda::stream>(::nvidia::cuda::stream_flags::NON_BLOCKING, 0);
|
_cuda_stream = std::make_shared<::nvidia::cuda::stream>(::nvidia::cuda::stream_flags::NON_BLOCKING, 0);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ void face_tracking_instance::async_initialize(std::shared_ptr<void> ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the current CUDA context for working.
|
// Update the current CUDA context for working.
|
||||||
gs::context gctx;
|
streamfx::obs::gs::context gctx;
|
||||||
auto cctx = _cuda->get_context()->enter();
|
auto cctx = _cuda->get_context()->enter();
|
||||||
|
|
||||||
// Create Face Detection feature.
|
// Create Face Detection feature.
|
||||||
|
@ -215,7 +215,7 @@ void face_tracking_instance::async_track(std::shared_ptr<void> ptr)
|
||||||
return; // Can't track a new frame right now.
|
return; // Can't track a new frame right now.
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Start Asynchronous Tracking"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Start Asynchronous Tracking"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Don't push additional tracking frames while processing one.
|
// Don't push additional tracking frames while processing one.
|
||||||
|
@ -230,17 +230,19 @@ void face_tracking_instance::async_track(std::shared_ptr<void> ptr)
|
||||||
if (!_ar_texture || (_ar_texture->get_width() != _size.first) || (_ar_texture->get_height() != _size.second)) {
|
if (!_ar_texture || (_ar_texture->get_width() != _size.first) || (_ar_texture->get_height() != _size.second)) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto prof = _profile_capture_realloc->track();
|
auto prof = _profile_capture_realloc->track();
|
||||||
gs::debug_marker marker{gs::debug_color_allocate, "Reallocate GPU Buffer"};
|
streamfx::obs::gs::debug_marker marker{streamfx::obs::gs::debug_color_allocate, "Reallocate GPU Buffer"};
|
||||||
#endif
|
#endif
|
||||||
_ar_texture = std::make_shared<gs::texture>(_size.first, _size.second, GS_RGBA_UNORM, uint32_t(1), nullptr,
|
_ar_texture =
|
||||||
gs::texture::flags::None);
|
std::make_shared<streamfx::obs::gs::texture>(_size.first, _size.second, GS_RGBA_UNORM, uint32_t(1),
|
||||||
|
nullptr, streamfx::obs::gs::texture::flags::None);
|
||||||
_ar_texture_cuda_fresh = false;
|
_ar_texture_cuda_fresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Copy texture
|
{ // Copy texture
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto prof = _profile_capture_copy->track();
|
auto prof = _profile_capture_copy->track();
|
||||||
gs::debug_marker marker{gs::debug_color_copy, "Copy Capture", obs_source_get_name(_self)};
|
streamfx::obs::gs::debug_marker marker{streamfx::obs::gs::debug_color_copy, "Copy Capture",
|
||||||
|
obs_source_get_name(_self)};
|
||||||
#endif
|
#endif
|
||||||
gs_copy_texture(_ar_texture->get_object(), _rt->get_texture()->get_object());
|
gs_copy_texture(_ar_texture->get_object(), _rt->get_texture()->get_object());
|
||||||
}
|
}
|
||||||
|
@ -263,7 +265,7 @@ void face_tracking_instance::async_track(std::shared_ptr<void> ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire GS context.
|
// Acquire GS context.
|
||||||
gs::context gctx{};
|
streamfx::obs::gs::context gctx{};
|
||||||
|
|
||||||
// Update the current CUDA context for working.
|
// Update the current CUDA context for working.
|
||||||
auto cctx = _cuda->get_context()->enter();
|
auto cctx = _cuda->get_context()->enter();
|
||||||
|
@ -272,8 +274,8 @@ void face_tracking_instance::async_track(std::shared_ptr<void> ptr)
|
||||||
if (!_ar_texture_cuda_fresh) {
|
if (!_ar_texture_cuda_fresh) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto prof = _profile_ar_realloc->track();
|
auto prof = _profile_ar_realloc->track();
|
||||||
gs::debug_marker marker{gs::debug_color_allocate, "%s: Reallocate CUDA Buffers",
|
streamfx::obs::gs::debug_marker marker{streamfx::obs::gs::debug_color_allocate,
|
||||||
obs_source_get_name(_self)};
|
"%s: Reallocate CUDA Buffers", obs_source_get_name(_self)};
|
||||||
#endif
|
#endif
|
||||||
// Assign new texture and allocate new memory.
|
// Assign new texture and allocate new memory.
|
||||||
std::size_t pitch = _ar_texture->get_width() * 4ul;
|
std::size_t pitch = _ar_texture->get_width() * 4ul;
|
||||||
|
@ -537,8 +539,10 @@ void face_tracking_instance::video_render(gs_effect_t*)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "NVIDIA Face Tracking '%s'...", obs_source_get_name(_self)};
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "NVIDIA Face Tracking '%s'...",
|
||||||
gs::debug_marker gdmp2{gs::debug_color_source, "... on '%s'", obs_source_get_name(obs_filter_get_parent(_self))};
|
obs_source_get_name(_self)};
|
||||||
|
streamfx::obs::gs::debug_marker gdmp2{streamfx::obs::gs::debug_color_source, "... on '%s'",
|
||||||
|
obs_source_get_name(obs_filter_get_parent(_self))};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!_rt_is_fresh) { // Capture the filter stack "below" us.
|
if (!_rt_is_fresh) { // Capture the filter stack "below" us.
|
||||||
|
@ -548,7 +552,7 @@ void face_tracking_instance::video_render(gs_effect_t*)
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_cache, "Cache"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache, "Cache"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_NO_DIRECT_RENDERING)) {
|
if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_NO_DIRECT_RENDERING)) {
|
||||||
|
@ -577,7 +581,7 @@ void face_tracking_instance::video_render(gs_effect_t*)
|
||||||
|
|
||||||
{ // Draw Texture
|
{ // Draw Texture
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_render, "Render"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs_effect_set_texture(gs_effect_get_param_by_name(default_effect, "image"), _rt->get_texture()->get_object());
|
gs_effect_set_texture(gs_effect_get_param_by_name(default_effect, "image"), _rt->get_texture()->get_object());
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace streamfx::filter::nvidia {
|
||||||
// Filter Cache
|
// Filter Cache
|
||||||
std::pair<uint32_t, uint32_t> _size;
|
std::pair<uint32_t, uint32_t> _size;
|
||||||
bool _rt_is_fresh;
|
bool _rt_is_fresh;
|
||||||
std::shared_ptr<gs::rendertarget> _rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
|
|
||||||
std::mutex _delete_protection;
|
std::mutex _delete_protection;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace streamfx::filter::nvidia {
|
||||||
double_t _cfg_stability;
|
double_t _cfg_stability;
|
||||||
|
|
||||||
// Operational Data
|
// Operational Data
|
||||||
std::shared_ptr<gs::vertex_buffer> _geometry;
|
std::shared_ptr<streamfx::obs::gs::vertex_buffer> _geometry;
|
||||||
struct {
|
struct {
|
||||||
streamfx::util::math::kalman1D<double_t> center[2];
|
streamfx::util::math::kalman1D<double_t> center[2];
|
||||||
streamfx::util::math::kalman1D<double_t> size[2];
|
streamfx::util::math::kalman1D<double_t> size[2];
|
||||||
|
@ -75,7 +75,7 @@ namespace streamfx::filter::nvidia {
|
||||||
std::vector<float_t> _ar_bboxes_confidence;
|
std::vector<float_t> _ar_bboxes_confidence;
|
||||||
std::vector<NvAR_Rect> _ar_bboxes_data;
|
std::vector<NvAR_Rect> _ar_bboxes_data;
|
||||||
NvAR_BBoxes _ar_bboxes;
|
NvAR_BBoxes _ar_bboxes;
|
||||||
std::shared_ptr<gs::texture> _ar_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _ar_texture;
|
||||||
bool _ar_texture_cuda_fresh;
|
bool _ar_texture_cuda_fresh;
|
||||||
std::shared_ptr<::nvidia::cuda::gstexture> _ar_texture_cuda;
|
std::shared_ptr<::nvidia::cuda::gstexture> _ar_texture_cuda;
|
||||||
std::shared_ptr<::nvidia::cuda::memory> _ar_texture_cuda_mem;
|
std::shared_ptr<::nvidia::cuda::memory> _ar_texture_cuda_mem;
|
||||||
|
|
|
@ -80,28 +80,29 @@ sdf_effects_instance::sdf_effects_instance(obs_data_t* settings, obs_source_t* s
|
||||||
_outline_offset(), _outline_sharpness(), _outline_sharpness_inv()
|
_outline_offset(), _outline_sharpness(), _outline_sharpness_inv()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
vec4 transparent = {0, 0, 0, 0};
|
vec4 transparent = {0, 0, 0, 0};
|
||||||
|
|
||||||
_source_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_source_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_sdf_write = std::make_shared<gs::rendertarget>(GS_RGBA32F, GS_ZS_NONE);
|
_sdf_write = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA32F, GS_ZS_NONE);
|
||||||
_sdf_read = std::make_shared<gs::rendertarget>(GS_RGBA32F, GS_ZS_NONE);
|
_sdf_read = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA32F, GS_ZS_NONE);
|
||||||
_output_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_output_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
|
|
||||||
std::shared_ptr<gs::rendertarget> initialize_rts[] = {_source_rt, _sdf_write, _sdf_read, _output_rt};
|
std::shared_ptr<streamfx::obs::gs::rendertarget> initialize_rts[] = {_source_rt, _sdf_write, _sdf_read,
|
||||||
|
_output_rt};
|
||||||
for (auto rt : initialize_rts) {
|
for (auto rt : initialize_rts) {
|
||||||
auto op = rt->render(1, 1);
|
auto op = rt->render(1, 1);
|
||||||
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &transparent, 0, 0);
|
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &transparent, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<const char*, gs::effect&> load_arr[] = {
|
std::pair<const char*, streamfx::obs::gs::effect&> load_arr[] = {
|
||||||
{"effects/sdf/sdf-producer.effect", _sdf_producer_effect},
|
{"effects/sdf/sdf-producer.effect", _sdf_producer_effect},
|
||||||
{"effects/sdf/sdf-consumer.effect", _sdf_consumer_effect},
|
{"effects/sdf/sdf-consumer.effect", _sdf_consumer_effect},
|
||||||
};
|
};
|
||||||
for (auto& kv : load_arr) {
|
for (auto& kv : load_arr) {
|
||||||
auto path = streamfx::data_file_path(kv.first).u8string();
|
auto path = streamfx::data_file_path(kv.first).u8string();
|
||||||
try {
|
try {
|
||||||
kv.second = gs::effect::create(path);
|
kv.second = streamfx::obs::gs::effect::create(path);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
DLOG_ERROR(LOG_PREFIX "Failed to load effect '%s' (located at '%s') with error(s): %s", kv.first,
|
DLOG_ERROR(LOG_PREFIX "Failed to load effect '%s' (located at '%s') with error(s): %s", kv.first,
|
||||||
path.c_str(), ex.what());
|
path.c_str(), ex.what());
|
||||||
|
@ -279,11 +280,11 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "SDF Effects '%s' on '%s'", obs_source_get_name(_self),
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "SDF Effects '%s' on '%s'",
|
||||||
obs_source_get_name(obs_filter_get_parent(_self))};
|
obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
vec4 color_transparent = {0, 0, 0, 0};
|
vec4 color_transparent = {0, 0, 0, 0};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -305,7 +306,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
||||||
// Store input texture.
|
// Store input texture.
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_cache, "Cache"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache, "Cache"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _source_rt->render(baseW, baseH);
|
auto op = _source_rt->render(baseW, baseH);
|
||||||
|
@ -347,7 +348,8 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Update Distance Field"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert,
|
||||||
|
"Update Distance Field"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _sdf_write->render(uint32_t(sdfW), uint32_t(sdfH));
|
auto op = _sdf_write->render(uint32_t(sdfW), uint32_t(sdfH));
|
||||||
|
@ -405,7 +407,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
||||||
// Optimized Render path.
|
// Optimized Render path.
|
||||||
try {
|
try {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Calculate"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Calculate"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _output_rt->render(baseW, baseH);
|
auto op = _output_rt->render(baseW, baseH);
|
||||||
|
@ -502,7 +504,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_render, "Render"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs_eparam_t* ep = gs_effect_get_param_by_name(final_effect, "image");
|
gs_eparam_t* ep = gs_effect_get_param_by_name(final_effect, "image");
|
||||||
|
|
|
@ -28,25 +28,25 @@
|
||||||
|
|
||||||
namespace streamfx::filter::sdf_effects {
|
namespace streamfx::filter::sdf_effects {
|
||||||
class sdf_effects_instance : public obs::source_instance {
|
class sdf_effects_instance : public obs::source_instance {
|
||||||
gs::effect _sdf_producer_effect;
|
streamfx::obs::gs::effect _sdf_producer_effect;
|
||||||
gs::effect _sdf_consumer_effect;
|
streamfx::obs::gs::effect _sdf_consumer_effect;
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
std::shared_ptr<gs::rendertarget> _source_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _source_rt;
|
||||||
std::shared_ptr<gs::texture> _source_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _source_texture;
|
||||||
bool _source_rendered;
|
bool _source_rendered;
|
||||||
|
|
||||||
// Distance Field
|
// Distance Field
|
||||||
std::shared_ptr<gs::rendertarget> _sdf_write;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _sdf_write;
|
||||||
std::shared_ptr<gs::rendertarget> _sdf_read;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _sdf_read;
|
||||||
std::shared_ptr<gs::texture> _sdf_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _sdf_texture;
|
||||||
double_t _sdf_scale;
|
double_t _sdf_scale;
|
||||||
float_t _sdf_threshold;
|
float_t _sdf_threshold;
|
||||||
|
|
||||||
// Effects
|
// Effects
|
||||||
bool _output_rendered;
|
bool _output_rendered;
|
||||||
std::shared_ptr<gs::texture> _output_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _output_texture;
|
||||||
std::shared_ptr<gs::rendertarget> _output_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _output_rt;
|
||||||
/// Inner Shadow
|
/// Inner Shadow
|
||||||
bool _inner_shadow;
|
bool _inner_shadow;
|
||||||
vec4 _inner_shadow_color;
|
vec4 _inner_shadow_color;
|
||||||
|
|
|
@ -32,7 +32,7 @@ static constexpr std::string_view HELP_URL =
|
||||||
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self)
|
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self)
|
||||||
{
|
{
|
||||||
_fx = std::make_shared<gfx::shader::shader>(self, gfx::shader::shader_mode::Filter);
|
_fx = std::make_shared<gfx::shader::shader>(self, gfx::shader::shader_mode::Filter);
|
||||||
_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
|
|
||||||
update(data);
|
update(data);
|
||||||
}
|
}
|
||||||
|
@ -89,13 +89,14 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Shader Filter '%s' on '%s'", obs_source_get_name(_self),
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Shader Filter '%s' on '%s'",
|
||||||
|
obs_source_get_name(_self),
|
||||||
obs_source_get_name(obs_filter_get_parent(_self))};
|
obs_source_get_name(obs_filter_get_parent(_self))};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_source, "Cache"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_source, "Cache"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rt->render(_fx->base_width(), _fx->base_height());
|
auto op = _rt->render(_fx->base_width(), _fx->base_height());
|
||||||
|
@ -124,7 +125,7 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_render, "Render"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_fx->prepare_render();
|
_fx->prepare_render();
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
namespace streamfx::filter::shader {
|
namespace streamfx::filter::shader {
|
||||||
class shader_instance : public obs::source_instance {
|
class shader_instance : public obs::source_instance {
|
||||||
std::shared_ptr<gfx::shader::shader> _fx;
|
std::shared_ptr<gfx::shader::shader> _fx;
|
||||||
std::shared_ptr<gs::rendertarget> _rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
shader_instance(obs_data_t* data, obs_source_t* self);
|
shader_instance(obs_data_t* data, obs_source_t* self);
|
||||||
|
|
|
@ -85,9 +85,9 @@ transform_instance::transform_instance(obs_data_t* data, obs_source_t* context)
|
||||||
: obs::source_instance(data, context), _cache_rendered(), _mipmap_enabled(), _source_rendered(), _source_size(),
|
: obs::source_instance(data, context), _cache_rendered(), _mipmap_enabled(), _source_rendered(), _source_size(),
|
||||||
_update_mesh(), _rotation_order(), _camera_orthographic(), _camera_fov()
|
_update_mesh(), _rotation_order(), _camera_orthographic(), _camera_fov()
|
||||||
{
|
{
|
||||||
_cache_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_cache_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_source_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_source_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_vertex_buffer = std::make_shared<gs::vertex_buffer>(uint32_t(4u), uint8_t(1u));
|
_vertex_buffer = std::make_shared<streamfx::obs::gs::vertex_buffer>(uint32_t(4u), uint8_t(1u));
|
||||||
|
|
||||||
_position = std::make_unique<streamfx::util::vec3a>();
|
_position = std::make_unique<streamfx::util::vec3a>();
|
||||||
_rotation = std::make_unique<streamfx::util::vec3a>();
|
_rotation = std::make_unique<streamfx::util::vec3a>();
|
||||||
|
@ -288,8 +288,8 @@ void transform_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "3D Transform '%s' on '%s'", obs_source_get_name(_self),
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "3D Transform '%s' on '%s'",
|
||||||
obs_source_get_name(obs_filter_get_parent(_self))};
|
obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t cache_width = base_width;
|
uint32_t cache_width = base_width;
|
||||||
|
@ -316,7 +316,7 @@ void transform_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
if (!_cache_rendered) {
|
if (!_cache_rendered) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_cache, "Cache"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache, "Cache"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _cache_rt->render(cache_width, cache_height);
|
auto op = _cache_rt->render(cache_width, cache_height);
|
||||||
|
@ -356,20 +356,20 @@ void transform_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
if (_mipmap_enabled) {
|
if (_mipmap_enabled) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Mipmap"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Mipmap"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!_mipmap_texture || (_mipmap_texture->get_width() != cache_width)
|
if (!_mipmap_texture || (_mipmap_texture->get_width() != cache_width)
|
||||||
|| (_mipmap_texture->get_height() != cache_height)) {
|
|| (_mipmap_texture->get_height() != cache_height)) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdr{gs::debug_color_allocate, "Allocate Mipmapped Texture"};
|
streamfx::obs::gs::debug_marker gdr{streamfx::obs::gs::debug_color_allocate, "Allocate Mipmapped Texture"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::size_t mip_levels = std::max(streamfx::util::math::get_power_of_two_exponent_ceil(cache_width),
|
std::size_t mip_levels = std::max(streamfx::util::math::get_power_of_two_exponent_ceil(cache_width),
|
||||||
streamfx::util::math::get_power_of_two_exponent_ceil(cache_height));
|
streamfx::util::math::get_power_of_two_exponent_ceil(cache_height));
|
||||||
_mipmap_texture =
|
_mipmap_texture = std::make_shared<streamfx::obs::gs::texture>(cache_width, cache_height, GS_RGBA,
|
||||||
std::make_shared<gs::texture>(cache_width, cache_height, GS_RGBA, static_cast<uint32_t>(mip_levels),
|
static_cast<uint32_t>(mip_levels), nullptr,
|
||||||
nullptr, gs::texture::flags::None);
|
streamfx::obs::gs::texture::flags::None);
|
||||||
}
|
}
|
||||||
_mipmapper.rebuild(_cache_texture, _mipmap_texture);
|
_mipmapper.rebuild(_cache_texture, _mipmap_texture);
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ void transform_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_convert, "Transform"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_convert, "Transform"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _source_rt->render(base_width, base_height);
|
auto op = _source_rt->render(base_width, base_height);
|
||||||
|
@ -430,7 +430,7 @@ void transform_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdm{gs::debug_color_render, "Render"};
|
streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), _source_texture->get_object());
|
gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), _source_texture->get_object());
|
||||||
|
|
|
@ -30,24 +30,24 @@ namespace streamfx::filter::transform {
|
||||||
class transform_instance : public obs::source_instance {
|
class transform_instance : public obs::source_instance {
|
||||||
// Cache
|
// Cache
|
||||||
bool _cache_rendered;
|
bool _cache_rendered;
|
||||||
std::shared_ptr<gs::rendertarget> _cache_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _cache_rt;
|
||||||
std::shared_ptr<gs::texture> _cache_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _cache_texture;
|
||||||
|
|
||||||
// Mip-mapping
|
// Mip-mapping
|
||||||
bool _mipmap_enabled;
|
bool _mipmap_enabled;
|
||||||
bool _mipmap_rendered;
|
bool _mipmap_rendered;
|
||||||
gs::mipmapper _mipmapper;
|
streamfx::obs::gs::mipmapper _mipmapper;
|
||||||
std::shared_ptr<gs::texture> _mipmap_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _mipmap_texture;
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
bool _source_rendered;
|
bool _source_rendered;
|
||||||
std::pair<uint32_t, uint32_t> _source_size;
|
std::pair<uint32_t, uint32_t> _source_size;
|
||||||
std::shared_ptr<gs::rendertarget> _source_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _source_rt;
|
||||||
std::shared_ptr<gs::texture> _source_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _source_texture;
|
||||||
|
|
||||||
// Mesh
|
// Mesh
|
||||||
bool _update_mesh;
|
bool _update_mesh;
|
||||||
std::shared_ptr<gs::vertex_buffer> _vertex_buffer;
|
std::shared_ptr<streamfx::obs::gs::vertex_buffer> _vertex_buffer;
|
||||||
uint32_t _rotation_order;
|
uint32_t _rotation_order;
|
||||||
std::unique_ptr<streamfx::util::vec3a> _position;
|
std::unique_ptr<streamfx::util::vec3a> _position;
|
||||||
std::unique_ptr<streamfx::util::vec3a> _rotation;
|
std::unique_ptr<streamfx::util::vec3a> _rotation;
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace gfx {
|
||||||
public:
|
public:
|
||||||
virtual ~base() {}
|
virtual ~base() {}
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::gs::texture> texture) = 0;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) = 0;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() = 0;
|
virtual ::gfx::blur::type get_type() = 0;
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ namespace gfx {
|
||||||
|
|
||||||
virtual double_t get_step_scale_y();
|
virtual double_t get_step_scale_y();
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() = 0;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> get() = 0;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class base_angle {
|
class base_angle {
|
||||||
|
|
|
@ -36,9 +36,10 @@
|
||||||
|
|
||||||
gfx::blur::box_linear_data::box_linear_data()
|
gfx::blur::box_linear_data::box_linear_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
try {
|
try {
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/blur/box-linear.effect").u8string());
|
_effect =
|
||||||
|
streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/box-linear.effect").u8string());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
DLOG_ERROR("<gfx::blur::box_linear> Failed to load _effect.");
|
DLOG_ERROR("<gfx::blur::box_linear> Failed to load _effect.");
|
||||||
}
|
}
|
||||||
|
@ -46,11 +47,11 @@ gfx::blur::box_linear_data::box_linear_data()
|
||||||
|
|
||||||
gfx::blur::box_linear_data::~box_linear_data()
|
gfx::blur::box_linear_data::~box_linear_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect gfx::blur::box_linear_data::get_effect()
|
streamfx::obs::gs::effect gfx::blur::box_linear_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
@ -187,13 +188,13 @@ std::shared_ptr<::gfx::blur::box_linear_data> gfx::blur::box_linear_factory::dat
|
||||||
gfx::blur::box_linear::box_linear()
|
gfx::blur::box_linear::box_linear()
|
||||||
: _data(::gfx::blur::box_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
: _data(::gfx::blur::box_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
_rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_linear::~box_linear() {}
|
gfx::blur::box_linear::~box_linear() {}
|
||||||
|
|
||||||
void gfx::blur::box_linear::set_input(std::shared_ptr<::gs::texture> texture)
|
void gfx::blur::box_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
@ -240,12 +241,12 @@ double_t gfx::blur::box_linear::get_step_scale_y()
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box_linear::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Box Linear Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Box Linear Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float_t width = float_t(_input_texture->get_width());
|
float_t width = float_t(_input_texture->get_width());
|
||||||
|
@ -265,7 +266,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render()
|
||||||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||||
|
|
||||||
// Two Pass Blur
|
// Two Pass Blur
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
if (effect) {
|
if (effect) {
|
||||||
// Pass 1
|
// Pass 1
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
|
@ -276,7 +277,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Horizontal");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Horizontal");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -292,7 +293,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Vertical");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Vertical");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -308,7 +309,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render()
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box_linear::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
@ -330,12 +331,13 @@ void gfx::blur::box_linear_directional::set_angle(double_t angle)
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box_linear_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Box Linear Directional Blur");
|
auto gdmp =
|
||||||
|
streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Box Linear Directional Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float_t width = float_t(_input_texture->get_width());
|
float_t width = float_t(_input_texture->get_width());
|
||||||
|
@ -355,7 +357,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear_directional::render()
|
||||||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||||
|
|
||||||
// One Pass Blur
|
// One Pass Blur
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
if (effect) {
|
if (effect) {
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
effect.get_parameter("pImageTexel")
|
effect.get_parameter("pImageTexel")
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class box_linear_data {
|
class box_linear_data {
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box_linear_data();
|
box_linear_data();
|
||||||
virtual ~box_linear_data();
|
virtual ~box_linear_data();
|
||||||
|
|
||||||
gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_linear_factory : public ::gfx::blur::ifactory {
|
class box_linear_factory : public ::gfx::blur::ifactory {
|
||||||
|
@ -85,17 +85,17 @@ namespace gfx {
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
std::shared_ptr<::gs::texture> _input_texture;
|
std::shared_ptr<::streamfx::obs::gs::texture> _input_texture;
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget2;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box_linear();
|
box_linear();
|
||||||
virtual ~box_linear() override;
|
virtual ~box_linear() override;
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ namespace gfx {
|
||||||
virtual double_t get_step_scale_x() override;
|
virtual double_t get_step_scale_x() override;
|
||||||
virtual double_t get_step_scale_y() override;
|
virtual double_t get_step_scale_y() override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
virtual std::shared_ptr<::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_linear_directional : public ::gfx::blur::box_linear, public ::gfx::blur::base_angle {
|
class box_linear_directional : public ::gfx::blur::box_linear, public ::gfx::blur::base_angle {
|
||||||
|
@ -122,7 +122,7 @@ namespace gfx {
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
|
|
||||||
gfx::blur::box_data::box_data()
|
gfx::blur::box_data::box_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
try {
|
try {
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/blur/box.effect").u8string());
|
_effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/box.effect").u8string());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
DLOG_ERROR("<gfx::blur::box> Failed to load _effect.");
|
DLOG_ERROR("<gfx::blur::box> Failed to load _effect.");
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,11 @@ gfx::blur::box_data::box_data()
|
||||||
|
|
||||||
gfx::blur::box_data::~box_data()
|
gfx::blur::box_data::~box_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect gfx::blur::box_data::get_effect()
|
streamfx::obs::gs::effect gfx::blur::box_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
@ -194,14 +194,14 @@ std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data()
|
||||||
|
|
||||||
gfx::blur::box::box() : _data(::gfx::blur::box_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
gfx::blur::box::box() : _data(::gfx::blur::box_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box::~box() {}
|
gfx::blur::box::~box() {}
|
||||||
|
|
||||||
void gfx::blur::box::set_input(std::shared_ptr<::gs::texture> texture)
|
void gfx::blur::box::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
@ -248,12 +248,12 @@ double_t gfx::blur::box::get_step_scale_y()
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Box Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Box Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float_t width = float_t(_input_texture->get_width());
|
float_t width = float_t(_input_texture->get_width());
|
||||||
|
@ -273,7 +273,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render()
|
||||||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||||
|
|
||||||
// Two Pass Blur
|
// Two Pass Blur
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
if (effect) {
|
if (effect) {
|
||||||
// Pass 1
|
// Pass 1
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
|
@ -284,7 +284,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Horizontal");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Horizontal");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -300,7 +300,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Vertical");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Vertical");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -316,7 +316,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render()
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
@ -338,12 +338,12 @@ void gfx::blur::box_directional::set_angle(double_t angle)
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Box Directional Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Box Directional Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float_t width = float_t(_input_texture->get_width());
|
float_t width = float_t(_input_texture->get_width());
|
||||||
|
@ -363,7 +363,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_directional::render()
|
||||||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||||
|
|
||||||
// One Pass Blur
|
// One Pass Blur
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
if (effect) {
|
if (effect) {
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
effect.get_parameter("pImageTexel")
|
effect.get_parameter("pImageTexel")
|
||||||
|
@ -413,12 +413,12 @@ void gfx::blur::box_rotational::set_angle(double_t angle)
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_rotational::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Box Rotational Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Box Rotational Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float_t width = float_t(_input_texture->get_width());
|
float_t width = float_t(_input_texture->get_width());
|
||||||
|
@ -438,7 +438,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render()
|
||||||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||||
|
|
||||||
// One Pass Blur
|
// One Pass Blur
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
if (effect) {
|
if (effect) {
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height));
|
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height));
|
||||||
|
@ -479,12 +479,12 @@ void gfx::blur::box_zoom::get_center(double_t& x, double_t& y)
|
||||||
y = _center.second;
|
y = _center.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::box_zoom::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_zoom::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Box Zoom Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Box Zoom Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float_t width = float_t(_input_texture->get_width());
|
float_t width = float_t(_input_texture->get_width());
|
||||||
|
@ -504,7 +504,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_zoom::render()
|
||||||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||||
|
|
||||||
// One Pass Blur
|
// One Pass Blur
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
if (effect) {
|
if (effect) {
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height));
|
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height));
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class box_data {
|
class box_data {
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box_data();
|
box_data();
|
||||||
virtual ~box_data();
|
virtual ~box_data();
|
||||||
|
|
||||||
gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_factory : public ::gfx::blur::ifactory {
|
class box_factory : public ::gfx::blur::ifactory {
|
||||||
|
@ -85,17 +85,17 @@ namespace gfx {
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
std::shared_ptr<::gs::texture> _input_texture;
|
std::shared_ptr<::streamfx::obs::gs::texture> _input_texture;
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget2;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box();
|
box();
|
||||||
virtual ~box() override;
|
virtual ~box() override;
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ namespace gfx {
|
||||||
virtual double_t get_step_scale_x() override;
|
virtual double_t get_step_scale_x() override;
|
||||||
virtual double_t get_step_scale_y() override;
|
virtual double_t get_step_scale_y() override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
virtual std::shared_ptr<::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_directional : public ::gfx::blur::box, public ::gfx::blur::base_angle {
|
class box_directional : public ::gfx::blur::box, public ::gfx::blur::base_angle {
|
||||||
|
@ -122,7 +122,7 @@ namespace gfx {
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_rotational : public ::gfx::blur::box,
|
class box_rotational : public ::gfx::blur::box,
|
||||||
|
@ -140,7 +140,7 @@ namespace gfx {
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_zoom : public ::gfx::blur::box, public ::gfx::blur::base_center {
|
class box_zoom : public ::gfx::blur::box, public ::gfx::blur::base_center {
|
||||||
|
@ -152,7 +152,7 @@ namespace gfx {
|
||||||
virtual void set_center(double_t x, double_t y) override;
|
virtual void set_center(double_t x, double_t y) override;
|
||||||
virtual void get_center(double_t& x, double_t& y) override;
|
virtual void get_center(double_t& x, double_t& y) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -52,9 +52,10 @@
|
||||||
|
|
||||||
gfx::blur::dual_filtering_data::dual_filtering_data()
|
gfx::blur::dual_filtering_data::dual_filtering_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
try {
|
try {
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/blur/dual-filtering.effect").u8string());
|
_effect = streamfx::obs::gs::effect::create(
|
||||||
|
streamfx::data_file_path("effects/blur/dual-filtering.effect").u8string());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
DLOG_ERROR("<gfx::blur::box_linear> Failed to load _effect.");
|
DLOG_ERROR("<gfx::blur::box_linear> Failed to load _effect.");
|
||||||
}
|
}
|
||||||
|
@ -62,11 +63,11 @@ gfx::blur::dual_filtering_data::dual_filtering_data()
|
||||||
|
|
||||||
gfx::blur::dual_filtering_data::~dual_filtering_data()
|
gfx::blur::dual_filtering_data::~dual_filtering_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect gfx::blur::dual_filtering_data::get_effect()
|
streamfx::obs::gs::effect gfx::blur::dual_filtering_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +181,7 @@ std::shared_ptr<::gfx::blur::dual_filtering_data> gfx::blur::dual_filtering_fact
|
||||||
gfx::blur::dual_filtering::dual_filtering()
|
gfx::blur::dual_filtering::dual_filtering()
|
||||||
: _data(::gfx::blur::dual_filtering_factory::get().data()), _size(0), _size_iterations(0)
|
: _data(::gfx::blur::dual_filtering_factory::get().data()), _size(0), _size_iterations(0)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_rts.resize(MAX_LEVELS + 1);
|
_rts.resize(MAX_LEVELS + 1);
|
||||||
for (std::size_t n = 0; n <= MAX_LEVELS; n++) {
|
for (std::size_t n = 0; n <= MAX_LEVELS; n++) {
|
||||||
gs_color_format cf = GS_RGBA;
|
gs_color_format cf = GS_RGBA;
|
||||||
|
@ -189,13 +190,13 @@ gfx::blur::dual_filtering::dual_filtering()
|
||||||
#elif 0
|
#elif 0
|
||||||
cf = GS_RGBA32F;
|
cf = GS_RGBA32F;
|
||||||
#endif
|
#endif
|
||||||
_rts[n] = std::make_shared<gs::rendertarget>(cf, GS_ZS_NONE);
|
_rts[n] = std::make_shared<streamfx::obs::gs::rendertarget>(cf, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::dual_filtering::~dual_filtering() {}
|
gfx::blur::dual_filtering::~dual_filtering() {}
|
||||||
|
|
||||||
void gfx::blur::dual_filtering::set_input(std::shared_ptr<::gs::texture> texture)
|
void gfx::blur::dual_filtering::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
@ -223,12 +224,12 @@ void gfx::blur::dual_filtering::set_step_scale(double_t, double_t) {}
|
||||||
|
|
||||||
void gfx::blur::dual_filtering::get_step_scale(double_t&, double_t&) {}
|
void gfx::blur::dual_filtering::get_step_scale(double_t&, double_t&) {}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Dual-Filtering Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Dual-Filtering Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto effect = _data->get_effect();
|
auto effect = _data->get_effect();
|
||||||
|
@ -257,11 +258,11 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
|
||||||
// Downsample
|
// Downsample
|
||||||
for (std::size_t n = 1; n <= actual_iterations; n++) {
|
for (std::size_t n = 1; n <= actual_iterations; n++) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Down %" PRIuMAX, n);
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Down %" PRIuMAX, n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Select Texture
|
// Select Texture
|
||||||
std::shared_ptr<gs::texture> tex_cur;
|
std::shared_ptr<streamfx::obs::gs::texture> tex_cur;
|
||||||
if (n > 1) {
|
if (n > 1) {
|
||||||
tex_cur = _rts[n - 1]->get_texture();
|
tex_cur = _rts[n - 1]->get_texture();
|
||||||
} else { // Idx 0 is a simply considered as a straight copy of the original and not rendered to.
|
} else { // Idx 0 is a simply considered as a straight copy of the original and not rendered to.
|
||||||
|
@ -294,11 +295,11 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
|
||||||
// Upsample
|
// Upsample
|
||||||
for (std::size_t n = actual_iterations; n > 0; n--) {
|
for (std::size_t n = actual_iterations; n > 0; n--) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Up %" PRIuMAX, n);
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Up %" PRIuMAX, n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Select Texture
|
// Select Texture
|
||||||
std::shared_ptr<gs::texture> tex_in = _rts[n]->get_texture();
|
std::shared_ptr<streamfx::obs::gs::texture> tex_in = _rts[n]->get_texture();
|
||||||
|
|
||||||
// Get Size
|
// Get Size
|
||||||
uint32_t iwidth = width >> n;
|
uint32_t iwidth = width >> n;
|
||||||
|
@ -326,7 +327,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
|
||||||
return _rts[0]->get_texture();
|
return _rts[0]->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::get()
|
||||||
{
|
{
|
||||||
return _rts[0]->get_texture();
|
return _rts[0]->get_texture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,13 +27,13 @@
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class dual_filtering_data {
|
class dual_filtering_data {
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dual_filtering_data();
|
dual_filtering_data();
|
||||||
virtual ~dual_filtering_data();
|
virtual ~dual_filtering_data();
|
||||||
|
|
||||||
gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
};
|
};
|
||||||
|
|
||||||
class dual_filtering_factory : public ::gfx::blur::ifactory {
|
class dual_filtering_factory : public ::gfx::blur::ifactory {
|
||||||
|
@ -86,15 +86,15 @@ namespace gfx {
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::size_t _size_iterations;
|
std::size_t _size_iterations;
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> _input_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _input_texture;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<gs::rendertarget>> _rts;
|
std::vector<std::shared_ptr<streamfx::obs::gs::rendertarget>> _rts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dual_filtering();
|
dual_filtering();
|
||||||
virtual ~dual_filtering() override;
|
virtual ~dual_filtering() override;
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
|
@ -106,9 +106,9 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void get_step_scale(double_t& x, double_t& y) override;
|
virtual void get_step_scale(double_t& x, double_t& y) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -42,8 +42,9 @@
|
||||||
|
|
||||||
gfx::blur::gaussian_linear_data::gaussian_linear_data()
|
gfx::blur::gaussian_linear_data::gaussian_linear_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/blur/gaussian-linear.effect").u8string());
|
_effect =
|
||||||
|
streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian-linear.effect").u8string());
|
||||||
|
|
||||||
// Precalculate Kernels
|
// Precalculate Kernels
|
||||||
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
|
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
|
||||||
|
@ -82,7 +83,7 @@ gfx::blur::gaussian_linear_data::~gaussian_linear_data()
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect gfx::blur::gaussian_linear_data::get_effect()
|
streamfx::obs::gs::effect gfx::blur::gaussian_linear_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
@ -230,15 +231,15 @@ std::shared_ptr<::gfx::blur::gaussian_linear_data> gfx::blur::gaussian_linear_fa
|
||||||
gfx::blur::gaussian_linear::gaussian_linear()
|
gfx::blur::gaussian_linear::gaussian_linear()
|
||||||
: _data(::gfx::blur::gaussian_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
: _data(::gfx::blur::gaussian_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
_rendertarget = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_rendertarget2 = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear::~gaussian_linear() {}
|
gfx::blur::gaussian_linear::~gaussian_linear() {}
|
||||||
|
|
||||||
void gfx::blur::gaussian_linear::set_input(std::shared_ptr<::gs::texture> texture)
|
void gfx::blur::gaussian_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
@ -284,15 +285,15 @@ double_t gfx::blur::gaussian_linear::get_step_scale_y()
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Gaussian Linear Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Gaussian Linear Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
auto kernel = _data->get_kernel(size_t(_size));
|
auto kernel = _data->get_kernel(size_t(_size));
|
||||||
|
|
||||||
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
||||||
|
@ -327,7 +328,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Horizontal");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Horizontal");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -347,7 +348,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Vertical");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Vertical");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -365,7 +366,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render()
|
||||||
return this->get();
|
return this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
@ -389,15 +390,16 @@ void gfx::blur::gaussian_linear_directional::set_angle(double_t angle)
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Gaussian Linear Directional Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance,
|
||||||
|
"Gaussian Linear Directional Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
auto kernel = _data->get_kernel(size_t(_size));
|
auto kernel = _data->get_kernel(size_t(_size));
|
||||||
|
|
||||||
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
||||||
|
|
|
@ -27,14 +27,14 @@
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class gaussian_linear_data {
|
class gaussian_linear_data {
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
std::vector<std::vector<float_t>> _kernels;
|
std::vector<std::vector<float_t>> _kernels;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian_linear_data();
|
gaussian_linear_data();
|
||||||
virtual ~gaussian_linear_data();
|
virtual ~gaussian_linear_data();
|
||||||
|
|
||||||
gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
|
|
||||||
std::vector<float_t> const& get_kernel(std::size_t width);
|
std::vector<float_t> const& get_kernel(std::size_t width);
|
||||||
};
|
};
|
||||||
|
@ -89,17 +89,17 @@ namespace gfx {
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
std::shared_ptr<::gs::texture> _input_texture;
|
std::shared_ptr<::streamfx::obs::gs::texture> _input_texture;
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget2;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian_linear();
|
gaussian_linear();
|
||||||
virtual ~gaussian_linear() override;
|
virtual ~gaussian_linear() override;
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ namespace gfx {
|
||||||
|
|
||||||
virtual double_t get_step_scale_y() override;
|
virtual double_t get_step_scale_y() override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_linear_directional : public ::gfx::blur::gaussian_linear, public ::gfx::blur::base_angle {
|
class gaussian_linear_directional : public ::gfx::blur::gaussian_linear, public ::gfx::blur::base_angle {
|
||||||
|
@ -133,7 +133,7 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
|
|
||||||
gfx::blur::gaussian_data::gaussian_data()
|
gfx::blur::gaussian_data::gaussian_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/blur/gaussian.effect").u8string());
|
_effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian.effect").u8string());
|
||||||
|
|
||||||
// Precalculate Kernels
|
// Precalculate Kernels
|
||||||
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
|
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
|
||||||
|
@ -80,11 +80,11 @@ gfx::blur::gaussian_data::gaussian_data()
|
||||||
|
|
||||||
gfx::blur::gaussian_data::~gaussian_data()
|
gfx::blur::gaussian_data::~gaussian_data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect gfx::blur::gaussian_data::get_effect()
|
streamfx::obs::gs::effect gfx::blur::gaussian_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
@ -238,14 +238,14 @@ std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data()
|
||||||
|
|
||||||
gfx::blur::gaussian::gaussian() : _data(::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
gfx::blur::gaussian::gaussian() : _data(::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_rendertarget = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_rendertarget2 = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian::~gaussian() {}
|
gfx::blur::gaussian::~gaussian() {}
|
||||||
|
|
||||||
void gfx::blur::gaussian::set_input(std::shared_ptr<::gs::texture> texture)
|
void gfx::blur::gaussian::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
@ -291,15 +291,15 @@ double_t gfx::blur::gaussian::get_step_scale_y()
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Gaussian Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Gaussian Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
auto kernel = _data->get_kernel(size_t(_size));
|
auto kernel = _data->get_kernel(size_t(_size));
|
||||||
|
|
||||||
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
||||||
|
@ -334,7 +334,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Horizontal");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Horizontal");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -354,7 +354,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Vertical");
|
auto gdm = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Vertical");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
auto op = _rendertarget2->render(uint32_t(width), uint32_t(height));
|
||||||
|
@ -372,7 +372,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render()
|
||||||
return this->get();
|
return this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
@ -396,15 +396,16 @@ void gfx::blur::gaussian_directional::set_angle(double_t angle)
|
||||||
m_angle = D_DEG_TO_RAD(angle);
|
m_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Gaussian Directional Blur");
|
auto gdmp =
|
||||||
|
streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Gaussian Directional Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
auto kernel = _data->get_kernel(size_t(_size));
|
auto kernel = _data->get_kernel(size_t(_size));
|
||||||
|
|
||||||
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
||||||
|
@ -454,15 +455,16 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render()
|
||||||
return ::gfx::blur::type::Rotational;
|
return ::gfx::blur::type::Rotational;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian_rotational::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_rotational::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Gaussian Rotational Blur");
|
auto gdmp =
|
||||||
|
streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Gaussian Rotational Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
auto kernel = _data->get_kernel(size_t(_size));
|
auto kernel = _data->get_kernel(size_t(_size));
|
||||||
|
|
||||||
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
||||||
|
@ -535,15 +537,15 @@ void gfx::blur::gaussian_rotational::set_angle(double_t angle)
|
||||||
return ::gfx::blur::type::Zoom;
|
return ::gfx::blur::type::Zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gs::texture> gfx::blur::gaussian_zoom::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_zoom::render()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto gdmp = gs::debug_marker(gs::debug_color_azure_radiance, "Gaussian Zoom Blur");
|
auto gdmp = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance, "Gaussian Zoom Blur");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs::effect effect = _data->get_effect();
|
streamfx::obs::gs::effect effect = _data->get_effect();
|
||||||
auto kernel = _data->get_kernel(size_t(_size));
|
auto kernel = _data->get_kernel(size_t(_size));
|
||||||
|
|
||||||
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits<double_t>::epsilon())) {
|
||||||
|
|
|
@ -27,14 +27,14 @@
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class gaussian_data {
|
class gaussian_data {
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
std::vector<std::vector<float_t>> _kernels;
|
std::vector<std::vector<float_t>> _kernels;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian_data();
|
gaussian_data();
|
||||||
virtual ~gaussian_data();
|
virtual ~gaussian_data();
|
||||||
|
|
||||||
gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
|
|
||||||
std::vector<float_t> const& get_kernel(std::size_t width);
|
std::vector<float_t> const& get_kernel(std::size_t width);
|
||||||
};
|
};
|
||||||
|
@ -89,17 +89,17 @@ namespace gfx {
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
std::shared_ptr<::gs::texture> _input_texture;
|
std::shared_ptr<::streamfx::obs::gs::texture> _input_texture;
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<::gs::rendertarget> _rendertarget2;
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian();
|
gaussian();
|
||||||
virtual ~gaussian() override;
|
virtual ~gaussian() override;
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ namespace gfx {
|
||||||
|
|
||||||
virtual double_t get_step_scale_y() override;
|
virtual double_t get_step_scale_y() override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_directional : public ::gfx::blur::gaussian, public ::gfx::blur::base_angle {
|
class gaussian_directional : public ::gfx::blur::gaussian, public ::gfx::blur::base_angle {
|
||||||
|
@ -132,7 +132,7 @@ namespace gfx {
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_rotational : public ::gfx::blur::gaussian,
|
class gaussian_rotational : public ::gfx::blur::gaussian,
|
||||||
|
@ -150,7 +150,7 @@ namespace gfx {
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_zoom : public ::gfx::blur::gaussian, public ::gfx::blur::base_center {
|
class gaussian_zoom : public ::gfx::blur::gaussian, public ::gfx::blur::base_center {
|
||||||
|
@ -162,7 +162,7 @@ namespace gfx {
|
||||||
virtual void set_center(double_t x, double_t y) override;
|
virtual void set_center(double_t x, double_t y) override;
|
||||||
virtual void get_center(double_t& x, double_t& y) override;
|
virtual void get_center(double_t& x, double_t& y) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -35,7 +35,7 @@ gfx::source_texture::source_texture(obs_source_t* parent)
|
||||||
throw std::invalid_argument("_parent must not be null");
|
throw std::invalid_argument("_parent must not be null");
|
||||||
}
|
}
|
||||||
_parent = std::make_shared<streamfx::obs::deprecated_source>(parent, false, false);
|
_parent = std::make_shared<streamfx::obs::deprecated_source>(parent, false, false);
|
||||||
_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent)
|
gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent)
|
||||||
|
@ -77,7 +77,7 @@ gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_so
|
||||||
}
|
}
|
||||||
this->_child = pchild;
|
this->_child = pchild;
|
||||||
this->_parent = pparent;
|
this->_parent = pparent;
|
||||||
this->_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
this->_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_source> _child, obs_source_t* _parent)
|
gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_source> _child, obs_source_t* _parent)
|
||||||
|
@ -106,7 +106,7 @@ void gfx::source_texture::clear()
|
||||||
_child.reset();
|
_child.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> gfx::source_texture::render(std::size_t width, std::size_t height)
|
std::shared_ptr<streamfx::obs::gs::texture> gfx::source_texture::render(std::size_t width, std::size_t height)
|
||||||
{
|
{
|
||||||
if ((width == 0) || (width >= 16384)) {
|
if ((width == 0) || (width >= 16384)) {
|
||||||
throw std::runtime_error("Width too large or too small.");
|
throw std::runtime_error("Width too large or too small.");
|
||||||
|
@ -120,8 +120,8 @@ std::shared_ptr<gs::texture> gfx::source_texture::render(std::size_t width, std:
|
||||||
|
|
||||||
if (_child) {
|
if (_child) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto cctr =
|
auto cctr = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_capture, "gfx::source_texture '%s'",
|
||||||
gs::debug_marker(gs::debug_color_capture, "gfx::source_texture '%s'", obs_source_get_name(_child->get()));
|
obs_source_get_name(_child->get()));
|
||||||
#endif
|
#endif
|
||||||
auto op = _rt->render(static_cast<uint32_t>(width), static_cast<uint32_t>(height));
|
auto op = _rt->render(static_cast<uint32_t>(width), static_cast<uint32_t>(height));
|
||||||
vec4 black;
|
vec4 black;
|
||||||
|
@ -131,7 +131,7 @@ std::shared_ptr<gs::texture> gfx::source_texture::render(std::size_t width, std:
|
||||||
obs_source_video_render(_child->get());
|
obs_source_video_render(_child->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> tex;
|
std::shared_ptr<streamfx::obs::gs::texture> tex;
|
||||||
_rt->get_texture(tex);
|
_rt->get_texture(tex);
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace gfx {
|
||||||
std::shared_ptr<streamfx::obs::deprecated_source> _parent;
|
std::shared_ptr<streamfx::obs::deprecated_source> _parent;
|
||||||
std::shared_ptr<streamfx::obs::deprecated_source> _child;
|
std::shared_ptr<streamfx::obs::deprecated_source> _child;
|
||||||
|
|
||||||
std::shared_ptr<gs::rendertarget> _rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
|
|
||||||
source_texture(obs_source_t* parent);
|
source_texture(obs_source_t* parent);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace gfx {
|
||||||
source_texture& operator=(source_texture&& other) = delete;
|
source_texture& operator=(source_texture&& other) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<gs::texture> render(std::size_t width, std::size_t height);
|
std::shared_ptr<streamfx::obs::gs::texture> render(std::size_t width, std::size_t height);
|
||||||
|
|
||||||
public: // Unsafe Methods
|
public: // Unsafe Methods
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -31,9 +31,10 @@ gfx::lut::consumer::consumer()
|
||||||
|
|
||||||
gfx::lut::consumer::~consumer() {}
|
gfx::lut::consumer::~consumer() {}
|
||||||
|
|
||||||
std::shared_ptr<gs::effect> gfx::lut::consumer::prepare(gfx::lut::color_depth depth, std::shared_ptr<gs::texture> lut)
|
std::shared_ptr<streamfx::obs::gs::effect> gfx::lut::consumer::prepare(gfx::lut::color_depth depth,
|
||||||
|
std::shared_ptr<streamfx::obs::gs::texture> lut)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
auto effect = _data->consumer_effect();
|
auto effect = _data->consumer_effect();
|
||||||
|
|
||||||
|
@ -42,11 +43,11 @@ std::shared_ptr<gs::effect> gfx::lut::consumer::prepare(gfx::lut::color_depth de
|
||||||
int32_t grid_size = static_cast<int32_t>(pow(2l, (idepth / 2)));
|
int32_t grid_size = static_cast<int32_t>(pow(2l, (idepth / 2)));
|
||||||
int32_t container_size = static_cast<int32_t>(pow(2l, (idepth + (idepth / 2))));
|
int32_t container_size = static_cast<int32_t>(pow(2l, (idepth + (idepth / 2))));
|
||||||
|
|
||||||
if (gs::effect_parameter efp = effect->get_parameter("lut_params_0"); efp) {
|
if (streamfx::obs::gs::effect_parameter efp = effect->get_parameter("lut_params_0"); efp) {
|
||||||
efp.set_int4(size, grid_size, container_size, 0l);
|
efp.set_int4(size, grid_size, container_size, 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gs::effect_parameter efp = effect->get_parameter("lut_params_1"); efp) {
|
if (streamfx::obs::gs::effect_parameter efp = effect->get_parameter("lut_params_1"); efp) {
|
||||||
float inverse_size = 1.f / static_cast<float>(size);
|
float inverse_size = 1.f / static_cast<float>(size);
|
||||||
float inverse_z_size = 1.f / static_cast<float>(grid_size);
|
float inverse_z_size = 1.f / static_cast<float>(grid_size);
|
||||||
float inverse_container_size = 1.f / static_cast<float>(container_size);
|
float inverse_container_size = 1.f / static_cast<float>(container_size);
|
||||||
|
@ -54,21 +55,21 @@ std::shared_ptr<gs::effect> gfx::lut::consumer::prepare(gfx::lut::color_depth de
|
||||||
efp.set_float4(inverse_size, inverse_z_size, inverse_container_size, half_texel);
|
efp.set_float4(inverse_size, inverse_z_size, inverse_container_size, half_texel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gs::effect_parameter efp = effect->get_parameter("lut"); efp) {
|
if (streamfx::obs::gs::effect_parameter efp = effect->get_parameter("lut"); efp) {
|
||||||
efp.set_texture(lut);
|
efp.set_texture(lut);
|
||||||
}
|
}
|
||||||
|
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::lut::consumer::consume(gfx::lut::color_depth depth, std::shared_ptr<gs::texture> lut,
|
void gfx::lut::consumer::consume(gfx::lut::color_depth depth, std::shared_ptr<streamfx::obs::gs::texture> lut,
|
||||||
std::shared_ptr<gs::texture> texture)
|
std::shared_ptr<streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
auto effect = prepare(depth, lut);
|
auto effect = prepare(depth, lut);
|
||||||
|
|
||||||
if (gs::effect_parameter efp = effect->get_parameter("image"); efp) {
|
if (streamfx::obs::gs::effect_parameter efp = effect->get_parameter("image"); efp) {
|
||||||
efp.set_texture(texture->get_object());
|
efp.set_texture(texture->get_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,10 @@ namespace gfx::lut {
|
||||||
consumer();
|
consumer();
|
||||||
~consumer();
|
~consumer();
|
||||||
|
|
||||||
std::shared_ptr<gs::effect> prepare(gfx::lut::color_depth depth, std::shared_ptr<gs::texture> lut);
|
std::shared_ptr<streamfx::obs::gs::effect> prepare(gfx::lut::color_depth depth,
|
||||||
|
std::shared_ptr<streamfx::obs::gs::texture> lut);
|
||||||
|
|
||||||
void consume(gfx::lut::color_depth depth, std::shared_ptr<gs::texture> lut,
|
void consume(gfx::lut::color_depth depth, std::shared_ptr<streamfx::obs::gs::texture> lut,
|
||||||
std::shared_ptr<gs::texture> texture);
|
std::shared_ptr<streamfx::obs::gs::texture> texture);
|
||||||
};
|
};
|
||||||
} // namespace gfx::lut
|
} // namespace gfx::lut
|
||||||
|
|
|
@ -49,12 +49,12 @@ gfx::lut::producer::producer()
|
||||||
|
|
||||||
gfx::lut::producer::~producer() {}
|
gfx::lut::producer::~producer() {}
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> gfx::lut::producer::produce(gfx::lut::color_depth depth)
|
std::shared_ptr<streamfx::obs::gs::texture> gfx::lut::producer::produce(gfx::lut::color_depth depth)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
if (!_rt || (_rt->get_color_format() != format_from_depth((depth)))) {
|
if (!_rt || (_rt->get_color_format() != format_from_depth((depth)))) {
|
||||||
_rt = std::make_shared<gs::rendertarget>(format_from_depth(depth), GS_ZS_NONE);
|
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(format_from_depth(depth), GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto effect = _data->producer_effect();
|
auto effect = _data->producer_effect();
|
||||||
|
@ -74,7 +74,7 @@ std::shared_ptr<gs::texture> gfx::lut::producer::produce(gfx::lut::color_depth d
|
||||||
gs_enable_stencil_write(false);
|
gs_enable_stencil_write(false);
|
||||||
gs_ortho(0, 1, 0, 1, 0, 1);
|
gs_ortho(0, 1, 0, 1, 0, 1);
|
||||||
|
|
||||||
if (gs::effect_parameter efp = effect->get_parameter("lut_params_0"); efp) {
|
if (streamfx::obs::gs::effect_parameter efp = effect->get_parameter("lut_params_0"); efp) {
|
||||||
efp.set_int4(size, grid_size, container_size, 0l);
|
efp.set_int4(size, grid_size, container_size, 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,12 @@
|
||||||
namespace gfx::lut {
|
namespace gfx::lut {
|
||||||
class producer {
|
class producer {
|
||||||
std::shared_ptr<gfx::lut::data> _data;
|
std::shared_ptr<gfx::lut::data> _data;
|
||||||
std::shared_ptr<gs::rendertarget> _rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
producer();
|
producer();
|
||||||
~producer();
|
~producer();
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> produce(gfx::lut::color_depth depth);
|
std::shared_ptr<streamfx::obs::gs::texture> produce(gfx::lut::color_depth depth);
|
||||||
};
|
};
|
||||||
} // namespace gfx::lut
|
} // namespace gfx::lut
|
||||||
|
|
|
@ -46,12 +46,12 @@ std::shared_ptr<gfx::lut::data> gfx::lut::data::instance()
|
||||||
|
|
||||||
gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
std::filesystem::path lut_producer_path = streamfx::data_file_path("effects/lut-producer.effect");
|
std::filesystem::path lut_producer_path = streamfx::data_file_path("effects/lut-producer.effect");
|
||||||
if (std::filesystem::exists(lut_producer_path)) {
|
if (std::filesystem::exists(lut_producer_path)) {
|
||||||
try {
|
try {
|
||||||
_producer_effect = std::make_shared<gs::effect>(lut_producer_path);
|
_producer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_producer_path);
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Loading LUT Producer effect failed: %s", ex.what());
|
DLOG_ERROR(LOCAL_PREFIX "Loading LUT Producer effect failed: %s", ex.what());
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
||||||
std::filesystem::path lut_consumer_path = streamfx::data_file_path("effects/lut-consumer.effect");
|
std::filesystem::path lut_consumer_path = streamfx::data_file_path("effects/lut-consumer.effect");
|
||||||
if (std::filesystem::exists(lut_consumer_path)) {
|
if (std::filesystem::exists(lut_consumer_path)) {
|
||||||
try {
|
try {
|
||||||
_consumer_effect = std::make_shared<gs::effect>(lut_consumer_path);
|
_consumer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_consumer_path);
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Loading LUT Consumer effect failed: %s", ex.what());
|
DLOG_ERROR(LOCAL_PREFIX "Loading LUT Consumer effect failed: %s", ex.what());
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
||||||
|
|
||||||
gfx::lut::data::~data()
|
gfx::lut::data::~data()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_producer_effect.reset();
|
_producer_effect.reset();
|
||||||
_consumer_effect.reset();
|
_consumer_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
namespace gfx::lut {
|
namespace gfx::lut {
|
||||||
class data {
|
class data {
|
||||||
std::shared_ptr<gs::effect> _producer_effect;
|
std::shared_ptr<streamfx::obs::gs::effect> _producer_effect;
|
||||||
std::shared_ptr<gs::effect> _consumer_effect;
|
std::shared_ptr<streamfx::obs::gs::effect> _consumer_effect;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<data> instance();
|
static std::shared_ptr<data> instance();
|
||||||
|
@ -37,12 +37,12 @@ namespace gfx::lut {
|
||||||
public:
|
public:
|
||||||
~data();
|
~data();
|
||||||
|
|
||||||
inline std::shared_ptr<gs::effect> producer_effect()
|
inline std::shared_ptr<streamfx::obs::gs::effect> producer_effect()
|
||||||
{
|
{
|
||||||
return _producer_effect;
|
return _producer_effect;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::shared_ptr<gs::effect> consumer_effect()
|
inline std::shared_ptr<streamfx::obs::gs::effect> consumer_effect()
|
||||||
{
|
{
|
||||||
return _consumer_effect;
|
return _consumer_effect;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,7 @@ static const std::string_view _annotation_scale = "scale";
|
||||||
static const std::string_view _annotation_enum_entry = "enum_%zu";
|
static const std::string_view _annotation_enum_entry = "enum_%zu";
|
||||||
static const std::string_view _annotation_enum_entry_name = "enum_%zu_name";
|
static const std::string_view _annotation_enum_entry_name = "enum_%zu_name";
|
||||||
|
|
||||||
inline bool get_annotation_string(gs::effect_parameter param, std::string anno_name, std::string& out)
|
inline bool get_annotation_string(streamfx::obs::gs::effect_parameter param, std::string anno_name, std::string& out)
|
||||||
{
|
{
|
||||||
if (!param)
|
if (!param)
|
||||||
return false;
|
return false;
|
||||||
|
@ -46,7 +46,7 @@ inline bool get_annotation_string(gs::effect_parameter param, std::string anno_n
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool get_annotation_float(gs::effect_parameter param, std::string anno_name, float_t& out)
|
inline bool get_annotation_float(streamfx::obs::gs::effect_parameter param, std::string anno_name, float_t& out)
|
||||||
{
|
{
|
||||||
if (!param) {
|
if (!param) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -76,7 +76,7 @@ gfx::shader::basic_field_type gfx::shader::get_field_type_from_string(std::strin
|
||||||
return basic_field_type::Input;
|
return basic_field_type::Input;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::string prefix)
|
gfx::shader::basic_parameter::basic_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: parameter(param, prefix), _field_type(basic_field_type::Input), _suffix(), _keys(), _names(), _min(), _max(),
|
: parameter(param, prefix), _field_type(basic_field_type::Input), _suffix(), _keys(), _names(), _min(), _max(),
|
||||||
_step(), _values()
|
_step(), _values()
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s
|
||||||
|
|
||||||
// Read Suffix Data
|
// Read Suffix Data
|
||||||
if (auto anno = get_parameter().get_annotation(_annotation_suffix); anno) {
|
if (auto anno = get_parameter().get_annotation(_annotation_suffix); anno) {
|
||||||
if (anno.get_type() == gs::effect_parameter::type::String)
|
if (anno.get_type() == streamfx::obs::gs::effect_parameter::type::String)
|
||||||
_suffix = anno.get_default_string();
|
_suffix = anno.get_default_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s
|
||||||
|
|
||||||
load_parameter_data(eanno, entry.data);
|
load_parameter_data(eanno, entry.data);
|
||||||
if (auto nanno = get_parameter().get_annotation(key_name);
|
if (auto nanno = get_parameter().get_annotation(key_name);
|
||||||
nanno && (nanno.get_type() == gs::effect_parameter::type::String)) {
|
nanno && (nanno.get_type() == streamfx::obs::gs::effect_parameter::type::String)) {
|
||||||
entry.name = nanno.get_default_string();
|
entry.name = nanno.get_default_string();
|
||||||
} else {
|
} else {
|
||||||
entry.name = "Unnamed Entry";
|
entry.name = "Unnamed Entry";
|
||||||
|
@ -155,12 +155,12 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s
|
||||||
|
|
||||||
gfx::shader::basic_parameter::~basic_parameter() {}
|
gfx::shader::basic_parameter::~basic_parameter() {}
|
||||||
|
|
||||||
void gfx::shader::basic_parameter::load_parameter_data(gs::effect_parameter parameter, basic_data& data)
|
void gfx::shader::basic_parameter::load_parameter_data(streamfx::obs::gs::effect_parameter parameter, basic_data& data)
|
||||||
{
|
{
|
||||||
parameter.get_default_value(&data.i32, 1);
|
parameter.get_default_value(&data.i32, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::bool_parameter::bool_parameter(gs::effect_parameter param, std::string prefix)
|
gfx::shader::bool_parameter::bool_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: basic_parameter(param, prefix)
|
: basic_parameter(param, prefix)
|
||||||
{
|
{
|
||||||
_min.resize(0);
|
_min.resize(0);
|
||||||
|
@ -213,7 +213,7 @@ void gfx::shader::bool_parameter::assign()
|
||||||
get_parameter().set_value(_data.data(), _data.size());
|
get_parameter().set_value(_data.data(), _data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::float_parameter::float_parameter(gs::effect_parameter param, std::string prefix)
|
gfx::shader::float_parameter::float_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: basic_parameter(param, prefix)
|
: basic_parameter(param, prefix)
|
||||||
{
|
{
|
||||||
_data.resize(get_size());
|
_data.resize(get_size());
|
||||||
|
@ -339,7 +339,7 @@ static inline obs_property_t* build_int_property(gfx::shader::basic_field_type f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::int_parameter::int_parameter(gs::effect_parameter param, std::string prefix)
|
gfx::shader::int_parameter::int_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: basic_parameter(param, prefix)
|
: basic_parameter(param, prefix)
|
||||||
{
|
{
|
||||||
_data.resize(get_size());
|
_data.resize(get_size());
|
||||||
|
|
|
@ -62,10 +62,10 @@ namespace gfx {
|
||||||
std::list<basic_enum_data> _values;
|
std::list<basic_enum_data> _values;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
basic_parameter(gs::effect_parameter param, std::string prefix);
|
basic_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix);
|
||||||
virtual ~basic_parameter();
|
virtual ~basic_parameter();
|
||||||
|
|
||||||
virtual void load_parameter_data(gs::effect_parameter parameter, basic_data& data);
|
virtual void load_parameter_data(streamfx::obs::gs::effect_parameter parameter, basic_data& data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline basic_field_type field_type()
|
inline basic_field_type field_type()
|
||||||
|
@ -98,7 +98,7 @@ namespace gfx {
|
||||||
std::vector<int32_t> _data;
|
std::vector<int32_t> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool_parameter(gs::effect_parameter param, std::string prefix);
|
bool_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix);
|
||||||
virtual ~bool_parameter();
|
virtual ~bool_parameter();
|
||||||
|
|
||||||
void defaults(obs_data_t* settings) override;
|
void defaults(obs_data_t* settings) override;
|
||||||
|
@ -114,7 +114,7 @@ namespace gfx {
|
||||||
std::vector<basic_data> _data;
|
std::vector<basic_data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
float_parameter(gs::effect_parameter param, std::string prefix);
|
float_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix);
|
||||||
virtual ~float_parameter();
|
virtual ~float_parameter();
|
||||||
|
|
||||||
void defaults(obs_data_t* settings) override;
|
void defaults(obs_data_t* settings) override;
|
||||||
|
@ -130,7 +130,7 @@ namespace gfx {
|
||||||
std::vector<basic_data> _data;
|
std::vector<basic_data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int_parameter(gs::effect_parameter param, std::string prefix);
|
int_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix);
|
||||||
virtual ~int_parameter();
|
virtual ~int_parameter();
|
||||||
|
|
||||||
void defaults(obs_data_t* settings) override;
|
void defaults(obs_data_t* settings) override;
|
||||||
|
|
|
@ -28,9 +28,9 @@
|
||||||
#define ANNO_TYPE "type"
|
#define ANNO_TYPE "type"
|
||||||
#define ANNO_SIZE "size"
|
#define ANNO_SIZE "size"
|
||||||
|
|
||||||
typedef gs::effect_parameter::type eptype;
|
typedef streamfx::obs::gs::effect_parameter::type eptype;
|
||||||
|
|
||||||
gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(gs::effect_parameter::type type)
|
gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case eptype::Boolean:
|
case eptype::Boolean:
|
||||||
|
@ -55,7 +55,7 @@ gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(gs::effect_pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t gfx::shader::get_length_from_effect_type(gs::effect_parameter::type type)
|
std::size_t gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
default:
|
default:
|
||||||
|
@ -110,7 +110,7 @@ gfx::shader::parameter_type gfx::shader::get_type_from_string(std::string v)
|
||||||
throw std::invalid_argument("Invalid parameter type string.");
|
throw std::invalid_argument("Invalid parameter type string.");
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::parameter::parameter(gs::effect_parameter param, std::string key_prefix)
|
gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std::string key_prefix)
|
||||||
: _param(param), _order(0), _key(_param.get_name()), _visible(true), _automatic(false), _name(_key), _description()
|
: _param(param), _order(0), _key(_param.get_name()), _visible(true), _automatic(false), _name(_key), _description()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -175,8 +175,8 @@ void gfx::shader::parameter::update(obs_data_t* settings) {}
|
||||||
|
|
||||||
void gfx::shader::parameter::assign() {}
|
void gfx::shader::parameter::assign() {}
|
||||||
|
|
||||||
std::shared_ptr<gfx::shader::parameter> gfx::shader::parameter::make_parameter(gs::effect_parameter param,
|
std::shared_ptr<gfx::shader::parameter>
|
||||||
std::string prefix)
|
gfx::shader::parameter::make_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
{
|
{
|
||||||
if (!param) {
|
if (!param) {
|
||||||
throw std::runtime_error("Bad call to make_parameter. This is a bug in the plugin.");
|
throw std::runtime_error("Bad call to make_parameter. This is a bug in the plugin.");
|
||||||
|
|
|
@ -39,15 +39,15 @@ namespace gfx {
|
||||||
Sampler
|
Sampler
|
||||||
};
|
};
|
||||||
|
|
||||||
parameter_type get_type_from_effect_type(gs::effect_parameter::type type);
|
parameter_type get_type_from_effect_type(streamfx::obs::gs::effect_parameter::type type);
|
||||||
|
|
||||||
std::size_t get_length_from_effect_type(gs::effect_parameter::type type);
|
std::size_t get_length_from_effect_type(streamfx::obs::gs::effect_parameter::type type);
|
||||||
|
|
||||||
parameter_type get_type_from_string(std::string v);
|
parameter_type get_type_from_string(std::string v);
|
||||||
|
|
||||||
class parameter {
|
class parameter {
|
||||||
// Parameter used for all functionality.
|
// Parameter used for all functionality.
|
||||||
gs::effect_parameter _param;
|
streamfx::obs::gs::effect_parameter _param;
|
||||||
|
|
||||||
// Real type of the parameter (libobs gets it wrong often).
|
// Real type of the parameter (libobs gets it wrong often).
|
||||||
parameter_type _type;
|
parameter_type _type;
|
||||||
|
@ -68,7 +68,7 @@ namespace gfx {
|
||||||
std::string _description;
|
std::string _description;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
parameter(gs::effect_parameter param, std::string key_prefix);
|
parameter(streamfx::obs::gs::effect_parameter param, std::string key_prefix);
|
||||||
virtual ~parameter(){};
|
virtual ~parameter(){};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -81,7 +81,7 @@ namespace gfx {
|
||||||
virtual void assign();
|
virtual void assign();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline gs::effect_parameter get_parameter()
|
inline streamfx::obs::gs::effect_parameter get_parameter()
|
||||||
{
|
{
|
||||||
return _param;
|
return _param;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,8 @@ namespace gfx {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<parameter> make_parameter(gs::effect_parameter param, std::string prefix);
|
static std::shared_ptr<parameter> make_parameter(streamfx::obs::gs::effect_parameter param,
|
||||||
|
std::string prefix);
|
||||||
};
|
};
|
||||||
} // namespace shader
|
} // namespace shader
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|
|
@ -42,7 +42,7 @@ gfx::shader::shader::shader(obs_source_t* self, shader_mode mode)
|
||||||
|
|
||||||
_have_current_params(false), _time(0), _time_loop(0), _loops(0), _random(), _random_seed(0),
|
_have_current_params(false), _time(0), _time_loop(0), _loops(0), _random(), _random_seed(0),
|
||||||
|
|
||||||
_rt_up_to_date(false), _rt(std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE))
|
_rt_up_to_date(false), _rt(std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE))
|
||||||
{
|
{
|
||||||
// Intialize random values.
|
// Intialize random values.
|
||||||
_random.seed(static_cast<unsigned long long>(_random_seed));
|
_random.seed(static_cast<unsigned long long>(_random_seed));
|
||||||
|
@ -98,7 +98,7 @@ try {
|
||||||
|
|
||||||
// Update Shader
|
// Update Shader
|
||||||
if (shader_dirty) {
|
if (shader_dirty) {
|
||||||
_shader = gs::effect(file);
|
_shader = streamfx::obs::gs::effect(file);
|
||||||
_shader_file_mt = std::filesystem::last_write_time(file);
|
_shader_file_mt = std::filesystem::last_write_time(file);
|
||||||
_shader_file_sz = std::filesystem::file_size(file);
|
_shader_file_sz = std::filesystem::file_size(file);
|
||||||
_shader_file = file;
|
_shader_file = file;
|
||||||
|
@ -470,8 +470,8 @@ void gfx::shader::shader::prepare_render()
|
||||||
}
|
}
|
||||||
|
|
||||||
// float4 Time: (Time in Seconds), (Time in Current Second), (Time in Seconds only), (Random Value)
|
// float4 Time: (Time in Seconds), (Time in Current Second), (Time in Seconds only), (Random Value)
|
||||||
if (gs::effect_parameter el = _shader.get_parameter("Time"); el != nullptr) {
|
if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter("Time"); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Float4) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Float4) {
|
||||||
el.set_float4(
|
el.set_float4(
|
||||||
_time, _time_loop, static_cast<float_t>(_loops),
|
_time, _time_loop, static_cast<float_t>(_loops),
|
||||||
static_cast<float_t>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max())));
|
static_cast<float_t>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max())));
|
||||||
|
@ -480,7 +480,7 @@ void gfx::shader::shader::prepare_render()
|
||||||
|
|
||||||
// float4 ViewSize: (Width), (Height), (1.0 / Width), (1.0 / Height)
|
// float4 ViewSize: (Width), (Height), (1.0 / Width), (1.0 / Height)
|
||||||
if (auto el = _shader.get_parameter("ViewSize"); el != nullptr) {
|
if (auto el = _shader.get_parameter("ViewSize"); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Float4) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Float4) {
|
||||||
el.set_float4(static_cast<float_t>(width()), static_cast<float_t>(height()),
|
el.set_float4(static_cast<float_t>(width()), static_cast<float_t>(height()),
|
||||||
1.0f / static_cast<float_t>(width()), 1.0f / static_cast<float_t>(height()));
|
1.0f / static_cast<float_t>(width()), 1.0f / static_cast<float_t>(height()));
|
||||||
}
|
}
|
||||||
|
@ -488,14 +488,14 @@ void gfx::shader::shader::prepare_render()
|
||||||
|
|
||||||
// float4x4 Random: float4[Per-Instance Random], float4[Per-Activation Random], float4x2[Per-Frame Random]
|
// float4x4 Random: float4[Per-Instance Random], float4[Per-Activation Random], float4x2[Per-Frame Random]
|
||||||
if (auto el = _shader.get_parameter("Random"); el != nullptr) {
|
if (auto el = _shader.get_parameter("Random"); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Matrix) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Matrix) {
|
||||||
el.set_value(_random_values, 16);
|
el.set_value(_random_values, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// int32 RandomSeed: Seed used for random generation
|
// int32 RandomSeed: Seed used for random generation
|
||||||
if (auto el = _shader.get_parameter("RandomSeed"); el != nullptr) {
|
if (auto el = _shader.get_parameter("RandomSeed"); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Integer) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Integer) {
|
||||||
el.set_int(_random_seed);
|
el.set_int(_random_seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ void gfx::shader::shader::set_size(uint32_t w, uint32_t h)
|
||||||
_base_height = h;
|
_base_height = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_input_a(std::shared_ptr<gs::texture> tex)
|
void gfx::shader::shader::set_input_a(std::shared_ptr<streamfx::obs::gs::texture> tex)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -555,8 +555,8 @@ void gfx::shader::shader::set_input_a(std::shared_ptr<gs::texture> tex)
|
||||||
"tex_a",
|
"tex_a",
|
||||||
};
|
};
|
||||||
for (auto& name : params) {
|
for (auto& name : params) {
|
||||||
if (gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) {
|
if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Texture) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Texture) {
|
||||||
el.set_texture(tex);
|
el.set_texture(tex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ void gfx::shader::shader::set_input_a(std::shared_ptr<gs::texture> tex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_input_b(std::shared_ptr<gs::texture> tex)
|
void gfx::shader::shader::set_input_b(std::shared_ptr<streamfx::obs::gs::texture> tex)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -575,8 +575,8 @@ void gfx::shader::shader::set_input_b(std::shared_ptr<gs::texture> tex)
|
||||||
"tex_b",
|
"tex_b",
|
||||||
};
|
};
|
||||||
for (auto& name : params) {
|
for (auto& name : params) {
|
||||||
if (gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) {
|
if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Texture) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Texture) {
|
||||||
el.set_texture(tex);
|
el.set_texture(tex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -589,8 +589,8 @@ void gfx::shader::shader::set_transition_time(float_t t)
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gs::effect_parameter el = _shader.get_parameter("TransitionTime"); el != nullptr) {
|
if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter("TransitionTime"); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Float) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Float) {
|
||||||
el.set_float(t);
|
el.set_float(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -600,8 +600,8 @@ void gfx::shader::shader::set_transition_size(uint32_t w, uint32_t h)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
if (gs::effect_parameter el = _shader.get_parameter("TransitionSize"); el != nullptr) {
|
if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter("TransitionSize"); el != nullptr) {
|
||||||
if (el.get_type() == gs::effect_parameter::type::Integer2) {
|
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Integer2) {
|
||||||
el.set_int2(static_cast<int32_t>(w), static_cast<int32_t>(h));
|
el.set_int2(static_cast<int32_t>(w), static_cast<int32_t>(h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace gfx {
|
||||||
bool _active;
|
bool _active;
|
||||||
|
|
||||||
// Shader
|
// Shader
|
||||||
gs::effect _shader;
|
streamfx::obs::gs::effect _shader;
|
||||||
std::filesystem::path _shader_file;
|
std::filesystem::path _shader_file;
|
||||||
std::string _shader_tech;
|
std::string _shader_tech;
|
||||||
std::filesystem::file_time_type _shader_file_mt;
|
std::filesystem::file_time_type _shader_file_mt;
|
||||||
|
@ -75,7 +75,7 @@ namespace gfx {
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
bool _rt_up_to_date;
|
bool _rt_up_to_date;
|
||||||
std::shared_ptr<gs::rendertarget> _rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
shader(obs_source_t* self, shader_mode mode);
|
shader(obs_source_t* self, shader_mode mode);
|
||||||
|
@ -117,9 +117,9 @@ namespace gfx {
|
||||||
public:
|
public:
|
||||||
void set_size(uint32_t w, uint32_t h);
|
void set_size(uint32_t w, uint32_t h);
|
||||||
|
|
||||||
void set_input_a(std::shared_ptr<gs::texture> tex);
|
void set_input_a(std::shared_ptr<streamfx::obs::gs::texture> tex);
|
||||||
|
|
||||||
void set_input_b(std::shared_ptr<gs::texture> tex);
|
void set_input_b(std::shared_ptr<streamfx::obs::gs::texture> tex);
|
||||||
|
|
||||||
void set_transition_time(float_t t);
|
void set_transition_time(float_t t);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ nvidia::cuda::gstexture::~gstexture()
|
||||||
_cuda->cuGraphicsUnregisterResource(_resource);
|
_cuda->cuGraphicsUnregisterResource(_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
nvidia::cuda::gstexture::gstexture(std::shared_ptr<gs::texture> texture)
|
nvidia::cuda::gstexture::gstexture(std::shared_ptr<streamfx::obs::gs::texture> texture)
|
||||||
: _cuda(::nvidia::cuda::cuda::get()), _texture(texture), _resource(), _is_mapped(false), _pointer()
|
: _cuda(::nvidia::cuda::cuda::get()), _texture(texture), _resource(), _is_mapped(false), _pointer()
|
||||||
{
|
{
|
||||||
D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this);
|
D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this);
|
||||||
|
@ -51,7 +51,7 @@ nvidia::cuda::gstexture::gstexture(std::shared_ptr<gs::texture> texture)
|
||||||
if (!texture)
|
if (!texture)
|
||||||
throw std::invalid_argument("texture");
|
throw std::invalid_argument("texture");
|
||||||
|
|
||||||
gs::context gctx;
|
streamfx::obs::gs::context gctx;
|
||||||
int dev_type = gs_get_device_type();
|
int dev_type = gs_get_device_type();
|
||||||
|
|
||||||
if (dev_type == GS_DEVICE_OPENGL) {
|
if (dev_type == GS_DEVICE_OPENGL) {
|
||||||
|
@ -61,12 +61,12 @@ nvidia::cuda::gstexture::gstexture(std::shared_ptr<gs::texture> texture)
|
||||||
if (dev_type == GS_DEVICE_DIRECT3D_11) {
|
if (dev_type == GS_DEVICE_DIRECT3D_11) {
|
||||||
ID3D11Resource* resource = nullptr;
|
ID3D11Resource* resource = nullptr;
|
||||||
switch (_texture->get_type()) {
|
switch (_texture->get_type()) {
|
||||||
case gs::texture::type::Cube:
|
case streamfx::obs::gs::texture::type::Cube:
|
||||||
case gs::texture::type::Normal: {
|
case streamfx::obs::gs::texture::type::Normal: {
|
||||||
resource = static_cast<ID3D11Resource*>(gs_texture_get_obj(_texture->get_object()));
|
resource = static_cast<ID3D11Resource*>(gs_texture_get_obj(_texture->get_object()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case gs::texture::type::Volume: {
|
case streamfx::obs::gs::texture::type::Volume: {
|
||||||
resource = static_cast<ID3D11Resource*>(gs_texture_get_obj(_texture->get_object()));
|
resource = static_cast<ID3D11Resource*>(gs_texture_get_obj(_texture->get_object()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void nvidia::cuda::gstexture::unmap()
|
||||||
_stream.reset();
|
_stream.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> nvidia::cuda::gstexture::get_texture()
|
std::shared_ptr<streamfx::obs::gs::texture> nvidia::cuda::gstexture::get_texture()
|
||||||
{
|
{
|
||||||
return _texture;
|
return _texture;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
namespace nvidia::cuda {
|
namespace nvidia::cuda {
|
||||||
class gstexture {
|
class gstexture {
|
||||||
std::shared_ptr<::nvidia::cuda::cuda> _cuda;
|
std::shared_ptr<::nvidia::cuda::cuda> _cuda;
|
||||||
std::shared_ptr<gs::texture> _texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _texture;
|
||||||
graphics_resource_t _resource;
|
graphics_resource_t _resource;
|
||||||
|
|
||||||
bool _is_mapped;
|
bool _is_mapped;
|
||||||
|
@ -36,12 +36,12 @@ namespace nvidia::cuda {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~gstexture();
|
~gstexture();
|
||||||
gstexture(std::shared_ptr<gs::texture> texture);
|
gstexture(std::shared_ptr<streamfx::obs::gs::texture> texture);
|
||||||
|
|
||||||
array_t map(std::shared_ptr<nvidia::cuda::stream> stream);
|
array_t map(std::shared_ptr<nvidia::cuda::stream> stream);
|
||||||
void unmap();
|
void unmap();
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> get_texture();
|
std::shared_ptr<streamfx::obs::gs::texture> get_texture();
|
||||||
::nvidia::cuda::graphics_resource_t get();
|
::nvidia::cuda::graphics_resource_t get();
|
||||||
};
|
};
|
||||||
} // namespace nvidia::cuda
|
} // namespace nvidia::cuda
|
||||||
|
|
|
@ -39,7 +39,7 @@ nvidia::cuda::obs::~obs()
|
||||||
{
|
{
|
||||||
D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this);
|
D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this);
|
||||||
|
|
||||||
auto gctx = gs::context{};
|
auto gctx = streamfx::obs::gs::context{};
|
||||||
{
|
{
|
||||||
auto stack = _context->enter();
|
auto stack = _context->enter();
|
||||||
_stream->synchronize();
|
_stream->synchronize();
|
||||||
|
@ -53,7 +53,7 @@ nvidia::cuda::obs::obs() : _cuda(::nvidia::cuda::cuda::get()), _context()
|
||||||
{
|
{
|
||||||
D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this);
|
D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this);
|
||||||
|
|
||||||
auto gctx = gs::context{};
|
auto gctx = streamfx::obs::gs::context{};
|
||||||
|
|
||||||
// Create Context
|
// Create Context
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
|
@ -33,37 +33,39 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::effect_parameter() : _effect_parent(nullptr), _pass_parent(nullptr), _param_parent(nullptr)
|
streamfx::obs::gs::effect_parameter::effect_parameter()
|
||||||
|
: _effect_parent(nullptr), _pass_parent(nullptr), _param_parent(nullptr)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::effect_parameter(gs_eparam_t* param)
|
streamfx::obs::gs::effect_parameter::effect_parameter(gs_eparam_t* param)
|
||||||
: _effect_parent(nullptr), _pass_parent(nullptr), _param_parent(nullptr)
|
: _effect_parent(nullptr), _pass_parent(nullptr), _param_parent(nullptr)
|
||||||
{
|
{
|
||||||
reset(param, [](void*) {});
|
reset(param, [](void*) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr<gs_effect_t> parent)
|
streamfx::obs::gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr<gs_effect_t> parent)
|
||||||
: effect_parameter(param)
|
: effect_parameter(param)
|
||||||
{
|
{
|
||||||
_effect_parent = parent;
|
_effect_parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr<gs_epass_t> parent) : effect_parameter(param)
|
streamfx::obs::gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr<gs_epass_t> parent)
|
||||||
|
: effect_parameter(param)
|
||||||
{
|
{
|
||||||
_pass_parent = parent;
|
_pass_parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr<gs_eparam_t> parent)
|
streamfx::obs::gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr<gs_eparam_t> parent)
|
||||||
: effect_parameter(param)
|
: effect_parameter(param)
|
||||||
{
|
{
|
||||||
_param_parent = parent;
|
_param_parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::~effect_parameter() {}
|
streamfx::obs::gs::effect_parameter::~effect_parameter() {}
|
||||||
|
|
||||||
gs::effect_parameter::effect_parameter(const effect_parameter& rhs)
|
streamfx::obs::gs::effect_parameter::effect_parameter(const effect_parameter& rhs)
|
||||||
{
|
{
|
||||||
reset(rhs.get(), [](void*) {});
|
reset(rhs.get(), [](void*) {});
|
||||||
_effect_parent = rhs._effect_parent;
|
_effect_parent = rhs._effect_parent;
|
||||||
|
@ -71,7 +73,7 @@ gs::effect_parameter::effect_parameter(const effect_parameter& rhs)
|
||||||
_param_parent = rhs._param_parent;
|
_param_parent = rhs._param_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter& gs::effect_parameter::operator=(const effect_parameter& rhs)
|
streamfx::obs::gs::effect_parameter& streamfx::obs::gs::effect_parameter::operator=(const effect_parameter& rhs)
|
||||||
{
|
{
|
||||||
reset(rhs.get(), [](void*) {});
|
reset(rhs.get(), [](void*) {});
|
||||||
_effect_parent = rhs._effect_parent;
|
_effect_parent = rhs._effect_parent;
|
||||||
|
@ -80,7 +82,7 @@ gs::effect_parameter& gs::effect_parameter::operator=(const effect_parameter& rh
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::effect_parameter(effect_parameter&& rhs) noexcept
|
streamfx::obs::gs::effect_parameter::effect_parameter(effect_parameter&& rhs) noexcept
|
||||||
try {
|
try {
|
||||||
reset(rhs.get(), [](gs_eparam_t*) {});
|
reset(rhs.get(), [](gs_eparam_t*) {});
|
||||||
_effect_parent = rhs._effect_parent;
|
_effect_parent = rhs._effect_parent;
|
||||||
|
@ -94,7 +96,7 @@ try {
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter& gs::effect_parameter::operator=(effect_parameter&& rhs) noexcept
|
streamfx::obs::gs::effect_parameter& streamfx::obs::gs::effect_parameter::operator=(effect_parameter&& rhs) noexcept
|
||||||
try {
|
try {
|
||||||
reset(rhs.get(), [](gs_eparam_t*) {});
|
reset(rhs.get(), [](gs_eparam_t*) {});
|
||||||
_effect_parent = rhs._effect_parent;
|
_effect_parent = rhs._effect_parent;
|
||||||
|
@ -111,12 +113,12 @@ try {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view gs::effect_parameter::get_name()
|
std::string_view streamfx::obs::gs::effect_parameter::get_name()
|
||||||
{
|
{
|
||||||
return std::string_view{get()->name};
|
return std::string_view{get()->name};
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter::type gs::effect_parameter::get_type()
|
streamfx::obs::gs::effect_parameter::type streamfx::obs::gs::effect_parameter::get_type()
|
||||||
{
|
{
|
||||||
switch (get()->type) {
|
switch (get()->type) {
|
||||||
case GS_SHADER_PARAM_BOOL:
|
case GS_SHADER_PARAM_BOOL:
|
||||||
|
@ -149,12 +151,12 @@ gs::effect_parameter::type gs::effect_parameter::get_type()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::size_t gs::effect_parameter::count_annotations()
|
inline std::size_t streamfx::obs::gs::effect_parameter::count_annotations()
|
||||||
{
|
{
|
||||||
return gs_param_get_num_annotations(get());
|
return gs_param_get_num_annotations(get());
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect_parameter::get_annotation(std::size_t idx)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect_parameter::get_annotation(std::size_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= get()->annotations.num) {
|
if (idx >= get()->annotations.num) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -163,19 +165,19 @@ gs::effect_parameter gs::effect_parameter::get_annotation(std::size_t idx)
|
||||||
return effect_parameter(get()->annotations.array + idx, *this);
|
return effect_parameter(get()->annotations.array + idx, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect_parameter::get_annotation(const std::string_view name)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect_parameter::get_annotation(const std::string_view name)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < get()->annotations.num; idx++) {
|
for (std::size_t idx = 0; idx < get()->annotations.num; idx++) {
|
||||||
auto ptr = get()->annotations.array + idx;
|
auto ptr = get()->annotations.array + idx;
|
||||||
if (name == std::string_view{ptr->name}) {
|
if (name == std::string_view{ptr->name}) {
|
||||||
return gs::effect_parameter(ptr, *this);
|
return streamfx::obs::gs::effect_parameter(ptr, *this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect_parameter::has_annotation(const std::string_view name)
|
bool streamfx::obs::gs::effect_parameter::has_annotation(const std::string_view name)
|
||||||
{
|
{
|
||||||
auto eprm = get_annotation(name);
|
auto eprm = get_annotation(name);
|
||||||
if (eprm)
|
if (eprm)
|
||||||
|
@ -183,7 +185,7 @@ bool gs::effect_parameter::has_annotation(const std::string_view name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect_parameter::has_annotation(const std::string_view name, effect_parameter::type type)
|
bool streamfx::obs::gs::effect_parameter::has_annotation(const std::string_view name, effect_parameter::type type)
|
||||||
{
|
{
|
||||||
auto eprm = get_annotation(name);
|
auto eprm = get_annotation(name);
|
||||||
if (eprm)
|
if (eprm)
|
||||||
|
@ -191,14 +193,14 @@ bool gs::effect_parameter::has_annotation(const std::string_view name, effect_pa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_bool(bool v)
|
void streamfx::obs::gs::effect_parameter::set_bool(bool v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Boolean)
|
if (get_type() != type::Boolean)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_bool(get(), v);
|
gs_effect_set_bool(get(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_bool(bool& v)
|
void streamfx::obs::gs::effect_parameter::get_bool(bool& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Boolean)
|
if (get_type() != type::Boolean)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -211,7 +213,7 @@ void gs::effect_parameter::get_bool(bool& v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_bool(bool& v)
|
void streamfx::obs::gs::effect_parameter::get_default_bool(bool& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Boolean)
|
if (get_type() != type::Boolean)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -224,21 +226,21 @@ void gs::effect_parameter::get_default_bool(bool& v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_bool_array(bool v[], std::size_t sz)
|
void streamfx::obs::gs::effect_parameter::set_bool_array(bool v[], std::size_t sz)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Boolean)
|
if (get_type() != type::Boolean)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_val(get(), v, sz);
|
gs_effect_set_val(get(), v, sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_float(float_t x)
|
void streamfx::obs::gs::effect_parameter::set_float(float_t x)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float)
|
if (get_type() != type::Float)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_float(get(), x);
|
gs_effect_set_float(get(), x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_float(float_t& x)
|
void streamfx::obs::gs::effect_parameter::get_float(float_t& x)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float)
|
if (get_type() != type::Float)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -251,7 +253,7 @@ void gs::effect_parameter::get_float(float_t& x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_float(float_t& x)
|
void streamfx::obs::gs::effect_parameter::get_default_float(float_t& x)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float)
|
if (get_type() != type::Float)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -264,24 +266,24 @@ void gs::effect_parameter::get_default_float(float_t& x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_float2(vec2 const& v)
|
void streamfx::obs::gs::effect_parameter::set_float2(vec2 const& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float2)
|
if (get_type() != type::Float2)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_vec2(get(), &v);
|
gs_effect_set_vec2(get(), &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_float2(vec2& v)
|
void streamfx::obs::gs::effect_parameter::get_float2(vec2& v)
|
||||||
{
|
{
|
||||||
get_float2(v.x, v.y);
|
get_float2(v.x, v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_float2(vec2& v)
|
void streamfx::obs::gs::effect_parameter::get_default_float2(vec2& v)
|
||||||
{
|
{
|
||||||
get_default_float2(v.x, v.y);
|
get_default_float2(v.x, v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_float2(float_t x, float_t y)
|
void streamfx::obs::gs::effect_parameter::set_float2(float_t x, float_t y)
|
||||||
{
|
{
|
||||||
vec2 data;
|
vec2 data;
|
||||||
data.x = x;
|
data.x = x;
|
||||||
|
@ -289,7 +291,7 @@ void gs::effect_parameter::set_float2(float_t x, float_t y)
|
||||||
set_float2(data);
|
set_float2(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_float2(float_t& x, float_t& y)
|
void streamfx::obs::gs::effect_parameter::get_float2(float_t& x, float_t& y)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float2)
|
if (get_type() != type::Float2)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -303,7 +305,7 @@ void gs::effect_parameter::get_float2(float_t& x, float_t& y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_float2(float_t& x, float_t& y)
|
void streamfx::obs::gs::effect_parameter::get_default_float2(float_t& x, float_t& y)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float2)
|
if (get_type() != type::Float2)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -317,24 +319,24 @@ void gs::effect_parameter::get_default_float2(float_t& x, float_t& y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_float3(vec3 const& v)
|
void streamfx::obs::gs::effect_parameter::set_float3(vec3 const& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float3)
|
if (get_type() != type::Float3)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_vec3(get(), &v);
|
gs_effect_set_vec3(get(), &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_float3(vec3& v)
|
void streamfx::obs::gs::effect_parameter::get_float3(vec3& v)
|
||||||
{
|
{
|
||||||
get_float3(v.x, v.y, v.z);
|
get_float3(v.x, v.y, v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_float3(vec3& v)
|
void streamfx::obs::gs::effect_parameter::get_default_float3(vec3& v)
|
||||||
{
|
{
|
||||||
get_default_float3(v.x, v.y, v.z);
|
get_default_float3(v.x, v.y, v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_float3(float_t x, float_t y, float_t z)
|
void streamfx::obs::gs::effect_parameter::set_float3(float_t x, float_t y, float_t z)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float3)
|
if (get_type() != type::Float3)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -342,7 +344,7 @@ void gs::effect_parameter::set_float3(float_t x, float_t y, float_t z)
|
||||||
gs_effect_set_vec3(get(), &v);
|
gs_effect_set_vec3(get(), &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_float3(float_t& x, float_t& y, float_t& z)
|
void streamfx::obs::gs::effect_parameter::get_float3(float_t& x, float_t& y, float_t& z)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float3)
|
if (get_type() != type::Float3)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -357,7 +359,7 @@ void gs::effect_parameter::get_float3(float_t& x, float_t& y, float_t& z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_float3(float_t& x, float_t& y, float_t& z)
|
void streamfx::obs::gs::effect_parameter::get_default_float3(float_t& x, float_t& y, float_t& z)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float3)
|
if (get_type() != type::Float3)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -372,24 +374,24 @@ void gs::effect_parameter::get_default_float3(float_t& x, float_t& y, float_t& z
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_float4(vec4 const& v)
|
void streamfx::obs::gs::effect_parameter::set_float4(vec4 const& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float4)
|
if (get_type() != type::Float4)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_vec4(get(), &v);
|
gs_effect_set_vec4(get(), &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_float4(vec4& v)
|
void streamfx::obs::gs::effect_parameter::get_float4(vec4& v)
|
||||||
{
|
{
|
||||||
get_float4(v.x, v.y, v.z, v.w);
|
get_float4(v.x, v.y, v.z, v.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_float4(vec4& v)
|
void streamfx::obs::gs::effect_parameter::get_default_float4(vec4& v)
|
||||||
{
|
{
|
||||||
get_default_float4(v.x, v.y, v.z, v.w);
|
get_default_float4(v.x, v.y, v.z, v.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_float4(float_t x, float_t y, float_t z, float_t w)
|
void streamfx::obs::gs::effect_parameter::set_float4(float_t x, float_t y, float_t z, float_t w)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float4)
|
if (get_type() != type::Float4)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -397,7 +399,7 @@ void gs::effect_parameter::set_float4(float_t x, float_t y, float_t z, float_t w
|
||||||
gs_effect_set_vec4(get(), &v);
|
gs_effect_set_vec4(get(), &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_float4(float_t& x, float_t& y, float_t& z, float_t& w)
|
void streamfx::obs::gs::effect_parameter::get_float4(float_t& x, float_t& y, float_t& z, float_t& w)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float4)
|
if (get_type() != type::Float4)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -413,7 +415,7 @@ void gs::effect_parameter::get_float4(float_t& x, float_t& y, float_t& z, float_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_float4(float_t& x, float_t& y, float_t& z, float_t& w)
|
void streamfx::obs::gs::effect_parameter::get_default_float4(float_t& x, float_t& y, float_t& z, float_t& w)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Float4)
|
if (get_type() != type::Float4)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -429,14 +431,14 @@ void gs::effect_parameter::get_default_float4(float_t& x, float_t& y, float_t& z
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_int(int32_t x)
|
void streamfx::obs::gs::effect_parameter::set_int(int32_t x)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_int(get(), x);
|
gs_effect_set_int(get(), x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_int(int32_t& x)
|
void streamfx::obs::gs::effect_parameter::get_int(int32_t& x)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -449,7 +451,7 @@ void gs::effect_parameter::get_int(int32_t& x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_int(int32_t& x)
|
void streamfx::obs::gs::effect_parameter::get_default_int(int32_t& x)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -462,7 +464,7 @@ void gs::effect_parameter::get_default_int(int32_t& x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_int2(int32_t x, int32_t y)
|
void streamfx::obs::gs::effect_parameter::set_int2(int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -470,7 +472,7 @@ void gs::effect_parameter::set_int2(int32_t x, int32_t y)
|
||||||
gs_effect_set_val(get(), v, sizeof(int) * 2);
|
gs_effect_set_val(get(), v, sizeof(int) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_int2(int32_t& x, int32_t& y)
|
void streamfx::obs::gs::effect_parameter::get_int2(int32_t& x, int32_t& y)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -484,7 +486,7 @@ void gs::effect_parameter::get_int2(int32_t& x, int32_t& y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_int2(int32_t& x, int32_t& y)
|
void streamfx::obs::gs::effect_parameter::get_default_int2(int32_t& x, int32_t& y)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer2) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -498,7 +500,7 @@ void gs::effect_parameter::get_default_int2(int32_t& x, int32_t& y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_int3(int32_t x, int32_t y, int32_t z)
|
void streamfx::obs::gs::effect_parameter::set_int3(int32_t x, int32_t y, int32_t z)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -506,7 +508,7 @@ void gs::effect_parameter::set_int3(int32_t x, int32_t y, int32_t z)
|
||||||
gs_effect_set_val(get(), v, sizeof(int) * 3);
|
gs_effect_set_val(get(), v, sizeof(int) * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_int3(int32_t& x, int32_t& y, int32_t& z)
|
void streamfx::obs::gs::effect_parameter::get_int3(int32_t& x, int32_t& y, int32_t& z)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -521,7 +523,7 @@ void gs::effect_parameter::get_int3(int32_t& x, int32_t& y, int32_t& z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_int3(int32_t& x, int32_t& y, int32_t& z)
|
void streamfx::obs::gs::effect_parameter::get_default_int3(int32_t& x, int32_t& y, int32_t& z)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer3) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -536,7 +538,7 @@ void gs::effect_parameter::get_default_int3(int32_t& x, int32_t& y, int32_t& z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_int4(int32_t x, int32_t y, int32_t z, int32_t w)
|
void streamfx::obs::gs::effect_parameter::set_int4(int32_t x, int32_t y, int32_t z, int32_t w)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -544,7 +546,7 @@ void gs::effect_parameter::set_int4(int32_t x, int32_t y, int32_t z, int32_t w)
|
||||||
gs_effect_set_val(get(), v, sizeof(int) * 4);
|
gs_effect_set_val(get(), v, sizeof(int) * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_int4(int32_t& x, int32_t& y, int32_t& z, int32_t& w)
|
void streamfx::obs::gs::effect_parameter::get_int4(int32_t& x, int32_t& y, int32_t& z, int32_t& w)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -560,7 +562,7 @@ void gs::effect_parameter::get_int4(int32_t& x, int32_t& y, int32_t& z, int32_t&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_int4(int32_t& x, int32_t& y, int32_t& z, int32_t& w)
|
void streamfx::obs::gs::effect_parameter::get_default_int4(int32_t& x, int32_t& y, int32_t& z, int32_t& w)
|
||||||
{
|
{
|
||||||
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
|
if ((get_type() != type::Integer4) && (get_type() != type::Unknown))
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -576,14 +578,14 @@ void gs::effect_parameter::get_default_int4(int32_t& x, int32_t& y, int32_t& z,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_matrix(matrix4 const& v)
|
void streamfx::obs::gs::effect_parameter::set_matrix(matrix4 const& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Matrix)
|
if (get_type() != type::Matrix)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_matrix4(get(), &v);
|
gs_effect_set_matrix4(get(), &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_matrix(matrix4& v)
|
void streamfx::obs::gs::effect_parameter::get_matrix(matrix4& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Matrix)
|
if (get_type() != type::Matrix)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -614,7 +616,7 @@ void gs::effect_parameter::get_matrix(matrix4& v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_matrix(matrix4& v)
|
void streamfx::obs::gs::effect_parameter::get_default_matrix(matrix4& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Matrix)
|
if (get_type() != type::Matrix)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -645,42 +647,42 @@ void gs::effect_parameter::get_default_matrix(matrix4& v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_texture(std::shared_ptr<gs::texture> v)
|
void streamfx::obs::gs::effect_parameter::set_texture(std::shared_ptr<streamfx::obs::gs::texture> v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Texture)
|
if (get_type() != type::Texture)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_texture(get(), v->get_object());
|
gs_effect_set_texture(get(), v->get_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_texture(gs_texture_t* v)
|
void streamfx::obs::gs::effect_parameter::set_texture(gs_texture_t* v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Texture)
|
if (get_type() != type::Texture)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_texture(get(), v);
|
gs_effect_set_texture(get(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_sampler(std::shared_ptr<gs::sampler> v)
|
void streamfx::obs::gs::effect_parameter::set_sampler(std::shared_ptr<streamfx::obs::gs::sampler> v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Texture)
|
if (get_type() != type::Texture)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_next_sampler(get(), v->get_object());
|
gs_effect_set_next_sampler(get(), v->get_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_sampler(gs_sampler_state* v)
|
void streamfx::obs::gs::effect_parameter::set_sampler(gs_sampler_state* v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::Texture)
|
if (get_type() != type::Texture)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_next_sampler(get(), v);
|
gs_effect_set_next_sampler(get(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::set_string(std::string const& v)
|
void streamfx::obs::gs::effect_parameter::set_string(std::string const& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::String)
|
if (get_type() != type::String)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
gs_effect_set_val(get(), v.c_str(), v.length());
|
gs_effect_set_val(get(), v.c_str(), v.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_string(std::string& v)
|
void streamfx::obs::gs::effect_parameter::get_string(std::string& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::String)
|
if (get_type() != type::String)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
@ -694,7 +696,7 @@ void gs::effect_parameter::get_string(std::string& v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::effect_parameter::get_default_string(std::string& v)
|
void streamfx::obs::gs::effect_parameter::get_default_string(std::string& v)
|
||||||
{
|
{
|
||||||
if (get_type() != type::String)
|
if (get_type() != type::String)
|
||||||
throw std::bad_cast();
|
throw std::bad_cast();
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "gs-sampler.hpp"
|
#include "gs-sampler.hpp"
|
||||||
#include "gs-texture.hpp"
|
#include "gs-texture.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class effect_parameter : public std::shared_ptr<gs_eparam_t> {
|
class effect_parameter : public std::shared_ptr<gs_eparam_t> {
|
||||||
std::shared_ptr<gs_effect_t> _effect_parent;
|
std::shared_ptr<gs_effect_t> _effect_parent;
|
||||||
std::shared_ptr<gs_epass_t> _pass_parent;
|
std::shared_ptr<gs_epass_t> _pass_parent;
|
||||||
|
@ -189,10 +189,10 @@ namespace gs {
|
||||||
void get_matrix(matrix4& v);
|
void get_matrix(matrix4& v);
|
||||||
void get_default_matrix(matrix4& v);
|
void get_default_matrix(matrix4& v);
|
||||||
|
|
||||||
void set_texture(std::shared_ptr<gs::texture> v);
|
void set_texture(std::shared_ptr<streamfx::obs::gs::texture> v);
|
||||||
void set_texture(gs_texture_t* v);
|
void set_texture(gs_texture_t* v);
|
||||||
|
|
||||||
void set_sampler(std::shared_ptr<gs::sampler> v);
|
void set_sampler(std::shared_ptr<streamfx::obs::gs::sampler> v);
|
||||||
void set_sampler(gs_sampler_state* v);
|
void set_sampler(gs_sampler_state* v);
|
||||||
|
|
||||||
void set_string(std::string const& v);
|
void set_string(std::string const& v);
|
||||||
|
@ -304,4 +304,4 @@ namespace gs {
|
||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -31,49 +31,50 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_pass::effect_pass(gs_epass_t* pass, std::shared_ptr<gs_technique_t> parent) : _parent(parent)
|
streamfx::obs::gs::effect_pass::effect_pass(gs_epass_t* pass, std::shared_ptr<gs_technique_t> parent) : _parent(parent)
|
||||||
{
|
{
|
||||||
reset(pass, [](void*) {});
|
reset(pass, [](void*) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_pass::~effect_pass() {}
|
streamfx::obs::gs::effect_pass::~effect_pass() {}
|
||||||
|
|
||||||
std::string gs::effect_pass::name()
|
std::string streamfx::obs::gs::effect_pass::name()
|
||||||
{
|
{
|
||||||
const char* name_c = get()->name;
|
const char* name_c = get()->name;
|
||||||
std::size_t name_len = strnlen(name_c, 256);
|
std::size_t name_len = strnlen(name_c, 256);
|
||||||
return name_c ? std::string(name_c, name_c + name_len) : std::string();
|
return name_c ? std::string(name_c, name_c + name_len) : std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t gs::effect_pass::count_vertex_parameters()
|
std::size_t streamfx::obs::gs::effect_pass::count_vertex_parameters()
|
||||||
{
|
{
|
||||||
return static_cast<size_t>(get()->vertshader_params.num);
|
return static_cast<size_t>(get()->vertshader_params.num);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect_pass::get_vertex_parameter(std::size_t idx)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect_pass::get_vertex_parameter(std::size_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= count_vertex_parameters())
|
if (idx >= count_vertex_parameters())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return gs::effect_parameter((get()->vertshader_params.array + idx)->eparam, *this);
|
return streamfx::obs::gs::effect_parameter((get()->vertshader_params.array + idx)->eparam, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect_pass::get_vertex_parameter(std::string name)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect_pass::get_vertex_parameter(std::string name)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < count_vertex_parameters(); idx++) {
|
for (std::size_t idx = 0; idx < count_vertex_parameters(); idx++) {
|
||||||
auto ptr = get()->vertshader_params.array + idx;
|
auto ptr = get()->vertshader_params.array + idx;
|
||||||
if (strcmp(ptr->eparam->name, name.c_str()) == 0)
|
if (strcmp(ptr->eparam->name, name.c_str()) == 0)
|
||||||
return gs::effect_parameter(ptr->eparam, *this);
|
return streamfx::obs::gs::effect_parameter(ptr->eparam, *this);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect_pass::has_vertex_parameter(std::string name)
|
bool streamfx::obs::gs::effect_pass::has_vertex_parameter(std::string name)
|
||||||
{
|
{
|
||||||
return (get_vertex_parameter(name) != nullptr);
|
return (get_vertex_parameter(name) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect_pass::has_vertex_parameter(std::string name, gs::effect_parameter::type type)
|
bool streamfx::obs::gs::effect_pass::has_vertex_parameter(std::string name,
|
||||||
|
streamfx::obs::gs::effect_parameter::type type)
|
||||||
{
|
{
|
||||||
if (auto el = get_vertex_parameter(name); el != nullptr) {
|
if (auto el = get_vertex_parameter(name); el != nullptr) {
|
||||||
return el.get_type() == type;
|
return el.get_type() == type;
|
||||||
|
@ -81,35 +82,36 @@ bool gs::effect_pass::has_vertex_parameter(std::string name, gs::effect_paramete
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t gs::effect_pass::count_pixel_parameters()
|
std::size_t streamfx::obs::gs::effect_pass::count_pixel_parameters()
|
||||||
{
|
{
|
||||||
return static_cast<size_t>(get()->pixelshader_params.num);
|
return static_cast<size_t>(get()->pixelshader_params.num);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect_pass::get_pixel_parameter(std::size_t idx)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect_pass::get_pixel_parameter(std::size_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= count_pixel_parameters())
|
if (idx >= count_pixel_parameters())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return gs::effect_parameter((get()->pixelshader_params.array + idx)->eparam, *this);
|
return streamfx::obs::gs::effect_parameter((get()->pixelshader_params.array + idx)->eparam, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect_pass::get_pixel_parameter(std::string name)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect_pass::get_pixel_parameter(std::string name)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < count_pixel_parameters(); idx++) {
|
for (std::size_t idx = 0; idx < count_pixel_parameters(); idx++) {
|
||||||
auto ptr = get()->pixelshader_params.array + idx;
|
auto ptr = get()->pixelshader_params.array + idx;
|
||||||
if (strcmp(ptr->eparam->name, name.c_str()) == 0)
|
if (strcmp(ptr->eparam->name, name.c_str()) == 0)
|
||||||
return gs::effect_parameter(ptr->eparam, *this);
|
return streamfx::obs::gs::effect_parameter(ptr->eparam, *this);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect_pass::has_pixel_parameter(std::string name)
|
bool streamfx::obs::gs::effect_pass::has_pixel_parameter(std::string name)
|
||||||
{
|
{
|
||||||
return (get_pixel_parameter(name) != nullptr);
|
return (get_pixel_parameter(name) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect_pass::has_pixel_parameter(std::string name, gs::effect_parameter::type type)
|
bool streamfx::obs::gs::effect_pass::has_pixel_parameter(std::string name,
|
||||||
|
streamfx::obs::gs::effect_parameter::type type)
|
||||||
{
|
{
|
||||||
if (auto el = get_pixel_parameter(name); el != nullptr) {
|
if (auto el = get_pixel_parameter(name); el != nullptr) {
|
||||||
return el.get_type() == type;
|
return el.get_type() == type;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "gs-effect-parameter.hpp"
|
#include "gs-effect-parameter.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class effect_pass : public std::shared_ptr<gs_epass_t> {
|
class effect_pass : public std::shared_ptr<gs_epass_t> {
|
||||||
std::shared_ptr<gs_technique_t> _parent;
|
std::shared_ptr<gs_technique_t> _parent;
|
||||||
|
|
||||||
|
@ -36,15 +36,15 @@ namespace gs {
|
||||||
//
|
//
|
||||||
|
|
||||||
std::size_t count_vertex_parameters();
|
std::size_t count_vertex_parameters();
|
||||||
gs::effect_parameter get_vertex_parameter(std::size_t idx);
|
streamfx::obs::gs::effect_parameter get_vertex_parameter(std::size_t idx);
|
||||||
gs::effect_parameter get_vertex_parameter(std::string name);
|
streamfx::obs::gs::effect_parameter get_vertex_parameter(std::string name);
|
||||||
bool has_vertex_parameter(std::string name);
|
bool has_vertex_parameter(std::string name);
|
||||||
bool has_vertex_parameter(std::string name, gs::effect_parameter::type type);
|
bool has_vertex_parameter(std::string name, streamfx::obs::gs::effect_parameter::type type);
|
||||||
|
|
||||||
std::size_t count_pixel_parameters();
|
std::size_t count_pixel_parameters();
|
||||||
gs::effect_parameter get_pixel_parameter(std::size_t idx);
|
streamfx::obs::gs::effect_parameter get_pixel_parameter(std::size_t idx);
|
||||||
gs::effect_parameter get_pixel_parameter(std::string name);
|
streamfx::obs::gs::effect_parameter get_pixel_parameter(std::string name);
|
||||||
bool has_pixel_parameter(std::string name);
|
bool has_pixel_parameter(std::string name);
|
||||||
bool has_pixel_parameter(std::string name, gs::effect_parameter::type type);
|
bool has_pixel_parameter(std::string name, streamfx::obs::gs::effect_parameter::type type);
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -32,46 +32,47 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_technique::effect_technique(gs_technique_t* technique, std::shared_ptr<gs_effect_t> parent) : _parent(parent)
|
streamfx::obs::gs::effect_technique::effect_technique(gs_technique_t* technique, std::shared_ptr<gs_effect_t> parent)
|
||||||
|
: _parent(parent)
|
||||||
{
|
{
|
||||||
reset(technique, [](void*) {});
|
reset(technique, [](void*) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_technique::~effect_technique() {}
|
streamfx::obs::gs::effect_technique::~effect_technique() {}
|
||||||
|
|
||||||
std::string gs::effect_technique::name()
|
std::string streamfx::obs::gs::effect_technique::name()
|
||||||
{
|
{
|
||||||
const char* name_c = get()->name;
|
const char* name_c = get()->name;
|
||||||
std::size_t name_len = strnlen(name_c, 256);
|
std::size_t name_len = strnlen(name_c, 256);
|
||||||
return name_c ? std::string(name_c, name_c + name_len) : std::string();
|
return name_c ? std::string(name_c, name_c + name_len) : std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t gs::effect_technique::count_passes()
|
std::size_t streamfx::obs::gs::effect_technique::count_passes()
|
||||||
{
|
{
|
||||||
return static_cast<size_t>(get()->passes.num);
|
return static_cast<size_t>(get()->passes.num);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_pass gs::effect_technique::get_pass(std::size_t idx)
|
streamfx::obs::gs::effect_pass streamfx::obs::gs::effect_technique::get_pass(std::size_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= get()->passes.num) {
|
if (idx >= get()->passes.num) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gs::effect_pass(get()->passes.array + idx, *this);
|
return streamfx::obs::gs::effect_pass(get()->passes.array + idx, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_pass gs::effect_technique::get_pass(std::string name)
|
streamfx::obs::gs::effect_pass streamfx::obs::gs::effect_technique::get_pass(std::string name)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < get()->passes.num; idx++) {
|
for (std::size_t idx = 0; idx < get()->passes.num; idx++) {
|
||||||
auto ptr = get()->passes.array + idx;
|
auto ptr = get()->passes.array + idx;
|
||||||
if (strcmp(ptr->name, name.c_str()) == 0)
|
if (strcmp(ptr->name, name.c_str()) == 0)
|
||||||
return gs::effect_pass(ptr, *this);
|
return streamfx::obs::gs::effect_pass(ptr, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect_technique::has_pass(std::string name)
|
bool streamfx::obs::gs::effect_technique::has_pass(std::string name)
|
||||||
{
|
{
|
||||||
if (get_pass(name) != nullptr)
|
if (get_pass(name) != nullptr)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "gs-effect-pass.hpp"
|
#include "gs-effect-pass.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class effect_technique : public std::shared_ptr<gs_technique_t> {
|
class effect_technique : public std::shared_ptr<gs_technique_t> {
|
||||||
std::shared_ptr<gs_effect_t> _parent;
|
std::shared_ptr<gs_effect_t> _parent;
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ namespace gs {
|
||||||
std::string name();
|
std::string name();
|
||||||
|
|
||||||
std::size_t count_passes();
|
std::size_t count_passes();
|
||||||
gs::effect_pass get_pass(std::size_t idx);
|
streamfx::obs::gs::effect_pass get_pass(std::size_t idx);
|
||||||
gs::effect_pass get_pass(std::string name);
|
streamfx::obs::gs::effect_pass get_pass(std::string name);
|
||||||
bool has_pass(std::string name);
|
bool has_pass(std::string name);
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -43,9 +43,9 @@ static std::string load_file_as_code(std::filesystem::path file)
|
||||||
return std::string(buf.data(), buf.data() + size);
|
return std::string(buf.data(), buf.data() + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect::effect(const std::string& code, const std::string& name)
|
streamfx::obs::gs::effect::effect(const std::string& code, const std::string& name)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
char* error_buffer = nullptr;
|
char* error_buffer = nullptr;
|
||||||
gs_effect_t* effect = gs_effect_create(code.c_str(), name.c_str(), &error_buffer);
|
gs_effect_t* effect = gs_effect_create(code.c_str(), name.c_str(), &error_buffer);
|
||||||
|
@ -58,81 +58,81 @@ gs::effect::effect(const std::string& code, const std::string& name)
|
||||||
reset(effect, [](gs_effect_t* ptr) { gs_effect_destroy(ptr); });
|
reset(effect, [](gs_effect_t* ptr) { gs_effect_destroy(ptr); });
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect::effect(std::filesystem::path file) : effect(load_file_as_code(file), file.u8string()) {}
|
streamfx::obs::gs::effect::effect(std::filesystem::path file) : effect(load_file_as_code(file), file.u8string()) {}
|
||||||
|
|
||||||
gs::effect::~effect()
|
streamfx::obs::gs::effect::~effect()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t gs::effect::count_techniques()
|
std::size_t streamfx::obs::gs::effect::count_techniques()
|
||||||
{
|
{
|
||||||
return static_cast<size_t>(get()->techniques.num);
|
return static_cast<size_t>(get()->techniques.num);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_technique gs::effect::get_technique(std::size_t idx)
|
streamfx::obs::gs::effect_technique streamfx::obs::gs::effect::get_technique(std::size_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= count_techniques()) {
|
if (idx >= count_techniques()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gs::effect_technique(get()->techniques.array + idx, *this);
|
return streamfx::obs::gs::effect_technique(get()->techniques.array + idx, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_technique gs::effect::get_technique(const std::string& name)
|
streamfx::obs::gs::effect_technique streamfx::obs::gs::effect::get_technique(const std::string& name)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < count_techniques(); idx++) {
|
for (std::size_t idx = 0; idx < count_techniques(); idx++) {
|
||||||
auto ptr = get()->techniques.array + idx;
|
auto ptr = get()->techniques.array + idx;
|
||||||
if (strcmp(ptr->name, name.c_str()) == 0) {
|
if (strcmp(ptr->name, name.c_str()) == 0) {
|
||||||
return gs::effect_technique(ptr, *this);
|
return streamfx::obs::gs::effect_technique(ptr, *this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect::has_technique(const std::string& name)
|
bool streamfx::obs::gs::effect::has_technique(const std::string& name)
|
||||||
{
|
{
|
||||||
if (get_technique(name))
|
if (get_technique(name))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t gs::effect::count_parameters()
|
std::size_t streamfx::obs::gs::effect::count_parameters()
|
||||||
{
|
{
|
||||||
return get()->params.num;
|
return get()->params.num;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect::get_parameter(std::size_t idx)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect::get_parameter(std::size_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= count_parameters()) {
|
if (idx >= count_parameters()) {
|
||||||
throw std::out_of_range("Index is out of range.");
|
throw std::out_of_range("Index is out of range.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return gs::effect_parameter(get()->params.array + idx, *this);
|
return streamfx::obs::gs::effect_parameter(get()->params.array + idx, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::effect_parameter gs::effect::get_parameter(const std::string& name)
|
streamfx::obs::gs::effect_parameter streamfx::obs::gs::effect::get_parameter(const std::string& name)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < count_parameters(); idx++) {
|
for (std::size_t idx = 0; idx < count_parameters(); idx++) {
|
||||||
auto ptr = get()->params.array + idx;
|
auto ptr = get()->params.array + idx;
|
||||||
if (strcmp(ptr->name, name.c_str()) == 0) {
|
if (strcmp(ptr->name, name.c_str()) == 0) {
|
||||||
return gs::effect_parameter(ptr, *this);
|
return streamfx::obs::gs::effect_parameter(ptr, *this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect::has_parameter(const std::string& name)
|
bool streamfx::obs::gs::effect::has_parameter(const std::string& name)
|
||||||
{
|
{
|
||||||
if (get_parameter(name))
|
if (get_parameter(name))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::effect::has_parameter(const std::string& name, effect_parameter::type type)
|
bool streamfx::obs::gs::effect::has_parameter(const std::string& name, effect_parameter::type type)
|
||||||
{
|
{
|
||||||
auto eprm = get_parameter(name);
|
auto eprm = get_parameter(name);
|
||||||
if (eprm)
|
if (eprm)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "gs-effect-parameter.hpp"
|
#include "gs-effect-parameter.hpp"
|
||||||
#include "gs-effect-technique.hpp"
|
#include "gs-effect-technique.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class effect : public std::shared_ptr<gs_effect_t> {
|
class effect : public std::shared_ptr<gs_effect_t> {
|
||||||
public:
|
public:
|
||||||
effect(){};
|
effect(){};
|
||||||
|
@ -33,13 +33,13 @@ namespace gs {
|
||||||
~effect();
|
~effect();
|
||||||
|
|
||||||
std::size_t count_techniques();
|
std::size_t count_techniques();
|
||||||
gs::effect_technique get_technique(std::size_t idx);
|
streamfx::obs::gs::effect_technique get_technique(std::size_t idx);
|
||||||
gs::effect_technique get_technique(const std::string& name);
|
streamfx::obs::gs::effect_technique get_technique(const std::string& name);
|
||||||
bool has_technique(const std::string& name);
|
bool has_technique(const std::string& name);
|
||||||
|
|
||||||
std::size_t count_parameters();
|
std::size_t count_parameters();
|
||||||
gs::effect_parameter get_parameter(std::size_t idx);
|
streamfx::obs::gs::effect_parameter get_parameter(std::size_t idx);
|
||||||
gs::effect_parameter get_parameter(const std::string& name);
|
streamfx::obs::gs::effect_parameter get_parameter(const std::string& name);
|
||||||
bool has_parameter(const std::string& name);
|
bool has_parameter(const std::string& name);
|
||||||
bool has_parameter(const std::string& name, effect_parameter::type type);
|
bool has_parameter(const std::string& name, effect_parameter::type type);
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@ namespace gs {
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gs::effect create(const std::string& file)
|
static streamfx::obs::gs::effect create(const std::string& file)
|
||||||
{
|
{
|
||||||
return gs::effect(file);
|
return streamfx::obs::gs::effect(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
static gs::effect create(const std::string& code, const std::string& name)
|
static streamfx::obs::gs::effect create(const std::string& code, const std::string& name)
|
||||||
{
|
{
|
||||||
return gs::effect(code, name);
|
return streamfx::obs::gs::effect(code, name);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "plugin.hpp"
|
#include "plugin.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class context {
|
class context {
|
||||||
public:
|
public:
|
||||||
inline context()
|
inline context()
|
||||||
|
@ -87,4 +87,4 @@ namespace gs {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -22,40 +22,41 @@
|
||||||
#include "gs-limits.hpp"
|
#include "gs-limits.hpp"
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
|
|
||||||
gs::index_buffer::index_buffer(uint32_t maximumVertices)
|
streamfx::obs::gs::index_buffer::index_buffer(uint32_t maximumVertices)
|
||||||
{
|
{
|
||||||
this->reserve(maximumVertices);
|
this->reserve(maximumVertices);
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_index_buffer = gs_indexbuffer_create(gs_index_type::GS_UNSIGNED_LONG, this->data(), maximumVertices, GS_DYNAMIC);
|
_index_buffer = gs_indexbuffer_create(gs_index_type::GS_UNSIGNED_LONG, this->data(), maximumVertices, GS_DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::index_buffer::index_buffer() : index_buffer(MAXIMUM_VERTICES) {}
|
streamfx::obs::gs::index_buffer::index_buffer() : index_buffer(MAXIMUM_VERTICES) {}
|
||||||
|
|
||||||
gs::index_buffer::index_buffer(index_buffer& other) : index_buffer(static_cast<uint32_t>(other.size()))
|
streamfx::obs::gs::index_buffer::index_buffer(index_buffer& other) : index_buffer(static_cast<uint32_t>(other.size()))
|
||||||
{
|
{
|
||||||
std::copy(other.begin(), other.end(), this->end());
|
std::copy(other.begin(), other.end(), this->end());
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::index_buffer::index_buffer(std::vector<uint32_t>& other) : index_buffer(static_cast<uint32_t>(other.size()))
|
streamfx::obs::gs::index_buffer::index_buffer(std::vector<uint32_t>& other)
|
||||||
|
: index_buffer(static_cast<uint32_t>(other.size()))
|
||||||
{
|
{
|
||||||
std::copy(other.begin(), other.end(), this->end());
|
std::copy(other.begin(), other.end(), this->end());
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::index_buffer::~index_buffer()
|
streamfx::obs::gs::index_buffer::~index_buffer()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_indexbuffer_destroy(_index_buffer);
|
gs_indexbuffer_destroy(_index_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_indexbuffer_t* gs::index_buffer::get()
|
gs_indexbuffer_t* streamfx::obs::gs::index_buffer::get()
|
||||||
{
|
{
|
||||||
return get(true);
|
return get(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_indexbuffer_t* gs::index_buffer::get(bool refreshGPU)
|
gs_indexbuffer_t* streamfx::obs::gs::index_buffer::get(bool refreshGPU)
|
||||||
{
|
{
|
||||||
if (refreshGPU) {
|
if (refreshGPU) {
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_indexbuffer_flush(_index_buffer);
|
gs_indexbuffer_flush(_index_buffer);
|
||||||
}
|
}
|
||||||
return _index_buffer;
|
return _index_buffer;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class index_buffer : public std::vector<uint32_t> {
|
class index_buffer : public std::vector<uint32_t> {
|
||||||
public:
|
public:
|
||||||
index_buffer(uint32_t maximumVertices);
|
index_buffer(uint32_t maximumVertices);
|
||||||
|
@ -37,4 +37,4 @@ namespace gs {
|
||||||
protected:
|
protected:
|
||||||
gs_indexbuffer_t* _index_buffer;
|
gs_indexbuffer_t* _index_buffer;
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu;
|
static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu;
|
||||||
static const uint32_t MAXIMUM_UVW_LAYERS = 8u;
|
static const uint32_t MAXIMUM_UVW_LAYERS = 8u;
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -36,16 +36,16 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gs::mipmapper::~mipmapper()
|
streamfx::obs::gs::mipmapper::~mipmapper()
|
||||||
{
|
{
|
||||||
_vb.reset();
|
_vb.reset();
|
||||||
_rt.reset();
|
_rt.reset();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::mipmapper::mipmapper()
|
streamfx::obs::gs::mipmapper::mipmapper()
|
||||||
{
|
{
|
||||||
_vb = std::make_unique<gs::vertex_buffer>(uint32_t(3u), uint8_t(1u));
|
_vb = std::make_unique<streamfx::obs::gs::vertex_buffer>(uint32_t(3u), uint8_t(1u));
|
||||||
|
|
||||||
{
|
{
|
||||||
auto vtx = _vb->at(0);
|
auto vtx = _vb->at(0);
|
||||||
|
@ -71,10 +71,11 @@ gs::mipmapper::mipmapper()
|
||||||
|
|
||||||
_vb->update();
|
_vb->update();
|
||||||
|
|
||||||
_effect = gs::effect::create(streamfx::data_file_path("effects/mipgen.effect").u8string());
|
_effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/mipgen.effect").u8string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr<gs::texture> target)
|
void streamfx::obs::gs::mipmapper::rebuild(std::shared_ptr<streamfx::obs::gs::texture> source,
|
||||||
|
std::shared_ptr<streamfx::obs::gs::texture> target)
|
||||||
{
|
{
|
||||||
{ // Validate arguments and structure.
|
{ // Validate arguments and structure.
|
||||||
if (!source || !target)
|
if (!source || !target)
|
||||||
|
@ -100,11 +101,11 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a unique lock on the graphics context.
|
// Get a unique lock on the graphics context.
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
// Do we need to recreate the render target for a different format?
|
// Do we need to recreate the render target for a different format?
|
||||||
if ((!_rt) || (source->get_color_format() != _rt->get_color_format())) {
|
if ((!_rt) || (source->get_color_format() != _rt->get_color_format())) {
|
||||||
_rt = std::make_unique<gs::rendertarget>(source->get_color_format(), GS_ZS_NONE);
|
_rt = std::make_unique<streamfx::obs::gs::rendertarget>(source->get_color_format(), GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab API related information.
|
// Grab API related information.
|
||||||
|
@ -125,7 +126,7 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use different methods for different types of textures.
|
// Use different methods for different types of textures.
|
||||||
if (source->get_type() == gs::texture::type::Normal) {
|
if (source->get_type() == streamfx::obs::gs::texture::type::Normal) {
|
||||||
while (true) {
|
while (true) {
|
||||||
uint32_t width = source->get_width();
|
uint32_t width = source->get_width();
|
||||||
uint32_t height = source->get_height();
|
uint32_t height = source->get_height();
|
||||||
|
@ -133,7 +134,8 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto cctr = gs::debug_marker(gs::debug_color_azure_radiance, "Mip Level %" PRId64 "", 0);
|
auto cctr = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance,
|
||||||
|
"Mip Level %" PRId64 "", 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -160,7 +162,8 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
|
||||||
// Render each mip map level.
|
// Render each mip map level.
|
||||||
for (size_t mip = 1; mip < max_mip_level; mip++) {
|
for (size_t mip = 1; mip < max_mip_level; mip++) {
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
auto cctr = gs::debug_marker(gs::debug_color_azure_radiance, "Mip Level %" PRIuMAX, mip);
|
auto cctr = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_azure_radiance,
|
||||||
|
"Mip Level %" PRIuMAX, mip);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t cwidth = std::max<uint32_t>(width >> mip, 1);
|
uint32_t cwidth = std::max<uint32_t>(width >> mip, 1);
|
||||||
|
|
|
@ -36,16 +36,17 @@
|
||||||
* resource. Super wasteful, but what else can we actually do?
|
* resource. Super wasteful, but what else can we actually do?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class mipmapper {
|
class mipmapper {
|
||||||
std::unique_ptr<gs::vertex_buffer> _vb;
|
std::unique_ptr<streamfx::obs::gs::vertex_buffer> _vb;
|
||||||
std::unique_ptr<gs::rendertarget> _rt;
|
std::unique_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~mipmapper();
|
~mipmapper();
|
||||||
mipmapper();
|
mipmapper();
|
||||||
|
|
||||||
void rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr<gs::texture> target);
|
void rebuild(std::shared_ptr<streamfx::obs::gs::texture> source,
|
||||||
|
std::shared_ptr<streamfx::obs::gs::texture> target);
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -21,73 +21,75 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
|
|
||||||
gs::rendertarget::~rendertarget()
|
streamfx::obs::gs::rendertarget::~rendertarget()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_texrender_destroy(_render_target);
|
gs_texrender_destroy(_render_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::rendertarget::rendertarget(gs_color_format colorFormat, gs_zstencil_format zsFormat)
|
streamfx::obs::gs::rendertarget::rendertarget(gs_color_format colorFormat, gs_zstencil_format zsFormat)
|
||||||
: _color_format(colorFormat), _zstencil_format(zsFormat)
|
: _color_format(colorFormat), _zstencil_format(zsFormat)
|
||||||
{
|
{
|
||||||
_is_being_rendered = false;
|
_is_being_rendered = false;
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_render_target = gs_texrender_create(colorFormat, zsFormat);
|
_render_target = gs_texrender_create(colorFormat, zsFormat);
|
||||||
if (!_render_target) {
|
if (!_render_target) {
|
||||||
throw std::runtime_error("Failed to create render target.");
|
throw std::runtime_error("Failed to create render target.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::rendertarget_op gs::rendertarget::render(uint32_t width, uint32_t height)
|
streamfx::obs::gs::rendertarget_op streamfx::obs::gs::rendertarget::render(uint32_t width, uint32_t height)
|
||||||
{
|
{
|
||||||
return {this, width, height};
|
return {this, width, height};
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_texture_t* gs::rendertarget::get_object()
|
gs_texture_t* streamfx::obs::gs::rendertarget::get_object()
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_texture_t* tex = gs_texrender_get_texture(_render_target);
|
gs_texture_t* tex = gs_texrender_get_texture(_render_target);
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> gs::rendertarget::get_texture()
|
std::shared_ptr<streamfx::obs::gs::texture> streamfx::obs::gs::rendertarget::get_texture()
|
||||||
{
|
{
|
||||||
return std::make_shared<gs::texture>(get_object(), false);
|
return std::make_shared<streamfx::obs::gs::texture>(get_object(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::rendertarget::get_texture(gs::texture& tex)
|
void streamfx::obs::gs::rendertarget::get_texture(streamfx::obs::gs::texture& tex)
|
||||||
{
|
{
|
||||||
tex = gs::texture(get_object(), false);
|
tex = streamfx::obs::gs::texture(get_object(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::rendertarget::get_texture(std::shared_ptr<gs::texture>& tex)
|
void streamfx::obs::gs::rendertarget::get_texture(std::shared_ptr<streamfx::obs::gs::texture>& tex)
|
||||||
{
|
{
|
||||||
tex = std::make_shared<gs::texture>(get_object(), false);
|
tex = std::make_shared<streamfx::obs::gs::texture>(get_object(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::rendertarget::get_texture(std::unique_ptr<gs::texture>& tex)
|
void streamfx::obs::gs::rendertarget::get_texture(std::unique_ptr<streamfx::obs::gs::texture>& tex)
|
||||||
{
|
{
|
||||||
tex = std::make_unique<gs::texture>(get_object(), false);
|
tex = std::make_unique<streamfx::obs::gs::texture>(get_object(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_color_format gs::rendertarget::get_color_format()
|
gs_color_format streamfx::obs::gs::rendertarget::get_color_format()
|
||||||
{
|
{
|
||||||
return _color_format;
|
return _color_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_zstencil_format gs::rendertarget::get_zstencil_format()
|
gs_zstencil_format streamfx::obs::gs::rendertarget::get_zstencil_format()
|
||||||
{
|
{
|
||||||
return _zstencil_format;
|
return _zstencil_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::rendertarget_op::rendertarget_op(gs::rendertarget* rt, uint32_t width, uint32_t height) : parent(rt)
|
streamfx::obs::gs::rendertarget_op::rendertarget_op(streamfx::obs::gs::rendertarget* rt, uint32_t width,
|
||||||
|
uint32_t height)
|
||||||
|
: parent(rt)
|
||||||
{
|
{
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
throw std::invalid_argument("rt");
|
throw std::invalid_argument("rt");
|
||||||
if (parent->_is_being_rendered)
|
if (parent->_is_being_rendered)
|
||||||
throw std::logic_error("Can't start rendering to the same render target twice.");
|
throw std::logic_error("Can't start rendering to the same render target twice.");
|
||||||
|
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_texrender_reset(parent->_render_target);
|
gs_texrender_reset(parent->_render_target);
|
||||||
if (!gs_texrender_begin(parent->_render_target, width, height)) {
|
if (!gs_texrender_begin(parent->_render_target, width, height)) {
|
||||||
throw std::runtime_error("Failed to begin rendering to render target.");
|
throw std::runtime_error("Failed to begin rendering to render target.");
|
||||||
|
@ -95,18 +97,18 @@ gs::rendertarget_op::rendertarget_op(gs::rendertarget* rt, uint32_t width, uint3
|
||||||
parent->_is_being_rendered = true;
|
parent->_is_being_rendered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::rendertarget_op::rendertarget_op(gs::rendertarget_op&& r)
|
streamfx::obs::gs::rendertarget_op::rendertarget_op(streamfx::obs::gs::rendertarget_op&& r)
|
||||||
{
|
{
|
||||||
this->parent = r.parent;
|
this->parent = r.parent;
|
||||||
r.parent = nullptr;
|
r.parent = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::rendertarget_op::~rendertarget_op()
|
streamfx::obs::gs::rendertarget_op::~rendertarget_op()
|
||||||
{
|
{
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_texrender_end(parent->_render_target);
|
gs_texrender_end(parent->_render_target);
|
||||||
parent->_is_being_rendered = false;
|
parent->_is_being_rendered = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "gs-texture.hpp"
|
#include "gs-texture.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class rendertarget_op;
|
class rendertarget_op;
|
||||||
|
|
||||||
class rendertarget {
|
class rendertarget {
|
||||||
|
@ -41,35 +41,35 @@ namespace gs {
|
||||||
|
|
||||||
gs_texture_t* get_object();
|
gs_texture_t* get_object();
|
||||||
|
|
||||||
std::shared_ptr<gs::texture> get_texture();
|
std::shared_ptr<streamfx::obs::gs::texture> get_texture();
|
||||||
|
|
||||||
void get_texture(gs::texture& tex);
|
void get_texture(streamfx::obs::gs::texture& tex);
|
||||||
|
|
||||||
void get_texture(std::shared_ptr<gs::texture>& tex);
|
void get_texture(std::shared_ptr<streamfx::obs::gs::texture>& tex);
|
||||||
|
|
||||||
void get_texture(std::unique_ptr<gs::texture>& tex);
|
void get_texture(std::unique_ptr<streamfx::obs::gs::texture>& tex);
|
||||||
|
|
||||||
gs_color_format get_color_format();
|
gs_color_format get_color_format();
|
||||||
|
|
||||||
gs_zstencil_format get_zstencil_format();
|
gs_zstencil_format get_zstencil_format();
|
||||||
|
|
||||||
gs::rendertarget_op render(uint32_t width, uint32_t height);
|
streamfx::obs::gs::rendertarget_op render(uint32_t width, uint32_t height);
|
||||||
};
|
};
|
||||||
|
|
||||||
class rendertarget_op {
|
class rendertarget_op {
|
||||||
gs::rendertarget* parent;
|
streamfx::obs::gs::rendertarget* parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~rendertarget_op();
|
~rendertarget_op();
|
||||||
|
|
||||||
rendertarget_op(gs::rendertarget* rt, uint32_t width, uint32_t height);
|
rendertarget_op(streamfx::obs::gs::rendertarget* rt, uint32_t width, uint32_t height);
|
||||||
|
|
||||||
// Move Constructor
|
// Move Constructor
|
||||||
rendertarget_op(gs::rendertarget_op&&);
|
rendertarget_op(streamfx::obs::gs::rendertarget_op&&);
|
||||||
|
|
||||||
// Copy Constructor
|
// Copy Constructor
|
||||||
rendertarget_op(const gs::rendertarget_op&) = delete;
|
rendertarget_op(const streamfx::obs::gs::rendertarget_op&) = delete;
|
||||||
|
|
||||||
rendertarget_op& operator=(const gs::rendertarget_op& r) = delete;
|
rendertarget_op& operator=(const streamfx::obs::gs::rendertarget_op& r) = delete;
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -20,93 +20,93 @@
|
||||||
#include "gs-sampler.hpp"
|
#include "gs-sampler.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
gs::sampler::sampler()
|
streamfx::obs::gs::sampler::sampler()
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0};
|
_sampler_info = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0};
|
||||||
_sampler_state = nullptr;
|
_sampler_state = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::sampler::~sampler()
|
streamfx::obs::gs::sampler::~sampler()
|
||||||
{
|
{
|
||||||
if (_sampler_state)
|
if (_sampler_state)
|
||||||
gs_samplerstate_destroy(_sampler_state);
|
gs_samplerstate_destroy(_sampler_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::sampler::set_filter(gs_sample_filter v)
|
void streamfx::obs::gs::sampler::set_filter(gs_sample_filter v)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info.filter = v;
|
_sampler_info.filter = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_sample_filter gs::sampler::get_filter()
|
gs_sample_filter streamfx::obs::gs::sampler::get_filter()
|
||||||
{
|
{
|
||||||
return _sampler_info.filter;
|
return _sampler_info.filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::sampler::set_address_mode_u(gs_address_mode v)
|
void streamfx::obs::gs::sampler::set_address_mode_u(gs_address_mode v)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info.address_u = v;
|
_sampler_info.address_u = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_address_mode gs::sampler::get_address_mode_u()
|
gs_address_mode streamfx::obs::gs::sampler::get_address_mode_u()
|
||||||
{
|
{
|
||||||
return _sampler_info.address_u;
|
return _sampler_info.address_u;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::sampler::set_address_mode_v(gs_address_mode v)
|
void streamfx::obs::gs::sampler::set_address_mode_v(gs_address_mode v)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info.address_v = v;
|
_sampler_info.address_v = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_address_mode gs::sampler::get_address_mode_v()
|
gs_address_mode streamfx::obs::gs::sampler::get_address_mode_v()
|
||||||
{
|
{
|
||||||
return _sampler_info.address_v;
|
return _sampler_info.address_v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::sampler::set_address_mode_w(gs_address_mode v)
|
void streamfx::obs::gs::sampler::set_address_mode_w(gs_address_mode v)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info.address_w = v;
|
_sampler_info.address_w = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_address_mode gs::sampler::get_address_mode_w()
|
gs_address_mode streamfx::obs::gs::sampler::get_address_mode_w()
|
||||||
{
|
{
|
||||||
return _sampler_info.address_w;
|
return _sampler_info.address_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::sampler::set_max_anisotropy(int32_t v)
|
void streamfx::obs::gs::sampler::set_max_anisotropy(int32_t v)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info.max_anisotropy = v;
|
_sampler_info.max_anisotropy = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t gs::sampler::get_max_anisotropy()
|
int32_t streamfx::obs::gs::sampler::get_max_anisotropy()
|
||||||
{
|
{
|
||||||
return _sampler_info.max_anisotropy;
|
return _sampler_info.max_anisotropy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::sampler::set_border_color(uint32_t v)
|
void streamfx::obs::gs::sampler::set_border_color(uint32_t v)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info.border_color = v;
|
_sampler_info.border_color = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
void streamfx::obs::gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
_sampler_info.border_color = (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(r) << 16)
|
_sampler_info.border_color = (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(r) << 16)
|
||||||
| (static_cast<uint32_t>(g) << 8) | static_cast<uint32_t>(b);
|
| (static_cast<uint32_t>(g) << 8) | static_cast<uint32_t>(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gs::sampler::get_border_color()
|
uint32_t streamfx::obs::gs::sampler::get_border_color()
|
||||||
{
|
{
|
||||||
return _sampler_info.border_color;
|
return _sampler_info.border_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t gs::sampler::get_border_color(bool r, bool g, bool b, bool a)
|
uint8_t streamfx::obs::gs::sampler::get_border_color(bool r, bool g, bool b, bool a)
|
||||||
{
|
{
|
||||||
if (a)
|
if (a)
|
||||||
return (_sampler_info.border_color >> 24) & 0xFF;
|
return (_sampler_info.border_color >> 24) & 0xFF;
|
||||||
|
@ -119,7 +119,7 @@ uint8_t gs::sampler::get_border_color(bool r, bool g, bool b, bool a)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_sampler_state* gs::sampler::refresh()
|
gs_sampler_state* streamfx::obs::gs::sampler::refresh()
|
||||||
{
|
{
|
||||||
gs_samplerstate_destroy(_sampler_state);
|
gs_samplerstate_destroy(_sampler_state);
|
||||||
_sampler_state = gs_samplerstate_create(&_sampler_info);
|
_sampler_state = gs_samplerstate_create(&_sampler_info);
|
||||||
|
@ -127,7 +127,7 @@ gs_sampler_state* gs::sampler::refresh()
|
||||||
return _sampler_state;
|
return _sampler_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_sampler_state* gs::sampler::get_object()
|
gs_sampler_state* streamfx::obs::gs::sampler::get_object()
|
||||||
{
|
{
|
||||||
if (_dirty)
|
if (_dirty)
|
||||||
return refresh();
|
return refresh();
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class sampler {
|
class sampler {
|
||||||
public:
|
public:
|
||||||
sampler();
|
sampler();
|
||||||
|
@ -55,4 +55,4 @@ namespace gs {
|
||||||
gs_sampler_info _sampler_info;
|
gs_sampler_info _sampler_info;
|
||||||
gs_sampler_state* _sampler_state;
|
gs_sampler_state* _sampler_state;
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -23,22 +23,22 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
|
|
||||||
static uint32_t decode_flags(gs::texture::flags texture_flags)
|
static uint32_t decode_flags(streamfx::obs::gs::texture::flags texture_flags)
|
||||||
{
|
{
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
if (has(texture_flags, gs::texture::flags::Dynamic))
|
if (has(texture_flags, streamfx::obs::gs::texture::flags::Dynamic))
|
||||||
flags |= GS_DYNAMIC;
|
flags |= GS_DYNAMIC;
|
||||||
if (has(texture_flags, gs::texture::flags::BuildMipMaps))
|
if (has(texture_flags, streamfx::obs::gs::texture::flags::BuildMipMaps))
|
||||||
flags |= GS_BUILD_MIPMAPS;
|
flags |= GS_BUILD_MIPMAPS;
|
||||||
if (has(texture_flags, gs::texture::flags::Shared))
|
if (has(texture_flags, streamfx::obs::gs::texture::flags::Shared))
|
||||||
flags |= GS_SHARED_TEX;
|
flags |= GS_SHARED_TEX;
|
||||||
if (has(texture_flags, gs::texture::flags::GlobalShared))
|
if (has(texture_flags, streamfx::obs::gs::texture::flags::GlobalShared))
|
||||||
flags |= GS_SHARED_KM_TEX;
|
flags |= GS_SHARED_KM_TEX;
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels,
|
streamfx::obs::gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels,
|
||||||
const uint8_t** mip_data, gs::texture::flags texture_flags)
|
const uint8_t** mip_data, streamfx::obs::gs::texture::flags texture_flags)
|
||||||
{
|
{
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
throw std::logic_error("width must be at least 1");
|
throw std::logic_error("width must be at least 1");
|
||||||
|
@ -54,7 +54,7 @@ gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, ui
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_texture = gs_texture_create(width, height, format, mip_levels, mip_data, decode_flags(texture_flags));
|
_texture = gs_texture_create(width, height, format, mip_levels, mip_data, decode_flags(texture_flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,9 @@ gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, ui
|
||||||
_type = type::Normal;
|
_type = type::Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels,
|
streamfx::obs::gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format,
|
||||||
const uint8_t** mip_data, gs::texture::flags texture_flags)
|
uint32_t mip_levels, const uint8_t** mip_data,
|
||||||
|
streamfx::obs::gs::texture::flags texture_flags)
|
||||||
{
|
{
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
throw std::logic_error("width must be at least 1");
|
throw std::logic_error("width must be at least 1");
|
||||||
|
@ -86,7 +87,7 @@ gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_texture =
|
_texture =
|
||||||
gs_voltexture_create(width, height, depth, format, mip_levels, mip_data, decode_flags(texture_flags));
|
gs_voltexture_create(width, height, depth, format, mip_levels, mip_data, decode_flags(texture_flags));
|
||||||
}
|
}
|
||||||
|
@ -97,8 +98,8 @@ gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f
|
||||||
_type = type::Volume;
|
_type = type::Volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
|
streamfx::obs::gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels,
|
||||||
gs::texture::flags texture_flags)
|
const uint8_t** mip_data, streamfx::obs::gs::texture::flags texture_flags)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
throw std::logic_error("size must be at least 1");
|
throw std::logic_error("size must be at least 1");
|
||||||
|
@ -112,7 +113,7 @@ gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels,
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_texture = gs_cubetexture_create(size, format, mip_levels, mip_data, decode_flags(texture_flags));
|
_texture = gs_cubetexture_create(size, format, mip_levels, mip_data, decode_flags(texture_flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,23 +123,23 @@ gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels,
|
||||||
_type = type::Cube;
|
_type = type::Cube;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::texture::texture(std::string file)
|
streamfx::obs::gs::texture::texture(std::string file)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (os_stat(file.c_str(), &st) != 0)
|
if (os_stat(file.c_str(), &st) != 0)
|
||||||
throw std::ios_base::failure(file);
|
throw std::ios_base::failure(file);
|
||||||
|
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_texture = gs_texture_create_from_file(file.c_str());
|
_texture = gs_texture_create_from_file(file.c_str());
|
||||||
|
|
||||||
if (!_texture)
|
if (!_texture)
|
||||||
throw std::runtime_error("Failed to load texture.");
|
throw std::runtime_error("Failed to load texture.");
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::texture::~texture()
|
streamfx::obs::gs::texture::~texture()
|
||||||
{
|
{
|
||||||
if (_is_owner && _texture) {
|
if (_is_owner && _texture) {
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
switch (gs_get_texture_type(_texture)) {
|
switch (gs_get_texture_type(_texture)) {
|
||||||
case GS_TEXTURE_2D:
|
case GS_TEXTURE_2D:
|
||||||
gs_texture_destroy(_texture);
|
gs_texture_destroy(_texture);
|
||||||
|
@ -154,18 +155,18 @@ gs::texture::~texture()
|
||||||
_texture = nullptr;
|
_texture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::texture::load(int32_t unit)
|
void streamfx::obs::gs::texture::load(int32_t unit)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_load_texture(_texture, unit);
|
gs_load_texture(_texture, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_texture_t* gs::texture::get_object()
|
gs_texture_t* streamfx::obs::gs::texture::get_object()
|
||||||
{
|
{
|
||||||
return _texture;
|
return _texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gs::texture::get_width()
|
uint32_t streamfx::obs::gs::texture::get_width()
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case type::Normal:
|
case type::Normal:
|
||||||
|
@ -178,7 +179,7 @@ uint32_t gs::texture::get_width()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gs::texture::get_height()
|
uint32_t streamfx::obs::gs::texture::get_height()
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case type::Normal:
|
case type::Normal:
|
||||||
|
@ -191,7 +192,7 @@ uint32_t gs::texture::get_height()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gs::texture::get_depth()
|
uint32_t streamfx::obs::gs::texture::get_depth()
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case type::Normal:
|
case type::Normal:
|
||||||
|
@ -204,12 +205,12 @@ uint32_t gs::texture::get_depth()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::texture::type gs::texture::get_type()
|
streamfx::obs::gs::texture::type streamfx::obs::gs::texture::get_type()
|
||||||
{
|
{
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_color_format gs::texture::get_color_format()
|
gs_color_format streamfx::obs::gs::texture::get_color_format()
|
||||||
{
|
{
|
||||||
return gs_texture_get_color_format(_texture);
|
return gs_texture_get_color_format(_texture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class texture {
|
class texture {
|
||||||
public:
|
public:
|
||||||
enum class type : uint8_t { Normal, Volume, Cube };
|
enum class type : uint8_t { Normal, Volume, Cube };
|
||||||
|
@ -52,7 +52,7 @@ namespace gs {
|
||||||
* \param texture_flags Texture Flags
|
* \param texture_flags Texture Flags
|
||||||
*/
|
*/
|
||||||
texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
|
texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
|
||||||
gs::texture::flags texture_flags);
|
streamfx::obs::gs::texture::flags texture_flags);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Create a 3D Texture
|
* \brief Create a 3D Texture
|
||||||
|
@ -66,7 +66,7 @@ namespace gs {
|
||||||
* \param texture_flags Texture Flags
|
* \param texture_flags Texture Flags
|
||||||
*/
|
*/
|
||||||
texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels,
|
texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels,
|
||||||
const uint8_t** mip_data, gs::texture::flags texture_flags);
|
const uint8_t** mip_data, streamfx::obs::gs::texture::flags texture_flags);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Create a Cube Texture
|
* \brief Create a Cube Texture
|
||||||
|
@ -78,7 +78,7 @@ namespace gs {
|
||||||
* \param texture_flags Texture Flags
|
* \param texture_flags Texture Flags
|
||||||
*/
|
*/
|
||||||
texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
|
texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data,
|
||||||
gs::texture::flags texture_flags);
|
streamfx::obs::gs::texture::flags texture_flags);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Load a texture from a file
|
* \brief Load a texture from a file
|
||||||
|
@ -107,10 +107,10 @@ namespace gs {
|
||||||
|
|
||||||
uint32_t get_depth();
|
uint32_t get_depth();
|
||||||
|
|
||||||
gs::texture::type get_type();
|
streamfx::obs::gs::texture::type get_type();
|
||||||
|
|
||||||
gs_color_format get_color_format();
|
gs_color_format get_color_format();
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
||||||
P_ENABLE_BITMASK_OPERATORS(gs::texture::flags)
|
P_ENABLE_BITMASK_OPERATORS(streamfx::obs::gs::texture::flags)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "gs-vertex.hpp"
|
#include "gs-vertex.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
gs::vertex::vertex()
|
streamfx::obs::gs::vertex::vertex()
|
||||||
: position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), _has_store(true), _store(nullptr)
|
: position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), _has_store(true), _store(nullptr)
|
||||||
{
|
{
|
||||||
_store =
|
_store =
|
||||||
|
@ -46,14 +46,14 @@ gs::vertex::vertex()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex::~vertex()
|
streamfx::obs::gs::vertex::~vertex()
|
||||||
{
|
{
|
||||||
if (_has_store) {
|
if (_has_store) {
|
||||||
streamfx::util::free_aligned(_store);
|
streamfx::util::free_aligned(_store);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex::vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS])
|
streamfx::obs::gs::vertex::vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS])
|
||||||
: position(p), normal(n), tangent(t), color(col), _has_store(false)
|
: position(p), normal(n), tangent(t), color(col), _has_store(false)
|
||||||
{
|
{
|
||||||
if (uvs != nullptr) {
|
if (uvs != nullptr) {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "gs-limits.hpp"
|
#include "gs-limits.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
struct vertex {
|
struct vertex {
|
||||||
vec3* position;
|
vec3* position;
|
||||||
vec3* normal;
|
vec3* normal;
|
||||||
|
@ -37,4 +37,4 @@ namespace gs {
|
||||||
bool _has_store;
|
bool _has_store;
|
||||||
void* _store;
|
void* _store;
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
|
|
||||||
void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
|
void streamfx::obs::gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
|
||||||
{
|
{
|
||||||
finalize();
|
finalize();
|
||||||
|
|
||||||
|
@ -62,11 +62,11 @@ void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
|
||||||
|
|
||||||
// Allocate actual GPU vertex buffer.
|
// Allocate actual GPU vertex buffer.
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_buffer = decltype(_buffer)(gs_vertexbuffer_create(_data.get(), GS_DYNAMIC | GS_DUP_BUFFER),
|
_buffer = decltype(_buffer)(gs_vertexbuffer_create(_data.get(), GS_DYNAMIC | GS_DUP_BUFFER),
|
||||||
[this](gs_vertbuffer_t* v) {
|
[this](gs_vertbuffer_t* v) {
|
||||||
try {
|
try {
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_vertexbuffer_destroy(v);
|
gs_vertexbuffer_destroy(v);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (obs_get_version() < MAKE_SEMANTIC_VERSION(26, 0, 0)) {
|
if (obs_get_version() < MAKE_SEMANTIC_VERSION(26, 0, 0)) {
|
||||||
|
@ -83,7 +83,7 @@ void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::vertex_buffer::finalize()
|
void streamfx::obs::gs::vertex_buffer::finalize()
|
||||||
{
|
{
|
||||||
// Free data
|
// Free data
|
||||||
streamfx::util::free_aligned(_positions);
|
streamfx::util::free_aligned(_positions);
|
||||||
|
@ -99,12 +99,12 @@ void gs::vertex_buffer::finalize()
|
||||||
_data.reset();
|
_data.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex_buffer::~vertex_buffer()
|
streamfx::obs::gs::vertex_buffer::~vertex_buffer()
|
||||||
{
|
{
|
||||||
finalize();
|
finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex_buffer::vertex_buffer(uint32_t size, uint8_t layers)
|
streamfx::obs::gs::vertex_buffer::vertex_buffer(uint32_t size, uint8_t layers)
|
||||||
: _capacity(size), _size(size), _layers(layers),
|
: _capacity(size), _size(size), _layers(layers),
|
||||||
|
|
||||||
_buffer(nullptr), _data(nullptr),
|
_buffer(nullptr), _data(nullptr),
|
||||||
|
@ -116,7 +116,7 @@ gs::vertex_buffer::vertex_buffer(uint32_t size, uint8_t layers)
|
||||||
initialize(_size, _layers);
|
initialize(_size, _layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb)
|
streamfx::obs::gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb)
|
||||||
: _capacity(0), _size(0), _layers(0),
|
: _capacity(0), _size(0), _layers(0),
|
||||||
|
|
||||||
_buffer(nullptr), _data(nullptr),
|
_buffer(nullptr), _data(nullptr),
|
||||||
|
@ -125,7 +125,7 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb)
|
||||||
|
|
||||||
_obs_data(nullptr)
|
_obs_data(nullptr)
|
||||||
{
|
{
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_vb_data* vbd = gs_vertexbuffer_get_data(vb);
|
gs_vb_data* vbd = gs_vertexbuffer_get_data(vb);
|
||||||
if (!vbd)
|
if (!vbd)
|
||||||
throw std::runtime_error("vertex buffer with no data");
|
throw std::runtime_error("vertex buffer with no data");
|
||||||
|
@ -157,7 +157,8 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(other._capacity, other._layers)
|
streamfx::obs::gs::vertex_buffer::vertex_buffer(vertex_buffer const& other)
|
||||||
|
: vertex_buffer(other._capacity, other._layers)
|
||||||
{ // Copy Constructor
|
{ // Copy Constructor
|
||||||
memcpy(_positions, other._positions, _capacity * sizeof(vec3));
|
memcpy(_positions, other._positions, _capacity * sizeof(vec3));
|
||||||
memcpy(_normals, other._normals, _capacity * sizeof(vec3));
|
memcpy(_normals, other._normals, _capacity * sizeof(vec3));
|
||||||
|
@ -168,7 +169,7 @@ gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(oth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::vertex_buffer::operator=(vertex_buffer const& other)
|
void streamfx::obs::gs::vertex_buffer::operator=(vertex_buffer const& other)
|
||||||
{ // Copy operator
|
{ // Copy operator
|
||||||
initialize(other._capacity, other._layers);
|
initialize(other._capacity, other._layers);
|
||||||
_size = other._size;
|
_size = other._size;
|
||||||
|
@ -184,7 +185,7 @@ void gs::vertex_buffer::operator=(vertex_buffer const& other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other) noexcept
|
streamfx::obs::gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other) noexcept
|
||||||
{ // Move Constructor
|
{ // Move Constructor
|
||||||
_capacity = other._capacity;
|
_capacity = other._capacity;
|
||||||
_size = other._size;
|
_size = other._size;
|
||||||
|
@ -202,7 +203,7 @@ gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other) noexcept
|
||||||
_obs_data = other._obs_data;
|
_obs_data = other._obs_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::vertex_buffer::operator=(vertex_buffer const&& other)
|
void streamfx::obs::gs::vertex_buffer::operator=(vertex_buffer const&& other)
|
||||||
{ // Move Assignment
|
{ // Move Assignment
|
||||||
finalize();
|
finalize();
|
||||||
|
|
||||||
|
@ -222,7 +223,7 @@ void gs::vertex_buffer::operator=(vertex_buffer const&& other)
|
||||||
_obs_data = other._obs_data;
|
_obs_data = other._obs_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::vertex_buffer::resize(uint32_t size)
|
void streamfx::obs::gs::vertex_buffer::resize(uint32_t size)
|
||||||
{
|
{
|
||||||
if (size > _capacity) {
|
if (size > _capacity) {
|
||||||
throw std::out_of_range("size larger than capacity");
|
throw std::out_of_range("size larger than capacity");
|
||||||
|
@ -230,70 +231,70 @@ void gs::vertex_buffer::resize(uint32_t size)
|
||||||
_size = size;
|
_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gs::vertex_buffer::size()
|
uint32_t streamfx::obs::gs::vertex_buffer::size()
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gs::vertex_buffer::capacity()
|
uint32_t streamfx::obs::gs::vertex_buffer::capacity()
|
||||||
{
|
{
|
||||||
return _capacity;
|
return _capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gs::vertex_buffer::empty()
|
bool streamfx::obs::gs::vertex_buffer::empty()
|
||||||
{
|
{
|
||||||
return _size == 0;
|
return _size == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gs::vertex gs::vertex_buffer::at(uint32_t idx)
|
const streamfx::obs::gs::vertex streamfx::obs::gs::vertex_buffer::at(uint32_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= _size) {
|
if (idx >= _size) {
|
||||||
throw std::out_of_range("idx out of range");
|
throw std::out_of_range("idx out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
gs::vertex vtx(&_positions[idx], &_normals[idx], &_tangents[idx], &_colors[idx], nullptr);
|
streamfx::obs::gs::vertex vtx(&_positions[idx], &_normals[idx], &_tangents[idx], &_colors[idx], nullptr);
|
||||||
for (std::size_t n = 0; n < _layers; n++) {
|
for (std::size_t n = 0; n < _layers; n++) {
|
||||||
vtx.uv[n] = &_uvs[n][idx];
|
vtx.uv[n] = &_uvs[n][idx];
|
||||||
}
|
}
|
||||||
return vtx;
|
return vtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gs::vertex gs::vertex_buffer::operator[](uint32_t const pos)
|
const streamfx::obs::gs::vertex streamfx::obs::gs::vertex_buffer::operator[](uint32_t const pos)
|
||||||
{
|
{
|
||||||
return at(pos);
|
return at(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs::vertex_buffer::set_uv_layers(uint8_t layers)
|
void streamfx::obs::gs::vertex_buffer::set_uv_layers(uint8_t layers)
|
||||||
{
|
{
|
||||||
_layers = layers;
|
_layers = layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t gs::vertex_buffer::get_uv_layers()
|
uint8_t streamfx::obs::gs::vertex_buffer::get_uv_layers()
|
||||||
{
|
{
|
||||||
return _layers;
|
return _layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3* gs::vertex_buffer::get_positions()
|
vec3* streamfx::obs::gs::vertex_buffer::get_positions()
|
||||||
{
|
{
|
||||||
return _positions;
|
return _positions;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3* gs::vertex_buffer::get_normals()
|
vec3* streamfx::obs::gs::vertex_buffer::get_normals()
|
||||||
{
|
{
|
||||||
return _normals;
|
return _normals;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3* gs::vertex_buffer::get_tangents()
|
vec3* streamfx::obs::gs::vertex_buffer::get_tangents()
|
||||||
{
|
{
|
||||||
return _tangents;
|
return _tangents;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t* gs::vertex_buffer::get_colors()
|
uint32_t* streamfx::obs::gs::vertex_buffer::get_colors()
|
||||||
{
|
{
|
||||||
return _colors;
|
return _colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4* gs::vertex_buffer::get_uv_layer(uint8_t idx)
|
vec4* streamfx::obs::gs::vertex_buffer::get_uv_layer(uint8_t idx)
|
||||||
{
|
{
|
||||||
if (idx >= _layers) {
|
if (idx >= _layers) {
|
||||||
throw std::out_of_range("idx out of range");
|
throw std::out_of_range("idx out of range");
|
||||||
|
@ -301,17 +302,17 @@ vec4* gs::vertex_buffer::get_uv_layer(uint8_t idx)
|
||||||
return _uvs[idx];
|
return _uvs[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU)
|
gs_vertbuffer_t* streamfx::obs::gs::vertex_buffer::update(bool refreshGPU)
|
||||||
{
|
{
|
||||||
if (refreshGPU) {
|
if (refreshGPU) {
|
||||||
auto gctx = gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
gs_vertexbuffer_flush_direct(_buffer.get(), _data.get());
|
gs_vertexbuffer_flush_direct(_buffer.get(), _data.get());
|
||||||
_obs_data = gs_vertexbuffer_get_data(_buffer.get());
|
_obs_data = gs_vertexbuffer_get_data(_buffer.get());
|
||||||
}
|
}
|
||||||
return _buffer.get();
|
return _buffer.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
gs_vertbuffer_t* gs::vertex_buffer::update()
|
gs_vertbuffer_t* streamfx::obs::gs::vertex_buffer::update()
|
||||||
{
|
{
|
||||||
return update(true);
|
return update(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "gs-limits.hpp"
|
#include "gs-limits.hpp"
|
||||||
#include "gs-vertex.hpp"
|
#include "gs-vertex.hpp"
|
||||||
|
|
||||||
namespace gs {
|
namespace streamfx::obs::gs {
|
||||||
class vertex_buffer {
|
class vertex_buffer {
|
||||||
uint32_t _capacity;
|
uint32_t _capacity;
|
||||||
uint32_t _size;
|
uint32_t _size;
|
||||||
|
@ -121,9 +121,9 @@ namespace gs {
|
||||||
|
|
||||||
bool empty();
|
bool empty();
|
||||||
|
|
||||||
const gs::vertex at(uint32_t idx);
|
const streamfx::obs::gs::vertex at(uint32_t idx);
|
||||||
|
|
||||||
const gs::vertex operator[](uint32_t const pos);
|
const streamfx::obs::gs::vertex operator[](uint32_t const pos);
|
||||||
|
|
||||||
void set_uv_layers(uint8_t layers);
|
void set_uv_layers(uint8_t layers);
|
||||||
|
|
||||||
|
@ -173,4 +173,4 @@ namespace gs {
|
||||||
|
|
||||||
gs_vertbuffer_t* update(bool refreshGPU);
|
gs_vertbuffer_t* update(bool refreshGPU);
|
||||||
};
|
};
|
||||||
} // namespace gs
|
} // namespace streamfx::obs::gs
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static std::shared_ptr<streamfx::util::threadpool> _threadpool;
|
static std::shared_ptr<streamfx::util::threadpool> _threadpool;
|
||||||
static std::shared_ptr<gs::vertex_buffer> _gs_fstri_vb;
|
static std::shared_ptr<streamfx::obs::gs::vertex_buffer> _gs_fstri_vb;
|
||||||
|
|
||||||
MODULE_EXPORT bool obs_module_load(void)
|
MODULE_EXPORT bool obs_module_load(void)
|
||||||
try {
|
try {
|
||||||
|
@ -91,7 +91,7 @@ try {
|
||||||
|
|
||||||
// GS Stuff
|
// GS Stuff
|
||||||
{
|
{
|
||||||
_gs_fstri_vb = std::make_shared<gs::vertex_buffer>(uint32_t(3), uint8_t(1));
|
_gs_fstri_vb = std::make_shared<streamfx::obs::gs::vertex_buffer>(uint32_t(3), uint8_t(1));
|
||||||
{
|
{
|
||||||
auto vtx = _gs_fstri_vb->at(0);
|
auto vtx = _gs_fstri_vb->at(0);
|
||||||
vec3_set(vtx.position, 0, 0, 0);
|
vec3_set(vtx.position, 0, 0, 0);
|
||||||
|
|
|
@ -143,8 +143,8 @@ void mirror_instance::video_render(gs_effect_t* effect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Source Mirror '%s' for '%s'", obs_source_get_name(_self),
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Source Mirror '%s' for '%s'",
|
||||||
obs_source_get_name(_source.get())};
|
obs_source_get_name(_self), obs_source_get_name(_source.get())};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_source_size.first = obs_source_get_width(_source.get());
|
_source_size.first = obs_source_get_width(_source.get());
|
||||||
|
|
|
@ -83,7 +83,8 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Shader Source '%s'", obs_source_get_name(_self)};
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Shader Source '%s'",
|
||||||
|
obs_source_get_name(_self)};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_fx->prepare_render();
|
_fx->prepare_render();
|
||||||
|
|
|
@ -84,7 +84,8 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
gs::debug_marker gdmp{gs::debug_color_source, "Shader Transition '%s'", obs_source_get_name(_self)};
|
streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Shader Transition '%s'",
|
||||||
|
obs_source_get_name(_self)};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
obs_transition_video_render(_self,
|
obs_transition_video_render(_self,
|
||||||
|
@ -95,8 +96,8 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
void shader_instance::transition_render(gs_texture_t* a, gs_texture_t* b, float_t t, uint32_t cx, uint32_t cy)
|
void shader_instance::transition_render(gs_texture_t* a, gs_texture_t* b, float_t t, uint32_t cx, uint32_t cy)
|
||||||
{
|
{
|
||||||
_fx->set_input_a(std::make_shared<::gs::texture>(a, false));
|
_fx->set_input_a(std::make_shared<::streamfx::obs::gs::texture>(a, false));
|
||||||
_fx->set_input_b(std::make_shared<::gs::texture>(b, false));
|
_fx->set_input_b(std::make_shared<::streamfx::obs::gs::texture>(b, false));
|
||||||
_fx->set_transition_time(t);
|
_fx->set_transition_time(t);
|
||||||
_fx->set_transition_size(cx, cy);
|
_fx->set_transition_size(cx, cy);
|
||||||
_fx->prepare_render();
|
_fx->prepare_render();
|
||||||
|
|
Loading…
Reference in a new issue