From c84c301d49b61744ca33ea1effce14dc640e8a74 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Tue, 8 Jun 2021 04:38:24 +0200 Subject: [PATCH] obs/gs: Apply coding guidelines --- source/encoders/encoder-ffmpeg.cpp | 10 +- source/ffmpeg/hwapi/d3d11.cpp | 8 +- source/filters/filter-blur.cpp | 27 ++-- source/filters/filter-blur.hpp | 33 ++--- source/filters/filter-color-grade.cpp | 22 +-- source/filters/filter-color-grade.hpp | 26 ++-- source/filters/filter-displacement.cpp | 8 +- source/filters/filter-displacement.hpp | 10 +- source/filters/filter-dynamic-mask.cpp | 22 +-- source/filters/filter-dynamic-mask.hpp | 16 +-- source/filters/filter-nv-face-tracking.cpp | 44 +++--- source/filters/filter-nv-face-tracking.hpp | 38 ++--- source/filters/filter-sdf-effects.cpp | 32 +++-- source/filters/filter-sdf-effects.hpp | 26 ++-- source/filters/filter-shader.cpp | 11 +- source/filters/filter-shader.hpp | 4 +- source/filters/filter-transform.cpp | 26 ++-- source/filters/filter-transform.hpp | 36 ++--- source/gfx/blur/gfx-blur-base.hpp | 6 +- source/gfx/blur/gfx-blur-box-linear.cpp | 38 ++--- source/gfx/blur/gfx-blur-box-linear.hpp | 22 +-- source/gfx/blur/gfx-blur-box.cpp | 54 +++---- source/gfx/blur/gfx-blur-box.hpp | 26 ++-- source/gfx/blur/gfx-blur-dual-filtering.cpp | 31 ++-- source/gfx/blur/gfx-blur-dual-filtering.hpp | 14 +- source/gfx/blur/gfx-blur-gaussian-linear.cpp | 42 +++--- source/gfx/blur/gfx-blur-gaussian-linear.hpp | 22 +-- source/gfx/blur/gfx-blur-gaussian.cpp | 64 +++++---- source/gfx/blur/gfx-blur-gaussian.hpp | 26 ++-- source/gfx/gfx-source-texture.cpp | 12 +- source/gfx/gfx-source-texture.hpp | 4 +- source/gfx/lut/gfx-lut-consumer.cpp | 19 +-- source/gfx/lut/gfx-lut-consumer.hpp | 7 +- source/gfx/lut/gfx-lut-producer.cpp | 8 +- source/gfx/lut/gfx-lut-producer.hpp | 6 +- source/gfx/lut/gfx-lut.cpp | 8 +- source/gfx/lut/gfx-lut.hpp | 8 +- source/gfx/shader/gfx-shader-param-basic.cpp | 18 +-- source/gfx/shader/gfx-shader-param-basic.hpp | 10 +- source/gfx/shader/gfx-shader-param.cpp | 12 +- source/gfx/shader/gfx-shader-param.hpp | 13 +- source/gfx/shader/gfx-shader.cpp | 34 ++--- source/gfx/shader/gfx-shader.hpp | 10 +- source/nvidia/cuda/nvidia-cuda-gs-texture.cpp | 14 +- source/nvidia/cuda/nvidia-cuda-gs-texture.hpp | 12 +- source/nvidia/cuda/nvidia-cuda-obs.cpp | 4 +- source/obs/gs/gs-effect-parameter.cpp | 132 +++++++++--------- source/obs/gs/gs-effect-parameter.hpp | 8 +- source/obs/gs/gs-effect-pass.cpp | 36 ++--- source/obs/gs/gs-effect-pass.hpp | 24 ++-- source/obs/gs/gs-effect-technique.cpp | 19 +-- source/obs/gs/gs-effect-technique.hpp | 12 +- source/obs/gs/gs-effect.cpp | 36 ++--- source/obs/gs/gs-effect.hpp | 30 ++-- source/obs/gs/gs-helper.hpp | 4 +- source/obs/gs/gs-indexbuffer.cpp | 21 +-- source/obs/gs/gs-indexbuffer.hpp | 4 +- source/obs/gs/gs-limits.hpp | 4 +- source/obs/gs/gs-mipmapper.cpp | 23 +-- source/obs/gs/gs-mipmapper.hpp | 13 +- source/obs/gs/gs-rendertarget.cpp | 46 +++--- source/obs/gs/gs-rendertarget.hpp | 24 ++-- source/obs/gs/gs-sampler.cpp | 36 ++--- source/obs/gs/gs-sampler.hpp | 4 +- source/obs/gs/gs-texture.cpp | 53 +++---- source/obs/gs/gs-texture.hpp | 14 +- source/obs/gs/gs-vertex.cpp | 6 +- source/obs/gs/gs-vertex.hpp | 4 +- source/obs/gs/gs-vertexbuffer.cpp | 59 ++++---- source/obs/gs/gs-vertexbuffer.hpp | 8 +- source/plugin.cpp | 6 +- source/sources/source-mirror.cpp | 4 +- source/sources/source-shader.cpp | 3 +- source/transitions/transition-shader.cpp | 7 +- 74 files changed, 810 insertions(+), 773 deletions(-) diff --git a/source/encoders/encoder-ffmpeg.cpp b/source/encoders/encoder-ffmpeg.cpp index b1e7c77c..bf718ec2 100644 --- a/source/encoders/encoder-ffmpeg.cpp +++ b/source/encoders/encoder-ffmpeg.cpp @@ -113,7 +113,7 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool } #ifdef WIN32 - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); if (gs_get_device_type() == GS_DEVICE_DIRECT3D_11) { _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); // Initialize Encoder - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); int res = avcodec_open2(_context, _codec, NULL); if (res < 0) { 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() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); if (_context) { // Flush encoders that require it. 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); { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); res = avcodec_receive_packet(_context, &_packet); } if (res != 0) { @@ -680,7 +680,7 @@ int ffmpeg_instance::send_frame(std::shared_ptr const frame) { int res = 0; { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); res = avcodec_send_frame(_context, frame.get()); } if (res == 0) { diff --git a/source/ffmpeg/hwapi/d3d11.cpp b/source/ffmpeg/hwapi/d3d11.cpp index 130a1db2..425aec43 100644 --- a/source/ffmpeg/hwapi/d3d11.cpp +++ b/source/ffmpeg/hwapi/d3d11.cpp @@ -137,7 +137,7 @@ std::shared_ptr d3d11::create(device target) std::shared_ptr d3d11::create_from_obs() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); if (GS_DEVICE_DIRECT3D_11 != gs_get_device_type()) { throw std::runtime_error("OBS Device is not a D3D11 Device."); @@ -189,7 +189,7 @@ AVBufferRef* d3d11_instance::create_device_context() std::shared_ptr d3d11_instance::allocate_frame(AVBufferRef* frames) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); // Allocate a frame. auto frame = std::shared_ptr(av_frame_alloc(), [](AVFrame* frame) { @@ -211,7 +211,7 @@ std::shared_ptr 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, std::shared_ptr frame) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); // Attempt to acquire shared texture. ATL::CComPtr input; @@ -254,7 +254,7 @@ void d3d11_instance::copy_from_obs(AVBufferRef*, uint32_t handle, uint64_t lock_ std::shared_ptr d3d11_instance::avframe_from_obs(AVBufferRef* frames, uint32_t handle, uint64_t lock_key, uint64_t* next_lock_key) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); auto frame = this->allocate_frame(frames); this->copy_from_obs(frames, handle, lock_key, next_lock_key, frame); diff --git a/source/filters/filter-blur.cpp b/source/filters/filter-blur.cpp index 8ee454d5..42458fb9 100644 --- a/source/filters/filter-blur.cpp +++ b/source/filters/filter-blur.cpp @@ -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) { { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); // Create RenderTargets - this->_source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - this->_output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); // Load Effects { auto file = streamfx::data_file_path("effects/mask.effect").string(); try { - _effect_mask = gs::effect::create(file); + _effect_mask = streamfx::obs::gs::effect::create(file); } catch (std::runtime_error& ex) { DLOG_ERROR(" 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() {} -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) { if (effect.has_parameter("image_orig")) { @@ -328,7 +328,7 @@ void blur_instance::video_tick(float) if (_mask.type == mask_type::Image) { if (_mask.image.path_old != _mask.image.path) { try { - _mask.image.texture = std::make_shared(_mask.image.path); + _mask.image.texture = std::make_shared(_mask.image.path); _mask.image.path_old = _mask.image.path; } catch (...) { DLOG_ERROR(" 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 - 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 if (!_source_rendered) { // Source To Texture { #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 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) { { #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 _blur->set_input(_source_texture); @@ -434,7 +435,7 @@ void blur_instance::video_render(gs_effect_t* effect) // Mask if (_mask.enabled) { #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 gs_blend_state_push(); @@ -492,8 +493,8 @@ void blur_instance::video_render(gs_effect_t* effect) } #ifdef ENABLE_PROFILING - gs::debug_marker gdm{gs::debug_color_capture, "Capture '%s'", - obs_source_get_name(_mask.source.source_texture->get_object())}; + streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_capture, "Capture '%s'", + obs_source_get_name(_mask.source.source_texture->get_object())}; #endif this->_mask.source.texture = this->_mask.source.source_texture->render(source_width, source_height); @@ -528,7 +529,7 @@ void blur_instance::video_render(gs_effect_t* effect) // Draw source { #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 // It is important that we do not modify the blend state here, as it is set correctly by OBS diff --git a/source/filters/filter-blur.hpp b/source/filters/filter-blur.hpp index 2db15e97..8c6770e8 100644 --- a/source/filters/filter-blur.hpp +++ b/source/filters/filter-blur.hpp @@ -40,17 +40,17 @@ namespace streamfx::filter::blur { class blur_instance : public obs::source_instance { // Effects - gs::effect _effect_mask; + streamfx::obs::gs::effect _effect_mask; // Input - std::shared_ptr _source_rt; - std::shared_ptr _source_texture; - bool _source_rendered; + std::shared_ptr _source_rt; + std::shared_ptr _source_texture; + bool _source_rendered; // Rendering - std::shared_ptr _output_texture; - std::shared_ptr _output_rt; - bool _output_rendered; + std::shared_ptr _output_texture; + std::shared_ptr _output_rt; + bool _output_rendered; // Blur std::shared_ptr<::gfx::blur::base> _blur; @@ -74,16 +74,16 @@ namespace streamfx::filter::blur { bool invert; } region; struct { - std::string path; - std::string path_old; - std::shared_ptr texture; + std::string path; + std::string path_old; + std::shared_ptr texture; } image; struct { - std::string name_old; - std::string name; - bool is_scene; - std::shared_ptr source_texture; - std::shared_ptr texture; + std::string name_old; + std::string name; + bool is_scene; + std::shared_ptr source_texture; + std::shared_ptr texture; } source; struct { float_t r; @@ -107,7 +107,8 @@ namespace streamfx::filter::blur { virtual void video_render(gs_effect_t* effect) override; 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 { diff --git a/source/filters/filter-color-grade.cpp b/source/filters/filter-color-grade.cpp index 817cc3c2..49ab6b14 100644 --- a/source/filters/filter-color-grade.cpp +++ b/source/filters/filter-color-grade.cpp @@ -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."); } else { try { - _effect = gs::effect::create(path.u8string()); + _effect = streamfx::obs::gs::effect::create(path.u8string()); } catch (std::exception const& ex) { DLOG_ERROR(LOCAL_PREFIX "Failed to load effect '%s': %s", path.u8string().c_str(), ex.what()); 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) { - _cache_rt = std::make_unique(format, GS_ZS_NONE); + _cache_rt = std::make_unique(format, GS_ZS_NONE); } float_t fix_gamma_value(double_t v) @@ -287,7 +287,7 @@ void color_grade_instance::prepare_effect() void color_grade_instance::rebuild_lut() { #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 // 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. if (!_lut_rt || (lut_texture->get_color_format() != _lut_rt->get_color_format())) { // Create a new render target with new format. - _lut_rt = std::make_unique(lut_texture->get_color_format(), GS_ZS_NONE); + _lut_rt = std::make_unique(lut_texture->get_color_format(), GS_ZS_NONE); } // Prepare our color grade effect. @@ -361,7 +361,8 @@ void color_grade_instance::video_render(gs_effect_t* shader) } #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 // 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. if (!_ccache_fresh || !_ccache_texture) { #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 // If the input cache render target doesn't exist, create it. if (!_ccache_rt) { - _ccache_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _ccache_rt = std::make_shared(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. try { #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 // If the LUT was changed, rebuild the LUT first. if (_lut_dirty) { @@ -491,7 +493,7 @@ void color_grade_instance::video_render(gs_effect_t* shader) } if ((!_lut_initialized || !_lut_enabled) && !_cache_fresh) { #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 // Reallocate the rendertarget if necessary. 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. { #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 // Revert GPU status to what OBS Studio expects. gs_enable_depth_test(false); diff --git a/source/filters/filter-color-grade.hpp b/source/filters/filter-color-grade.hpp index f37fe401..0ef3e488 100644 --- a/source/filters/filter-color-grade.hpp +++ b/source/filters/filter-color-grade.hpp @@ -45,7 +45,7 @@ namespace streamfx::filter::color_grade { }; class color_grade_instance : public obs::source_instance { - gs::effect _effect; + streamfx::obs::gs::effect _effect; // User Configuration vec4 _lift; @@ -63,22 +63,22 @@ namespace streamfx::filter::color_grade { gfx::lut::color_depth _lut_depth; // Capture Cache - std::shared_ptr _ccache_rt; - std::shared_ptr _ccache_texture; - bool _ccache_fresh; + std::shared_ptr _ccache_rt; + std::shared_ptr _ccache_texture; + bool _ccache_fresh; // LUT work flow - bool _lut_initialized; - bool _lut_dirty; - std::shared_ptr _lut_producer; - std::shared_ptr _lut_consumer; - std::shared_ptr _lut_rt; - std::shared_ptr _lut_texture; + bool _lut_initialized; + bool _lut_dirty; + std::shared_ptr _lut_producer; + std::shared_ptr _lut_consumer; + std::shared_ptr _lut_rt; + std::shared_ptr _lut_texture; // Render Cache - std::shared_ptr _cache_rt; - std::shared_ptr _cache_texture; - bool _cache_fresh; + std::shared_ptr _cache_rt; + std::shared_ptr _cache_texture; + bool _cache_fresh; public: color_grade_instance(obs_data_t* data, obs_source_t* self); diff --git a/source/filters/filter-displacement.cpp b/source/filters/filter-displacement.cpp index cbd4daeb..4432af8f 100644 --- a/source/filters/filter-displacement.cpp +++ b/source/filters/filter-displacement.cpp @@ -33,7 +33,7 @@ using namespace streamfx::filter::displacement; displacement_instance::displacement_instance(obs_data_t* data, obs_source_t* 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); } @@ -68,7 +68,7 @@ void displacement_instance::update(obs_data_t* settings) std::string new_file = obs_data_get_string(settings, ST_FILE); if (new_file != _texture_file) { try { - _texture = std::make_shared(new_file); + _texture = std::make_shared(new_file); _texture_file = new_file; } catch (...) { _texture.reset(); @@ -90,8 +90,8 @@ void displacement_instance::video_render(gs_effect_t*) } #ifdef ENABLE_PROFILING - gs::debug_marker gdmp{gs::debug_color_source, "Displacement Mapping '%s' on '%s'", obs_source_get_name(_self), - obs_source_get_name(obs_filter_get_parent(_self))}; + streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Displacement Mapping '%s' on '%s'", + obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))}; #endif if (!obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { diff --git a/source/filters/filter-displacement.hpp b/source/filters/filter-displacement.hpp index 5501d936..3308413b 100644 --- a/source/filters/filter-displacement.hpp +++ b/source/filters/filter-displacement.hpp @@ -24,13 +24,13 @@ namespace streamfx::filter::displacement { class displacement_instance : public obs::source_instance { - gs::effect _effect; + streamfx::obs::gs::effect _effect; // Displacement Map - std::shared_ptr _texture; - std::string _texture_file; - float_t _scale[2]; - float_t _scale_type; + std::shared_ptr _texture; + std::string _texture_file; + float_t _scale[2]; + float_t _scale_type; // Cache uint32_t _width; diff --git a/source/filters/filter-dynamic-mask.cpp b/source/filters/filter-dynamic-mask.cpp index 9135fbf2..fbed8039 100644 --- a/source/filters/filter-dynamic-mask.cpp +++ b/source/filters/filter-dynamic-mask.cpp @@ -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(), _have_final_texture(false), _final_rt(), _final_texture(), _channels(), _precalc() { - _filter_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - _final_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _filter_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _final_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); 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) { 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. try { auto input = std::make_shared(obs_data_get_string(settings, ST_INPUT)); - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); auto capture = std::make_shared(input, _self); 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 - gs::debug_marker gdmp{gs::debug_color_source, "Dynamic Mask '%s' on '%s'", obs_source_get_name(_self), - obs_source_get_name(obs_filter_get_parent(_self))}; + streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Dynamic Mask '%s' on '%s'", + obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))}; #endif 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 if (!_have_filter_texture) { #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 if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { @@ -257,8 +257,8 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect) if (!_have_input_texture) { #ifdef ENABLE_PROFILING - gs::debug_marker gdm{gs::debug_color_capture, "Capture '%s'", - obs_source_get_name(_input_capture->get_object())}; + streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_capture, "Capture '%s'", + obs_source_get_name(_input_capture->get_object())}; #endif _input_texture = _input_capture->render(_input->width(), _input->height()); @@ -268,7 +268,7 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect) // Draw source if (!_have_final_texture) { #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 { @@ -325,7 +325,7 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect) // Draw source { #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 // It is important that we do not modify the blend state here, as it is set correctly by OBS diff --git a/source/filters/filter-dynamic-mask.hpp b/source/filters/filter-dynamic-mask.hpp index 0f552adf..34654fd5 100644 --- a/source/filters/filter-dynamic-mask.hpp +++ b/source/filters/filter-dynamic-mask.hpp @@ -34,22 +34,22 @@ namespace streamfx::filter::dynamic_mask { class dynamic_mask_instance : public obs::source_instance { std::map, std::string> _translation_map; - gs::effect _effect; + streamfx::obs::gs::effect _effect; - bool _have_filter_texture; - std::shared_ptr _filter_rt; - std::shared_ptr _filter_texture; + bool _have_filter_texture; + std::shared_ptr _filter_rt; + std::shared_ptr _filter_texture; bool _have_input_texture; std::shared_ptr _input; std::shared_ptr _input_capture; - std::shared_ptr _input_texture; + std::shared_ptr _input_texture; std::shared_ptr _input_vs; std::shared_ptr _input_ac; - bool _have_final_texture; - std::shared_ptr _final_rt; - std::shared_ptr _final_texture; + bool _have_final_texture; + std::shared_ptr _final_rt; + std::shared_ptr _final_texture; struct channel_data { float_t value = 0.0; diff --git a/source/filters/filter-nv-face-tracking.cpp b/source/filters/filter-nv-face-tracking.cpp index 5612c3a0..1e52a4b5 100644 --- a/source/filters/filter-nv-face-tracking.cpp +++ b/source/filters/filter-nv-face-tracking.cpp @@ -73,9 +73,9 @@ face_tracking_instance::face_tracking_instance(obs_data_t* settings, obs_source_ #endif { // Create render target, vertex buffer, and CUDA stream. - auto gctx = gs::context{}; - _rt = std::make_shared(GS_RGBA_UNORM, GS_ZS_NONE); - _geometry = std::make_shared(uint32_t(4), uint8_t(1)); + auto gctx = streamfx::obs::gs::context{}; + _rt = std::make_shared(GS_RGBA_UNORM, GS_ZS_NONE); + _geometry = std::make_shared(uint32_t(4), uint8_t(1)); auto cctx = _cuda->get_context()->enter(); _cuda_stream = std::make_shared<::nvidia::cuda::stream>(::nvidia::cuda::stream_flags::NON_BLOCKING, 0); } @@ -137,8 +137,8 @@ void face_tracking_instance::async_initialize(std::shared_ptr ptr) } // Update the current CUDA context for working. - gs::context gctx; - auto cctx = _cuda->get_context()->enter(); + streamfx::obs::gs::context gctx; + auto cctx = _cuda->get_context()->enter(); // Create Face Detection feature. { @@ -215,7 +215,7 @@ void face_tracking_instance::async_track(std::shared_ptr ptr) return; // Can't track a new frame right now. #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 // Don't push additional tracking frames while processing one. @@ -229,18 +229,20 @@ void face_tracking_instance::async_track(std::shared_ptr ptr) // Check if things exist as planned. if (!_ar_texture || (_ar_texture->get_width() != _size.first) || (_ar_texture->get_height() != _size.second)) { #ifdef ENABLE_PROFILING - auto prof = _profile_capture_realloc->track(); - gs::debug_marker marker{gs::debug_color_allocate, "Reallocate GPU Buffer"}; + auto prof = _profile_capture_realloc->track(); + streamfx::obs::gs::debug_marker marker{streamfx::obs::gs::debug_color_allocate, "Reallocate GPU Buffer"}; #endif - _ar_texture = std::make_shared(_size.first, _size.second, GS_RGBA_UNORM, uint32_t(1), nullptr, - gs::texture::flags::None); + _ar_texture = + std::make_shared(_size.first, _size.second, GS_RGBA_UNORM, uint32_t(1), + nullptr, streamfx::obs::gs::texture::flags::None); _ar_texture_cuda_fresh = false; } { // Copy texture #ifdef ENABLE_PROFILING - auto prof = _profile_capture_copy->track(); - gs::debug_marker marker{gs::debug_color_copy, "Copy Capture", obs_source_get_name(_self)}; + auto prof = _profile_capture_copy->track(); + streamfx::obs::gs::debug_marker marker{streamfx::obs::gs::debug_color_copy, "Copy Capture", + obs_source_get_name(_self)}; #endif 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 ptr) } // Acquire GS context. - gs::context gctx{}; + streamfx::obs::gs::context gctx{}; // Update the current CUDA context for working. auto cctx = _cuda->get_context()->enter(); @@ -271,9 +273,9 @@ void face_tracking_instance::async_track(std::shared_ptr ptr) // Refresh any now broken buffers. if (!_ar_texture_cuda_fresh) { #ifdef ENABLE_PROFILING - auto prof = _profile_ar_realloc->track(); - gs::debug_marker marker{gs::debug_color_allocate, "%s: Reallocate CUDA Buffers", - obs_source_get_name(_self)}; + auto prof = _profile_ar_realloc->track(); + streamfx::obs::gs::debug_marker marker{streamfx::obs::gs::debug_color_allocate, + "%s: Reallocate CUDA Buffers", obs_source_get_name(_self)}; #endif // Assign new texture and allocate new memory. 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 - gs::debug_marker gdmp{gs::debug_color_source, "NVIDIA Face Tracking '%s'...", obs_source_get_name(_self)}; - gs::debug_marker gdmp2{gs::debug_color_source, "... on '%s'", obs_source_get_name(obs_filter_get_parent(_self))}; + streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "NVIDIA Face Tracking '%s'...", + 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 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 - gs::debug_marker gdm{gs::debug_color_cache, "Cache"}; + streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_cache, "Cache"}; #endif 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 #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 gs_effect_set_texture(gs_effect_get_param_by_name(default_effect, "image"), _rt->get_texture()->get_object()); diff --git a/source/filters/filter-nv-face-tracking.hpp b/source/filters/filter-nv-face-tracking.hpp index 1c890765..c7925dcc 100644 --- a/source/filters/filter-nv-face-tracking.hpp +++ b/source/filters/filter-nv-face-tracking.hpp @@ -38,9 +38,9 @@ namespace streamfx::filter::nvidia { class face_tracking_instance : public obs::source_instance { // Filter Cache - std::pair _size; - bool _rt_is_fresh; - std::shared_ptr _rt; + std::pair _size; + bool _rt_is_fresh; + std::shared_ptr _rt; std::mutex _delete_protection; @@ -50,7 +50,7 @@ namespace streamfx::filter::nvidia { double_t _cfg_stability; // Operational Data - std::shared_ptr _geometry; + std::shared_ptr _geometry; struct { streamfx::util::math::kalman1D center[2]; streamfx::util::math::kalman1D size[2]; @@ -67,21 +67,21 @@ namespace streamfx::filter::nvidia { std::shared_ptr<::nvidia::cuda::stream> _cuda_stream; // Nvidia AR interop - std::shared_ptr<::nvidia::ar::ar> _ar_library; - std::atomic_bool _ar_loaded; - std::shared_ptr _ar_feature; - std::atomic_bool _ar_is_tracking; - std::mutex _ar_lock; - std::vector _ar_bboxes_confidence; - std::vector _ar_bboxes_data; - NvAR_BBoxes _ar_bboxes; - std::shared_ptr _ar_texture; - bool _ar_texture_cuda_fresh; - std::shared_ptr<::nvidia::cuda::gstexture> _ar_texture_cuda; - std::shared_ptr<::nvidia::cuda::memory> _ar_texture_cuda_mem; - NvCVImage _ar_image; - NvCVImage _ar_image_bgr; - NvCVImage _ar_image_temp; + std::shared_ptr<::nvidia::ar::ar> _ar_library; + std::atomic_bool _ar_loaded; + std::shared_ptr _ar_feature; + std::atomic_bool _ar_is_tracking; + std::mutex _ar_lock; + std::vector _ar_bboxes_confidence; + std::vector _ar_bboxes_data; + NvAR_BBoxes _ar_bboxes; + std::shared_ptr _ar_texture; + bool _ar_texture_cuda_fresh; + std::shared_ptr<::nvidia::cuda::gstexture> _ar_texture_cuda; + std::shared_ptr<::nvidia::cuda::memory> _ar_texture_cuda_mem; + NvCVImage _ar_image; + NvCVImage _ar_image_bgr; + NvCVImage _ar_image_temp; // Tasks std::shared_ptr<::streamfx::util::threadpool::task> _async_initialize; diff --git a/source/filters/filter-sdf-effects.cpp b/source/filters/filter-sdf-effects.cpp index 63553b72..5055ea87 100644 --- a/source/filters/filter-sdf-effects.cpp +++ b/source/filters/filter-sdf-effects.cpp @@ -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() { { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); vec4 transparent = {0, 0, 0, 0}; - _source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - _sdf_write = std::make_shared(GS_RGBA32F, GS_ZS_NONE); - _sdf_read = std::make_shared(GS_RGBA32F, GS_ZS_NONE); - _output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _sdf_write = std::make_shared(GS_RGBA32F, GS_ZS_NONE); + _sdf_read = std::make_shared(GS_RGBA32F, GS_ZS_NONE); + _output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - std::shared_ptr initialize_rts[] = {_source_rt, _sdf_write, _sdf_read, _output_rt}; + std::shared_ptr initialize_rts[] = {_source_rt, _sdf_write, _sdf_read, + _output_rt}; for (auto rt : initialize_rts) { auto op = rt->render(1, 1); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &transparent, 0, 0); } - std::pair load_arr[] = { + std::pair load_arr[] = { {"effects/sdf/sdf-producer.effect", _sdf_producer_effect}, {"effects/sdf/sdf-consumer.effect", _sdf_consumer_effect}, }; for (auto& kv : load_arr) { auto path = streamfx::data_file_path(kv.first).u8string(); try { - kv.second = gs::effect::create(path); + kv.second = streamfx::obs::gs::effect::create(path); } catch (const std::exception& ex) { DLOG_ERROR(LOG_PREFIX "Failed to load effect '%s' (located at '%s') with error(s): %s", kv.first, path.c_str(), ex.what()); @@ -279,11 +280,11 @@ void sdf_effects_instance::video_render(gs_effect_t* effect) } #ifdef ENABLE_PROFILING - gs::debug_marker gdmp{gs::debug_color_source, "SDF Effects '%s' on '%s'", obs_source_get_name(_self), - obs_source_get_name(obs_filter_get_parent(_self))}; + streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "SDF Effects '%s' on '%s'", + obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))}; #endif - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); vec4 color_transparent = {0, 0, 0, 0}; try { @@ -305,7 +306,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect) // Store input texture. { #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 auto op = _source_rt->render(baseW, baseH); @@ -347,7 +348,8 @@ void sdf_effects_instance::video_render(gs_effect_t* effect) { #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 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. try { #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 auto op = _output_rt->render(baseW, baseH); @@ -502,7 +504,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect) { #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 gs_eparam_t* ep = gs_effect_get_param_by_name(final_effect, "image"); diff --git a/source/filters/filter-sdf-effects.hpp b/source/filters/filter-sdf-effects.hpp index 21b00684..3abc8b1b 100644 --- a/source/filters/filter-sdf-effects.hpp +++ b/source/filters/filter-sdf-effects.hpp @@ -28,25 +28,25 @@ namespace streamfx::filter::sdf_effects { class sdf_effects_instance : public obs::source_instance { - gs::effect _sdf_producer_effect; - gs::effect _sdf_consumer_effect; + streamfx::obs::gs::effect _sdf_producer_effect; + streamfx::obs::gs::effect _sdf_consumer_effect; // Input - std::shared_ptr _source_rt; - std::shared_ptr _source_texture; - bool _source_rendered; + std::shared_ptr _source_rt; + std::shared_ptr _source_texture; + bool _source_rendered; // Distance Field - std::shared_ptr _sdf_write; - std::shared_ptr _sdf_read; - std::shared_ptr _sdf_texture; - double_t _sdf_scale; - float_t _sdf_threshold; + std::shared_ptr _sdf_write; + std::shared_ptr _sdf_read; + std::shared_ptr _sdf_texture; + double_t _sdf_scale; + float_t _sdf_threshold; // Effects - bool _output_rendered; - std::shared_ptr _output_texture; - std::shared_ptr _output_rt; + bool _output_rendered; + std::shared_ptr _output_texture; + std::shared_ptr _output_rt; /// Inner Shadow bool _inner_shadow; vec4 _inner_shadow_color; diff --git a/source/filters/filter-shader.cpp b/source/filters/filter-shader.cpp index de06d8f2..90b2583c 100644 --- a/source/filters/filter-shader.cpp +++ b/source/filters/filter-shader.cpp @@ -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) { _fx = std::make_shared(self, gfx::shader::shader_mode::Filter); - _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); update(data); } @@ -89,13 +89,14 @@ void shader_instance::video_render(gs_effect_t* effect) } #ifdef ENABLE_PROFILING - gs::debug_marker gdmp{gs::debug_color_source, "Shader Filter '%s' on '%s'", obs_source_get_name(_self), - obs_source_get_name(obs_filter_get_parent(_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))}; #endif { #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 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 - gs::debug_marker gdm{gs::debug_color_render, "Render"}; + streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"}; #endif _fx->prepare_render(); diff --git a/source/filters/filter-shader.hpp b/source/filters/filter-shader.hpp index 6f921850..2520616e 100644 --- a/source/filters/filter-shader.hpp +++ b/source/filters/filter-shader.hpp @@ -25,8 +25,8 @@ namespace streamfx::filter::shader { class shader_instance : public obs::source_instance { - std::shared_ptr _fx; - std::shared_ptr _rt; + std::shared_ptr _fx; + std::shared_ptr _rt; public: shader_instance(obs_data_t* data, obs_source_t* self); diff --git a/source/filters/filter-transform.cpp b/source/filters/filter-transform.cpp index 304c0973..8f90b744 100644 --- a/source/filters/filter-transform.cpp +++ b/source/filters/filter-transform.cpp @@ -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(), _update_mesh(), _rotation_order(), _camera_orthographic(), _camera_fov() { - _cache_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - _source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - _vertex_buffer = std::make_shared(uint32_t(4u), uint8_t(1u)); + _cache_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _vertex_buffer = std::make_shared(uint32_t(4u), uint8_t(1u)); _position = std::make_unique(); _rotation = std::make_unique(); @@ -288,8 +288,8 @@ void transform_instance::video_render(gs_effect_t* effect) } #ifdef ENABLE_PROFILING - gs::debug_marker gdmp{gs::debug_color_source, "3D Transform '%s' on '%s'", obs_source_get_name(_self), - obs_source_get_name(obs_filter_get_parent(_self))}; + streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "3D Transform '%s' on '%s'", + obs_source_get_name(_self), obs_source_get_name(obs_filter_get_parent(_self))}; #endif uint32_t cache_width = base_width; @@ -316,7 +316,7 @@ void transform_instance::video_render(gs_effect_t* effect) if (!_cache_rendered) { #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 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) { #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 if (!_mipmap_texture || (_mipmap_texture->get_width() != cache_width) || (_mipmap_texture->get_height() != cache_height)) { #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 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)); - _mipmap_texture = - std::make_shared(cache_width, cache_height, GS_RGBA, static_cast(mip_levels), - nullptr, gs::texture::flags::None); + _mipmap_texture = std::make_shared(cache_width, cache_height, GS_RGBA, + static_cast(mip_levels), nullptr, + streamfx::obs::gs::texture::flags::None); } _mipmapper.rebuild(_cache_texture, _mipmap_texture); @@ -382,7 +382,7 @@ void transform_instance::video_render(gs_effect_t* effect) { #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 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 - gs::debug_marker gdm{gs::debug_color_render, "Render"}; + streamfx::obs::gs::debug_marker gdm{streamfx::obs::gs::debug_color_render, "Render"}; #endif gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), _source_texture->get_object()); diff --git a/source/filters/filter-transform.hpp b/source/filters/filter-transform.hpp index c548472e..2fc75519 100644 --- a/source/filters/filter-transform.hpp +++ b/source/filters/filter-transform.hpp @@ -29,30 +29,30 @@ namespace streamfx::filter::transform { class transform_instance : public obs::source_instance { // Cache - bool _cache_rendered; - std::shared_ptr _cache_rt; - std::shared_ptr _cache_texture; + bool _cache_rendered; + std::shared_ptr _cache_rt; + std::shared_ptr _cache_texture; // Mip-mapping - bool _mipmap_enabled; - bool _mipmap_rendered; - gs::mipmapper _mipmapper; - std::shared_ptr _mipmap_texture; + bool _mipmap_enabled; + bool _mipmap_rendered; + streamfx::obs::gs::mipmapper _mipmapper; + std::shared_ptr _mipmap_texture; // Input - bool _source_rendered; - std::pair _source_size; - std::shared_ptr _source_rt; - std::shared_ptr _source_texture; + bool _source_rendered; + std::pair _source_size; + std::shared_ptr _source_rt; + std::shared_ptr _source_texture; // Mesh - bool _update_mesh; - std::shared_ptr _vertex_buffer; - uint32_t _rotation_order; - std::unique_ptr _position; - std::unique_ptr _rotation; - std::unique_ptr _scale; - std::unique_ptr _shear; + bool _update_mesh; + std::shared_ptr _vertex_buffer; + uint32_t _rotation_order; + std::unique_ptr _position; + std::unique_ptr _rotation; + std::unique_ptr _scale; + std::unique_ptr _shear; // Camera bool _camera_orthographic; diff --git a/source/gfx/blur/gfx-blur-base.hpp b/source/gfx/blur/gfx-blur-base.hpp index cb5bf8de..d9969d41 100644 --- a/source/gfx/blur/gfx-blur-base.hpp +++ b/source/gfx/blur/gfx-blur-base.hpp @@ -33,7 +33,7 @@ namespace gfx { public: 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; @@ -53,9 +53,9 @@ namespace gfx { 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 { diff --git a/source/gfx/blur/gfx-blur-box-linear.cpp b/source/gfx/blur/gfx-blur-box-linear.cpp index 6dd5ce53..91a7d1ab 100644 --- a/source/gfx/blur/gfx-blur-box-linear.cpp +++ b/source/gfx/blur/gfx-blur-box-linear.cpp @@ -36,9 +36,10 @@ gfx::blur::box_linear_data::box_linear_data() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); 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 (...) { DLOG_ERROR(" Failed to load _effect."); } @@ -46,11 +47,11 @@ 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(); } -gs::effect gfx::blur::box_linear_data::get_effect() +streamfx::obs::gs::effect gfx::blur::box_linear_data::get_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() : _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); - _rendertarget2 = 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<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); } 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; } @@ -240,12 +241,12 @@ double_t gfx::blur::box_linear::get_step_scale_y() 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 - 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 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); // Two Pass Blur - gs::effect effect = _data->get_effect(); + streamfx::obs::gs::effect effect = _data->get_effect(); if (effect) { // Pass 1 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 - 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 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 - 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 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(); } -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(); } @@ -330,12 +331,13 @@ void gfx::blur::box_linear_directional::set_angle(double_t 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 - 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 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); // One Pass Blur - gs::effect effect = _data->get_effect(); + streamfx::obs::gs::effect effect = _data->get_effect(); if (effect) { effect.get_parameter("pImage").set_texture(_input_texture); effect.get_parameter("pImageTexel") diff --git a/source/gfx/blur/gfx-blur-box-linear.hpp b/source/gfx/blur/gfx-blur-box-linear.hpp index bf9abde7..91adc3b1 100644 --- a/source/gfx/blur/gfx-blur-box-linear.hpp +++ b/source/gfx/blur/gfx-blur-box-linear.hpp @@ -26,13 +26,13 @@ namespace gfx { namespace blur { class box_linear_data { - gs::effect _effect; + streamfx::obs::gs::effect _effect; public: 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 { @@ -83,19 +83,19 @@ namespace gfx { protected: std::shared_ptr<::gfx::blur::box_linear_data> _data; - double_t _size; - std::pair _step_scale; - std::shared_ptr<::gs::texture> _input_texture; - std::shared_ptr<::gs::rendertarget> _rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::streamfx::obs::gs::texture> _input_texture; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> _rendertarget2; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2; public: box_linear(); 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; @@ -107,8 +107,8 @@ namespace gfx { virtual double_t get_step_scale_x() override; virtual double_t get_step_scale_y() override; - virtual std::shared_ptr<::gs::texture> render() override; - virtual std::shared_ptr<::gs::texture> get() override; + virtual std::shared_ptr<::streamfx::obs::gs::texture> render() 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 { @@ -122,7 +122,7 @@ namespace gfx { virtual double_t get_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 gfx diff --git a/source/gfx/blur/gfx-blur-box.cpp b/source/gfx/blur/gfx-blur-box.cpp index 280d3115..74dbb902 100644 --- a/source/gfx/blur/gfx-blur-box.cpp +++ b/source/gfx/blur/gfx-blur-box.cpp @@ -36,9 +36,9 @@ gfx::blur::box_data::box_data() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); 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 (...) { DLOG_ERROR(" Failed to load _effect."); } @@ -46,11 +46,11 @@ gfx::blur::box_data::box_data() gfx::blur::box_data::~box_data() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); _effect.reset(); } -gs::effect gfx::blur::box_data::get_effect() +streamfx::obs::gs::effect gfx::blur::box_data::get_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.}) { - auto gctx = gs::context(); - _rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); - _rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); + auto gctx = streamfx::obs::gs::context(); + _rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); + _rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); } 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; } @@ -248,12 +248,12 @@ double_t gfx::blur::box::get_step_scale_y() 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 - 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 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); // Two Pass Blur - gs::effect effect = _data->get_effect(); + streamfx::obs::gs::effect effect = _data->get_effect(); if (effect) { // Pass 1 effect.get_parameter("pImage").set_texture(_input_texture); @@ -284,7 +284,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render() { #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 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 - 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 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(); } -std::shared_ptr<::gs::texture> gfx::blur::box::get() +std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::get() { return _rendertarget->get_texture(); } @@ -338,12 +338,12 @@ void gfx::blur::box_directional::set_angle(double_t 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 - 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 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); // One Pass Blur - gs::effect effect = _data->get_effect(); + streamfx::obs::gs::effect effect = _data->get_effect(); if (effect) { effect.get_parameter("pImage").set_texture(_input_texture); effect.get_parameter("pImageTexel") @@ -413,12 +413,12 @@ void gfx::blur::box_rotational::set_angle(double_t 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 - 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 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); // One Pass Blur - gs::effect effect = _data->get_effect(); + streamfx::obs::gs::effect effect = _data->get_effect(); if (effect) { effect.get_parameter("pImage").set_texture(_input_texture); 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; } -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 - 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 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); // One Pass Blur - gs::effect effect = _data->get_effect(); + streamfx::obs::gs::effect effect = _data->get_effect(); if (effect) { effect.get_parameter("pImage").set_texture(_input_texture); effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); diff --git a/source/gfx/blur/gfx-blur-box.hpp b/source/gfx/blur/gfx-blur-box.hpp index b96ea7a2..acd3712c 100644 --- a/source/gfx/blur/gfx-blur-box.hpp +++ b/source/gfx/blur/gfx-blur-box.hpp @@ -26,13 +26,13 @@ namespace gfx { namespace blur { class box_data { - gs::effect _effect; + streamfx::obs::gs::effect _effect; public: box_data(); virtual ~box_data(); - gs::effect get_effect(); + streamfx::obs::gs::effect get_effect(); }; class box_factory : public ::gfx::blur::ifactory { @@ -83,19 +83,19 @@ namespace gfx { protected: std::shared_ptr<::gfx::blur::box_data> _data; - double_t _size; - std::pair _step_scale; - std::shared_ptr<::gs::texture> _input_texture; - std::shared_ptr<::gs::rendertarget> _rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::streamfx::obs::gs::texture> _input_texture; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> _rendertarget2; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2; public: box(); 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; @@ -107,8 +107,8 @@ namespace gfx { virtual double_t get_step_scale_x() override; virtual double_t get_step_scale_y() override; - virtual std::shared_ptr<::gs::texture> render() override; - virtual std::shared_ptr<::gs::texture> get() override; + virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; + virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override; }; 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 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, @@ -140,7 +140,7 @@ namespace gfx { virtual double_t get_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 { @@ -152,7 +152,7 @@ namespace gfx { virtual void set_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 gfx diff --git a/source/gfx/blur/gfx-blur-dual-filtering.cpp b/source/gfx/blur/gfx-blur-dual-filtering.cpp index 84e17752..8359db37 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.cpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.cpp @@ -52,9 +52,10 @@ gfx::blur::dual_filtering_data::dual_filtering_data() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); 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 (...) { DLOG_ERROR(" Failed to load _effect."); } @@ -62,11 +63,11 @@ 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(); } -gs::effect gfx::blur::dual_filtering_data::get_effect() +streamfx::obs::gs::effect gfx::blur::dual_filtering_data::get_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() : _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); for (std::size_t n = 0; n <= MAX_LEVELS; n++) { gs_color_format cf = GS_RGBA; @@ -189,13 +190,13 @@ gfx::blur::dual_filtering::dual_filtering() #elif 0 cf = GS_RGBA32F; #endif - _rts[n] = std::make_shared(cf, GS_ZS_NONE); + _rts[n] = std::make_shared(cf, GS_ZS_NONE); } } 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; } @@ -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&) {} -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 - 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 auto effect = _data->get_effect(); @@ -257,11 +258,11 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() // Downsample for (std::size_t n = 1; n <= actual_iterations; n++) { #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 // Select Texture - std::shared_ptr tex_cur; + std::shared_ptr tex_cur; if (n > 1) { 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. @@ -294,11 +295,11 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() // Upsample for (std::size_t n = actual_iterations; n > 0; n--) { #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 // Select Texture - std::shared_ptr tex_in = _rts[n]->get_texture(); + std::shared_ptr tex_in = _rts[n]->get_texture(); // Get Size uint32_t iwidth = width >> n; @@ -326,7 +327,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() 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(); } diff --git a/source/gfx/blur/gfx-blur-dual-filtering.hpp b/source/gfx/blur/gfx-blur-dual-filtering.hpp index a0fcdbad..a9ccd39f 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.hpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.hpp @@ -27,13 +27,13 @@ namespace gfx { namespace blur { class dual_filtering_data { - gs::effect _effect; + streamfx::obs::gs::effect _effect; public: 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 { @@ -86,15 +86,15 @@ namespace gfx { double_t _size; std::size_t _size_iterations; - std::shared_ptr _input_texture; + std::shared_ptr _input_texture; - std::vector> _rts; + std::vector> _rts; public: dual_filtering(); 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; @@ -106,9 +106,9 @@ namespace gfx { 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 gfx diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.cpp b/source/gfx/blur/gfx-blur-gaussian-linear.cpp index 8b7e1a5e..f2597ab6 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.cpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.cpp @@ -42,8 +42,9 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data() { - auto gctx = gs::context(); - _effect = gs::effect::create(streamfx::data_file_path("effects/blur/gaussian-linear.effect").u8string()); + auto gctx = streamfx::obs::gs::context(); + _effect = + streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian-linear.effect").u8string()); // Precalculate Kernels 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(); } -gs::effect gfx::blur::gaussian_linear_data::get_effect() +streamfx::obs::gs::effect gfx::blur::gaussian_linear_data::get_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() : _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_RGBA, GS_ZS_NONE); - _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); } 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; } @@ -284,16 +285,16 @@ double_t gfx::blur::gaussian_linear::get_step_scale_y() 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 - 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 - gs::effect effect = _data->get_effect(); - auto kernel = _data->get_kernel(size_t(_size)); + streamfx::obs::gs::effect effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { return _input_texture; @@ -327,7 +328,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() { #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 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 - 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 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(); } -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(); } @@ -389,16 +390,17 @@ void gfx::blur::gaussian_linear_directional::set_angle(double_t 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 - 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 - gs::effect effect = _data->get_effect(); - auto kernel = _data->get_kernel(size_t(_size)); + streamfx::obs::gs::effect effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { return _input_texture; diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.hpp b/source/gfx/blur/gfx-blur-gaussian-linear.hpp index 76ed579b..53287493 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.hpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.hpp @@ -27,14 +27,14 @@ namespace gfx { namespace blur { class gaussian_linear_data { - gs::effect _effect; + streamfx::obs::gs::effect _effect; std::vector> _kernels; public: gaussian_linear_data(); virtual ~gaussian_linear_data(); - gs::effect get_effect(); + streamfx::obs::gs::effect get_effect(); std::vector const& get_kernel(std::size_t width); }; @@ -87,19 +87,19 @@ namespace gfx { protected: std::shared_ptr<::gfx::blur::gaussian_linear_data> _data; - double_t _size; - std::pair _step_scale; - std::shared_ptr<::gs::texture> _input_texture; - std::shared_ptr<::gs::rendertarget> _rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::streamfx::obs::gs::texture> _input_texture; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> _rendertarget2; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2; public: gaussian_linear(); 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; @@ -115,9 +115,9 @@ namespace gfx { 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 { @@ -133,7 +133,7 @@ namespace gfx { 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 gfx diff --git a/source/gfx/blur/gfx-blur-gaussian.cpp b/source/gfx/blur/gfx-blur-gaussian.cpp index cbd48053..5f293e7e 100644 --- a/source/gfx/blur/gfx-blur-gaussian.cpp +++ b/source/gfx/blur/gfx-blur-gaussian.cpp @@ -43,8 +43,8 @@ gfx::blur::gaussian_data::gaussian_data() { - auto gctx = gs::context(); - _effect = gs::effect::create(streamfx::data_file_path("effects/blur/gaussian.effect").u8string()); + auto gctx = streamfx::obs::gs::context(); + _effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian.effect").u8string()); // Precalculate Kernels 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() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); _effect.reset(); } -gs::effect gfx::blur::gaussian_data::get_effect() +streamfx::obs::gs::effect gfx::blur::gaussian_data::get_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.}) { - auto gctx = gs::context(); - _rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); - _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); + auto gctx = streamfx::obs::gs::context(); + _rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); } 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; } @@ -291,16 +291,16 @@ double_t gfx::blur::gaussian::get_step_scale_y() 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 - 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 - gs::effect effect = _data->get_effect(); - auto kernel = _data->get_kernel(size_t(_size)); + streamfx::obs::gs::effect effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { return _input_texture; @@ -334,7 +334,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() { #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 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 - 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 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(); } -std::shared_ptr<::gs::texture> gfx::blur::gaussian::get() +std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::get() { return _rendertarget->get_texture(); } @@ -396,16 +396,17 @@ void gfx::blur::gaussian_directional::set_angle(double_t 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 - 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 - gs::effect effect = _data->get_effect(); - auto kernel = _data->get_kernel(size_t(_size)); + streamfx::obs::gs::effect effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { return _input_texture; @@ -454,16 +455,17 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render() 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 - 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 - gs::effect effect = _data->get_effect(); - auto kernel = _data->get_kernel(size_t(_size)); + streamfx::obs::gs::effect effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { return _input_texture; @@ -535,16 +537,16 @@ void gfx::blur::gaussian_rotational::set_angle(double_t angle) 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 - 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 - gs::effect effect = _data->get_effect(); - auto kernel = _data->get_kernel(size_t(_size)); + streamfx::obs::gs::effect effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { return _input_texture; diff --git a/source/gfx/blur/gfx-blur-gaussian.hpp b/source/gfx/blur/gfx-blur-gaussian.hpp index acb8362d..576742ce 100644 --- a/source/gfx/blur/gfx-blur-gaussian.hpp +++ b/source/gfx/blur/gfx-blur-gaussian.hpp @@ -27,14 +27,14 @@ namespace gfx { namespace blur { class gaussian_data { - gs::effect _effect; + streamfx::obs::gs::effect _effect; std::vector> _kernels; public: gaussian_data(); virtual ~gaussian_data(); - gs::effect get_effect(); + streamfx::obs::gs::effect get_effect(); std::vector const& get_kernel(std::size_t width); }; @@ -87,19 +87,19 @@ namespace gfx { protected: std::shared_ptr<::gfx::blur::gaussian_data> _data; - double_t _size; - std::pair _step_scale; - std::shared_ptr<::gs::texture> _input_texture; - std::shared_ptr<::gs::rendertarget> _rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::streamfx::obs::gs::texture> _input_texture; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> _rendertarget2; + std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2; public: gaussian(); 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; @@ -115,9 +115,9 @@ namespace gfx { 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 { @@ -132,7 +132,7 @@ namespace gfx { virtual double_t get_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, @@ -150,7 +150,7 @@ namespace gfx { virtual double_t get_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 { @@ -162,7 +162,7 @@ namespace gfx { virtual void set_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 gfx diff --git a/source/gfx/gfx-source-texture.cpp b/source/gfx/gfx-source-texture.cpp index 62a945f8..570fabeb 100644 --- a/source/gfx/gfx-source-texture.cpp +++ b/source/gfx/gfx-source-texture.cpp @@ -35,7 +35,7 @@ gfx::source_texture::source_texture(obs_source_t* parent) throw std::invalid_argument("_parent must not be null"); } _parent = std::make_shared(parent, false, false); - _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } 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_child = pchild; this->_parent = pparent; - this->_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } gfx::source_texture::source_texture(std::shared_ptr _child, obs_source_t* _parent) @@ -106,7 +106,7 @@ void gfx::source_texture::clear() _child.reset(); } -std::shared_ptr gfx::source_texture::render(std::size_t width, std::size_t height) +std::shared_ptr gfx::source_texture::render(std::size_t width, std::size_t height) { if ((width == 0) || (width >= 16384)) { throw std::runtime_error("Width too large or too small."); @@ -120,8 +120,8 @@ std::shared_ptr gfx::source_texture::render(std::size_t width, std: if (_child) { #ifdef ENABLE_PROFILING - auto cctr = - gs::debug_marker(gs::debug_color_capture, "gfx::source_texture '%s'", obs_source_get_name(_child->get())); + auto cctr = streamfx::obs::gs::debug_marker(streamfx::obs::gs::debug_color_capture, "gfx::source_texture '%s'", + obs_source_get_name(_child->get())); #endif auto op = _rt->render(static_cast(width), static_cast(height)); vec4 black; @@ -131,7 +131,7 @@ std::shared_ptr gfx::source_texture::render(std::size_t width, std: obs_source_video_render(_child->get()); } - std::shared_ptr tex; + std::shared_ptr tex; _rt->get_texture(tex); return tex; } diff --git a/source/gfx/gfx-source-texture.hpp b/source/gfx/gfx-source-texture.hpp index d2e562f9..70743ef0 100644 --- a/source/gfx/gfx-source-texture.hpp +++ b/source/gfx/gfx-source-texture.hpp @@ -27,7 +27,7 @@ namespace gfx { std::shared_ptr _parent; std::shared_ptr _child; - std::shared_ptr _rt; + std::shared_ptr _rt; source_texture(obs_source_t* parent); @@ -50,7 +50,7 @@ namespace gfx { source_texture& operator=(source_texture&& other) = delete; public: - std::shared_ptr render(std::size_t width, std::size_t height); + std::shared_ptr render(std::size_t width, std::size_t height); public: // Unsafe Methods void clear(); diff --git a/source/gfx/lut/gfx-lut-consumer.cpp b/source/gfx/lut/gfx-lut-consumer.cpp index b930c216..b03762a8 100644 --- a/source/gfx/lut/gfx-lut-consumer.cpp +++ b/source/gfx/lut/gfx-lut-consumer.cpp @@ -31,9 +31,10 @@ gfx::lut::consumer::consumer() gfx::lut::consumer::~consumer() {} -std::shared_ptr gfx::lut::consumer::prepare(gfx::lut::color_depth depth, std::shared_ptr lut) +std::shared_ptr gfx::lut::consumer::prepare(gfx::lut::color_depth depth, + std::shared_ptr lut) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); auto effect = _data->consumer_effect(); @@ -42,11 +43,11 @@ std::shared_ptr gfx::lut::consumer::prepare(gfx::lut::color_depth de int32_t grid_size = static_cast(pow(2l, (idepth / 2))); int32_t container_size = static_cast(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); } - 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(size); float inverse_z_size = 1.f / static_cast(grid_size); float inverse_container_size = 1.f / static_cast(container_size); @@ -54,21 +55,21 @@ std::shared_ptr gfx::lut::consumer::prepare(gfx::lut::color_depth de 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); } return effect; } -void gfx::lut::consumer::consume(gfx::lut::color_depth depth, std::shared_ptr lut, - std::shared_ptr texture) +void gfx::lut::consumer::consume(gfx::lut::color_depth depth, std::shared_ptr lut, + std::shared_ptr texture) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); 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()); } diff --git a/source/gfx/lut/gfx-lut-consumer.hpp b/source/gfx/lut/gfx-lut-consumer.hpp index a6b2d6c8..be77af83 100644 --- a/source/gfx/lut/gfx-lut-consumer.hpp +++ b/source/gfx/lut/gfx-lut-consumer.hpp @@ -33,9 +33,10 @@ namespace gfx::lut { consumer(); ~consumer(); - std::shared_ptr prepare(gfx::lut::color_depth depth, std::shared_ptr lut); + std::shared_ptr prepare(gfx::lut::color_depth depth, + std::shared_ptr lut); - void consume(gfx::lut::color_depth depth, std::shared_ptr lut, - std::shared_ptr texture); + void consume(gfx::lut::color_depth depth, std::shared_ptr lut, + std::shared_ptr texture); }; } // namespace gfx::lut diff --git a/source/gfx/lut/gfx-lut-producer.cpp b/source/gfx/lut/gfx-lut-producer.cpp index d220603c..36c2c62d 100644 --- a/source/gfx/lut/gfx-lut-producer.cpp +++ b/source/gfx/lut/gfx-lut-producer.cpp @@ -49,12 +49,12 @@ gfx::lut::producer::producer() gfx::lut::producer::~producer() {} -std::shared_ptr gfx::lut::producer::produce(gfx::lut::color_depth depth) +std::shared_ptr 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)))) { - _rt = std::make_shared(format_from_depth(depth), GS_ZS_NONE); + _rt = std::make_shared(format_from_depth(depth), GS_ZS_NONE); } auto effect = _data->producer_effect(); @@ -74,7 +74,7 @@ std::shared_ptr gfx::lut::producer::produce(gfx::lut::color_depth d gs_enable_stencil_write(false); 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); } diff --git a/source/gfx/lut/gfx-lut-producer.hpp b/source/gfx/lut/gfx-lut-producer.hpp index 27b48796..152ea86e 100644 --- a/source/gfx/lut/gfx-lut-producer.hpp +++ b/source/gfx/lut/gfx-lut-producer.hpp @@ -27,13 +27,13 @@ namespace gfx::lut { class producer { - std::shared_ptr _data; - std::shared_ptr _rt; + std::shared_ptr _data; + std::shared_ptr _rt; public: producer(); ~producer(); - std::shared_ptr produce(gfx::lut::color_depth depth); + std::shared_ptr produce(gfx::lut::color_depth depth); }; } // namespace gfx::lut diff --git a/source/gfx/lut/gfx-lut.cpp b/source/gfx/lut/gfx-lut.cpp index 5a38c678..83283199 100644 --- a/source/gfx/lut/gfx-lut.cpp +++ b/source/gfx/lut/gfx-lut.cpp @@ -46,12 +46,12 @@ std::shared_ptr gfx::lut::data::instance() 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"); if (std::filesystem::exists(lut_producer_path)) { try { - _producer_effect = std::make_shared(lut_producer_path); + _producer_effect = std::make_shared(lut_producer_path); } catch (std::exception const& ex) { 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"); if (std::filesystem::exists(lut_consumer_path)) { try { - _consumer_effect = std::make_shared(lut_consumer_path); + _consumer_effect = std::make_shared(lut_consumer_path); } catch (std::exception const& ex) { 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() { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); _producer_effect.reset(); _consumer_effect.reset(); } diff --git a/source/gfx/lut/gfx-lut.hpp b/source/gfx/lut/gfx-lut.hpp index e40705d3..dc7811e5 100644 --- a/source/gfx/lut/gfx-lut.hpp +++ b/source/gfx/lut/gfx-lut.hpp @@ -25,8 +25,8 @@ namespace gfx::lut { class data { - std::shared_ptr _producer_effect; - std::shared_ptr _consumer_effect; + std::shared_ptr _producer_effect; + std::shared_ptr _consumer_effect; public: static std::shared_ptr instance(); @@ -37,12 +37,12 @@ namespace gfx::lut { public: ~data(); - inline std::shared_ptr producer_effect() + inline std::shared_ptr producer_effect() { return _producer_effect; }; - inline std::shared_ptr consumer_effect() + inline std::shared_ptr consumer_effect() { return _consumer_effect; }; diff --git a/source/gfx/shader/gfx-shader-param-basic.cpp b/source/gfx/shader/gfx-shader-param-basic.cpp index 28564b33..929d5c75 100644 --- a/source/gfx/shader/gfx-shader-param-basic.cpp +++ b/source/gfx/shader/gfx-shader-param-basic.cpp @@ -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_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) return false; @@ -46,7 +46,7 @@ inline bool get_annotation_string(gs::effect_parameter param, std::string anno_n 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) { 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; } -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(), _step(), _values() { @@ -111,7 +111,7 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s // Read Suffix Data 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(); } @@ -135,7 +135,7 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s load_parameter_data(eanno, entry.data); 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(); } else { 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() {} -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); } -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) { _min.resize(0); @@ -213,7 +213,7 @@ void gfx::shader::bool_parameter::assign() 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) { _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) { _data.resize(get_size()); diff --git a/source/gfx/shader/gfx-shader-param-basic.hpp b/source/gfx/shader/gfx-shader-param-basic.hpp index 2e0f5f30..fd9b888f 100644 --- a/source/gfx/shader/gfx-shader-param-basic.hpp +++ b/source/gfx/shader/gfx-shader-param-basic.hpp @@ -62,10 +62,10 @@ namespace gfx { std::list _values; 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 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: inline basic_field_type field_type() @@ -98,7 +98,7 @@ namespace gfx { std::vector _data; public: - bool_parameter(gs::effect_parameter param, std::string prefix); + bool_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix); virtual ~bool_parameter(); void defaults(obs_data_t* settings) override; @@ -114,7 +114,7 @@ namespace gfx { std::vector _data; public: - float_parameter(gs::effect_parameter param, std::string prefix); + float_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix); virtual ~float_parameter(); void defaults(obs_data_t* settings) override; @@ -130,7 +130,7 @@ namespace gfx { std::vector _data; public: - int_parameter(gs::effect_parameter param, std::string prefix); + int_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix); virtual ~int_parameter(); void defaults(obs_data_t* settings) override; diff --git a/source/gfx/shader/gfx-shader-param.cpp b/source/gfx/shader/gfx-shader-param.cpp index 3ffa0198..88c0ab1f 100644 --- a/source/gfx/shader/gfx-shader-param.cpp +++ b/source/gfx/shader/gfx-shader-param.cpp @@ -28,9 +28,9 @@ #define ANNO_TYPE "type" #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) { 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) { 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."); } -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() { { @@ -175,8 +175,8 @@ void gfx::shader::parameter::update(obs_data_t* settings) {} void gfx::shader::parameter::assign() {} -std::shared_ptr gfx::shader::parameter::make_parameter(gs::effect_parameter param, - std::string prefix) +std::shared_ptr + gfx::shader::parameter::make_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) { if (!param) { throw std::runtime_error("Bad call to make_parameter. This is a bug in the plugin."); diff --git a/source/gfx/shader/gfx-shader-param.hpp b/source/gfx/shader/gfx-shader-param.hpp index 2f10f162..21b62d8d 100644 --- a/source/gfx/shader/gfx-shader-param.hpp +++ b/source/gfx/shader/gfx-shader-param.hpp @@ -39,15 +39,15 @@ namespace gfx { 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); class parameter { // 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). parameter_type _type; @@ -68,7 +68,7 @@ namespace gfx { std::string _description; protected: - parameter(gs::effect_parameter param, std::string key_prefix); + parameter(streamfx::obs::gs::effect_parameter param, std::string key_prefix); virtual ~parameter(){}; public: @@ -81,7 +81,7 @@ namespace gfx { virtual void assign(); public: - inline gs::effect_parameter get_parameter() + inline streamfx::obs::gs::effect_parameter get_parameter() { return _param; } @@ -137,7 +137,8 @@ namespace gfx { } public: - static std::shared_ptr make_parameter(gs::effect_parameter param, std::string prefix); + static std::shared_ptr make_parameter(streamfx::obs::gs::effect_parameter param, + std::string prefix); }; } // namespace shader } // namespace gfx diff --git a/source/gfx/shader/gfx-shader.cpp b/source/gfx/shader/gfx-shader.cpp index 761e70dd..7f75c310 100644 --- a/source/gfx/shader/gfx-shader.cpp +++ b/source/gfx/shader/gfx-shader.cpp @@ -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), - _rt_up_to_date(false), _rt(std::make_shared(GS_RGBA, GS_ZS_NONE)) + _rt_up_to_date(false), _rt(std::make_shared(GS_RGBA, GS_ZS_NONE)) { // Intialize random values. _random.seed(static_cast(_random_seed)); @@ -98,7 +98,7 @@ try { // Update Shader if (shader_dirty) { - _shader = gs::effect(file); + _shader = streamfx::obs::gs::effect(file); _shader_file_mt = std::filesystem::last_write_time(file); _shader_file_sz = std::filesystem::file_size(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) - if (gs::effect_parameter el = _shader.get_parameter("Time"); el != nullptr) { - if (el.get_type() == gs::effect_parameter::type::Float4) { + if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter("Time"); el != nullptr) { + if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Float4) { el.set_float4( _time, _time_loop, static_cast(_loops), static_cast(static_cast(_random()) / static_cast(_random.max()))); @@ -480,7 +480,7 @@ void gfx::shader::shader::prepare_render() // float4 ViewSize: (Width), (Height), (1.0 / Width), (1.0 / Height) 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(width()), static_cast(height()), 1.0f / static_cast(width()), 1.0f / static_cast(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] 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); } } // int32 RandomSeed: Seed used for random generation 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); } } @@ -544,7 +544,7 @@ void gfx::shader::shader::set_size(uint32_t w, uint32_t h) _base_height = h; } -void gfx::shader::shader::set_input_a(std::shared_ptr tex) +void gfx::shader::shader::set_input_a(std::shared_ptr tex) { if (!_shader) return; @@ -555,8 +555,8 @@ void gfx::shader::shader::set_input_a(std::shared_ptr tex) "tex_a", }; for (auto& name : params) { - if (gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) { - if (el.get_type() == gs::effect_parameter::type::Texture) { + if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) { + if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Texture) { el.set_texture(tex); break; } @@ -564,7 +564,7 @@ void gfx::shader::shader::set_input_a(std::shared_ptr tex) } } -void gfx::shader::shader::set_input_b(std::shared_ptr tex) +void gfx::shader::shader::set_input_b(std::shared_ptr tex) { if (!_shader) return; @@ -575,8 +575,8 @@ void gfx::shader::shader::set_input_b(std::shared_ptr tex) "tex_b", }; for (auto& name : params) { - if (gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) { - if (el.get_type() == gs::effect_parameter::type::Texture) { + if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter(name.data()); el != nullptr) { + if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Texture) { el.set_texture(tex); break; } @@ -589,8 +589,8 @@ void gfx::shader::shader::set_transition_time(float_t t) if (!_shader) return; - if (gs::effect_parameter el = _shader.get_parameter("TransitionTime"); el != nullptr) { - if (el.get_type() == gs::effect_parameter::type::Float) { + if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter("TransitionTime"); el != nullptr) { + if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Float) { el.set_float(t); } } @@ -600,8 +600,8 @@ void gfx::shader::shader::set_transition_size(uint32_t w, uint32_t h) { if (!_shader) return; - if (gs::effect_parameter el = _shader.get_parameter("TransitionSize"); el != nullptr) { - if (el.get_type() == gs::effect_parameter::type::Integer2) { + if (streamfx::obs::gs::effect_parameter el = _shader.get_parameter("TransitionSize"); el != nullptr) { + if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Integer2) { el.set_int2(static_cast(w), static_cast(h)); } } diff --git a/source/gfx/shader/gfx-shader.hpp b/source/gfx/shader/gfx-shader.hpp index f4bfef2e..d5a302f0 100644 --- a/source/gfx/shader/gfx-shader.hpp +++ b/source/gfx/shader/gfx-shader.hpp @@ -50,7 +50,7 @@ namespace gfx { bool _active; // Shader - gs::effect _shader; + streamfx::obs::gs::effect _shader; std::filesystem::path _shader_file; std::string _shader_tech; std::filesystem::file_time_type _shader_file_mt; @@ -74,8 +74,8 @@ namespace gfx { float_t _random_values[16]; // 0..4 Per-Instance-Random, 4..8 Per-Activation-Random 9..15 Per-Frame-Random // Rendering - bool _rt_up_to_date; - std::shared_ptr _rt; + bool _rt_up_to_date; + std::shared_ptr _rt; public: shader(obs_source_t* self, shader_mode mode); @@ -117,9 +117,9 @@ namespace gfx { public: void set_size(uint32_t w, uint32_t h); - void set_input_a(std::shared_ptr tex); + void set_input_a(std::shared_ptr tex); - void set_input_b(std::shared_ptr tex); + void set_input_b(std::shared_ptr tex); void set_transition_time(float_t t); diff --git a/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp b/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp index 127a10f7..c574ac9f 100644 --- a/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp +++ b/source/nvidia/cuda/nvidia-cuda-gs-texture.cpp @@ -43,7 +43,7 @@ nvidia::cuda::gstexture::~gstexture() _cuda->cuGraphicsUnregisterResource(_resource); } -nvidia::cuda::gstexture::gstexture(std::shared_ptr texture) +nvidia::cuda::gstexture::gstexture(std::shared_ptr texture) : _cuda(::nvidia::cuda::cuda::get()), _texture(texture), _resource(), _is_mapped(false), _pointer() { D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this); @@ -51,8 +51,8 @@ nvidia::cuda::gstexture::gstexture(std::shared_ptr texture) if (!texture) throw std::invalid_argument("texture"); - gs::context gctx; - int dev_type = gs_get_device_type(); + streamfx::obs::gs::context gctx; + int dev_type = gs_get_device_type(); if (dev_type == GS_DEVICE_OPENGL) { // ToDo @@ -61,12 +61,12 @@ nvidia::cuda::gstexture::gstexture(std::shared_ptr texture) if (dev_type == GS_DEVICE_DIRECT3D_11) { ID3D11Resource* resource = nullptr; switch (_texture->get_type()) { - case gs::texture::type::Cube: - case gs::texture::type::Normal: { + case streamfx::obs::gs::texture::type::Cube: + case streamfx::obs::gs::texture::type::Normal: { resource = static_cast(gs_texture_get_obj(_texture->get_object())); break; } - case gs::texture::type::Volume: { + case streamfx::obs::gs::texture::type::Volume: { resource = static_cast(gs_texture_get_obj(_texture->get_object())); break; } @@ -132,7 +132,7 @@ void nvidia::cuda::gstexture::unmap() _stream.reset(); } -std::shared_ptr nvidia::cuda::gstexture::get_texture() +std::shared_ptr nvidia::cuda::gstexture::get_texture() { return _texture; } diff --git a/source/nvidia/cuda/nvidia-cuda-gs-texture.hpp b/source/nvidia/cuda/nvidia-cuda-gs-texture.hpp index 97b4fe1e..d56f885b 100644 --- a/source/nvidia/cuda/nvidia-cuda-gs-texture.hpp +++ b/source/nvidia/cuda/nvidia-cuda-gs-texture.hpp @@ -26,9 +26,9 @@ namespace nvidia::cuda { class gstexture { - std::shared_ptr<::nvidia::cuda::cuda> _cuda; - std::shared_ptr _texture; - graphics_resource_t _resource; + std::shared_ptr<::nvidia::cuda::cuda> _cuda; + std::shared_ptr _texture; + graphics_resource_t _resource; bool _is_mapped; array_t _pointer; @@ -36,12 +36,12 @@ namespace nvidia::cuda { public: ~gstexture(); - gstexture(std::shared_ptr texture); + gstexture(std::shared_ptr texture); array_t map(std::shared_ptr stream); void unmap(); - std::shared_ptr get_texture(); - ::nvidia::cuda::graphics_resource_t get(); + std::shared_ptr get_texture(); + ::nvidia::cuda::graphics_resource_t get(); }; } // namespace nvidia::cuda diff --git a/source/nvidia/cuda/nvidia-cuda-obs.cpp b/source/nvidia/cuda/nvidia-cuda-obs.cpp index 20b63a2c..ee213b7c 100644 --- a/source/nvidia/cuda/nvidia-cuda-obs.cpp +++ b/source/nvidia/cuda/nvidia-cuda-obs.cpp @@ -39,7 +39,7 @@ nvidia::cuda::obs::~obs() { D_LOG_DEBUG("Finalizing... (Addr: 0x%" PRIuPTR ")", this); - auto gctx = gs::context{}; + auto gctx = streamfx::obs::gs::context{}; { auto stack = _context->enter(); _stream->synchronize(); @@ -53,7 +53,7 @@ nvidia::cuda::obs::obs() : _cuda(::nvidia::cuda::cuda::get()), _context() { D_LOG_DEBUG("Initializating... (Addr: 0x%" PRIuPTR ")", this); - auto gctx = gs::context{}; + auto gctx = streamfx::obs::gs::context{}; // Create Context #ifdef WIN32 diff --git a/source/obs/gs/gs-effect-parameter.cpp b/source/obs/gs/gs-effect-parameter.cpp index 7d67b948..16e4a022 100644 --- a/source/obs/gs/gs-effect-parameter.cpp +++ b/source/obs/gs/gs-effect-parameter.cpp @@ -33,37 +33,39 @@ extern "C" { #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(); } -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) { reset(param, [](void*) {}); } -gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr parent) +streamfx::obs::gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr parent) : effect_parameter(param) { _effect_parent = parent; } -gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr parent) : effect_parameter(param) +streamfx::obs::gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr parent) + : effect_parameter(param) { _pass_parent = parent; } -gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr parent) +streamfx::obs::gs::effect_parameter::effect_parameter(gs_eparam_t* param, std::shared_ptr parent) : effect_parameter(param) { _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*) {}); _effect_parent = rhs._effect_parent; @@ -71,7 +73,7 @@ gs::effect_parameter::effect_parameter(const effect_parameter& rhs) _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*) {}); _effect_parent = rhs._effect_parent; @@ -80,7 +82,7 @@ gs::effect_parameter& gs::effect_parameter::operator=(const effect_parameter& rh return *this; } -gs::effect_parameter::effect_parameter(effect_parameter&& rhs) noexcept +streamfx::obs::gs::effect_parameter::effect_parameter(effect_parameter&& rhs) noexcept try { reset(rhs.get(), [](gs_eparam_t*) {}); _effect_parent = rhs._effect_parent; @@ -94,7 +96,7 @@ try { } 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 { reset(rhs.get(), [](gs_eparam_t*) {}); _effect_parent = rhs._effect_parent; @@ -111,12 +113,12 @@ try { 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}; } -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) { 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()); } -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) { 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); } -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++) { auto ptr = get()->annotations.array + idx; if (name == std::string_view{ptr->name}) { - return gs::effect_parameter(ptr, *this); + return streamfx::obs::gs::effect_parameter(ptr, *this); } } 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); if (eprm) @@ -183,7 +185,7 @@ bool gs::effect_parameter::has_annotation(const std::string_view name) 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); if (eprm) @@ -191,14 +193,14 @@ bool gs::effect_parameter::has_annotation(const std::string_view name, effect_pa 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) throw std::bad_cast(); 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) 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) 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) throw std::bad_cast(); 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) throw std::bad_cast(); 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) 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) 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) throw std::bad_cast(); 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); } -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); } -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; data.x = x; @@ -289,7 +291,7 @@ void gs::effect_parameter::set_float2(float_t x, float_t y) 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) 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) 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) throw std::bad_cast(); 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); } -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); } -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) 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); } -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) 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) 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) throw std::bad_cast(); 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); } -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); } -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) 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); } -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) 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) 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)) throw std::bad_cast(); 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)) 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)) 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)) 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); } -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)) 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)) 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)) 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); } -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)) 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)) 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)) 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); } -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)) 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)) 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) throw std::bad_cast(); 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) 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) 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 v) +void streamfx::obs::gs::effect_parameter::set_texture(std::shared_ptr v) { if (get_type() != type::Texture) throw std::bad_cast(); 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) throw std::bad_cast(); gs_effect_set_texture(get(), v); } -void gs::effect_parameter::set_sampler(std::shared_ptr v) +void streamfx::obs::gs::effect_parameter::set_sampler(std::shared_ptr v) { if (get_type() != type::Texture) throw std::bad_cast(); 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) throw std::bad_cast(); 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) throw std::bad_cast(); 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) 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) throw std::bad_cast(); diff --git a/source/obs/gs/gs-effect-parameter.hpp b/source/obs/gs/gs-effect-parameter.hpp index bafae6b3..c5686461 100644 --- a/source/obs/gs/gs-effect-parameter.hpp +++ b/source/obs/gs/gs-effect-parameter.hpp @@ -22,7 +22,7 @@ #include "gs-sampler.hpp" #include "gs-texture.hpp" -namespace gs { +namespace streamfx::obs::gs { class effect_parameter : public std::shared_ptr { std::shared_ptr _effect_parent; std::shared_ptr _pass_parent; @@ -189,10 +189,10 @@ namespace gs { void get_matrix(matrix4& v); void get_default_matrix(matrix4& v); - void set_texture(std::shared_ptr v); + void set_texture(std::shared_ptr v); void set_texture(gs_texture_t* v); - void set_sampler(std::shared_ptr v); + void set_sampler(std::shared_ptr v); void set_sampler(gs_sampler_state* v); void set_string(std::string const& v); @@ -304,4 +304,4 @@ namespace gs { return v; }; }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-effect-pass.cpp b/source/obs/gs/gs-effect-pass.cpp index 01f90278..46f44ef8 100644 --- a/source/obs/gs/gs-effect-pass.cpp +++ b/source/obs/gs/gs-effect-pass.cpp @@ -31,49 +31,50 @@ extern "C" { #endif } -gs::effect_pass::effect_pass(gs_epass_t* pass, std::shared_ptr parent) : _parent(parent) +streamfx::obs::gs::effect_pass::effect_pass(gs_epass_t* pass, std::shared_ptr parent) : _parent(parent) { 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; std::size_t name_len = strnlen(name_c, 256); 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(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()) 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++) { auto ptr = get()->vertshader_params.array + idx; 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; } -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); } -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) { return el.get_type() == type; @@ -81,35 +82,36 @@ bool gs::effect_pass::has_vertex_parameter(std::string name, gs::effect_paramete 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(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()) 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++) { auto ptr = get()->pixelshader_params.array + idx; 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; } -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); } -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) { return el.get_type() == type; diff --git a/source/obs/gs/gs-effect-pass.hpp b/source/obs/gs/gs-effect-pass.hpp index 8fa5d847..8d69a4df 100644 --- a/source/obs/gs/gs-effect-pass.hpp +++ b/source/obs/gs/gs-effect-pass.hpp @@ -21,7 +21,7 @@ #include "common.hpp" #include "gs-effect-parameter.hpp" -namespace gs { +namespace streamfx::obs::gs { class effect_pass : public std::shared_ptr { std::shared_ptr _parent; @@ -35,16 +35,16 @@ namespace gs { //gs::shader get_vertex_shader(); // - std::size_t count_vertex_parameters(); - gs::effect_parameter get_vertex_parameter(std::size_t idx); - gs::effect_parameter get_vertex_parameter(std::string name); - bool has_vertex_parameter(std::string name); - bool has_vertex_parameter(std::string name, gs::effect_parameter::type type); + std::size_t count_vertex_parameters(); + streamfx::obs::gs::effect_parameter get_vertex_parameter(std::size_t idx); + 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, streamfx::obs::gs::effect_parameter::type type); - std::size_t count_pixel_parameters(); - gs::effect_parameter get_pixel_parameter(std::size_t idx); - gs::effect_parameter get_pixel_parameter(std::string name); - bool has_pixel_parameter(std::string name); - bool has_pixel_parameter(std::string name, gs::effect_parameter::type type); + std::size_t count_pixel_parameters(); + streamfx::obs::gs::effect_parameter get_pixel_parameter(std::size_t idx); + 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, streamfx::obs::gs::effect_parameter::type type); }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-effect-technique.cpp b/source/obs/gs/gs-effect-technique.cpp index cf02b1c8..8304e127 100644 --- a/source/obs/gs/gs-effect-technique.cpp +++ b/source/obs/gs/gs-effect-technique.cpp @@ -32,46 +32,47 @@ extern "C" { #endif } -gs::effect_technique::effect_technique(gs_technique_t* technique, std::shared_ptr parent) : _parent(parent) +streamfx::obs::gs::effect_technique::effect_technique(gs_technique_t* technique, std::shared_ptr parent) + : _parent(parent) { 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; std::size_t name_len = strnlen(name_c, 256); 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(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) { 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++) { auto ptr = get()->passes.array + idx; if (strcmp(ptr->name, name.c_str()) == 0) - return gs::effect_pass(ptr, *this); + return streamfx::obs::gs::effect_pass(ptr, *this); } 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) return true; diff --git a/source/obs/gs/gs-effect-technique.hpp b/source/obs/gs/gs-effect-technique.hpp index 07cd0866..fafee067 100644 --- a/source/obs/gs/gs-effect-technique.hpp +++ b/source/obs/gs/gs-effect-technique.hpp @@ -21,7 +21,7 @@ #include "common.hpp" #include "gs-effect-pass.hpp" -namespace gs { +namespace streamfx::obs::gs { class effect_technique : public std::shared_ptr { std::shared_ptr _parent; @@ -31,9 +31,9 @@ namespace gs { std::string name(); - std::size_t count_passes(); - gs::effect_pass get_pass(std::size_t idx); - gs::effect_pass get_pass(std::string name); - bool has_pass(std::string name); + std::size_t count_passes(); + streamfx::obs::gs::effect_pass get_pass(std::size_t idx); + streamfx::obs::gs::effect_pass get_pass(std::string name); + bool has_pass(std::string name); }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-effect.cpp b/source/obs/gs/gs-effect.cpp index fba331e3..ee8f7b6a 100644 --- a/source/obs/gs/gs-effect.cpp +++ b/source/obs/gs/gs-effect.cpp @@ -43,9 +43,9 @@ static std::string load_file_as_code(std::filesystem::path file) 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; 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); }); } -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(); } -std::size_t gs::effect::count_techniques() +std::size_t streamfx::obs::gs::effect::count_techniques() { return static_cast(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()) { 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++) { auto ptr = get()->techniques.array + idx; if (strcmp(ptr->name, name.c_str()) == 0) { - return gs::effect_technique(ptr, *this); + return streamfx::obs::gs::effect_technique(ptr, *this); } } 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)) return true; return false; } -std::size_t gs::effect::count_parameters() +std::size_t streamfx::obs::gs::effect::count_parameters() { 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()) { 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++) { auto ptr = get()->params.array + idx; if (strcmp(ptr->name, name.c_str()) == 0) { - return gs::effect_parameter(ptr, *this); + return streamfx::obs::gs::effect_parameter(ptr, *this); } } 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)) return true; 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); if (eprm) diff --git a/source/obs/gs/gs-effect.hpp b/source/obs/gs/gs-effect.hpp index a47deec1..a5ca5dde 100644 --- a/source/obs/gs/gs-effect.hpp +++ b/source/obs/gs/gs-effect.hpp @@ -24,7 +24,7 @@ #include "gs-effect-parameter.hpp" #include "gs-effect-technique.hpp" -namespace gs { +namespace streamfx::obs::gs { class effect : public std::shared_ptr { public: effect(){}; @@ -32,16 +32,16 @@ namespace gs { effect(std::filesystem::path file); ~effect(); - std::size_t count_techniques(); - gs::effect_technique get_technique(std::size_t idx); - gs::effect_technique get_technique(const std::string& name); - bool has_technique(const std::string& name); + std::size_t count_techniques(); + streamfx::obs::gs::effect_technique get_technique(std::size_t idx); + streamfx::obs::gs::effect_technique get_technique(const std::string& name); + bool has_technique(const std::string& name); - std::size_t count_parameters(); - gs::effect_parameter get_parameter(std::size_t idx); - gs::effect_parameter get_parameter(const std::string& name); - bool has_parameter(const std::string& name); - bool has_parameter(const std::string& name, effect_parameter::type type); + std::size_t count_parameters(); + streamfx::obs::gs::effect_parameter get_parameter(std::size_t idx); + 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, effect_parameter::type type); public /* Legacy Support */: inline gs_effect_t* get_object() @@ -49,14 +49,14 @@ namespace gs { 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 diff --git a/source/obs/gs/gs-helper.hpp b/source/obs/gs/gs-helper.hpp index ccb12f9c..e8f1315c 100644 --- a/source/obs/gs/gs-helper.hpp +++ b/source/obs/gs/gs-helper.hpp @@ -22,7 +22,7 @@ #include #include "plugin.hpp" -namespace gs { +namespace streamfx::obs::gs { class context { public: inline context() @@ -87,4 +87,4 @@ namespace gs { } }; #endif -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-indexbuffer.cpp b/source/obs/gs/gs-indexbuffer.cpp index e7c7767a..02cd4d3f 100644 --- a/source/obs/gs/gs-indexbuffer.cpp +++ b/source/obs/gs/gs-indexbuffer.cpp @@ -22,40 +22,41 @@ #include "gs-limits.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); - 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); } -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(other.size())) +streamfx::obs::gs::index_buffer::index_buffer(index_buffer& other) : index_buffer(static_cast(other.size())) { std::copy(other.begin(), other.end(), this->end()); } -gs::index_buffer::index_buffer(std::vector& other) : index_buffer(static_cast(other.size())) +streamfx::obs::gs::index_buffer::index_buffer(std::vector& other) + : index_buffer(static_cast(other.size())) { 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_t* gs::index_buffer::get() +gs_indexbuffer_t* streamfx::obs::gs::index_buffer::get() { 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) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); gs_indexbuffer_flush(_index_buffer); } return _index_buffer; diff --git a/source/obs/gs/gs-indexbuffer.hpp b/source/obs/gs/gs-indexbuffer.hpp index de6fb4be..b160f0bd 100644 --- a/source/obs/gs/gs-indexbuffer.hpp +++ b/source/obs/gs/gs-indexbuffer.hpp @@ -21,7 +21,7 @@ #include "common.hpp" #include -namespace gs { +namespace streamfx::obs::gs { class index_buffer : public std::vector { public: index_buffer(uint32_t maximumVertices); @@ -37,4 +37,4 @@ namespace gs { protected: gs_indexbuffer_t* _index_buffer; }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-limits.hpp b/source/obs/gs/gs-limits.hpp index 155cfaf1..9182244f 100644 --- a/source/obs/gs/gs-limits.hpp +++ b/source/obs/gs/gs-limits.hpp @@ -20,7 +20,7 @@ #pragma once #include "common.hpp" -namespace gs { +namespace streamfx::obs::gs { static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu; static const uint32_t MAXIMUM_UVW_LAYERS = 8u; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-mipmapper.cpp b/source/obs/gs/gs-mipmapper.cpp index ace57a69..6a654c64 100644 --- a/source/obs/gs/gs-mipmapper.cpp +++ b/source/obs/gs/gs-mipmapper.cpp @@ -36,16 +36,16 @@ #endif #endif -gs::mipmapper::~mipmapper() +streamfx::obs::gs::mipmapper::~mipmapper() { _vb.reset(); _rt.reset(); _effect.reset(); } -gs::mipmapper::mipmapper() +streamfx::obs::gs::mipmapper::mipmapper() { - _vb = std::make_unique(uint32_t(3u), uint8_t(1u)); + _vb = std::make_unique(uint32_t(3u), uint8_t(1u)); { auto vtx = _vb->at(0); @@ -71,10 +71,11 @@ gs::mipmapper::mipmapper() _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 source, std::shared_ptr target) +void streamfx::obs::gs::mipmapper::rebuild(std::shared_ptr source, + std::shared_ptr target) { { // Validate arguments and structure. if (!source || !target) @@ -100,11 +101,11 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr } // 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? if ((!_rt) || (source->get_color_format() != _rt->get_color_format())) { - _rt = std::make_unique(source->get_color_format(), GS_ZS_NONE); + _rt = std::make_unique(source->get_color_format(), GS_ZS_NONE); } // Grab API related information. @@ -125,7 +126,7 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr } // 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) { uint32_t width = source->get_width(); uint32_t height = source->get_height(); @@ -133,7 +134,8 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr { #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 #ifdef _WIN32 @@ -160,7 +162,8 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr // Render each mip map level. for (size_t mip = 1; mip < max_mip_level; mip++) { #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 uint32_t cwidth = std::max(width >> mip, 1); diff --git a/source/obs/gs/gs-mipmapper.hpp b/source/obs/gs/gs-mipmapper.hpp index 49bd6180..7d482e6c 100644 --- a/source/obs/gs/gs-mipmapper.hpp +++ b/source/obs/gs/gs-mipmapper.hpp @@ -36,16 +36,17 @@ * resource. Super wasteful, but what else can we actually do? */ -namespace gs { +namespace streamfx::obs::gs { class mipmapper { - std::unique_ptr _vb; - std::unique_ptr _rt; - gs::effect _effect; + std::unique_ptr _vb; + std::unique_ptr _rt; + streamfx::obs::gs::effect _effect; public: ~mipmapper(); mipmapper(); - void rebuild(std::shared_ptr source, std::shared_ptr target); + void rebuild(std::shared_ptr source, + std::shared_ptr target); }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-rendertarget.cpp b/source/obs/gs/gs-rendertarget.cpp index 1b4ba67f..c0a65f99 100644 --- a/source/obs/gs/gs-rendertarget.cpp +++ b/source/obs/gs/gs-rendertarget.cpp @@ -21,73 +21,75 @@ #include #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::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) { _is_being_rendered = false; - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); _render_target = gs_texrender_create(colorFormat, zsFormat); if (!_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}; } -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); return tex; } -std::shared_ptr gs::rendertarget::get_texture() +std::shared_ptr streamfx::obs::gs::rendertarget::get_texture() { - return std::make_shared(get_object(), false); + return std::make_shared(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& tex) +void streamfx::obs::gs::rendertarget::get_texture(std::shared_ptr& tex) { - tex = std::make_shared(get_object(), false); + tex = std::make_shared(get_object(), false); } -void gs::rendertarget::get_texture(std::unique_ptr& tex) +void streamfx::obs::gs::rendertarget::get_texture(std::unique_ptr& tex) { - tex = std::make_unique(get_object(), false); + tex = std::make_unique(get_object(), false); } -gs_color_format gs::rendertarget::get_color_format() +gs_color_format streamfx::obs::gs::rendertarget::get_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; } -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) throw std::invalid_argument("rt"); if (parent->_is_being_rendered) 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); if (!gs_texrender_begin(parent->_render_target, width, height)) { 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; } -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; r.parent = nullptr; } -gs::rendertarget_op::~rendertarget_op() +streamfx::obs::gs::rendertarget_op::~rendertarget_op() { if (parent == nullptr) return; - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); gs_texrender_end(parent->_render_target); parent->_is_being_rendered = false; } diff --git a/source/obs/gs/gs-rendertarget.hpp b/source/obs/gs/gs-rendertarget.hpp index 561acd69..0b864fb1 100644 --- a/source/obs/gs/gs-rendertarget.hpp +++ b/source/obs/gs/gs-rendertarget.hpp @@ -21,7 +21,7 @@ #include "common.hpp" #include "gs-texture.hpp" -namespace gs { +namespace streamfx::obs::gs { class rendertarget_op; class rendertarget { @@ -41,35 +41,35 @@ namespace gs { gs_texture_t* get_object(); - std::shared_ptr get_texture(); + std::shared_ptr get_texture(); - void get_texture(gs::texture& tex); + void get_texture(streamfx::obs::gs::texture& tex); - void get_texture(std::shared_ptr& tex); + void get_texture(std::shared_ptr& tex); - void get_texture(std::unique_ptr& tex); + void get_texture(std::unique_ptr& tex); gs_color_format get_color_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 { - gs::rendertarget* parent; + streamfx::obs::gs::rendertarget* parent; public: ~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 - rendertarget_op(gs::rendertarget_op&&); + rendertarget_op(streamfx::obs::gs::rendertarget_op&&); // 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 diff --git a/source/obs/gs/gs-sampler.cpp b/source/obs/gs/gs-sampler.cpp index 98e13642..bd6913bb 100644 --- a/source/obs/gs/gs-sampler.cpp +++ b/source/obs/gs/gs-sampler.cpp @@ -20,93 +20,93 @@ #include "gs-sampler.hpp" #include -gs::sampler::sampler() +streamfx::obs::gs::sampler::sampler() { _dirty = true; _sampler_info = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0}; _sampler_state = nullptr; } -gs::sampler::~sampler() +streamfx::obs::gs::sampler::~sampler() { if (_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; _sampler_info.filter = v; } -gs_sample_filter gs::sampler::get_filter() +gs_sample_filter streamfx::obs::gs::sampler::get_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; _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; } -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; _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; } -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; _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; } -void gs::sampler::set_max_anisotropy(int32_t v) +void streamfx::obs::gs::sampler::set_max_anisotropy(int32_t v) { _dirty = true; _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; } -void gs::sampler::set_border_color(uint32_t v) +void streamfx::obs::gs::sampler::set_border_color(uint32_t v) { _dirty = true; _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; _sampler_info.border_color = (static_cast(a) << 24) | (static_cast(r) << 16) | (static_cast(g) << 8) | static_cast(b); } -uint32_t gs::sampler::get_border_color() +uint32_t streamfx::obs::gs::sampler::get_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) 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; } -gs_sampler_state* gs::sampler::refresh() +gs_sampler_state* streamfx::obs::gs::sampler::refresh() { gs_samplerstate_destroy(_sampler_state); _sampler_state = gs_samplerstate_create(&_sampler_info); @@ -127,7 +127,7 @@ gs_sampler_state* gs::sampler::refresh() return _sampler_state; } -gs_sampler_state* gs::sampler::get_object() +gs_sampler_state* streamfx::obs::gs::sampler::get_object() { if (_dirty) return refresh(); diff --git a/source/obs/gs/gs-sampler.hpp b/source/obs/gs/gs-sampler.hpp index 9f1eba6a..f05cb181 100644 --- a/source/obs/gs/gs-sampler.hpp +++ b/source/obs/gs/gs-sampler.hpp @@ -20,7 +20,7 @@ #pragma once #include "common.hpp" -namespace gs { +namespace streamfx::obs::gs { class sampler { public: sampler(); @@ -55,4 +55,4 @@ namespace gs { gs_sampler_info _sampler_info; gs_sampler_state* _sampler_state; }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-texture.cpp b/source/obs/gs/gs-texture.cpp index fed01dfa..eb4f17e9 100644 --- a/source/obs/gs/gs-texture.cpp +++ b/source/obs/gs/gs-texture.cpp @@ -23,22 +23,22 @@ #include #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; - if (has(texture_flags, gs::texture::flags::Dynamic)) + if (has(texture_flags, streamfx::obs::gs::texture::flags::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; - if (has(texture_flags, gs::texture::flags::Shared)) + if (has(texture_flags, streamfx::obs::gs::texture::flags::Shared)) 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; return flags; } -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) +streamfx::obs::gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, + const uint8_t** mip_data, streamfx::obs::gs::texture::flags texture_flags) { if (width == 0) 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)); } @@ -64,8 +64,9 @@ gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, ui _type = type::Normal; } -gs::texture::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) +streamfx::obs::gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, + uint32_t mip_levels, const uint8_t** mip_data, + streamfx::obs::gs::texture::flags texture_flags) { if (width == 0) 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 = 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; } -gs::texture::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::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, + const uint8_t** mip_data, streamfx::obs::gs::texture::flags texture_flags) { if (size == 0) 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)); } @@ -122,23 +123,23 @@ gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, _type = type::Cube; } -gs::texture::texture(std::string file) +streamfx::obs::gs::texture::texture(std::string file) { struct stat st; if (os_stat(file.c_str(), &st) != 0) 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()); if (!_texture) throw std::runtime_error("Failed to load texture."); } -gs::texture::~texture() +streamfx::obs::gs::texture::~texture() { if (_is_owner && _texture) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); switch (gs_get_texture_type(_texture)) { case GS_TEXTURE_2D: gs_texture_destroy(_texture); @@ -154,18 +155,18 @@ gs::texture::~texture() _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_texture_t* gs::texture::get_object() +gs_texture_t* streamfx::obs::gs::texture::get_object() { return _texture; } -uint32_t gs::texture::get_width() +uint32_t streamfx::obs::gs::texture::get_width() { switch (_type) { case type::Normal: @@ -178,7 +179,7 @@ uint32_t gs::texture::get_width() return 0; } -uint32_t gs::texture::get_height() +uint32_t streamfx::obs::gs::texture::get_height() { switch (_type) { case type::Normal: @@ -191,7 +192,7 @@ uint32_t gs::texture::get_height() return 0; } -uint32_t gs::texture::get_depth() +uint32_t streamfx::obs::gs::texture::get_depth() { switch (_type) { case type::Normal: @@ -204,12 +205,12 @@ uint32_t gs::texture::get_depth() return 0; } -gs::texture::type gs::texture::get_type() +streamfx::obs::gs::texture::type streamfx::obs::gs::texture::get_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); } diff --git a/source/obs/gs/gs-texture.hpp b/source/obs/gs/gs-texture.hpp index 2364c241..9e3af286 100644 --- a/source/obs/gs/gs-texture.hpp +++ b/source/obs/gs/gs-texture.hpp @@ -20,7 +20,7 @@ #pragma once #include "common.hpp" -namespace gs { +namespace streamfx::obs::gs { class texture { public: enum class type : uint8_t { Normal, Volume, Cube }; @@ -52,7 +52,7 @@ namespace gs { * \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, - gs::texture::flags texture_flags); + streamfx::obs::gs::texture::flags texture_flags); /*! * \brief Create a 3D Texture @@ -66,7 +66,7 @@ namespace gs { * \param texture_flags Texture Flags */ 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 @@ -78,7 +78,7 @@ namespace gs { * \param texture_flags Texture Flags */ 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 @@ -107,10 +107,10 @@ namespace gs { uint32_t get_depth(); - gs::texture::type get_type(); + streamfx::obs::gs::texture::type get_type(); 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) diff --git a/source/obs/gs/gs-vertex.cpp b/source/obs/gs/gs-vertex.cpp index 4f6af78f..1052a4f7 100644 --- a/source/obs/gs/gs-vertex.cpp +++ b/source/obs/gs/gs-vertex.cpp @@ -20,7 +20,7 @@ #include "gs-vertex.hpp" #include -gs::vertex::vertex() +streamfx::obs::gs::vertex::vertex() : position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), _has_store(true), _store(nullptr) { _store = @@ -46,14 +46,14 @@ gs::vertex::vertex() } } -gs::vertex::~vertex() +streamfx::obs::gs::vertex::~vertex() { if (_has_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) { if (uvs != nullptr) { diff --git a/source/obs/gs/gs-vertex.hpp b/source/obs/gs/gs-vertex.hpp index 60e79b87..8289c973 100644 --- a/source/obs/gs/gs-vertex.hpp +++ b/source/obs/gs/gs-vertex.hpp @@ -21,7 +21,7 @@ #include "common.hpp" #include "gs-limits.hpp" -namespace gs { +namespace streamfx::obs::gs { struct vertex { vec3* position; vec3* normal; @@ -37,4 +37,4 @@ namespace gs { bool _has_store; void* _store; }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/obs/gs/gs-vertexbuffer.cpp b/source/obs/gs/gs-vertexbuffer.cpp index da64bc15..1ede2ced 100644 --- a/source/obs/gs/gs-vertexbuffer.cpp +++ b/source/obs/gs/gs-vertexbuffer.cpp @@ -21,7 +21,7 @@ #include #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(); @@ -62,11 +62,11 @@ void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers) // 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), [this](gs_vertbuffer_t* v) { try { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); gs_vertexbuffer_destroy(v); } catch (...) { 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 streamfx::util::free_aligned(_positions); @@ -99,12 +99,12 @@ void gs::vertex_buffer::finalize() _data.reset(); } -gs::vertex_buffer::~vertex_buffer() +streamfx::obs::gs::vertex_buffer::~vertex_buffer() { 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), _buffer(nullptr), _data(nullptr), @@ -116,7 +116,7 @@ gs::vertex_buffer::vertex_buffer(uint32_t size, uint8_t 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), _buffer(nullptr), _data(nullptr), @@ -125,7 +125,7 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb) _obs_data(nullptr) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); gs_vb_data* vbd = gs_vertexbuffer_get_data(vb); if (!vbd) 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 memcpy(_positions, other._positions, _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 initialize(other._capacity, other._layers); _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 _capacity = other._capacity; _size = other._size; @@ -202,7 +203,7 @@ gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other) noexcept _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 finalize(); @@ -222,7 +223,7 @@ void gs::vertex_buffer::operator=(vertex_buffer const&& other) _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) { throw std::out_of_range("size larger than capacity"); @@ -230,70 +231,70 @@ void gs::vertex_buffer::resize(uint32_t size) _size = size; } -uint32_t gs::vertex_buffer::size() +uint32_t streamfx::obs::gs::vertex_buffer::size() { return _size; } -uint32_t gs::vertex_buffer::capacity() +uint32_t streamfx::obs::gs::vertex_buffer::capacity() { return _capacity; } -bool gs::vertex_buffer::empty() +bool streamfx::obs::gs::vertex_buffer::empty() { 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) { 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++) { vtx.uv[n] = &_uvs[n][idx]; } 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); } -void gs::vertex_buffer::set_uv_layers(uint8_t layers) +void streamfx::obs::gs::vertex_buffer::set_uv_layers(uint8_t layers) { _layers = layers; } -uint8_t gs::vertex_buffer::get_uv_layers() +uint8_t streamfx::obs::gs::vertex_buffer::get_uv_layers() { return _layers; } -vec3* gs::vertex_buffer::get_positions() +vec3* streamfx::obs::gs::vertex_buffer::get_positions() { return _positions; } -vec3* gs::vertex_buffer::get_normals() +vec3* streamfx::obs::gs::vertex_buffer::get_normals() { return _normals; } -vec3* gs::vertex_buffer::get_tangents() +vec3* streamfx::obs::gs::vertex_buffer::get_tangents() { return _tangents; } -uint32_t* gs::vertex_buffer::get_colors() +uint32_t* streamfx::obs::gs::vertex_buffer::get_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) { 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]; } -gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU) +gs_vertbuffer_t* streamfx::obs::gs::vertex_buffer::update(bool refreshGPU) { if (refreshGPU) { - auto gctx = gs::context(); + auto gctx = streamfx::obs::gs::context(); gs_vertexbuffer_flush_direct(_buffer.get(), _data.get()); _obs_data = gs_vertexbuffer_get_data(_buffer.get()); } return _buffer.get(); } -gs_vertbuffer_t* gs::vertex_buffer::update() +gs_vertbuffer_t* streamfx::obs::gs::vertex_buffer::update() { return update(true); } diff --git a/source/obs/gs/gs-vertexbuffer.hpp b/source/obs/gs/gs-vertexbuffer.hpp index 90d0498d..3bb61cd6 100644 --- a/source/obs/gs/gs-vertexbuffer.hpp +++ b/source/obs/gs/gs-vertexbuffer.hpp @@ -22,7 +22,7 @@ #include "gs-limits.hpp" #include "gs-vertex.hpp" -namespace gs { +namespace streamfx::obs::gs { class vertex_buffer { uint32_t _capacity; uint32_t _size; @@ -121,9 +121,9 @@ namespace gs { 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); @@ -173,4 +173,4 @@ namespace gs { gs_vertbuffer_t* update(bool refreshGPU); }; -} // namespace gs +} // namespace streamfx::obs::gs diff --git a/source/plugin.cpp b/source/plugin.cpp index 75666bcf..ab505216 100644 --- a/source/plugin.cpp +++ b/source/plugin.cpp @@ -73,8 +73,8 @@ //static std::shared_ptr _updater; #endif -static std::shared_ptr _threadpool; -static std::shared_ptr _gs_fstri_vb; +static std::shared_ptr _threadpool; +static std::shared_ptr _gs_fstri_vb; MODULE_EXPORT bool obs_module_load(void) try { @@ -91,7 +91,7 @@ try { // GS Stuff { - _gs_fstri_vb = std::make_shared(uint32_t(3), uint8_t(1)); + _gs_fstri_vb = std::make_shared(uint32_t(3), uint8_t(1)); { auto vtx = _gs_fstri_vb->at(0); vec3_set(vtx.position, 0, 0, 0); diff --git a/source/sources/source-mirror.cpp b/source/sources/source-mirror.cpp index 4fb966be..0acf1e23 100644 --- a/source/sources/source-mirror.cpp +++ b/source/sources/source-mirror.cpp @@ -143,8 +143,8 @@ void mirror_instance::video_render(gs_effect_t* effect) return; #ifdef ENABLE_PROFILING - gs::debug_marker gdmp{gs::debug_color_source, "Source Mirror '%s' for '%s'", obs_source_get_name(_self), - obs_source_get_name(_source.get())}; + streamfx::obs::gs::debug_marker gdmp{streamfx::obs::gs::debug_color_source, "Source Mirror '%s' for '%s'", + obs_source_get_name(_self), obs_source_get_name(_source.get())}; #endif _source_size.first = obs_source_get_width(_source.get()); diff --git a/source/sources/source-shader.cpp b/source/sources/source-shader.cpp index 5d644875..c45ef1ed 100644 --- a/source/sources/source-shader.cpp +++ b/source/sources/source-shader.cpp @@ -83,7 +83,8 @@ void shader_instance::video_render(gs_effect_t* effect) } #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 _fx->prepare_render(); diff --git a/source/transitions/transition-shader.cpp b/source/transitions/transition-shader.cpp index 99324eca..8e797315 100644 --- a/source/transitions/transition-shader.cpp +++ b/source/transitions/transition-shader.cpp @@ -84,7 +84,8 @@ void shader_instance::video_render(gs_effect_t* effect) } #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 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) { - _fx->set_input_a(std::make_shared<::gs::texture>(a, false)); - _fx->set_input_b(std::make_shared<::gs::texture>(b, false)); + _fx->set_input_a(std::make_shared<::streamfx::obs::gs::texture>(a, false)); + _fx->set_input_b(std::make_shared<::streamfx::obs::gs::texture>(b, false)); _fx->set_transition_time(t); _fx->set_transition_size(cx, cy); _fx->prepare_render();