mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-23 11:55:11 +00:00
core: Clean up some older C++ code
- Remove float_t and double_t usage, as they aren't related to sized types. - Remove unused aligned types, their usage has been replaced quite a while ago. - Update the templates for pow and is_power_of_two.
This commit is contained in:
parent
6b02b76e6c
commit
d2a543f118
45 changed files with 474 additions and 508 deletions
|
@ -401,7 +401,7 @@ uint32_t autoframing_instance::get_height()
|
|||
return std::max<uint32_t>(_out_size.second, 1);
|
||||
}
|
||||
|
||||
void autoframing_instance::video_tick(float_t seconds)
|
||||
void autoframing_instance::video_tick(float seconds)
|
||||
{
|
||||
auto target = obs_filter_get_target(_self);
|
||||
auto width = obs_source_get_base_width(target);
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace streamfx::filter::autoframing {
|
|||
uint32_t get_width() override;
|
||||
uint32_t get_height() override;
|
||||
|
||||
virtual void video_tick(float_t seconds) override;
|
||||
virtual void video_tick(float seconds) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -290,12 +290,12 @@ void blur_instance::update(obs_data_t* settings)
|
|||
_mask.type = static_cast<mask_type>(obs_data_get_int(settings, ST_KEY_MASK_TYPE));
|
||||
switch (_mask.type) {
|
||||
case mask_type::Region:
|
||||
_mask.region.left = float_t(obs_data_get_double(settings, ST_KEY_MASK_REGION_LEFT) / 100.0);
|
||||
_mask.region.top = float_t(obs_data_get_double(settings, ST_KEY_MASK_REGION_TOP) / 100.0);
|
||||
_mask.region.right = 1.0f - float_t(obs_data_get_double(settings, ST_KEY_MASK_REGION_RIGHT) / 100.0);
|
||||
_mask.region.bottom = 1.0f - float_t(obs_data_get_double(settings, ST_KEY_MASK_REGION_BOTTOM) / 100.0);
|
||||
_mask.region.feather = float_t(obs_data_get_double(settings, ST_KEY_MASK_REGION_FEATHER) / 100.0);
|
||||
_mask.region.feather_shift = float_t(obs_data_get_double(settings, ST_KEY_MASK_REGION_FEATHER_SHIFT) / 100.0);
|
||||
_mask.region.left = float(obs_data_get_double(settings, ST_KEY_MASK_REGION_LEFT) / 100.0);
|
||||
_mask.region.top = float(obs_data_get_double(settings, ST_KEY_MASK_REGION_TOP) / 100.0);
|
||||
_mask.region.right = 1.0f - float(obs_data_get_double(settings, ST_KEY_MASK_REGION_RIGHT) / 100.0);
|
||||
_mask.region.bottom = 1.0f - float(obs_data_get_double(settings, ST_KEY_MASK_REGION_BOTTOM) / 100.0);
|
||||
_mask.region.feather = float(obs_data_get_double(settings, ST_KEY_MASK_REGION_FEATHER) / 100.0);
|
||||
_mask.region.feather_shift = float(obs_data_get_double(settings, ST_KEY_MASK_REGION_FEATHER_SHIFT) / 100.0);
|
||||
_mask.region.invert = obs_data_get_bool(settings, ST_KEY_MASK_REGION_INVERT);
|
||||
break;
|
||||
case mask_type::Image:
|
||||
|
@ -310,8 +310,8 @@ void blur_instance::update(obs_data_t* settings)
|
|||
_mask.color.r = static_cast<float>((color >> 0) & 0xFF) / 255.0f;
|
||||
_mask.color.g = static_cast<float>((color >> 8) & 0xFF) / 255.0f;
|
||||
_mask.color.b = static_cast<float>((color >> 16) & 0xFF) / 255.0f;
|
||||
_mask.color.a = static_cast<float_t>(obs_data_get_double(settings, ST_KEY_MASK_ALPHA));
|
||||
_mask.multiplier = float_t(obs_data_get_double(settings, ST_KEY_MASK_MULTIPLIER));
|
||||
_mask.color.a = static_cast<float>(obs_data_get_double(settings, ST_KEY_MASK_ALPHA));
|
||||
_mask.multiplier = float(obs_data_get_double(settings, ST_KEY_MASK_MULTIPLIER));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ void blur_instance::video_render(gs_effect_t* effect)
|
|||
std::string technique = "";
|
||||
switch (this->_mask.type) {
|
||||
case mask_type::Region:
|
||||
if (this->_mask.region.feather > std::numeric_limits<float_t>::epsilon()) {
|
||||
if (this->_mask.region.feather > std::numeric_limits<float>::epsilon()) {
|
||||
if (this->_mask.region.invert) {
|
||||
technique = "RegionFeatherInverted";
|
||||
} else {
|
||||
|
|
|
@ -55,12 +55,12 @@ namespace streamfx::filter::blur {
|
|||
bool enabled;
|
||||
mask_type type;
|
||||
struct {
|
||||
float_t left;
|
||||
float_t top;
|
||||
float_t right;
|
||||
float_t bottom;
|
||||
float_t feather;
|
||||
float_t feather_shift;
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
float feather;
|
||||
float feather_shift;
|
||||
bool invert;
|
||||
} region;
|
||||
struct {
|
||||
|
@ -76,12 +76,12 @@ namespace streamfx::filter::blur {
|
|||
std::shared_ptr<streamfx::obs::gs::texture> texture;
|
||||
} source;
|
||||
struct {
|
||||
float_t r;
|
||||
float_t g;
|
||||
float_t b;
|
||||
float_t a;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float a;
|
||||
} color;
|
||||
float_t multiplier;
|
||||
float multiplier;
|
||||
} _mask;
|
||||
|
||||
public:
|
||||
|
@ -93,7 +93,7 @@ namespace streamfx::filter::blur {
|
|||
virtual void migrate(obs_data_t* settings, uint64_t version) override;
|
||||
virtual void update(obs_data_t* settings) override;
|
||||
|
||||
virtual void video_tick(float_t time) override;
|
||||
virtual void video_tick(float time) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -156,12 +156,12 @@ void color_grade_instance::allocate_rendertarget(gs_color_format format)
|
|||
_cache_rt = std::make_unique<streamfx::obs::gs::rendertarget>(format, GS_ZS_NONE);
|
||||
}
|
||||
|
||||
float_t fix_gamma_value(double_t v)
|
||||
float fix_gamma_value(double_t v)
|
||||
{
|
||||
if (v < 0.0) {
|
||||
return static_cast<float_t>(-v + 1.0);
|
||||
return static_cast<float>(-v + 1.0);
|
||||
} else {
|
||||
return static_cast<float_t>(1.0 / (v + 1.0));
|
||||
return static_cast<float>(1.0 / (v + 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,38 +174,38 @@ void color_grade_instance::migrate(obs_data_t* data, uint64_t version) {}
|
|||
|
||||
void color_grade_instance::update(obs_data_t* data)
|
||||
{
|
||||
_lift.x = static_cast<float_t>(obs_data_get_double(data, ST_KEY_LIFT_(ST_RED)) / 100.0);
|
||||
_lift.y = static_cast<float_t>(obs_data_get_double(data, ST_KEY_LIFT_(ST_GREEN)) / 100.0);
|
||||
_lift.z = static_cast<float_t>(obs_data_get_double(data, ST_KEY_LIFT_(ST_BLUE)) / 100.0);
|
||||
_lift.w = static_cast<float_t>(obs_data_get_double(data, ST_KEY_LIFT_(ST_ALL)) / 100.0);
|
||||
_lift.x = static_cast<float>(obs_data_get_double(data, ST_KEY_LIFT_(ST_RED)) / 100.0);
|
||||
_lift.y = static_cast<float>(obs_data_get_double(data, ST_KEY_LIFT_(ST_GREEN)) / 100.0);
|
||||
_lift.z = static_cast<float>(obs_data_get_double(data, ST_KEY_LIFT_(ST_BLUE)) / 100.0);
|
||||
_lift.w = static_cast<float>(obs_data_get_double(data, ST_KEY_LIFT_(ST_ALL)) / 100.0);
|
||||
_gamma.x = fix_gamma_value(obs_data_get_double(data, ST_KEY_GAMMA_(ST_RED)) / 100.0);
|
||||
_gamma.y = fix_gamma_value(obs_data_get_double(data, ST_KEY_GAMMA_(ST_GREEN)) / 100.0);
|
||||
_gamma.z = fix_gamma_value(obs_data_get_double(data, ST_KEY_GAMMA_(ST_BLUE)) / 100.0);
|
||||
_gamma.w = fix_gamma_value(obs_data_get_double(data, ST_KEY_GAMMA_(ST_ALL)) / 100.0);
|
||||
_gain.x = static_cast<float_t>(obs_data_get_double(data, ST_KEY_GAIN_(ST_RED)) / 100.0);
|
||||
_gain.y = static_cast<float_t>(obs_data_get_double(data, ST_KEY_GAIN_(ST_GREEN)) / 100.0);
|
||||
_gain.z = static_cast<float_t>(obs_data_get_double(data, ST_KEY_GAIN_(ST_BLUE)) / 100.0);
|
||||
_gain.w = static_cast<float_t>(obs_data_get_double(data, ST_KEY_GAIN_(ST_ALL)) / 100.0);
|
||||
_offset.x = static_cast<float_t>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_RED)) / 100.0);
|
||||
_offset.y = static_cast<float_t>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_GREEN)) / 100.0);
|
||||
_offset.z = static_cast<float_t>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_BLUE)) / 100.0);
|
||||
_offset.w = static_cast<float_t>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_ALL)) / 100.0);
|
||||
_gain.x = static_cast<float>(obs_data_get_double(data, ST_KEY_GAIN_(ST_RED)) / 100.0);
|
||||
_gain.y = static_cast<float>(obs_data_get_double(data, ST_KEY_GAIN_(ST_GREEN)) / 100.0);
|
||||
_gain.z = static_cast<float>(obs_data_get_double(data, ST_KEY_GAIN_(ST_BLUE)) / 100.0);
|
||||
_gain.w = static_cast<float>(obs_data_get_double(data, ST_KEY_GAIN_(ST_ALL)) / 100.0);
|
||||
_offset.x = static_cast<float>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_RED)) / 100.0);
|
||||
_offset.y = static_cast<float>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_GREEN)) / 100.0);
|
||||
_offset.z = static_cast<float>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_BLUE)) / 100.0);
|
||||
_offset.w = static_cast<float>(obs_data_get_double(data, ST_KEY_OFFSET_(ST_ALL)) / 100.0);
|
||||
_tint_detection = static_cast<detection_mode>(obs_data_get_int(data, ST_KEY_TINT_DETECTION));
|
||||
_tint_luma = static_cast<luma_mode>(obs_data_get_int(data, ST_KEY_TINT_MODE));
|
||||
_tint_exponent = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_EXPONENT));
|
||||
_tint_low.x = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_LOW, ST_RED)) / 100.0);
|
||||
_tint_low.y = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_LOW, ST_GREEN)) / 100.0);
|
||||
_tint_low.z = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_LOW, ST_BLUE)) / 100.0);
|
||||
_tint_mid.x = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_MID, ST_RED)) / 100.0);
|
||||
_tint_mid.y = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_MID, ST_GREEN)) / 100.0);
|
||||
_tint_mid.z = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_MID, ST_BLUE)) / 100.0);
|
||||
_tint_hig.x = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_HIGH, ST_RED)) / 100.0);
|
||||
_tint_hig.y = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_HIGH, ST_GREEN)) / 100.0);
|
||||
_tint_hig.z = static_cast<float_t>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_HIGH, ST_BLUE)) / 100.0);
|
||||
_correction.x = static_cast<float_t>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_HUE)) / 360.0);
|
||||
_correction.y = static_cast<float_t>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_SATURATION)) / 100.0);
|
||||
_correction.z = static_cast<float_t>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_LIGHTNESS)) / 100.0);
|
||||
_correction.w = static_cast<float_t>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_CONTRAST)) / 100.0);
|
||||
_tint_exponent = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_EXPONENT));
|
||||
_tint_low.x = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_LOW, ST_RED)) / 100.0);
|
||||
_tint_low.y = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_LOW, ST_GREEN)) / 100.0);
|
||||
_tint_low.z = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_LOW, ST_BLUE)) / 100.0);
|
||||
_tint_mid.x = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_MID, ST_RED)) / 100.0);
|
||||
_tint_mid.y = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_MID, ST_GREEN)) / 100.0);
|
||||
_tint_mid.z = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_MID, ST_BLUE)) / 100.0);
|
||||
_tint_hig.x = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_HIGH, ST_RED)) / 100.0);
|
||||
_tint_hig.y = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_HIGH, ST_GREEN)) / 100.0);
|
||||
_tint_hig.z = static_cast<float>(obs_data_get_double(data, ST_KEY_TINT_(ST_TONE_HIGH, ST_BLUE)) / 100.0);
|
||||
_correction.x = static_cast<float>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_HUE)) / 360.0);
|
||||
_correction.y = static_cast<float>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_SATURATION)) / 100.0);
|
||||
_correction.z = static_cast<float>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_LIGHTNESS)) / 100.0);
|
||||
_correction.w = static_cast<float>(obs_data_get_double(data, ST_KEY_CORRECTION_(ST_CONTRAST)) / 100.0);
|
||||
|
||||
{
|
||||
int64_t v = obs_data_get_int(data, ST_KEY_RENDERMODE);
|
||||
|
@ -370,7 +370,7 @@ void color_grade_instance::video_render(gs_effect_t* shader)
|
|||
|
||||
{
|
||||
auto op = _ccache_rt->render(width, height);
|
||||
gs_ortho(0, static_cast<float_t>(width), 0, static_cast<float_t>(height), 0, 1);
|
||||
gs_ortho(0, static_cast<float>(width), 0, static_cast<float>(height), 0, 1);
|
||||
|
||||
// Blank out the input cache.
|
||||
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &blank, 0., 0);
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace streamfx::filter::color_grade {
|
|||
vec4 _offset;
|
||||
detection_mode _tint_detection;
|
||||
luma_mode _tint_luma;
|
||||
float_t _tint_exponent;
|
||||
float _tint_exponent;
|
||||
vec3 _tint_low;
|
||||
vec3 _tint_mid;
|
||||
vec3 _tint_hig;
|
||||
|
@ -83,7 +83,7 @@ namespace streamfx::filter::color_grade {
|
|||
|
||||
void rebuild_lut();
|
||||
|
||||
virtual void video_tick(float_t time) override;
|
||||
virtual void video_tick(float time) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ uint32_t streamfx::filter::denoising::denoising_instance::get_height()
|
|||
return std::max<uint32_t>(_size.second, 1);
|
||||
}
|
||||
|
||||
void denoising_instance::video_tick(float_t time)
|
||||
void denoising_instance::video_tick(float time)
|
||||
{
|
||||
auto parent = obs_filter_get_parent(_self);
|
||||
auto target = obs_filter_get_target(_self);
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace streamfx::filter::denoising {
|
|||
uint32_t get_width() override;
|
||||
uint32_t get_height() override;
|
||||
|
||||
void video_tick(float_t time) override;
|
||||
void video_tick(float time) override;
|
||||
void video_render(gs_effect_t* effect) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -158,11 +158,11 @@ void dynamic_mask_instance::update(obs_data_t* settings)
|
|||
}
|
||||
|
||||
std::string chv_key = std::string(ST_KEY_CHANNEL_VALUE) + "." + kv1.second;
|
||||
found->second.value = static_cast<float_t>(obs_data_get_double(settings, chv_key.c_str()));
|
||||
found->second.value = static_cast<float>(obs_data_get_double(settings, chv_key.c_str()));
|
||||
_precalc.base.ptr[static_cast<size_t>(kv1.first)] = found->second.value;
|
||||
|
||||
std::string chm_key = std::string(ST_KEY_CHANNEL_MULTIPLIER) + "." + kv1.second;
|
||||
found->second.scale = static_cast<float_t>(obs_data_get_double(settings, chm_key.c_str()));
|
||||
found->second.scale = static_cast<float>(obs_data_get_double(settings, chm_key.c_str()));
|
||||
_precalc.scale.ptr[static_cast<size_t>(kv1.first)] = found->second.scale;
|
||||
|
||||
vec4* ch = &_precalc.matrix.x;
|
||||
|
@ -185,7 +185,7 @@ void dynamic_mask_instance::update(obs_data_t* settings)
|
|||
|
||||
for (auto kv2 : channel_translations) {
|
||||
std::string ab_key = std::string(ST_KEY_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second;
|
||||
found->second.values.ptr[static_cast<size_t>(kv2.first)] = static_cast<float_t>(obs_data_get_double(settings, ab_key.c_str()));
|
||||
found->second.values.ptr[static_cast<size_t>(kv2.first)] = static_cast<float>(obs_data_get_double(settings, ab_key.c_str()));
|
||||
ch->ptr[static_cast<size_t>(kv2.first)] = found->second.values.ptr[static_cast<size_t>(kv2.first)];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ namespace streamfx::filter::dynamic_mask {
|
|||
int64_t _debug_texture;
|
||||
|
||||
struct channel_data {
|
||||
float_t value = 0.0;
|
||||
float_t scale = 1.0;
|
||||
float value = 0.0;
|
||||
float scale = 1.0;
|
||||
vec4 values = {0, 0, 0, 0};
|
||||
};
|
||||
std::map<channel, channel_data> _channels;
|
||||
|
@ -94,7 +94,7 @@ namespace streamfx::filter::dynamic_mask {
|
|||
virtual void save(obs_data_t* settings) override;
|
||||
|
||||
virtual gs_color_space video_get_color_space(size_t count, const gs_color_space* preferred_spaces) override;
|
||||
virtual void video_tick(float_t time) override;
|
||||
virtual void video_tick(float time) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
void enum_active_sources(obs_source_enum_proc_t enum_callback, void* param) override;
|
||||
|
|
|
@ -160,15 +160,15 @@ void sdf_effects_instance::update(obs_data_t* data)
|
|||
cs c;
|
||||
};
|
||||
color = uint32_t(obs_data_get_int(data, ST_KEY_SHADOW_OUTER_COLOR));
|
||||
_outer_shadow_color.x = float_t(c.r / 255.0);
|
||||
_outer_shadow_color.y = float_t(c.g / 255.0);
|
||||
_outer_shadow_color.z = float_t(c.b / 255.0);
|
||||
_outer_shadow_color.w = float_t(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_ALPHA) / 100.0);
|
||||
_outer_shadow_color.x = float(c.r / 255.0);
|
||||
_outer_shadow_color.y = float(c.g / 255.0);
|
||||
_outer_shadow_color.z = float(c.b / 255.0);
|
||||
_outer_shadow_color.w = float(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_ALPHA) / 100.0);
|
||||
}
|
||||
_outer_shadow_range_min = float_t(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_RANGE_MINIMUM));
|
||||
_outer_shadow_range_max = float_t(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_RANGE_MAXIMUM));
|
||||
_outer_shadow_offset_x = float_t(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_OFFSET_X));
|
||||
_outer_shadow_offset_y = float_t(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_OFFSET_Y));
|
||||
_outer_shadow_range_min = float(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_RANGE_MINIMUM));
|
||||
_outer_shadow_range_max = float(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_RANGE_MAXIMUM));
|
||||
_outer_shadow_offset_x = float(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_OFFSET_X));
|
||||
_outer_shadow_offset_y = float(obs_data_get_double(data, ST_KEY_SHADOW_OUTER_OFFSET_Y));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -183,15 +183,15 @@ void sdf_effects_instance::update(obs_data_t* data)
|
|||
cs c;
|
||||
};
|
||||
color = uint32_t(obs_data_get_int(data, ST_KEY_SHADOW_INNER_COLOR));
|
||||
_inner_shadow_color.x = float_t(c.r / 255.0);
|
||||
_inner_shadow_color.y = float_t(c.g / 255.0);
|
||||
_inner_shadow_color.z = float_t(c.b / 255.0);
|
||||
_inner_shadow_color.w = float_t(obs_data_get_double(data, ST_KEY_SHADOW_INNER_ALPHA) / 100.0);
|
||||
_inner_shadow_color.x = float(c.r / 255.0);
|
||||
_inner_shadow_color.y = float(c.g / 255.0);
|
||||
_inner_shadow_color.z = float(c.b / 255.0);
|
||||
_inner_shadow_color.w = float(obs_data_get_double(data, ST_KEY_SHADOW_INNER_ALPHA) / 100.0);
|
||||
}
|
||||
_inner_shadow_range_min = float_t(obs_data_get_double(data, ST_KEY_SHADOW_INNER_RANGE_MINIMUM));
|
||||
_inner_shadow_range_max = float_t(obs_data_get_double(data, ST_KEY_SHADOW_INNER_RANGE_MAXIMUM));
|
||||
_inner_shadow_offset_x = float_t(obs_data_get_double(data, ST_KEY_SHADOW_INNER_OFFSET_X));
|
||||
_inner_shadow_offset_y = float_t(obs_data_get_double(data, ST_KEY_SHADOW_INNER_OFFSET_Y));
|
||||
_inner_shadow_range_min = float(obs_data_get_double(data, ST_KEY_SHADOW_INNER_RANGE_MINIMUM));
|
||||
_inner_shadow_range_max = float(obs_data_get_double(data, ST_KEY_SHADOW_INNER_RANGE_MAXIMUM));
|
||||
_inner_shadow_offset_x = float(obs_data_get_double(data, ST_KEY_SHADOW_INNER_OFFSET_X));
|
||||
_inner_shadow_offset_y = float(obs_data_get_double(data, ST_KEY_SHADOW_INNER_OFFSET_Y));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -206,16 +206,16 @@ void sdf_effects_instance::update(obs_data_t* data)
|
|||
cs c;
|
||||
};
|
||||
color = uint32_t(obs_data_get_int(data, ST_KEY_GLOW_OUTER_COLOR));
|
||||
_outer_glow_color.x = float_t(c.r / 255.0);
|
||||
_outer_glow_color.y = float_t(c.g / 255.0);
|
||||
_outer_glow_color.z = float_t(c.b / 255.0);
|
||||
_outer_glow_color.w = float_t(obs_data_get_double(data, ST_KEY_GLOW_OUTER_ALPHA) / 100.0);
|
||||
_outer_glow_color.x = float(c.r / 255.0);
|
||||
_outer_glow_color.y = float(c.g / 255.0);
|
||||
_outer_glow_color.z = float(c.b / 255.0);
|
||||
_outer_glow_color.w = float(obs_data_get_double(data, ST_KEY_GLOW_OUTER_ALPHA) / 100.0);
|
||||
}
|
||||
_outer_glow_width = float_t(obs_data_get_double(data, ST_KEY_GLOW_OUTER_WIDTH));
|
||||
_outer_glow_sharpness = float_t(obs_data_get_double(data, ST_KEY_GLOW_OUTER_SHARPNESS) / 100.0);
|
||||
_outer_glow_sharpness_inv = float_t(1.0f / (1.0f - _outer_glow_sharpness));
|
||||
if (_outer_glow_sharpness >= (1.0f - std::numeric_limits<float_t>::epsilon())) {
|
||||
_outer_glow_sharpness = 1.0f - std::numeric_limits<float_t>::epsilon();
|
||||
_outer_glow_width = float(obs_data_get_double(data, ST_KEY_GLOW_OUTER_WIDTH));
|
||||
_outer_glow_sharpness = float(obs_data_get_double(data, ST_KEY_GLOW_OUTER_SHARPNESS) / 100.0);
|
||||
_outer_glow_sharpness_inv = float(1.0f / (1.0f - _outer_glow_sharpness));
|
||||
if (_outer_glow_sharpness >= (1.0f - std::numeric_limits<float>::epsilon())) {
|
||||
_outer_glow_sharpness = 1.0f - std::numeric_limits<float>::epsilon();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,16 +231,16 @@ void sdf_effects_instance::update(obs_data_t* data)
|
|||
cs c;
|
||||
};
|
||||
color = uint32_t(obs_data_get_int(data, ST_KEY_GLOW_INNER_COLOR));
|
||||
_inner_glow_color.x = float_t(c.r / 255.0);
|
||||
_inner_glow_color.y = float_t(c.g / 255.0);
|
||||
_inner_glow_color.z = float_t(c.b / 255.0);
|
||||
_inner_glow_color.w = float_t(obs_data_get_double(data, ST_KEY_GLOW_INNER_ALPHA) / 100.0);
|
||||
_inner_glow_color.x = float(c.r / 255.0);
|
||||
_inner_glow_color.y = float(c.g / 255.0);
|
||||
_inner_glow_color.z = float(c.b / 255.0);
|
||||
_inner_glow_color.w = float(obs_data_get_double(data, ST_KEY_GLOW_INNER_ALPHA) / 100.0);
|
||||
}
|
||||
_inner_glow_width = float_t(obs_data_get_double(data, ST_KEY_GLOW_INNER_WIDTH));
|
||||
_inner_glow_sharpness = float_t(obs_data_get_double(data, ST_KEY_GLOW_INNER_SHARPNESS) / 100.0);
|
||||
_inner_glow_sharpness_inv = float_t(1.0f / (1.0f - _inner_glow_sharpness));
|
||||
if (_inner_glow_sharpness >= (1.0f - std::numeric_limits<float_t>::epsilon())) {
|
||||
_inner_glow_sharpness = 1.0f - std::numeric_limits<float_t>::epsilon();
|
||||
_inner_glow_width = float(obs_data_get_double(data, ST_KEY_GLOW_INNER_WIDTH));
|
||||
_inner_glow_sharpness = float(obs_data_get_double(data, ST_KEY_GLOW_INNER_SHARPNESS) / 100.0);
|
||||
_inner_glow_sharpness_inv = float(1.0f / (1.0f - _inner_glow_sharpness));
|
||||
if (_inner_glow_sharpness >= (1.0f - std::numeric_limits<float>::epsilon())) {
|
||||
_inner_glow_sharpness = 1.0f - std::numeric_limits<float>::epsilon();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,25 +256,25 @@ void sdf_effects_instance::update(obs_data_t* data)
|
|||
cs c;
|
||||
};
|
||||
color = uint32_t(obs_data_get_int(data, ST_KEY_OUTLINE_COLOR));
|
||||
_outline_color.x = float_t(c.r / 255.0);
|
||||
_outline_color.y = float_t(c.g / 255.0);
|
||||
_outline_color.z = float_t(c.b / 255.0);
|
||||
_outline_color.w = float_t(obs_data_get_double(data, ST_KEY_OUTLINE_ALPHA) / 100.0);
|
||||
_outline_color.x = float(c.r / 255.0);
|
||||
_outline_color.y = float(c.g / 255.0);
|
||||
_outline_color.z = float(c.b / 255.0);
|
||||
_outline_color.w = float(obs_data_get_double(data, ST_KEY_OUTLINE_ALPHA) / 100.0);
|
||||
}
|
||||
_outline_width = float_t(obs_data_get_double(data, ST_KEY_OUTLINE_WIDTH));
|
||||
_outline_offset = float_t(obs_data_get_double(data, ST_KEY_OUTLINE_OFFSET));
|
||||
_outline_sharpness = float_t(obs_data_get_double(data, ST_KEY_OUTLINE_SHARPNESS) / 100.0);
|
||||
_outline_sharpness_inv = float_t(1.0f / (1.0f - _outline_sharpness));
|
||||
if (_outline_sharpness >= (1.0f - std::numeric_limits<float_t>::epsilon())) {
|
||||
_outline_sharpness = 1.0f - std::numeric_limits<float_t>::epsilon();
|
||||
_outline_width = float(obs_data_get_double(data, ST_KEY_OUTLINE_WIDTH));
|
||||
_outline_offset = float(obs_data_get_double(data, ST_KEY_OUTLINE_OFFSET));
|
||||
_outline_sharpness = float(obs_data_get_double(data, ST_KEY_OUTLINE_SHARPNESS) / 100.0);
|
||||
_outline_sharpness_inv = float(1.0f / (1.0f - _outline_sharpness));
|
||||
if (_outline_sharpness >= (1.0f - std::numeric_limits<float>::epsilon())) {
|
||||
_outline_sharpness = 1.0f - std::numeric_limits<float>::epsilon();
|
||||
}
|
||||
}
|
||||
|
||||
_sdf_scale = double_t(obs_data_get_double(data, ST_KEY_SDF_SCALE) / 100.0);
|
||||
_sdf_threshold = float_t(obs_data_get_double(data, ST_KEY_SDF_THRESHOLD) / 100.0);
|
||||
_sdf_threshold = float(obs_data_get_double(data, ST_KEY_SDF_THRESHOLD) / 100.0);
|
||||
}
|
||||
|
||||
void sdf_effects_instance::video_tick(float_t)
|
||||
void sdf_effects_instance::video_tick(float)
|
||||
{
|
||||
if (obs_source_t* target = obs_filter_get_target(_self); target != nullptr) {
|
||||
_source_rendered = false;
|
||||
|
@ -372,7 +372,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
|||
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &color_transparent, 0, 0);
|
||||
|
||||
_sdf_producer_effect.get_parameter("_image").set_texture(_source_texture);
|
||||
_sdf_producer_effect.get_parameter("_size").set_float2(float_t(sdfW), float_t(sdfH));
|
||||
_sdf_producer_effect.get_parameter("_size").set_float2(float(sdfW), float(sdfH));
|
||||
_sdf_producer_effect.get_parameter("_sdf").set_texture(_sdf_texture);
|
||||
_sdf_producer_effect.get_parameter("_threshold").set_float(_sdf_threshold);
|
||||
|
||||
|
@ -447,7 +447,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
|||
_sdf_consumer_effect.get_parameter("pShadowColor").set_float4(_outer_shadow_color);
|
||||
_sdf_consumer_effect.get_parameter("pShadowMin").set_float(_outer_shadow_range_min);
|
||||
_sdf_consumer_effect.get_parameter("pShadowMax").set_float(_outer_shadow_range_max);
|
||||
_sdf_consumer_effect.get_parameter("pShadowOffset").set_float2(_outer_shadow_offset_x / float_t(baseW), _outer_shadow_offset_y / float_t(baseH));
|
||||
_sdf_consumer_effect.get_parameter("pShadowOffset").set_float2(_outer_shadow_offset_x / float(baseW), _outer_shadow_offset_y / float(baseH));
|
||||
while (gs_effect_loop(_sdf_consumer_effect.get_object(), "ShadowOuter")) {
|
||||
_gfx_util->draw_fullscreen_triangle();
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
|
|||
_sdf_consumer_effect.get_parameter("pShadowColor").set_float4(_inner_shadow_color);
|
||||
_sdf_consumer_effect.get_parameter("pShadowMin").set_float(_inner_shadow_range_min);
|
||||
_sdf_consumer_effect.get_parameter("pShadowMax").set_float(_inner_shadow_range_max);
|
||||
_sdf_consumer_effect.get_parameter("pShadowOffset").set_float2(_inner_shadow_offset_x / float_t(baseW), _inner_shadow_offset_y / float_t(baseH));
|
||||
_sdf_consumer_effect.get_parameter("pShadowOffset").set_float2(_inner_shadow_offset_x / float(baseW), _inner_shadow_offset_y / float(baseH));
|
||||
while (gs_effect_loop(_sdf_consumer_effect.get_object(), "ShadowInner")) {
|
||||
_gfx_util->draw_fullscreen_triangle();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace streamfx::filter::sdf_effects {
|
|||
std::shared_ptr<streamfx::obs::gs::rendertarget> _sdf_read;
|
||||
std::shared_ptr<streamfx::obs::gs::texture> _sdf_texture;
|
||||
double_t _sdf_scale;
|
||||
float_t _sdf_threshold;
|
||||
float _sdf_threshold;
|
||||
|
||||
// Effects
|
||||
bool _output_rendered;
|
||||
|
@ -37,36 +37,36 @@ namespace streamfx::filter::sdf_effects {
|
|||
/// Inner Shadow
|
||||
bool _inner_shadow;
|
||||
vec4 _inner_shadow_color;
|
||||
float_t _inner_shadow_range_min;
|
||||
float_t _inner_shadow_range_max;
|
||||
float_t _inner_shadow_offset_x;
|
||||
float_t _inner_shadow_offset_y;
|
||||
float _inner_shadow_range_min;
|
||||
float _inner_shadow_range_max;
|
||||
float _inner_shadow_offset_x;
|
||||
float _inner_shadow_offset_y;
|
||||
/// Outer Shadow
|
||||
bool _outer_shadow;
|
||||
vec4 _outer_shadow_color;
|
||||
float_t _outer_shadow_range_min;
|
||||
float_t _outer_shadow_range_max;
|
||||
float_t _outer_shadow_offset_x;
|
||||
float_t _outer_shadow_offset_y;
|
||||
float _outer_shadow_range_min;
|
||||
float _outer_shadow_range_max;
|
||||
float _outer_shadow_offset_x;
|
||||
float _outer_shadow_offset_y;
|
||||
/// Inner Glow
|
||||
bool _inner_glow;
|
||||
vec4 _inner_glow_color;
|
||||
float_t _inner_glow_width;
|
||||
float_t _inner_glow_sharpness;
|
||||
float_t _inner_glow_sharpness_inv;
|
||||
float _inner_glow_width;
|
||||
float _inner_glow_sharpness;
|
||||
float _inner_glow_sharpness_inv;
|
||||
/// Outer Glow
|
||||
bool _outer_glow;
|
||||
vec4 _outer_glow_color;
|
||||
float_t _outer_glow_width;
|
||||
float_t _outer_glow_sharpness;
|
||||
float_t _outer_glow_sharpness_inv;
|
||||
float _outer_glow_width;
|
||||
float _outer_glow_sharpness;
|
||||
float _outer_glow_sharpness_inv;
|
||||
/// Outline
|
||||
bool _outline;
|
||||
vec4 _outline_color;
|
||||
float_t _outline_width;
|
||||
float_t _outline_offset;
|
||||
float_t _outline_sharpness;
|
||||
float_t _outline_sharpness_inv;
|
||||
float _outline_width;
|
||||
float _outline_offset;
|
||||
float _outline_sharpness;
|
||||
float _outline_sharpness_inv;
|
||||
|
||||
public:
|
||||
sdf_effects_instance(obs_data_t* settings, obs_source_t* self);
|
||||
|
@ -76,7 +76,7 @@ namespace streamfx::filter::sdf_effects {
|
|||
virtual void migrate(obs_data_t* data, uint64_t version) override;
|
||||
virtual void update(obs_data_t* settings) override;
|
||||
|
||||
virtual void video_tick(float_t) override;
|
||||
virtual void video_tick(float) override;
|
||||
virtual void video_render(gs_effect_t*) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ void shader_instance::update(obs_data_t* data)
|
|||
_fx->update(data);
|
||||
}
|
||||
|
||||
void shader_instance::video_tick(float_t sec_since_last)
|
||||
void shader_instance::video_tick(float sec_since_last)
|
||||
{
|
||||
if (_fx->tick(sec_since_last)) {
|
||||
obs_data_t* data = obs_source_get_settings(_self);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace streamfx::filter::shader {
|
|||
virtual void migrate(obs_data_t* data, uint64_t version) override;
|
||||
virtual void update(obs_data_t* data) override;
|
||||
|
||||
virtual void video_tick(float_t sec_since_last) override;
|
||||
virtual void video_tick(float sec_since_last) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
void show() override;
|
||||
|
|
|
@ -193,7 +193,7 @@ uint32_t streamfx::filter::upscaling::upscaling_instance::get_height()
|
|||
return std::max<uint32_t>(_out_size.second, 1);
|
||||
}
|
||||
|
||||
void upscaling_instance::video_tick(float_t time)
|
||||
void upscaling_instance::video_tick(float time)
|
||||
{
|
||||
auto target = obs_filter_get_target(_self);
|
||||
auto width = obs_source_get_base_width(target);
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace streamfx::filter::upscaling {
|
|||
uint32_t get_width() override;
|
||||
uint32_t get_height() override;
|
||||
|
||||
void video_tick(float_t time) override;
|
||||
void video_tick(float time) override;
|
||||
void video_render(gs_effect_t* effect) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -202,7 +202,7 @@ uint32_t streamfx::filter::virtual_greenscreen::virtual_greenscreen_instance::ge
|
|||
return std::max<uint32_t>(_size.second, 1);
|
||||
}
|
||||
|
||||
void virtual_greenscreen_instance::video_tick(float_t time)
|
||||
void virtual_greenscreen_instance::video_tick(float time)
|
||||
{
|
||||
auto target = obs_filter_get_target(_self);
|
||||
auto width = obs_source_get_base_width(target);
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace streamfx::filter::virtual_greenscreen {
|
|||
uint32_t get_width() override;
|
||||
uint32_t get_height() override;
|
||||
|
||||
void video_tick(float_t time) override;
|
||||
void video_tick(float time) override;
|
||||
void video_render(gs_effect_t* effect) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -236,8 +236,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear::r
|
|||
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());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
gs_enable_color(true, true, true, true);
|
||||
|
@ -257,10 +257,10 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear::r
|
|||
if (effect) {
|
||||
// Pass 1
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f);
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), 0.f);
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float(1.0f / (float(_size) * 2.0f + 1.0f)));
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -276,7 +276,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear::r
|
|||
|
||||
// Pass 2
|
||||
effect.get_parameter("pImage").set_texture(_rendertarget2->get_texture());
|
||||
effect.get_parameter("pImageTexel").set_float2(0., float_t(1.f / height));
|
||||
effect.get_parameter("pImageTexel").set_float2(0., float(1.f / height));
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -326,8 +326,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear_di
|
|||
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());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
gs_blend_state_push();
|
||||
gs_reset_blend_state();
|
||||
|
@ -346,10 +346,10 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear_di
|
|||
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. / width * cos(_angle)), float_t(1.f / height * sin(_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1. / width * cos(_angle)), float(1.f / height * sin(_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float(1.0f / (float(_size) * 2.0f + 1.0f)));
|
||||
|
||||
{
|
||||
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
||||
|
|
|
@ -246,8 +246,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box::render()
|
|||
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());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
gs_enable_color(true, true, true, true);
|
||||
|
@ -267,10 +267,10 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box::render()
|
|||
if (effect) {
|
||||
// Pass 1
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f);
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), 0.f);
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float(1.0f / (float(_size) * 2.0f + 1.0f)));
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -286,7 +286,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box::render()
|
|||
|
||||
// Pass 2
|
||||
effect.get_parameter("pImage").set_texture(_rendertarget2->get_texture());
|
||||
effect.get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height));
|
||||
effect.get_parameter("pImageTexel").set_float2(0.f, float(1.f / height));
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -336,8 +336,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_direction
|
|||
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());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
gs_blend_state_push();
|
||||
gs_reset_blend_state();
|
||||
|
@ -356,10 +356,10 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_direction
|
|||
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. / width * cos(_angle)), float_t(1.f / height * sin(_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1. / width * cos(_angle)), float(1.f / height * sin(_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float(1.0f / (float(_size) * 2.0f + 1.0f)));
|
||||
|
||||
{
|
||||
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
||||
|
@ -410,8 +410,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_rotationa
|
|||
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());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
gs_blend_state_push();
|
||||
gs_reset_blend_state();
|
||||
|
@ -430,12 +430,12 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_rotationa
|
|||
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));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pAngle").set_float(float_t(_angle / _size));
|
||||
effect.get_parameter("pCenter").set_float2(float_t(_center.first), float_t(_center.second));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), float(1.f / height));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float(1.0f / (float(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pAngle").set_float(float(_angle / _size));
|
||||
effect.get_parameter("pCenter").set_float2(float(_center.first), float(_center.second));
|
||||
|
||||
{
|
||||
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
||||
|
@ -476,8 +476,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_zoom::ren
|
|||
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());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
gs_blend_state_push();
|
||||
gs_reset_blend_state();
|
||||
|
@ -496,11 +496,11 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_zoom::ren
|
|||
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));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pCenter").set_float2(float_t(_center.first), float_t(_center.second));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), float(1.f / height));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pSizeInverseMul").set_float(float(1.0f / (float(_size) * 2.0f + 1.0f)));
|
||||
effect.get_parameter("pCenter").set_float2(float(_center.first), float(_center.second));
|
||||
|
||||
{
|
||||
auto op = _rendertarget->render(uint32_t(width), uint32_t(height));
|
||||
|
|
|
@ -40,7 +40,7 @@ streamfx::gfx::blur::gaussian_linear_data::gaussian_linear_data() : _gfx_util(::
|
|||
// Precalculate Kernels
|
||||
for (std::size_t kernel_size = 1; kernel_size <= ST_MAX_BLUR_SIZE; kernel_size++) {
|
||||
std::vector<double_t> kernel_math(ST_MAX_KERNEL_SIZE);
|
||||
std::vector<float_t> kernel_data(ST_MAX_KERNEL_SIZE);
|
||||
std::vector<float> kernel_data(ST_MAX_KERNEL_SIZE);
|
||||
double_t actual_width = 1.;
|
||||
|
||||
// Find actual kernel width.
|
||||
|
@ -61,7 +61,7 @@ streamfx::gfx::blur::gaussian_linear_data::gaussian_linear_data() : _gfx_util(::
|
|||
// Normalize to fill the entire 0..1 range over the width.
|
||||
double_t inverse_sum = 1.0 / sum;
|
||||
for (std::size_t p = 0; p <= kernel_size; p++) {
|
||||
kernel_data.at(p) = float_t(kernel_math[p] * inverse_sum);
|
||||
kernel_data.at(p) = float(kernel_math[p] * inverse_sum);
|
||||
}
|
||||
|
||||
_kernels.push_back(std::move(kernel_data));
|
||||
|
@ -78,7 +78,7 @@ streamfx::obs::gs::effect streamfx::gfx::blur::gaussian_linear_data::get_effect(
|
|||
return _effect;
|
||||
}
|
||||
|
||||
std::vector<float_t> const& streamfx::gfx::blur::gaussian_linear_data::get_kernel(std::size_t width)
|
||||
std::vector<float> const& streamfx::gfx::blur::gaussian_linear_data::get_kernel(std::size_t width)
|
||||
{
|
||||
if (width < 1)
|
||||
width = 1;
|
||||
|
@ -292,8 +292,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_line
|
|||
return _input_texture;
|
||||
}
|
||||
|
||||
float_t width = float_t(_input_texture->get_width());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
// Setup
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
@ -310,13 +310,13 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_line
|
|||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||
|
||||
// First Pass
|
||||
if (_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f);
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), 0.f);
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -336,7 +336,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_line
|
|||
|
||||
// Second Pass
|
||||
if (_step_scale.second > std::numeric_limits<double_t>::epsilon()) {
|
||||
effect.get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height));
|
||||
effect.get_parameter("pImageTexel").set_float2(0.f, float(1.f / height));
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -397,8 +397,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_line
|
|||
return _input_texture;
|
||||
}
|
||||
|
||||
float_t width = float_t(_input_texture->get_width());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
// Setup
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
@ -415,9 +415,9 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_line
|
|||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width * cos(_angle)), float_t(1.f / height * sin(_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width * cos(_angle)), float(1.f / height * sin(_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||
|
||||
// First Pass
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace streamfx::gfx {
|
|||
class gaussian_linear_data {
|
||||
streamfx::obs::gs::effect _effect;
|
||||
std::shared_ptr<streamfx::gfx::util> _gfx_util;
|
||||
std::vector<std::vector<float_t>> _kernels;
|
||||
std::vector<std::vector<float>> _kernels;
|
||||
|
||||
public:
|
||||
gaussian_linear_data();
|
||||
|
@ -30,7 +30,7 @@ namespace streamfx::gfx {
|
|||
|
||||
streamfx::obs::gs::effect get_effect();
|
||||
|
||||
std::vector<float_t> const& get_kernel(std::size_t width);
|
||||
std::vector<float> const& get_kernel(std::size_t width);
|
||||
};
|
||||
|
||||
class gaussian_linear_factory : public ::streamfx::gfx::blur::ifactory {
|
||||
|
|
|
@ -108,7 +108,7 @@ std::shared_ptr<streamfx::gfx::util> streamfx::gfx::blur::gaussian_data::get_gfx
|
|||
return _gfx_util;
|
||||
}
|
||||
|
||||
std::vector<float_t> const& streamfx::gfx::blur::gaussian_data::get_kernel(std::size_t width)
|
||||
std::vector<float> const& streamfx::gfx::blur::gaussian_data::get_kernel(std::size_t width)
|
||||
{
|
||||
width = std::clamp<size_t>(width, 1, ST_MAX_BLUR_SIZE);
|
||||
return _kernels.at(width);
|
||||
|
@ -321,8 +321,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian::ren
|
|||
}
|
||||
|
||||
auto kernel = _data->get_kernel(size_t(_size));
|
||||
float_t width = float_t(_input_texture->get_width());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
// Setup
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
@ -338,14 +338,14 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian::ren
|
|||
gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS);
|
||||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size * ST_OVERSAMPLE_MULTIPLIER));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size * ST_OVERSAMPLE_MULTIPLIER));
|
||||
effect.get_parameter("pKernel").set_value(kernel.data(), ST_KERNEL_SIZE);
|
||||
|
||||
// First Pass
|
||||
if (_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f);
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), 0.f);
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -365,7 +365,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian::ren
|
|||
// Second Pass
|
||||
if (_step_scale.second > std::numeric_limits<double_t>::epsilon()) {
|
||||
effect.get_parameter("pImage").set_texture(_rendertarget->get_texture());
|
||||
effect.get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height));
|
||||
effect.get_parameter("pImageTexel").set_float2(0.f, float(1.f / height));
|
||||
|
||||
{
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
|
@ -426,8 +426,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_dire
|
|||
}
|
||||
|
||||
auto kernel = _data->get_kernel(size_t(_size));
|
||||
float_t width = float_t(_input_texture->get_width());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
// Setup
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
@ -444,9 +444,9 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_dire
|
|||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width * cos(m_angle)), float_t(1.f / height * sin(m_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size * ST_OVERSAMPLE_MULTIPLIER));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width * cos(m_angle)), float(1.f / height * sin(m_angle)));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size * ST_OVERSAMPLE_MULTIPLIER));
|
||||
effect.get_parameter("pKernel").set_value(kernel.data(), ST_KERNEL_SIZE);
|
||||
|
||||
{
|
||||
|
@ -482,8 +482,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_rota
|
|||
}
|
||||
|
||||
auto kernel = _data->get_kernel(size_t(_size));
|
||||
float_t width = float_t(_input_texture->get_width());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
// Setup
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
@ -500,11 +500,11 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_rota
|
|||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size * ST_OVERSAMPLE_MULTIPLIER));
|
||||
effect.get_parameter("pAngle").set_float(float_t(m_angle / _size));
|
||||
effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), float(1.f / height));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size * ST_OVERSAMPLE_MULTIPLIER));
|
||||
effect.get_parameter("pAngle").set_float(float(m_angle / _size));
|
||||
effect.get_parameter("pCenter").set_float2(float(m_center.first), float(m_center.second));
|
||||
effect.get_parameter("pKernel").set_value(kernel.data(), ST_KERNEL_SIZE);
|
||||
|
||||
// First Pass
|
||||
|
@ -563,8 +563,8 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_zoom
|
|||
return _input_texture;
|
||||
}
|
||||
|
||||
float_t width = float_t(_input_texture->get_width());
|
||||
float_t height = float_t(_input_texture->get_height());
|
||||
float width = float(_input_texture->get_width());
|
||||
float height = float(_input_texture->get_height());
|
||||
|
||||
// Setup
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
@ -581,10 +581,10 @@ std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_zoom
|
|||
gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO);
|
||||
|
||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||
effect.get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height));
|
||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||
effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second));
|
||||
effect.get_parameter("pImageTexel").set_float2(float(1.f / width), float(1.f / height));
|
||||
effect.get_parameter("pStepScale").set_float2(float(_step_scale.first), float(_step_scale.second));
|
||||
effect.get_parameter("pSize").set_float(float(_size));
|
||||
effect.get_parameter("pCenter").set_float2(float(m_center.first), float(m_center.second));
|
||||
effect.get_parameter("pKernel").set_value(kernel.data(), ST_KERNEL_SIZE);
|
||||
|
||||
// First Pass
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace streamfx::gfx {
|
|||
|
||||
std::shared_ptr<streamfx::gfx::util> get_gfx_util();
|
||||
|
||||
std::vector<float_t> const& get_kernel(std::size_t width);
|
||||
std::vector<float> const& get_kernel(std::size_t width);
|
||||
};
|
||||
|
||||
class gaussian_factory : public ::streamfx::gfx::blur::ifactory {
|
||||
|
|
|
@ -277,8 +277,8 @@ void streamfx::gfx::mipmapper::rebuild(std::shared_ptr<streamfx::obs::gs::textur
|
|||
|
||||
uint32_t cwidth = std::max<uint32_t>(width >> mip, 1);
|
||||
uint32_t cheight = std::max<uint32_t>(height >> mip, 1);
|
||||
float_t iwidth = 1.f / static_cast<float_t>(cwidth);
|
||||
float_t iheight = 1.f / static_cast<float_t>(cheight);
|
||||
float iwidth = 1.f / static_cast<float>(cwidth);
|
||||
float iheight = 1.f / static_cast<float>(cheight);
|
||||
|
||||
try {
|
||||
auto op = _rt->render(cwidth, cheight);
|
||||
|
|
|
@ -74,7 +74,7 @@ std::shared_ptr<streamfx::obs::gs::texture> streamfx::gfx::source_texture::rende
|
|||
auto op = _rt->render(static_cast<uint32_t>(width), static_cast<uint32_t>(height));
|
||||
vec4 black;
|
||||
vec4_zero(&black);
|
||||
gs_ortho(0, static_cast<float>(width), 0, static_cast<float_t>(height), 0, 1);
|
||||
gs_ortho(0, static_cast<float>(width), 0, static_cast<float>(height), 0, 1);
|
||||
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
||||
obs_source_video_render(_child.get());
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ inline bool get_annotation_string(streamfx::obs::gs::effect_parameter param, std
|
|||
return false;
|
||||
}
|
||||
|
||||
inline bool get_annotation_float(streamfx::obs::gs::effect_parameter param, std::string_view anno_name, float_t& out)
|
||||
inline bool get_annotation_float(streamfx::obs::gs::effect_parameter param, std::string_view anno_name, float& out)
|
||||
{
|
||||
if (!param) {
|
||||
return false;
|
||||
|
@ -203,8 +203,8 @@ streamfx::gfx::shader::float_parameter::float_parameter(streamfx::gfx::shader::s
|
|||
|
||||
// Reset minimum, maximum, step and scale.
|
||||
for (std::size_t idx = 0; idx < get_size(); idx++) {
|
||||
_min[idx].f32 = std::numeric_limits<float_t>::lowest();
|
||||
_max[idx].f32 = std::numeric_limits<float_t>::max();
|
||||
_min[idx].f32 = std::numeric_limits<float>::lowest();
|
||||
_max[idx].f32 = std::numeric_limits<float>::max();
|
||||
_step[idx].f32 = 0.01f;
|
||||
_scale[idx].f32 = 1.00f;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ streamfx::gfx::shader::float_parameter::~float_parameter() {}
|
|||
|
||||
void streamfx::gfx::shader::float_parameter::defaults(obs_data_t* settings)
|
||||
{
|
||||
std::vector<float_t> defaults;
|
||||
std::vector<float> defaults;
|
||||
defaults.resize(get_size());
|
||||
get_parameter().get_default_value(defaults.data(), get_size());
|
||||
|
||||
|
@ -245,7 +245,7 @@ void streamfx::gfx::shader::float_parameter::defaults(obs_data_t* settings)
|
|||
}
|
||||
}
|
||||
|
||||
static inline obs_property_t* build_float_property(streamfx::gfx::shader::basic_field_type ft, obs_properties_t* props, const char* key, const char* name, float_t min, float_t max, float_t step, std::list<streamfx::gfx::shader::basic_enum_data> edata)
|
||||
static inline obs_property_t* build_float_property(streamfx::gfx::shader::basic_field_type ft, obs_properties_t* props, const char* key, const char* name, float min, float max, float step, std::list<streamfx::gfx::shader::basic_enum_data> edata)
|
||||
{
|
||||
switch (ft) {
|
||||
case streamfx::gfx::shader::basic_field_type::Enum: {
|
||||
|
@ -287,7 +287,7 @@ void streamfx::gfx::shader::float_parameter::properties(obs_properties_t* props,
|
|||
void streamfx::gfx::shader::float_parameter::update(obs_data_t* settings)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < get_size(); idx++) {
|
||||
_data[idx].f32 = static_cast<float_t>(obs_data_get_double(settings, key_at(idx).data())) * _scale[idx].f32;
|
||||
_data[idx].f32 = static_cast<float>(obs_data_get_double(settings, key_at(idx).data())) * _scale[idx].f32;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace streamfx::gfx {
|
|||
union {
|
||||
int32_t i32;
|
||||
uint32_t ui32;
|
||||
float_t f32;
|
||||
float f32;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ streamfx::gfx::shader::shader::shader(obs_source_t* self, shader_mode mode)
|
|||
// Initialize random values.
|
||||
_random.seed(static_cast<unsigned long long>(_random_seed));
|
||||
for (size_t idx = 0; idx < 16; idx++) {
|
||||
_random_values[idx] = static_cast<float_t>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
_random_values[idx] = static_cast<float>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ void streamfx::gfx::shader::shader::update(obs_data_t* data)
|
|||
_random_seed = seed;
|
||||
_random.seed(static_cast<unsigned long long>(_random_seed));
|
||||
for (size_t idx = 0; idx < 16; idx++) {
|
||||
_random_values[idx] = static_cast<float_t>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
_random_values[idx] = static_cast<float>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,9 +399,9 @@ uint32_t streamfx::gfx::shader::shader::base_height()
|
|||
return _base_height;
|
||||
}
|
||||
|
||||
bool streamfx::gfx::shader::shader::tick(float_t time)
|
||||
bool streamfx::gfx::shader::shader::tick(float time)
|
||||
{
|
||||
_shader_file_tick = static_cast<float_t>(static_cast<double_t>(_shader_file_tick) + static_cast<double_t>(time));
|
||||
_shader_file_tick = static_cast<float>(static_cast<double_t>(_shader_file_tick) + static_cast<double_t>(time));
|
||||
if (_shader_file_tick >= 1.0f / 3.0f) {
|
||||
_shader_file_tick -= 1.0f / 3.0f;
|
||||
bool v1, v2;
|
||||
|
@ -422,7 +422,7 @@ bool streamfx::gfx::shader::shader::tick(float_t time)
|
|||
|
||||
// Recreate Per-Activation-Random values.
|
||||
for (size_t idx = 0; idx < 8; idx++) {
|
||||
_random_values[8 + idx] = static_cast<float_t>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
_random_values[8 + idx] = static_cast<float>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
}
|
||||
|
||||
// Flag Render Target as outdated.
|
||||
|
@ -444,14 +444,14 @@ void streamfx::gfx::shader::shader::prepare_render()
|
|||
// float4 Time: (Time in Seconds), (Time in Current Second), (Time in Seconds only), (Random Value)
|
||||
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<float_t>(_loops), static_cast<float_t>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max())));
|
||||
el.set_float4(_time, _time_loop, static_cast<float>(_loops), static_cast<float>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max())));
|
||||
}
|
||||
}
|
||||
|
||||
// float4 ViewSize: (Width), (Height), (1.0 / Width), (1.0 / Height)
|
||||
if (auto el = _shader.get_parameter("ViewSize"); el != nullptr) {
|
||||
if (el.get_type() == streamfx::obs::gs::effect_parameter::type::Float4) {
|
||||
el.set_float4(static_cast<float_t>(width()), static_cast<float_t>(height()), 1.0f / static_cast<float_t>(width()), 1.0f / static_cast<float_t>(height()));
|
||||
el.set_float4(static_cast<float>(width()), static_cast<float>(height()), 1.0f / static_cast<float>(width()), 1.0f / static_cast<float>(height()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ void streamfx::gfx::shader::shader::set_input_b(std::shared_ptr<streamfx::obs::g
|
|||
}
|
||||
}
|
||||
|
||||
void streamfx::gfx::shader::shader::set_transition_time(float_t t)
|
||||
void streamfx::gfx::shader::shader::set_transition_time(float t)
|
||||
{
|
||||
if (!_shader)
|
||||
return;
|
||||
|
@ -616,7 +616,7 @@ void streamfx::gfx::shader::shader::set_active(bool active)
|
|||
|
||||
// Recreate Per-Activation-Random values.
|
||||
for (size_t idx = 0; idx < 4; idx++) {
|
||||
_random_values[4 + idx] = static_cast<float_t>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
_random_values[4 + idx] = static_cast<float>(static_cast<double_t>(_random()) / static_cast<double_t>(_random.max()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace streamfx::gfx {
|
|||
std::string _shader_tech;
|
||||
std::filesystem::file_time_type _shader_file_mt;
|
||||
uintmax_t _shader_file_sz;
|
||||
float_t _shader_file_tick;
|
||||
float _shader_file_tick;
|
||||
shader_param_map_t _shader_params;
|
||||
|
||||
// Options
|
||||
|
@ -62,12 +62,12 @@ namespace streamfx::gfx {
|
|||
|
||||
// Cache
|
||||
bool _have_current_params;
|
||||
float_t _time;
|
||||
float_t _time_loop;
|
||||
float _time;
|
||||
float _time_loop;
|
||||
int32_t _loops;
|
||||
std::mt19937_64 _random;
|
||||
int32_t _random_seed;
|
||||
float_t _random_values[16]; // 0..4 Per-Instance-Random, 4..8 Per-Activation-Random 9..15 Per-Frame-Random
|
||||
float _random_values[16]; // 0..4 Per-Instance-Random, 4..8 Per-Activation-Random 9..15 Per-Frame-Random
|
||||
|
||||
// Rendering
|
||||
bool _rt_up_to_date;
|
||||
|
@ -103,7 +103,7 @@ namespace streamfx::gfx {
|
|||
|
||||
uint32_t base_height();
|
||||
|
||||
bool tick(float_t time);
|
||||
bool tick(float time);
|
||||
|
||||
void prepare_render();
|
||||
|
||||
|
@ -120,7 +120,7 @@ namespace streamfx::gfx {
|
|||
|
||||
void set_input_b(std::shared_ptr<streamfx::obs::gs::texture> tex, bool srgb = false);
|
||||
|
||||
void set_transition_time(float_t t);
|
||||
void set_transition_time(float t);
|
||||
|
||||
void set_transition_size(uint32_t w, uint32_t h);
|
||||
|
||||
|
|
|
@ -216,33 +216,33 @@ void streamfx::obs::gs::effect_parameter::set_bool_array(bool v[], std::size_t s
|
|||
gs_effect_set_val(get(), v, sz);
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::set_float(float_t x)
|
||||
void streamfx::obs::gs::effect_parameter::set_float(float x)
|
||||
{
|
||||
if (get_type() != type::Float)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_float(get(), x);
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::get_float(float_t& x)
|
||||
void streamfx::obs::gs::effect_parameter::get_float(float& x)
|
||||
{
|
||||
if (get_type() != type::Float)
|
||||
throw std::bad_cast();
|
||||
void* ptr = gs_effect_get_val(get());
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::get_default_float(float_t& x)
|
||||
void streamfx::obs::gs::effect_parameter::get_default_float(float& x)
|
||||
{
|
||||
if (get_type() != type::Float)
|
||||
throw std::bad_cast();
|
||||
void* ptr = gs_effect_get_default_val(get());
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = 0;
|
||||
|
@ -266,7 +266,7 @@ void streamfx::obs::gs::effect_parameter::get_default_float2(vec2& v)
|
|||
get_default_float2(v.x, v.y);
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::set_float2(float_t x, float_t y)
|
||||
void streamfx::obs::gs::effect_parameter::set_float2(float x, float y)
|
||||
{
|
||||
vec2 data;
|
||||
data.x = x;
|
||||
|
@ -274,28 +274,28 @@ void streamfx::obs::gs::effect_parameter::set_float2(float_t x, float_t y)
|
|||
set_float2(data);
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::get_float2(float_t& x, float_t& y)
|
||||
void streamfx::obs::gs::effect_parameter::get_float2(float& x, float& y)
|
||||
{
|
||||
if (get_type() != type::Float2)
|
||||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
y = *reinterpret_cast<float*>(ptr + sizeof(float));
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::get_default_float2(float_t& x, float_t& y)
|
||||
void streamfx::obs::gs::effect_parameter::get_default_float2(float& x, float& y)
|
||||
{
|
||||
if (get_type() != type::Float2)
|
||||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
y = *reinterpret_cast<float*>(ptr + sizeof(float));
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = y = 0;
|
||||
|
@ -319,7 +319,7 @@ void streamfx::obs::gs::effect_parameter::get_default_float3(vec3& v)
|
|||
get_default_float3(v.x, v.y, v.z);
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::set_float3(float_t x, float_t y, float_t z)
|
||||
void streamfx::obs::gs::effect_parameter::set_float3(float x, float y, float z)
|
||||
{
|
||||
if (get_type() != type::Float3)
|
||||
throw std::bad_cast();
|
||||
|
@ -327,30 +327,30 @@ void streamfx::obs::gs::effect_parameter::set_float3(float_t x, float_t y, float
|
|||
gs_effect_set_vec3(get(), &v);
|
||||
}
|
||||
|
||||
void streamfx::obs::gs::effect_parameter::get_float3(float_t& x, float_t& y, float_t& z)
|
||||
void streamfx::obs::gs::effect_parameter::get_float3(float& x, float& y, float& z)
|
||||
{
|
||||
if (get_type() != type::Float3)
|
||||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
|
||||
z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 2);
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
y = *reinterpret_cast<float*>(ptr + sizeof(float));
|
||||
z = *reinterpret_cast<float*>(ptr + sizeof(float) * 2);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = y = z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void streamfx::obs::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& x, float& y, float& z)
|
||||
{
|
||||
if (get_type() != type::Float3)
|
||||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
|
||||
z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 2);
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
y = *reinterpret_cast<float*>(ptr + sizeof(float));
|
||||
z = *reinterpret_cast<float*>(ptr + sizeof(float) * 2);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = y = z = 0;
|
||||
|
@ -374,7 +374,7 @@ void streamfx::obs::gs::effect_parameter::get_default_float4(vec4& v)
|
|||
get_default_float4(v.x, v.y, v.z, v.w);
|
||||
}
|
||||
|
||||
void streamfx::obs::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 x, float y, float z, float w)
|
||||
{
|
||||
if (get_type() != type::Float4)
|
||||
throw std::bad_cast();
|
||||
|
@ -382,32 +382,32 @@ void streamfx::obs::gs::effect_parameter::set_float4(float_t x, float_t y, float
|
|||
gs_effect_set_vec4(get(), &v);
|
||||
}
|
||||
|
||||
void streamfx::obs::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& x, float& y, float& z, float& w)
|
||||
{
|
||||
if (get_type() != type::Float4)
|
||||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
|
||||
z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 2);
|
||||
w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 3);
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
y = *reinterpret_cast<float*>(ptr + sizeof(float));
|
||||
z = *reinterpret_cast<float*>(ptr + sizeof(float) * 2);
|
||||
w = *reinterpret_cast<float*>(ptr + sizeof(float) * 3);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = y = z = w = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void streamfx::obs::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& x, float& y, float& z, float& w)
|
||||
{
|
||||
if (get_type() != type::Float4)
|
||||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
|
||||
if (ptr) {
|
||||
x = *reinterpret_cast<float_t*>(ptr);
|
||||
y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t));
|
||||
z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 2);
|
||||
w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 3);
|
||||
x = *reinterpret_cast<float*>(ptr);
|
||||
y = *reinterpret_cast<float*>(ptr + sizeof(float));
|
||||
z = *reinterpret_cast<float*>(ptr + sizeof(float) * 2);
|
||||
w = *reinterpret_cast<float*>(ptr + sizeof(float) * 3);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
x = y = z = w = 0;
|
||||
|
@ -574,22 +574,22 @@ void streamfx::obs::gs::effect_parameter::get_matrix(matrix4& v)
|
|||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_val(get()));
|
||||
if (ptr) {
|
||||
v.x.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 0);
|
||||
v.x.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 1);
|
||||
v.x.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 2);
|
||||
v.x.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 3);
|
||||
v.y.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 4);
|
||||
v.y.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 5);
|
||||
v.y.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 6);
|
||||
v.y.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 7);
|
||||
v.z.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 8);
|
||||
v.z.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 9);
|
||||
v.z.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 10);
|
||||
v.z.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 11);
|
||||
v.t.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 12);
|
||||
v.t.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 13);
|
||||
v.t.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 14);
|
||||
v.t.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 15);
|
||||
v.x.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 0);
|
||||
v.x.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 1);
|
||||
v.x.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 2);
|
||||
v.x.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 3);
|
||||
v.y.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 4);
|
||||
v.y.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 5);
|
||||
v.y.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 6);
|
||||
v.y.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 7);
|
||||
v.z.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 8);
|
||||
v.z.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 9);
|
||||
v.z.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 10);
|
||||
v.z.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 11);
|
||||
v.t.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 12);
|
||||
v.t.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 13);
|
||||
v.t.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 14);
|
||||
v.t.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 15);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
v.x = vec4{};
|
||||
|
@ -605,22 +605,22 @@ void streamfx::obs::gs::effect_parameter::get_default_matrix(matrix4& v)
|
|||
throw std::bad_cast();
|
||||
uint8_t* ptr = static_cast<uint8_t*>(gs_effect_get_default_val(get()));
|
||||
if (ptr) {
|
||||
v.x.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 0);
|
||||
v.x.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 1);
|
||||
v.x.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 2);
|
||||
v.x.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 3);
|
||||
v.y.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 4);
|
||||
v.y.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 5);
|
||||
v.y.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 6);
|
||||
v.y.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 7);
|
||||
v.z.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 8);
|
||||
v.z.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 9);
|
||||
v.z.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 10);
|
||||
v.z.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 11);
|
||||
v.t.x = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 12);
|
||||
v.t.y = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 13);
|
||||
v.t.z = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 14);
|
||||
v.t.w = *reinterpret_cast<float_t*>(ptr + sizeof(float_t) * 15);
|
||||
v.x.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 0);
|
||||
v.x.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 1);
|
||||
v.x.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 2);
|
||||
v.x.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 3);
|
||||
v.y.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 4);
|
||||
v.y.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 5);
|
||||
v.y.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 6);
|
||||
v.y.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 7);
|
||||
v.z.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 8);
|
||||
v.z.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 9);
|
||||
v.z.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 10);
|
||||
v.z.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 11);
|
||||
v.t.x = *reinterpret_cast<float*>(ptr + sizeof(float) * 12);
|
||||
v.t.y = *reinterpret_cast<float*>(ptr + sizeof(float) * 13);
|
||||
v.t.z = *reinterpret_cast<float*>(ptr + sizeof(float) * 14);
|
||||
v.t.w = *reinterpret_cast<float*>(ptr + sizeof(float) * 15);
|
||||
bfree(ptr);
|
||||
} else {
|
||||
v.x = vec4{};
|
||||
|
|
|
@ -129,30 +129,30 @@ namespace streamfx::obs::gs {
|
|||
|
||||
void set_bool_array(bool v[], std::size_t sz);
|
||||
|
||||
void set_float(float_t x);
|
||||
void get_float(float_t& x);
|
||||
void get_default_float(float_t& x);
|
||||
void set_float(float x);
|
||||
void get_float(float& x);
|
||||
void get_default_float(float& x);
|
||||
|
||||
void set_float2(vec2 const& v);
|
||||
void get_float2(vec2& v);
|
||||
void get_default_float2(vec2& v);
|
||||
void set_float2(float_t x, float_t y);
|
||||
void get_float2(float_t& x, float_t& y);
|
||||
void get_default_float2(float_t& x, float_t& y);
|
||||
void set_float2(float x, float y);
|
||||
void get_float2(float& x, float& y);
|
||||
void get_default_float2(float& x, float& y);
|
||||
|
||||
void set_float3(vec3 const& v);
|
||||
void get_float3(vec3& v);
|
||||
void get_default_float3(vec3& v);
|
||||
void set_float3(float_t x, float_t y, float_t z);
|
||||
void get_float3(float_t& x, float_t& y, float_t& z);
|
||||
void get_default_float3(float_t& x, float_t& y, float_t& z);
|
||||
void set_float3(float x, float y, float z);
|
||||
void get_float3(float& x, float& y, float& z);
|
||||
void get_default_float3(float& x, float& y, float& z);
|
||||
|
||||
void set_float4(vec4 const& v);
|
||||
void get_float4(vec4& v);
|
||||
void get_default_float4(vec4& v);
|
||||
void set_float4(float_t x, float_t y, float_t z, float_t w);
|
||||
void get_float4(float_t& x, float_t& y, float_t& z, float_t& w);
|
||||
void get_default_float4(float_t& x, float_t& y, float_t& z, float_t& w);
|
||||
void set_float4(float x, float y, float z, float w);
|
||||
void get_float4(float& x, float& y, float& z, float& w);
|
||||
void get_default_float4(float& x, float& y, float& z, float& w);
|
||||
|
||||
void set_int(int32_t x);
|
||||
void get_int(int32_t& x);
|
||||
|
@ -185,7 +185,7 @@ namespace streamfx::obs::gs {
|
|||
void get_default_string(std::string& v);
|
||||
|
||||
public /* Helpers */:
|
||||
inline float_t get_bool()
|
||||
inline float get_bool()
|
||||
{
|
||||
bool v;
|
||||
get_bool(v);
|
||||
|
@ -198,15 +198,15 @@ namespace streamfx::obs::gs {
|
|||
return v;
|
||||
};
|
||||
|
||||
inline float_t get_float()
|
||||
inline float get_float()
|
||||
{
|
||||
float_t v;
|
||||
float v;
|
||||
get_float(v);
|
||||
return v;
|
||||
};
|
||||
inline float_t get_default_float()
|
||||
inline float get_default_float()
|
||||
{
|
||||
float_t v;
|
||||
float v;
|
||||
get_default_float(v);
|
||||
return v;
|
||||
};
|
||||
|
|
|
@ -26,36 +26,36 @@ namespace streamfx::obs::gs {
|
|||
};
|
||||
|
||||
#if defined(ENABLE_PROFILING) && !defined(D_PLATFORM_MAC) && _DEBUG
|
||||
static constexpr float_t debug_color_white[4] = {1.f, 1.f, 1.f, 1.f};
|
||||
static constexpr float_t debug_color_gray[4] = {.5f, .5f, .5f, 1.f};
|
||||
static constexpr float_t debug_color_black[4] = {0.f, 0.f, 0.f, 1.f};
|
||||
static constexpr float_t debug_color_red[4] = {1.f, 0.f, 0.f, 1.f};
|
||||
static constexpr float_t debug_color_flush_orange[4] = {1.f, .5f, 0.f, 1.f};
|
||||
static constexpr float_t debug_color_yellow[4] = {1.f, 1.f, 0.f, 1.f};
|
||||
static constexpr float_t debug_color_chartreuse[4] = {.5f, 1.f, 0.f, 1.f};
|
||||
static constexpr float_t debug_color_green[4] = {0.f, 1.f, 0.f, 1.f};
|
||||
static constexpr float_t debug_color_spring_green[4] = {0.f, 1.f, .5f, 1.f};
|
||||
static constexpr float_t debug_color_teal[4] = {0.f, 1.f, 1.f, 1.f};
|
||||
static constexpr float_t debug_color_azure_radiance[4] = {0.f, .5f, 1.f, 1.f};
|
||||
static constexpr float_t debug_color_blue[4] = {0.f, 0.f, 1.f, 1.f};
|
||||
static constexpr float_t debug_color_electric_violet[4] = {.5f, 0.f, 1.f, 1.f};
|
||||
static constexpr float_t debug_color_magenta[4] = {1.f, 0.f, 1.f, 1.f};
|
||||
static constexpr float_t debug_color_rose[4] = {1.f, 0.f, .5f, 1.f};
|
||||
static constexpr float debug_color_white[4] = {1.f, 1.f, 1.f, 1.f};
|
||||
static constexpr float debug_color_gray[4] = {.5f, .5f, .5f, 1.f};
|
||||
static constexpr float debug_color_black[4] = {0.f, 0.f, 0.f, 1.f};
|
||||
static constexpr float debug_color_red[4] = {1.f, 0.f, 0.f, 1.f};
|
||||
static constexpr float debug_color_flush_orange[4] = {1.f, .5f, 0.f, 1.f};
|
||||
static constexpr float debug_color_yellow[4] = {1.f, 1.f, 0.f, 1.f};
|
||||
static constexpr float debug_color_chartreuse[4] = {.5f, 1.f, 0.f, 1.f};
|
||||
static constexpr float debug_color_green[4] = {0.f, 1.f, 0.f, 1.f};
|
||||
static constexpr float debug_color_spring_green[4] = {0.f, 1.f, .5f, 1.f};
|
||||
static constexpr float debug_color_teal[4] = {0.f, 1.f, 1.f, 1.f};
|
||||
static constexpr float debug_color_azure_radiance[4] = {0.f, .5f, 1.f, 1.f};
|
||||
static constexpr float debug_color_blue[4] = {0.f, 0.f, 1.f, 1.f};
|
||||
static constexpr float debug_color_electric_violet[4] = {.5f, 0.f, 1.f, 1.f};
|
||||
static constexpr float debug_color_magenta[4] = {1.f, 0.f, 1.f, 1.f};
|
||||
static constexpr float debug_color_rose[4] = {1.f, 0.f, .5f, 1.f};
|
||||
|
||||
static const float_t* debug_color_source = debug_color_white;
|
||||
static const float_t* debug_color_capture = debug_color_flush_orange;
|
||||
static const float_t* debug_color_cache = debug_color_capture;
|
||||
static const float_t* debug_color_convert = debug_color_electric_violet;
|
||||
static const float_t* debug_color_cache_render = debug_color_convert;
|
||||
static const float_t* debug_color_copy = debug_color_azure_radiance;
|
||||
static const float_t* debug_color_allocate = debug_color_red;
|
||||
static const float_t* debug_color_render = debug_color_teal;
|
||||
static const float* debug_color_source = debug_color_white;
|
||||
static const float* debug_color_capture = debug_color_flush_orange;
|
||||
static const float* debug_color_cache = debug_color_capture;
|
||||
static const float* debug_color_convert = debug_color_electric_violet;
|
||||
static const float* debug_color_cache_render = debug_color_convert;
|
||||
static const float* debug_color_copy = debug_color_azure_radiance;
|
||||
static const float* debug_color_allocate = debug_color_red;
|
||||
static const float* debug_color_render = debug_color_teal;
|
||||
|
||||
class debug_marker {
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
inline debug_marker(const float_t color[4], const char* format, ...)
|
||||
inline debug_marker(const float color[4], const char* format, ...)
|
||||
{
|
||||
std::size_t size;
|
||||
std::vector<char> buffer(64);
|
||||
|
|
|
@ -63,7 +63,7 @@ streamfx::obs::gs::texture::texture(uint32_t width, uint32_t height, uint32_t de
|
|||
throw std::logic_error("mip_levels must be at least 1");
|
||||
|
||||
if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) {
|
||||
bool isPOT = (streamfx::util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(width) / log(2)))), width) && streamfx::util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(height) / log(2)))), height) && streamfx::util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(depth) / log(2)))), depth));
|
||||
bool isPOT = (streamfx::util::math::is_close_epsilon(pow(2, static_cast<int64_t>(floor(log(width) / log(2)))), width) && streamfx::util::math::is_close_epsilon(pow(2, static_cast<int64_t>(floor(log(height) / log(2)))), height) && streamfx::util::math::is_close_epsilon(pow(2, static_cast<int64_t>(floor(log(depth) / log(2)))), depth));
|
||||
if (!isPOT)
|
||||
throw std::logic_error("mip mapping requires power of two dimensions");
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ streamfx::obs::gs::texture::texture(uint32_t size, gs_color_format format, uint3
|
|||
throw std::logic_error("mip_levels must be at least 1");
|
||||
|
||||
if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) {
|
||||
bool isPOT = streamfx::util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(size) / log(2)))), size);
|
||||
bool isPOT = streamfx::util::math::is_close_epsilon(pow(2, static_cast<int64_t>(floor(log(size) / log(2)))), size);
|
||||
if (!isPOT)
|
||||
throw std::logic_error("mip mapping requires power of two dimensions");
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
streamfx::obs::gs::vertex::vertex() : position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), _has_store(true), _store(nullptr)
|
||||
{
|
||||
_store = streamfx::util::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4) * MAXIMUM_UVW_LAYERS);
|
||||
_store = streamfx::util::memory::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4) * MAXIMUM_UVW_LAYERS);
|
||||
|
||||
std::size_t offset = 0;
|
||||
|
||||
|
@ -35,7 +35,7 @@ streamfx::obs::gs::vertex::vertex() : position(nullptr), normal(nullptr), tangen
|
|||
streamfx::obs::gs::vertex::~vertex()
|
||||
{
|
||||
if (_has_store) {
|
||||
streamfx::util::free_aligned(_store);
|
||||
streamfx::util::memory::free_aligned(_store);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ void streamfx::obs::gs::vertex_buffer::initialize(uint32_t capacity, uint8_t lay
|
|||
_data = std::make_shared<decltype(_data)::element_type>();
|
||||
_data->num = _capacity;
|
||||
_data->num_tex = _layers;
|
||||
_data->points = _positions = static_cast<vec3*>(streamfx::util::malloc_aligned(16, sizeof(vec3) * _capacity));
|
||||
_data->normals = _normals = static_cast<vec3*>(streamfx::util::malloc_aligned(16, sizeof(vec3) * _capacity));
|
||||
_data->tangents = _tangents = static_cast<vec3*>(streamfx::util::malloc_aligned(16, sizeof(vec3) * _capacity));
|
||||
_data->colors = _colors = static_cast<uint32_t*>(streamfx::util::malloc_aligned(16, sizeof(uint32_t) * _capacity));
|
||||
_data->points = _positions = static_cast<vec3*>(streamfx::util::memory::malloc_aligned(16, sizeof(vec3) * _capacity));
|
||||
_data->normals = _normals = static_cast<vec3*>(streamfx::util::memory::malloc_aligned(16, sizeof(vec3) * _capacity));
|
||||
_data->tangents = _tangents = static_cast<vec3*>(streamfx::util::memory::malloc_aligned(16, sizeof(vec3) * _capacity));
|
||||
_data->colors = _colors = static_cast<uint32_t*>(streamfx::util::memory::malloc_aligned(16, sizeof(uint32_t) * _capacity));
|
||||
|
||||
// Clear the allocated memory of any data.
|
||||
memset(_positions, 0, sizeof(vec3) * _capacity);
|
||||
|
@ -39,9 +39,9 @@ void streamfx::obs::gs::vertex_buffer::initialize(uint32_t capacity, uint8_t lay
|
|||
if (_layers == 0) {
|
||||
_data->tvarray = nullptr;
|
||||
} else {
|
||||
_data->tvarray = _uv_layers = static_cast<gs_tvertarray*>(streamfx::util::malloc_aligned(16, sizeof(gs_tvertarray) * _layers));
|
||||
_data->tvarray = _uv_layers = static_cast<gs_tvertarray*>(streamfx::util::memory::malloc_aligned(16, sizeof(gs_tvertarray) * _layers));
|
||||
for (uint8_t n = 0; n < _layers; n++) {
|
||||
_uv_layers[n].array = _uvs[n] = static_cast<vec4*>(streamfx::util::malloc_aligned(16, sizeof(vec4) * _capacity));
|
||||
_uv_layers[n].array = _uvs[n] = static_cast<vec4*>(streamfx::util::memory::malloc_aligned(16, sizeof(vec4) * _capacity));
|
||||
_uv_layers[n].width = 4;
|
||||
memset(_uvs[n], 0, sizeof(vec4) * _capacity);
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ void streamfx::obs::gs::vertex_buffer::initialize(uint32_t capacity, uint8_t lay
|
|||
void streamfx::obs::gs::vertex_buffer::finalize()
|
||||
{
|
||||
// Free data
|
||||
streamfx::util::free_aligned(_positions);
|
||||
streamfx::util::free_aligned(_normals);
|
||||
streamfx::util::free_aligned(_tangents);
|
||||
streamfx::util::free_aligned(_colors);
|
||||
streamfx::util::free_aligned(_uv_layers);
|
||||
streamfx::util::memory::free_aligned(_positions);
|
||||
streamfx::util::memory::free_aligned(_normals);
|
||||
streamfx::util::memory::free_aligned(_tangents);
|
||||
streamfx::util::memory::free_aligned(_colors);
|
||||
streamfx::util::memory::free_aligned(_uv_layers);
|
||||
for (std::size_t n = 0; n < _layers; n++) {
|
||||
streamfx::util::free_aligned(_uvs[n]);
|
||||
streamfx::util::memory::free_aligned(_uvs[n]);
|
||||
}
|
||||
|
||||
_buffer.reset();
|
||||
|
|
|
@ -850,7 +850,7 @@ namespace streamfx::obs {
|
|||
return GS_CS_SRGB;
|
||||
}
|
||||
|
||||
virtual void video_tick(float_t seconds) {}
|
||||
virtual void video_tick(float seconds) {}
|
||||
|
||||
virtual void video_render(gs_effect_t* effect) {}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ void mirror_instance::save(obs_data_t* data)
|
|||
}
|
||||
}
|
||||
|
||||
void mirror_instance::video_tick(float_t time) {}
|
||||
void mirror_instance::video_tick(float time) {}
|
||||
|
||||
void mirror_instance::video_render(gs_effect_t* effect)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace streamfx::source::mirror {
|
|||
virtual void update(obs_data_t*) override;
|
||||
virtual void save(obs_data_t*) override;
|
||||
|
||||
virtual void video_tick(float_t) override;
|
||||
virtual void video_tick(float) override;
|
||||
virtual void video_render(gs_effect_t*) override;
|
||||
|
||||
virtual void enum_active_sources(obs_source_enum_proc_t, void*) override;
|
||||
|
|
|
@ -66,7 +66,7 @@ void shader_instance::update(obs_data_t* data)
|
|||
_fx->update(data);
|
||||
}
|
||||
|
||||
void shader_instance::video_tick(float_t sec_since_last)
|
||||
void shader_instance::video_tick(float sec_since_last)
|
||||
{
|
||||
if (_fx->tick(sec_since_last)) {
|
||||
obs_data_t* data = obs_source_get_settings(_self);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace streamfx::source::shader {
|
|||
virtual void load(obs_data_t* data) override;
|
||||
virtual void update(obs_data_t* data) override;
|
||||
|
||||
virtual void video_tick(float_t sec_since_last) override;
|
||||
virtual void video_tick(float sec_since_last) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
void show() override;
|
||||
|
|
|
@ -66,7 +66,7 @@ void shader_instance::update(obs_data_t* data)
|
|||
_fx->update(data);
|
||||
}
|
||||
|
||||
void shader_instance::video_tick(float_t sec_since_last)
|
||||
void shader_instance::video_tick(float sec_since_last)
|
||||
{
|
||||
if (_fx->tick(sec_since_last)) {
|
||||
obs_data_t* data = obs_source_get_settings(_self);
|
||||
|
@ -93,7 +93,7 @@ void shader_instance::video_render(gs_effect_t* effect)
|
|||
obs_transition_video_render(_self, [](void* data, gs_texture_t* a, gs_texture_t* b, float t, uint32_t cx, uint32_t cy) { reinterpret_cast<shader_instance*>(data)->transition_render(a, b, t, cx, cy); });
|
||||
}
|
||||
|
||||
void shader_instance::transition_render(gs_texture_t* a, gs_texture_t* b, float_t t, uint32_t cx, uint32_t cy)
|
||||
void shader_instance::transition_render(gs_texture_t* a, gs_texture_t* b, float t, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
_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));
|
||||
|
@ -106,7 +106,7 @@ void shader_instance::transition_render(gs_texture_t* a, gs_texture_t* b, float_
|
|||
bool shader_instance::audio_render(uint64_t* ts_out, obs_source_audio_mix* audio_output, uint32_t mixers, std::size_t channels, std::size_t sample_rate)
|
||||
{
|
||||
return obs_transition_audio_render(
|
||||
_self, ts_out, audio_output, mixers, channels, sample_rate, [](void*, float_t t) { return 1.0f - t; }, [](void*, float_t t) { return t; });
|
||||
_self, ts_out, audio_output, mixers, channels, sample_rate, [](void*, float t) { return 1.0f - t; }, [](void*, float t) { return t; });
|
||||
}
|
||||
|
||||
void shader_instance::transition_start()
|
||||
|
|
|
@ -25,10 +25,10 @@ namespace streamfx::transition::shader {
|
|||
virtual void load(obs_data_t* data) override;
|
||||
virtual void update(obs_data_t* data) override;
|
||||
|
||||
virtual void video_tick(float_t sec_since_last) override;
|
||||
virtual void video_tick(float sec_since_last) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
void transition_render(gs_texture_t* a, gs_texture_t* b, float_t t, uint32_t cx, uint32_t cy);
|
||||
void transition_render(gs_texture_t* a, gs_texture_t* b, float t, uint32_t cx, uint32_t cy);
|
||||
|
||||
virtual bool audio_render(uint64_t* ts_out, struct obs_source_audio_mix* audio_output, uint32_t mixers, std::size_t channels, std::size_t sample_rate) override;
|
||||
|
||||
|
|
|
@ -22,66 +22,6 @@ obs_property_t* streamfx::util::obs_properties_add_tristate(obs_properties_t* pr
|
|||
return p;
|
||||
}
|
||||
|
||||
void* streamfx::util::vec2a::operator new(std::size_t count)
|
||||
{
|
||||
return streamfx::util::malloc_aligned(16, count);
|
||||
}
|
||||
|
||||
void* streamfx::util::vec2a::operator new[](std::size_t count)
|
||||
{
|
||||
return streamfx::util::malloc_aligned(16, count);
|
||||
}
|
||||
|
||||
void streamfx::util::vec2a::operator delete(void* p)
|
||||
{
|
||||
streamfx::util::free_aligned(p);
|
||||
}
|
||||
|
||||
void streamfx::util::vec2a::operator delete[](void* p)
|
||||
{
|
||||
streamfx::util::free_aligned(p);
|
||||
}
|
||||
|
||||
void* streamfx::util::vec3a::operator new(std::size_t count)
|
||||
{
|
||||
return streamfx::util::malloc_aligned(16, count);
|
||||
}
|
||||
|
||||
void* streamfx::util::vec3a::operator new[](std::size_t count)
|
||||
{
|
||||
return streamfx::util::malloc_aligned(16, count);
|
||||
}
|
||||
|
||||
void streamfx::util::vec3a::operator delete(void* p)
|
||||
{
|
||||
streamfx::util::free_aligned(p);
|
||||
}
|
||||
|
||||
void streamfx::util::vec3a::operator delete[](void* p)
|
||||
{
|
||||
streamfx::util::free_aligned(p);
|
||||
}
|
||||
|
||||
void* streamfx::util::vec4a::operator new(std::size_t count)
|
||||
{
|
||||
return streamfx::util::malloc_aligned(16, count);
|
||||
}
|
||||
|
||||
void* streamfx::util::vec4a::operator new[](std::size_t count)
|
||||
{
|
||||
return streamfx::util::malloc_aligned(16, count);
|
||||
}
|
||||
|
||||
void streamfx::util::vec4a::operator delete(void* p)
|
||||
{
|
||||
streamfx::util::free_aligned(p);
|
||||
}
|
||||
|
||||
void streamfx::util::vec4a::operator delete[](void* p)
|
||||
{
|
||||
streamfx::util::free_aligned(p);
|
||||
}
|
||||
|
||||
std::pair<int64_t, int64_t> streamfx::util::size_from_string(std::string_view text, bool allowSquare)
|
||||
{
|
||||
int64_t width, height;
|
||||
|
@ -122,7 +62,7 @@ std::pair<int64_t, int64_t> streamfx::util::size_from_string(std::string_view te
|
|||
return {width, height};
|
||||
}
|
||||
|
||||
void* streamfx::util::malloc_aligned(std::size_t align, std::size_t size)
|
||||
void* streamfx::util::memory::malloc_aligned(std::size_t align, std::size_t size)
|
||||
{
|
||||
#ifdef USE_MSC_ALLOC
|
||||
return _aligned_malloc(size, align);
|
||||
|
@ -146,7 +86,7 @@ void* streamfx::util::malloc_aligned(std::size_t align, std::size_t size)
|
|||
#endif
|
||||
}
|
||||
|
||||
void streamfx::util::free_aligned(void* mem)
|
||||
void streamfx::util::memory::free_aligned(void* mem)
|
||||
{
|
||||
#ifdef USE_MSC_ALLOC
|
||||
_aligned_free(mem);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "warning-disable.hpp"
|
||||
#include <bitset>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
@ -56,39 +57,13 @@ namespace streamfx::util {
|
|||
return tristate == -1;
|
||||
}
|
||||
|
||||
struct vec2a : public vec2 {
|
||||
// 16-byte Aligned version of vec2
|
||||
static void* operator new(std::size_t count);
|
||||
static void* operator new[](std::size_t count);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(align(16))
|
||||
#endif
|
||||
struct vec3a : public vec3 {
|
||||
// 16-byte Aligned version of vec3
|
||||
static void* operator new(std::size_t count);
|
||||
static void* operator new[](std::size_t count);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(align(16))
|
||||
#endif
|
||||
struct vec4a : public vec4 {
|
||||
// 16-byte Aligned version of vec4
|
||||
static void* operator new(std::size_t count);
|
||||
static void* operator new[](std::size_t count);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
};
|
||||
|
||||
std::pair<int64_t, int64_t> size_from_string(std::string_view text, bool allowSquare = true);
|
||||
|
||||
namespace math {
|
||||
/** Integer exponentiation by squaring.
|
||||
* Complexity: O(log(exp)
|
||||
* Has fall-backs to the normal methods for non-integer types.
|
||||
*/
|
||||
template<typename T>
|
||||
inline T pow(T base, T exp)
|
||||
{
|
||||
|
@ -102,19 +77,55 @@ namespace streamfx::util {
|
|||
return res;
|
||||
}
|
||||
|
||||
// Proven by tests to be the fastest implementation on Intel and AMD CPUs.
|
||||
// Ranking: log10, loop < bitscan < pow
|
||||
// loop and log10 trade blows, usually almost identical.
|
||||
// loop is used for integers, log10 for anything else.
|
||||
template<>
|
||||
inline float pow(float base, float exp)
|
||||
{
|
||||
return ::powf(base, exp);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline double pow(double base, double exp)
|
||||
{
|
||||
return ::pow(base, exp);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline long double pow(long double base, long double exp)
|
||||
{
|
||||
return ::powl(base, exp);
|
||||
}
|
||||
|
||||
/** Fast PoT testing
|
||||
*
|
||||
* This was tested and verified to be the fastest implementation on
|
||||
* Intel and AMD x86 CPUs, in both 32bit and 64bit modes. It is
|
||||
* possible to make it even faster with a bit of SIMD magic (see
|
||||
* json-simd), but it would no longer be generic - and not worth it.
|
||||
*
|
||||
* Ranking: popcnt < log10, loop < bitscan < pow
|
||||
* - log10 version is useful for floating point.
|
||||
* - popcnt and loop are fixed point and integers.
|
||||
* - Pretty clear solution here.
|
||||
*
|
||||
*/
|
||||
template<typename T>
|
||||
inline bool is_power_of_two(T v)
|
||||
{
|
||||
return T(1ull << uint64_t(floor(log10(T(v)) / log10(2.0)))) == v;
|
||||
}
|
||||
static_assert(std::is_integral<T>::value, "Input must be an integral type.");
|
||||
|
||||
template<typename T>
|
||||
inline bool is_power_of_two_loop(T v)
|
||||
{
|
||||
#if 1 // Optimizes to popcount if available.
|
||||
return std::bitset<sizeof(T) * 8>(v).count() == 0;
|
||||
|
||||
#elif 0 // Loop Variant 1, uses bit shifts.
|
||||
bool bit = false;
|
||||
for (std::size_t index = 0; index < (sizeof(T) * 8) || (v == 0); index++) {
|
||||
if (bit && (v & 1))
|
||||
return false;
|
||||
bit = (v & 1);
|
||||
v >>= 1;
|
||||
}
|
||||
return true;
|
||||
#elif 0 // Loop Variant 2, optimized by compiler to the above.
|
||||
bool have_bit = false;
|
||||
for (std::size_t index = 0; index < (sizeof(T) * 8); index++) {
|
||||
bool cur = (v & (static_cast<T>(1ull) << index)) != 0;
|
||||
|
@ -125,48 +136,61 @@ namespace streamfx::util {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma push_macro("P_IS_POWER_OF_TWO_AS_LOOP")
|
||||
#define P_IS_POWER_OF_TWO_AS_LOOP(x) \
|
||||
template<> \
|
||||
inline bool is_power_of_two(x v) \
|
||||
{ \
|
||||
return is_power_of_two_loop(v); \
|
||||
}
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(int8_t)
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(uint8_t)
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(int16_t)
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(uint16_t)
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(int32_t)
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(uint32_t)
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(int64_t)
|
||||
P_IS_POWER_OF_TWO_AS_LOOP(uint64_t)
|
||||
#undef P_IS_POWER_OF_TWO_AS_LOOP
|
||||
#pragma pop_macro("P_IS_POWER_OF_TWO_AS_LOOP")
|
||||
template<typename T>
|
||||
inline bool is_power_of_two(float v)
|
||||
{
|
||||
return T(1ull << uint64_t(floor(log10(v) / log10(2.0f)))) == v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool is_power_of_two(double v)
|
||||
{
|
||||
return T(1ull << uint64_t(floor(log10(v) / log10(2.0)))) == v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool is_power_of_two(long double v)
|
||||
{
|
||||
return T(1ull << uint64_t(floor(log10(v) / log10(2.0l)))) == v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool is_power_of_two_loop(T v)
|
||||
{
|
||||
return is_power_of_two<T>(v);
|
||||
}
|
||||
|
||||
/** Retrieves the lower bound on the exponent for a texture that would fit the given size.
|
||||
*
|
||||
*/
|
||||
template<typename T>
|
||||
inline uint64_t get_power_of_two_exponent_floor(T v)
|
||||
{
|
||||
return uint64_t(floor(log10(T(v)) / log10(2.0)));
|
||||
return uint64_t(floor(log10(T(v)) / log10(2.0l)));
|
||||
}
|
||||
|
||||
/** Retrieves the upper bound on the exponent for a texture that would fit the given size.
|
||||
*
|
||||
*/
|
||||
template<typename T>
|
||||
inline uint64_t get_power_of_two_exponent_ceil(T v)
|
||||
{
|
||||
return uint64_t(ceil(log10(T(v)) / log10(2.0)));
|
||||
return uint64_t(ceil(log10(T(v)) / log10(2.0l)));
|
||||
}
|
||||
|
||||
template<typename T, typename C>
|
||||
inline bool is_equal(T target, C value)
|
||||
inline bool is_close_epsilon(T target, C value)
|
||||
{
|
||||
return (target > (value - std::numeric_limits<T>::epsilon())) && (target < (value + std::numeric_limits<T>::epsilon()));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool is_close(T target, T value, T delta)
|
||||
inline bool is_close(T target, T value, T epsilon)
|
||||
{
|
||||
return (target > (value - delta)) && (target < (value + delta));
|
||||
return (target > (value - epsilon)) && (target < (value + epsilon));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -189,7 +213,7 @@ namespace streamfx::util {
|
|||
//static const double_t two_pi = pi * 2.;
|
||||
static const double_t two_pi_sqroot = 2.506628274631000502415765284811; //sqrt(two_pi);
|
||||
|
||||
if (is_equal<double_t>(0, o)) {
|
||||
if (is_close_epsilon<double_t>(0, o)) {
|
||||
return T(std::numeric_limits<double_t>::infinity());
|
||||
}
|
||||
|
||||
|
@ -197,7 +221,7 @@ namespace streamfx::util {
|
|||
double_t left_e = 1. / (o * two_pi_sqroot);
|
||||
double_t mid_right_e = ((x /* - u*/) / o);
|
||||
double_t right_e = -0.5 * mid_right_e * mid_right_e;
|
||||
double_t final = left_e * exp(right_e);
|
||||
double final = left_e * exp(right_e);
|
||||
|
||||
return T(final);
|
||||
}
|
||||
|
@ -237,10 +261,12 @@ namespace streamfx::util {
|
|||
};
|
||||
} // namespace math
|
||||
|
||||
inline std::size_t aligned_offset(std::size_t align, std::size_t pos)
|
||||
{
|
||||
return ((pos / align) + 1) * align;
|
||||
}
|
||||
void* malloc_aligned(std::size_t align, std::size_t size);
|
||||
void free_aligned(void* mem);
|
||||
namespace memory {
|
||||
inline std::size_t aligned_offset(std::size_t align, std::size_t pos)
|
||||
{
|
||||
return ((pos / align) + 1) * align;
|
||||
}
|
||||
void* malloc_aligned(std::size_t align, std::size_t size);
|
||||
void free_aligned(void* mem);
|
||||
} // namespace memory
|
||||
} // namespace streamfx::util
|
||||
|
|
Loading…
Reference in a new issue